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 #!/usr/bin/python -S
import glob, os, sys, tarfile, zipfile import glob, os, shutil, sys, tarfile, tempfile, zipfile
d = "download-cache/dist" dist = "download-cache/dist"
p = "setuptools-*" tmp = tempfile.mkdtemp()
x, = glob.glob(d + "/" + p) try:
if x.endswith(".zip"): setuptools, = glob.glob(dist + "/setuptools-*")
zipfile.ZipFile(x).extractall() if setuptools.endswith(".zip"):
else: zipfile.ZipFile(setuptools).extractall(tmp)
tarfile.TarFile.open(x, "r:*").extractall() else:
sys.path[:0] = p = glob.glob(p) tarfile.TarFile.open(setuptools, "r:*").extractall(tmp)
from setuptools.command.easy_install import main x, = os.listdir(tmp)
for x in "bin", "eggs": sys.path.insert(0, os.path.join(tmp, x))
try: from setuptools.command.easy_install import main
os.mkdir(x) for x in "bin", "eggs":
except OSError, e: try:
pass os.mkdir(x)
main(["-f", d, "-mxd", x, "zc.buildout"]) except OSError:
p.append(*glob.glob("eggs/zc.buildout-*")) pass
os.write(os.open("bin/buildout", os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0777), """\ 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 #!%s -S
import os, sys import os, sys
d = os.path.dirname(os.path.abspath(os.path.realpath(__file__))) 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) sys.path[:0] = (%s)
from zc.buildout.buildout import main from zc.buildout.buildout import main
sys.exit(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