Commit ea3ad793 authored by Julien Muchembled's avatar Julien Muchembled

re6st: fixes in rebootstrap script

- Make it compatible with Python 3.
- Install setuptools in a way that's compatible with slapos.rebootstrap
  (otherwise, rebootstrapping fails because signature dependency to
  setuptools changes).
parent e4659587
#!/usr/bin/python2 -S
import glob, os, sys, tarfile, zipfile
d = "download-cache/dist"
p = "setuptools-*"
x, = glob.glob(d + "/" + p)
if x.endswith(".zip"):
zipfile.ZipFile(x).extractall()
else:
tarfile.TarFile.open(x, "r:*").extractall()
sys.path[:0] = p = glob.glob(p)
from setuptools.command.easy_install import main
for x in "bin", "eggs":
try:
os.mkdir(x)
except OSError, e:
pass
main(["-f", d, "-mxd", x, "zc.buildout"])
p.append(*glob.glob("eggs/zc.buildout-*"))
os.write(os.open("bin/buildout", os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0777), """\
#!/usr/bin/python -S
import glob, os, shutil, sys, tarfile, tempfile, zipfile
dist = "download-cache/dist"
tmp = tempfile.mkdtemp()
try:
setuptools, = glob.glob(dist + "/setuptools-*")
if setuptools.endswith(".zip"):
zipfile.ZipFile(setuptools).extractall(tmp)
else:
tarfile.TarFile.open(setuptools, "r:*").extractall(tmp)
x, = os.listdir(tmp)
sys.path.insert(0, os.path.join(tmp, x))
from setuptools.command.easy_install import main
for x in "bin", "eggs":
try:
os.mkdir(x)
except OSError:
pass
main(["-f", dist, "-mxd", x, setuptools, "zc.buildout"])
finally:
shutil.rmtree(tmp)
with os.fdopen(os.open("bin/buildout", os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0o777), 'w') as f:
f.write("""\
#!%s -S
import os, sys
d = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
d = os.path.dirname(d) + os.sep
d = os.path.dirname(d) + %r
sys.path[:0] = (%s)
from zc.buildout.buildout import main
sys.exit(main())
""" % (sys.executable, ", ".join("d + %r" % p for p in p)))
""" % (
sys.executable,
"/%s/" % x,
", ".join(map("d + %r".__mod__, os.listdir(x))),
))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment