Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.recipe.build
Commits
84a8ce94
Commit
84a8ce94
authored
Mar 13, 2020
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default: 'script' renamed to 'install', new 'update', clean up globals/locals
parent
9ff1a5a3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
17 deletions
+28
-17
slapos/recipe/build/__init__.py
slapos/recipe/build/__init__.py
+28
-17
No files found.
slapos/recipe/build/__init__.py
View file @
84a8ce94
...
@@ -88,6 +88,8 @@ def guessworkdir(path):
...
@@ -88,6 +88,8 @@ def guessworkdir(path):
def
guessPlatform
():
def
guessPlatform
():
return
ARCH_MAP
[
uname
()[
-
2
]]
return
ARCH_MAP
[
uname
()[
-
2
]]
GLOBALS
=
(
lambda
*
x
:
{
x
.
__name__
:
x
for
x
in
x
})(
call
,
guessPlatform
,
guessworkdir
)
TRUE_LIST
=
(
'y'
,
'on'
,
'yes'
,
'true'
,
'1'
)
TRUE_LIST
=
(
'y'
,
'on'
,
'yes'
,
'true'
,
'1'
)
...
@@ -231,37 +233,45 @@ class Script(EnvironMixin):
...
@@ -231,37 +233,45 @@ class Script(EnvironMixin):
except
KeyError
:
except
KeyError
:
self
.
options
[
'location'
]
=
os
.
path
.
join
(
self
.
options
[
'location'
]
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
format
=
options
.
get
(
'format'
,
'yes'
)
in
TRUE_LIST
self
.
_format
=
options
.
get
(
'format'
,
'yes'
)
in
TRUE_LIST
init
=
options
.
get
(
'init'
)
missing
=
True
self
.
script
=
options
.
get
(
'script'
)
keys
=
'init'
,
'install'
,
'update'
if
self
.
script
:
for
option
in
keys
:
if
format
:
script
=
options
.
get
(
option
)
self
.
script
=
self
.
script
%
self
.
options
setattr
(
self
,
'_'
+
option
,
script
)
elif
not
init
:
if
script
:
raise
zc
.
buildout
.
UserError
(
'either init or script is required'
)
missing
=
False
if
missing
:
raise
zc
.
buildout
.
UserError
(
'at least one of the following option is required: '
+
', '
.
join
(
keys
))
if
self
.
options
.
get
(
'keep-on-error'
,
''
).
strip
().
lower
()
in
TRUE_LIST
:
if
self
.
options
.
get
(
'keep-on-error'
,
''
).
strip
().
lower
()
in
TRUE_LIST
:
self
.
logger
.
debug
(
'Keeping directories in case of errors'
)
self
.
logger
.
debug
(
'Keeping directories in case of errors'
)
self
.
keep_on_error
=
True
self
.
keep_on_error
=
True
else
:
else
:
self
.
keep_on_error
=
False
self
.
keep_on_error
=
False
EnvironMixin
.
__init__
(
self
,
False
)
EnvironMixin
.
__init__
(
self
,
False
)
if
init
:
if
self
.
_init
:
if
format
:
self
.
_exec
(
self
.
_init
)
init
=
init
%
options
exec
(
init
,
{
'self'
:
self
,
'options'
:
options
,
'env'
:
self
.
environ
})
def
_exec
(
self
,
script
):
options
=
self
.
options
exec
(
script
%
options
if
self
.
_format
else
script
,
dict
(
GLOBALS
,
self
=
self
,
options
=
options
,
location
=
options
[
'location'
],
))
def
install
(
self
):
def
install
(
self
):
if
not
self
.
script
:
if
not
self
.
_install
:
self
.
update
()
return
""
return
""
location
=
self
.
options
[
'location'
]
location
=
self
.
options
[
'location'
]
if
os
.
path
.
lexists
(
location
):
if
os
.
path
.
lexists
(
location
):
self
.
logger
.
warning
(
'Removing already existing path %r'
,
location
)
self
.
logger
.
warning
(
'Removing already existing path %r'
,
location
)
rmtree
(
location
)
rmtree
(
location
)
# env is used in script exec'ed below
env
=
self
.
environ
self
.
cleanup_list
=
[]
self
.
cleanup_list
=
[]
try
:
try
:
exec
(
self
.
script
)
self
.
_exec
(
self
.
_install
)
self
.
_checkPromise
(
'slapos_promise'
,
location
)
self
.
_checkPromise
(
'slapos_promise'
,
location
)
except
:
except
:
self
.
cleanup_list
.
append
(
location
)
self
.
cleanup_list
.
append
(
location
)
...
@@ -277,7 +287,8 @@ class Script(EnvironMixin):
...
@@ -277,7 +287,8 @@ class Script(EnvironMixin):
return
location
return
location
def
update
(
self
):
def
update
(
self
):
pass
if
self
.
_update
:
self
.
_exec
(
self
.
_update
)
def
applyPatchList
(
self
,
patch_string
,
patch_options
=
None
,
patch_binary
=
None
,
cwd
=
None
):
def
applyPatchList
(
self
,
patch_string
,
patch_options
=
None
,
patch_binary
=
None
,
cwd
=
None
):
if
patch_string
is
not
None
:
if
patch_string
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment