[cig-commits] r15368 - cs/buildbot/trunk/buildbot/scripts
leif at geodynamics.org
leif at geodynamics.org
Sun Jun 21 01:49:22 PDT 2009
Author: leif
Date: 2009-06-21 01:49:22 -0700 (Sun, 21 Jun 2009)
New Revision: 15368
Modified:
cs/buildbot/trunk/buildbot/scripts/packager.py
Log:
Fixes for Windows installer while preparing for the workshop formerly
known as CFEM. Most notably, a work-around for the error "unable to
remap xyz.dll to same address as parent". (The files must now be
copied to a staging area so the DLLs can be rebased... hence all the
changes.)
Modified: cs/buildbot/trunk/buildbot/scripts/packager.py
===================================================================
--- cs/buildbot/trunk/buildbot/scripts/packager.py 2009-06-20 21:58:18 UTC (rev 15367)
+++ cs/buildbot/trunk/buildbot/scripts/packager.py 2009-06-21 08:49:22 UTC (rev 15368)
@@ -2,7 +2,7 @@
import os, sys, platform
from popen2 import Popen4
from glob import glob
-from os.path import basename, dirname, isabs, isdir, isfile
+from os.path import basename, dirname, isabs, isdir, isfile, join
from buildbot.meta import Config, getNamePackageAndVersion
@@ -92,7 +92,8 @@
# Unfortunately, this will include all site-packages... oh well.
# Note that Windows has its own logic for including Python.
self.directories.append("lib/" + python)
- self.directories.append("include/" + python) # for distutils
+ if opSys == "linux":
+ self.directories.append("include/" + python) # for distutils
l = libglob % "python"
libs = glob(l)
self.libraries.extend(libs)
@@ -240,6 +241,22 @@
return
+def copyAll(srcList, prefix):
+ for src in srcList:
+ if isinstance(src, tuple):
+ src, dest = src
+ elif isabs(src):
+ dest = dirname(src)[1:]
+ else:
+ dest = dirname(src)
+ if not isabs(src):
+ src = join(prefix, src)
+ if not isdir(dest):
+ os.makedirs(dest)
+ os.system("cp -r %s %s" % (src, dest))
+ return
+
+
def installCigIcon(prefix):
import buildbot
cigIco = dirname(buildbot.__file__) + "/cig.ico"
@@ -272,9 +289,9 @@
return bashrc
-# Minimal set of Cygwin binaries, as determined while preparing for CFEM 2006.
def minCygwin(python):
- l = [
+ # Minimal set of Cygwin binaries, as determined while preparing for CFEM 2006.
+ l = [
"[.exe",
"bash.exe",
"cat.exe",
@@ -290,7 +307,7 @@
#"cygwin1.dll",
"cygz.dll", # for HDF5 (used by Cigma)
"echo.exe",
- "gunzip.exe",
+ "gunzip",
"lib" + python + ".dll",
"ln.exe",
"ls.exe",
@@ -305,12 +322,17 @@
"vim.exe",
"which.exe",
]
- l = ["/bin/" + b for b in l]
- l.extend([
- ("/lib/lapack/cygblas.dll", "bin"),
- ("/lib/lapack/cyglapack.dll", "bin"),
- ])
- return l
+ l = ["/bin/" + b for b in l]
+ l.extend([
+ ("/lib/lapack/cygblas.dll", "bin"),
+ ("/lib/lapack/cyglapack.dll", "bin"),
+ ])
+ # Additional Python stuff.
+ l.extend([
+ "/lib/" + python,
+ "/usr/include/" + python,
+ ])
+ return l
def installMungedCygwinDLL(munged):
# We don't require that the user has Cygwin installed. At the
@@ -344,24 +366,55 @@
return
-def installMinimalCygwin(prefix, python, pl):
-
- binaries = minCygwin(python)
- for b in binaries:
- pl.addFile(b)
+def installMinimalCygwin(python, prefix):
+ cygwin = minCygwin(python)
+ copyAll(cygwin, prefix)
+ installMungedCygwinDLL("bin/cygwin1.dll")
+ return
- tmp = prefix + "/tmp"
- if not isdir(tmp):
- os.mkdir(tmp)
- installMungedCygwinDLL(tmp + "/cygwin1.dll")
- pl.addFile(("tmp/cygwin1.dll", "bin"))
+
+def rebaseDLLs(stage):
+ # Work-around "unable to remap xyz.dll to same address as parent".
+ # The base and offset were determined through trial-and-error.
+
+ print "Rebasing DLLs."
- pl.addDirectory("/lib/" + python)
+ dlls = []
+ for dirpath, dirnames, filenames in os.walk(stage):
+ for filename in filenames:
+ if filename.endswith(".dll"):
+ dll = join(dirpath, filename)
+ print dll
+ dlls.append(dll)
+
+ if not dlls:
+ sys.exit("no DLLs found!")
+ dlls = ' '.join(dlls)
+
+ status = os.system("""rebase -b 0x50000000 -o 0x100000 %s""" % dlls)
+ if status != 0:
+ sys.exit("rebase: exit %d" % status)
return
-def generateISS(workdir, sourceDir, info, pl, bashrc, python):
+def stageWindowsInstallation(prefix, workdir, python, pl):
+
+ stage = join(workdir, "buildbot-win-stage")
+ spawn("rm", "-rf", stage)
+ os.mkdir(stage)
+ os.chdir(stage)
+
+ copyAll(pl.all(), prefix)
+
+ installMinimalCygwin(python, prefix)
+
+ rebaseDLLs(stage)
+
+ return stage
+
+
+def generateISS(workdir, sourceDir, info, pl, bashrc, python, stage=None):
s = open(workdir + "/buildbot.iss", "w")
@@ -400,12 +453,19 @@
[Files]
"""
)
- for src, dest in itwindirs(pl.directories, sourceDir):
- s.write("""Source: "%s\\*"; DestDir: "%s"; Flags: ignoreversion recursesubdirs\n""" % (src, dest))
- for src, dest in itwinfiles(pl.files(), sourceDir):
- s.write("""Source: "%s"; DestDir: "%s"; Flags: ignoreversion\n""" % (src, dest))
- for f in [bashrc, "cig.ico"]:
- s.write("""Source: "%s"; DestDir: "{app}"; Flags: ignoreversion\n""" % f)
+ if stage:
+ for pathname in os.listdir(stage):
+ if isfile(pathname):
+ s.write("""Source: "%s"; DestDir: "{app}"; Flags: ignoreversion\n""" % pathname)
+ else:
+ s.write("""Source: "%s\\*"; DestDir: "{app}\\%s"; Flags: ignoreversion recursesubdirs\n""" % (pathname, pathname))
+ else:
+ for src, dest in itwindirs(pl.directories, sourceDir):
+ s.write("""Source: "%s\\*"; DestDir: "%s"; Flags: ignoreversion recursesubdirs\n""" % (src, dest))
+ for src, dest in itwinfiles(pl.files(), sourceDir):
+ s.write("""Source: "%s"; DestDir: "%s"; Flags: ignoreversion\n""" % (src, dest))
+ for f in [bashrc, "cig.ico"]:
+ s.write("""Source: "%s"; DestDir: "{app}"; Flags: ignoreversion\n""" % f)
# [Dirs]
@@ -498,11 +558,11 @@
return
-
-def createWindowsInstaller(python, prefix, workdir, name, package, version, pl,
+
+def createWindowsInstaller(python, stage, workdir, name, package, version, pl,
installer):
- sourceDir = cygpath("-w", prefix)
+ sourceDir = cygpath("-w", stage)
info = {
"AppName": name,
@@ -510,21 +570,20 @@
"SourceDir": sourceDir,
}
- installMinimalCygwin(prefix, python, pl)
+ installCigIcon(stage)
+ bashrc = generateBashrc(stage, package, info)
- installCigIcon(prefix)
- bashrc = generateBashrc(prefix, package, info)
+ generateISS(workdir, sourceDir, info, pl, bashrc, python, stage)
- generateISS(workdir, sourceDir, info, pl, bashrc, python)
+ os.chdir(workdir)
- os.chdir(workdir)
os.system("unix2dos buildbot.iss")
status = os.system("iscc buildbot.iss")
if status != 0:
sys.exit("iscc: exit %d" % status)
- status = os.system("mv %s/Output/setup.exe %s.exe" % (prefix, installer))
+ status = os.system("mv %s/Output/setup.exe %s.exe" % (stage, installer))
if status != 0:
sys.exit("mv: exit %d" % status)
@@ -654,7 +713,8 @@
os.system("mv " + archive + " " + taggedArchive)
elif opSys == "win":
- createWindowsInstaller(python, prefix, workdir, name, package, version, pl,
+ stage = stageWindowsInstallation(prefix, workdir, python, pl)
+ createWindowsInstaller(python, stage, workdir, name, package, version, pl,
tag + "-" + distdir_arch)
else:
sys.exit("unknown OS: " + opSys)
More information about the CIG-COMMITS
mailing list