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
Eric Zheng
slapos.recipe.build
Commits
0fe3a21c
Commit
0fe3a21c
authored
Feb 24, 2020
by
Bryton Lacquement
🚪
Committed by
Julien Muchembled
Feb 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default: new 'init' option
The purpose is to replace colletive.recipe.shelloutput /reviewed-on
!11
parent
008302f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
README.rst
README.rst
+18
-4
slapos/recipe/build/__init__.py
slapos/recipe/build/__init__.py
+12
-2
No files found.
README.rst
View file @
0fe3a21c
...
...
@@ -4,12 +4,13 @@
.. contents::
Examples
-------
-
Default
-------
Recipe to build the software.
The default recipe can be used to execute ad-hoc Python code at both
init & install phases.
Example buildout::
Example buildout
that builds software
::
[buildout]
parts =
...
...
@@ -83,6 +84,19 @@ For example::
print('%(foo)s')
# will print “%(foo)s”
Using the init option::
[section-one]
recipe = slapos.recipe.build
init =
import os
options['foo'] = os.uname()[4]
[section-two]
bar = ${section-one:foo}
It is also possible to use both `init` & `script` in the same section.
Pure download
~~~~~~~~~~~~~
...
...
slapos/recipe/build/__init__.py
View file @
0fe3a21c
...
...
@@ -268,18 +268,28 @@ class Script(EnvironMixin):
except
KeyError
:
self
.
options
[
'location'
]
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
self
.
script
=
self
.
options
[
'script'
]
format
=
options
.
get
(
'format'
,
'yes'
)
in
TRUE_LIST
init
=
options
.
get
(
'init'
)
self
.
script
=
options
.
get
(
'script'
)
if
self
.
script
:
if
self
.
options
.
get
(
'format'
,
'yes'
)
in
TRUE_LIST
:
if
format
:
self
.
script
=
self
.
script
%
self
.
options
elif
not
init
:
raise
zc
.
buildout
.
UserError
(
'either init or script is required'
)
if
self
.
options
.
get
(
'keep-on-error'
,
''
).
strip
().
lower
()
in
TRUE_LIST
:
self
.
logger
.
debug
(
'Keeping directories in case of errors'
)
self
.
keep_on_error
=
True
else
:
self
.
keep_on_error
=
False
EnvironMixin
.
__init__
(
self
,
False
)
if
init
:
if
format
:
init
=
init
%
options
exec
(
init
,
{
'self'
:
self
,
'options'
:
options
,
'env'
:
self
.
environ
})
def
install
(
self
):
if
not
self
.
script
:
return
""
location
=
self
.
options
[
'location'
]
if
os
.
path
.
lexists
(
location
):
self
.
logger
.
warning
(
'Removing already existing path %r'
,
location
)
...
...
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