Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.rebootstrap
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.rebootstrap
Commits
4d38637b
Commit
4d38637b
authored
Mar 11, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a dedicated rebootstrap directory only if buildout:rebootstrap-directory is set.
parent
23c67201
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
13 deletions
+54
-13
README.txt
README.txt
+7
-0
slapos/rebootstrap/__init__.py
slapos/rebootstrap/__init__.py
+47
-13
No files found.
README.txt
View file @
4d38637b
...
...
@@ -33,6 +33,13 @@ Example profile and invocation
parts =
realrun
# Uncomment the following to use a dedicated buildout directory to
# build rebootstrap python # that is mandatory if the major version
# of python is different # between buildout's python and rebootstrap
# python.
#
# rebootstrap-directory = rebootstrap
[slapospython]
recipe = plone.recipe.command
...
...
slapos/rebootstrap/__init__.py
View file @
4d38637b
...
...
@@ -25,17 +25,23 @@ class Rebootstrap:
self
.
logger
=
logging
.
getLogger
(
__name__
)
self
.
buildout
=
buildout
buildout_directory
=
buildout
[
'buildout'
][
'directory'
]
self
.
rebootstrap_directory
=
os
.
path
.
join
(
buildout_directory
,
'rebootstrap'
)
# fetch section to build python, obligatory
self
.
python_section
=
(
buildout
[
'buildout'
].
get
(
'python'
)
or
\
buildout
[
'rebootstrap'
][
'section'
]
).
strip
()
self
.
wanted_python
=
buildout
[
self
.
python_section
][
'executable'
].
replace
(
buildout_directory
,
self
.
rebootstrap_directory
)
self
.
python_section
=
buildout
[
'buildout'
].
get
(
'python'
,
''
).
strip
()
if
not
self
.
python_section
:
raise
zc
.
buildout
.
UserError
(
'buildout:python is not defined.'
)
if
self
.
python_section
not
in
buildout
:
raise
zc
.
buildout
.
UserError
(
'[%s] is not defined.'
%
self
.
python_section
)
self
.
wanted_python
=
buildout
[
self
.
python_section
][
'executable'
]
rebootstrap_directory
=
buildout
[
'buildout'
].
get
(
'rebootstrap-directory'
)
if
rebootstrap_directory
:
self
.
rebootstrap_directory
=
os
.
path
.
join
(
buildout_directory
,
'rebootstrap'
)
self
.
wanted_python
=
self
.
wanted_python
.
replace
(
buildout_directory
,
self
.
rebootstrap_directory
,
1
)
else
:
self
.
rebootstrap_directory
=
buildout_directory
# query for currently running python
self
.
running_python
=
sys
.
executable
...
...
@@ -43,6 +49,10 @@ class Rebootstrap:
if
self
.
running_python
!=
self
.
wanted_python
:
self
.
install_section
()
self
.
reboot
()
elif
self
.
python_section
:
buildout
=
self
.
buildout
[
'buildout'
]
if
self
.
python_section
not
in
buildout
[
'parts'
].
split
():
buildout
[
'parts'
]
=
self
.
python_section
+
'
\
n
'
+
buildout
[
'parts'
]
def
reboot
(
self
):
message
=
"""
...
...
@@ -58,12 +68,13 @@ Buildout will be restarted automatically to have this change applied.
self
.
logger
.
info
(
message
)
args
=
map
(
zc
.
buildout
.
easy_install
.
_safe_arg
,
sys
.
argv
)
env
=
os
.
environ
if
'ORIG_PYTHON'
not
in
env
:
env
[
'ORIG_PYTHON'
]
=
sys
.
executable
os
.
execve
(
self
.
wanted_python
,
[
self
.
wanted_python
]
+
args
,
env
)
def
install_section
(
self
):
# For safety, we always try to install/update instead of the condition
# if not os.path.exists(self.wanted_python):
if
True
:
if
not
os
.
path
.
exists
(
self
.
wanted_python
)
or
\
self
.
rebootstrap_directory
!=
self
.
buildout
[
'buildout'
][
'directory'
]:
self
.
logger
.
info
(
'Installing section %r to provide %r'
%
(
self
.
python_section
,
self
.
wanted_python
))
args
=
map
(
zc
.
buildout
.
easy_install
.
_safe_arg
,
sys
.
argv
)
...
...
@@ -118,3 +129,26 @@ Buildout will be restarted automatically to have this change applied.
'%r
\
n
Unfortunately even after installing this section executable was'
' not found.
\
n
This is section responsibility to provide python (eg. '
'by compiling it).'
%
(
self
.
python_section
,
self
.
wanted_python
))
_uninstall_part_orig
=
zc
.
buildout
.
buildout
.
Buildout
.
_uninstall_part
def
_uninstall_part
(
self
,
part
,
installed_part_options
):
_uninstall_part_orig
(
self
,
part
,
installed_part_options
)
try
:
location
=
self
[
part
].
get
(
'location'
)
except
zc
.
buildout
.
buildout
.
MissingSection
:
return
if
location
and
sys
.
executable
.
startswith
(
location
):
message
=
"""
************ REBOOTSTRAP: IMPORTANT NOTICE ************
%r part that provides the running Python is uninstalled.
Buildout will be restarted automatically with the original Python.
************ REBOOTSTRAP: IMPORTANT NOTICE ************
"""
%
part
self
.
_logger
.
info
(
message
)
if
getattr
(
self
,
'dry_run'
,
False
):
sys
.
exit
()
args
=
map
(
zc
.
buildout
.
easy_install
.
_safe_arg
,
sys
.
argv
)
env
=
os
.
environ
orig_python
=
env
[
'ORIG_PYTHON'
]
os
.
execve
(
orig_python
,
[
orig_python
]
+
args
,
env
)
zc
.
buildout
.
buildout
.
Buildout
.
_uninstall_part
=
_uninstall_part
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