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
30039129
Commit
30039129
authored
May 04, 2016
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a dedicated buildout directory for building a rebootstrap python.
parent
4c8cca26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
28 deletions
+12
-28
slapos/rebootstrap/__init__.py
slapos/rebootstrap/__init__.py
+12
-28
No files found.
slapos/rebootstrap/__init__.py
View file @
30039129
...
...
@@ -24,13 +24,18 @@ class Rebootstrap:
def
__init__
(
self
,
buildout
):
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'
]
self
.
wanted_python
=
buildout
[
self
.
python_section
][
'executable'
].
replace
(
buildout_directory
,
self
.
rebootstrap_directory
)
# query for currently running python
self
.
running_python
=
sys
.
executable
...
...
@@ -53,12 +58,12 @@ 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
env
[
'ORIG_PYTHON'
]
=
sys
.
executable
os
.
execve
(
self
.
wanted_python
,
[
self
.
wanted_python
]
+
args
,
env
)
def
install_section
(
self
):
env
=
os
.
environ
if
not
os
.
path
.
exists
(
self
.
wanted_python
):
# For safety, we always try to install/update instead of the condition
# if not os.path.exists(self.wanted_python):
if
True
:
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
)
...
...
@@ -72,6 +77,8 @@ Buildout will be restarted automatically to have this change applied.
# rerun buildout with only neeeded section to reuse buildout
# ability to calcuate all dependency
args
.
extend
([
# chroot to rebootstrap directory
'buildout:directory=%s'
%
self
.
rebootstrap_directory
,
# install only required section with dependencies
'buildout:parts=%s'
%
self
.
python_section
,
# do not load this extension
...
...
@@ -89,26 +96,3 @@ 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