[cig-commits] r7466 - in cs/buildbot/trunk/buildbot: . scripts

leif at geodynamics.org leif at geodynamics.org
Mon Jun 25 01:37:22 PDT 2007


Author: leif
Date: 2007-06-25 01:37:22 -0700 (Mon, 25 Jun 2007)
New Revision: 7466

Modified:
   cs/buildbot/trunk/buildbot/meta.py
   cs/buildbot/trunk/buildbot/scripts/packager.py
   cs/buildbot/trunk/buildbot/scripts/shipper.py
Log:
Lots of fixes, esp. for Windows.

Modified: cs/buildbot/trunk/buildbot/meta.py
===================================================================
--- cs/buildbot/trunk/buildbot/meta.py	2007-06-25 07:54:54 UTC (rev 7465)
+++ cs/buildbot/trunk/buildbot/meta.py	2007-06-25 08:37:22 UTC (rev 7466)
@@ -42,7 +42,7 @@
     readConfigFromSubversionProp = classmethod(readConfigFromSubversionProp)
 
 
-def getPackageAndVersion():
+def getNamePackageAndVersion():
     # NYI: This is Autotools-specific.
     makefile = parse_makefile("Makefile")
-    return makefile['PACKAGE'], makefile['VERSION']
+    return makefile['PACKAGE_NAME'], makefile['PACKAGE'], makefile['VERSION']

Modified: cs/buildbot/trunk/buildbot/scripts/packager.py
===================================================================
--- cs/buildbot/trunk/buildbot/scripts/packager.py	2007-06-25 07:54:54 UTC (rev 7465)
+++ cs/buildbot/trunk/buildbot/scripts/packager.py	2007-06-25 08:37:22 UTC (rev 7466)
@@ -2,15 +2,13 @@
 import os, sys, platform
 from popen2 import Popen4
 from glob import glob
-from os.path import basename, dirname, isabs, isfile
-from buildbot.meta import Config, getPackageAndVersion
+from os.path import basename, dirname, isabs, isdir, isfile
+from buildbot.meta import Config, getNamePackageAndVersion
 
 
 class PackingList(object):
     def __init__(self, config, opSys, python):
-        self.all = []
         self.stripList = []
-        packingList = self.all
         stripList = self.stripList
 
         exe = ""
@@ -27,20 +25,17 @@
 
         self.directories = []
         for d in config.packaging.directories:
-            packingList.append(d)
             self.directories.append(d)
 
         self.programs = []
         for p in config.packaging.programs:
             p = "bin/" + p + exe
-            packingList.append(p)
             stripList.append(p)
             self.programs.append(p)
 
         self.scripts = []
         for s in config.packaging.scripts:
             s = "bin/" + s
-            packingList.append(s)
             self.scripts.append(s)
 
         self.libraries = []
@@ -53,22 +48,22 @@
                 l = "*mpich"
                 for p in ["mpirun", "mpiexec"]: # mpirun is evil symlink
                     p = "bin/" + p + exe
-                    packingList.append(p)
                     self.programs.append(p)
             elif l == "petsc" or l == "petsc-dev":
                 petsc = l
                 continue
             l = libglob % l
             libs = glob(l)
-            packingList.extend(libs)
             stripList.extend(libs)
             self.libraries.extend(libs)
         if petsc:
-            petsc_arch = os.environ['PETSC_ARCH']
-            petsc_libglob = "opt/" + petsc + "/" + petsc_arch + "/" + libglob
-            l = petsc_libglob % ""
+            if opSys == "win":
+                l = libglob % "petsc"
+            else:
+                petsc_arch = os.environ['PETSC_ARCH']
+                petsc_libglob = "opt/" + petsc + "/" + petsc_arch + "/" + libglob
+                l = petsc_libglob % ""
             libs = glob(l)
-            packingList.extend(libs)
             stripList.extend(libs)
             self.libraries.extend(libs)
 
@@ -79,11 +74,9 @@
             # Unfortunately, this will include all site-packages... oh well.
             # Note that Windows has its own logic for including Python.
             d = "lib/" + python
-            packingList.append(d)
             self.directories.append(d)
             l = libglob % "python"
             libs = glob(l)
-            packingList.extend(libs)
             self.libraries.extend(libs)
 
         else:
@@ -93,7 +86,6 @@
                 # Here we use glob expansion b/c eggs make the actual
                 # directory names hard to determine.
                 entries = glob(p)
-                packingList.extend(entries)
                 for e in entries:
                     if isfile(e):
                         self.misc.append(e)
@@ -125,6 +117,14 @@
         return
 
 
+    def all(self):
+        for d in self.directories:
+            yield d
+        for f in self.files():
+            yield f
+        return
+
+
 def tupleUp(l, n):
     tuples = []
     i = iter(l)
@@ -139,13 +139,22 @@
     return tuples
 
 
-def spawn(*cmd):
-    print ' '.join(cmd)
-    child = Popen4(cmd)
+def spawn(*argv):
+    print ' '.join(argv)
+    status = os.spawnvp(os.P_WAIT, argv[0], argv)
+    if status != 0:
+        statusMsg = "%s: %s: exit %d" % (sys.argv[0], argv[0], status)
+        sys.exit(statusMsg)
+    return
 
+
+def ospawn(*argv):
+    print ' '.join(argv)
+    child = Popen4(argv)
+
     child.tochild.close()
 
-    output = [line.rstrip() for line in child.fromchild]
+    output = child.fromchild.readlines()
     status = child.wait()
 
     exitStatus = None
@@ -156,19 +165,40 @@
         statusStr = "exit %d" % exitStatus
     else:
         statusStr = "status %d" % status
-    print "%s: %s" % (cmd[0], statusStr)
-    
+    if exitStatus != 0:
+        sys.exit("%s: %s: %s" % (sys.argv[0], argv[0], statusStr))
+
     return output
 
 
 def cygpath(*args):
-    output = spawn("cygpath", *args)
-    return output[0]
+    output = ospawn("cygpath", *args)
+    return output[0].rstrip()
 
 
+def getSVNInfo():
+    url, revision = None, "unknown"
+    output = ospawn("svn", "info")
+    for line in output:
+        values = line.split()
+        if len(values) == 2:
+            k, v = values
+            if k == "Revision:":
+                revision = "r" + v
+            elif k == "URL:":
+                url = v
+    return url, revision
+
+
 def itwindirs(l):
     for src in l:
-        if isabs(src):
+        if isinstance(src, tuple):
+            src, dest = src
+            if isabs(src):
+                src = cygpath("-w", src)
+            else:
+                src = src.replace("/", "\\")
+        elif isabs(src):
             dest = src[1:]
             src = cygpath("-w", src)
         else:
@@ -180,11 +210,21 @@
 
 
 def itwinfiles(l):
-    for f in l:
-        d = dirname(f)
-        f = f.replace("/", "\\")
-        d = d.replace("/", "\\")
-        yield f, d
+    for src in l:
+        if isinstance(src, tuple):
+            src, dest = src
+            if isabs(src):
+                src = cygpath("-w", src)
+            else:
+                src = src.replace("/", "\\")
+        elif isabs(src):
+            dest = dirname(src)[1:]
+            src = cygpath("-w", src)
+        else:
+            dest = dirname(src)
+            src = src.replace("/", "\\")
+        dest = "{app}\\" + dest.replace("/", "\\")
+        yield src, dest
     return
 
 
@@ -227,6 +267,7 @@
         "bash.exe",
         "cat.exe",
         "cp.exe",
+        "cygg2c.dll", # I cooked this one myself.
         "cygiconv-2.dll",
         "cygintl-3.dll",
         "cygintl-8.dll",
@@ -253,12 +294,12 @@
         ]
      l = ["/bin/" + b for b in l]
      l.extend([
-         "/lib/lapack/cygblas.dll",
-         "/lib/lapack/cyglapack.dll",
+         ("/lib/lapack/cygblas.dll", "bin"),
+         ("/lib/lapack/cyglapack.dll", "bin"),
          ])
      return l
 
-def installMungedCygwinDLL(prefix):
+def installMungedCygwinDLL(munged):
     # We don't require that the user has Cygwin installed.  At the
     # same time, we need to avoid conflicts if they *do* have it
     # installed.
@@ -284,7 +325,7 @@
     status = os.system("""sed -b """
                        """-e "s/Cygnus Solutions/Cigwin Solutions/g" """
                        """-e s/cygwin1S4/cigwin1S4/g """
-                       """/bin/cygwin1.dll > %s/bin/cygwin1.dll""" % prefix)
+                       """/bin/cygwin1.dll > %s""" % munged)
     if status != 0:
         sys.exit("sed: exit %d" % status)
     return
@@ -294,17 +335,14 @@
     
     binaries = minCygwin(python)
     for b in binaries:
-        command = "cp %s %s/bin" % (b, prefix)
-        print command
-        status = os.system(command)
-        if status != 0:
-            sys.exit("cp: exit %d" % status)
-        f = basename(b)
-        pl.addFile("bin/" + f)
+        pl.addFile(b)
+
+    tmp = prefix + "/tmp"
+    if not isdir(tmp):
+        os.mkdir(tmp)
+    installMungedCygwinDLL(tmp + "/cygwin1.dll")
+    pl.addFile(("tmp/cygwin1.dll", "bin"))
     
-    installMungedCygwinDLL(prefix)
-    pl.addFile("bin/cygwin1.dll")
-    
     pl.addDirectory("/lib/" + python)
 
     return
@@ -351,8 +389,8 @@
     )
     for src, dest in itwindirs(pl.directories):
         s.write("""Source: "%s\\*"; DestDir: "%s"; Flags: ignoreversion recursesubdirs\n""" % (src, dest))
-    for f, d in itwinfiles(pl.files()):
-        s.write("""Source: "%s"; DestDir: "{app}\\%s"; Flags: ignoreversion\n""" % (f, d))
+    for src, dest in itwinfiles(pl.files()):
+        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)
 
@@ -448,14 +486,14 @@
     return
 
     
-def createWindowsInstaller(python, prefix, package, version, pl,
+def createWindowsInstaller(python, prefix, name, package, version, pl,
                            installer):
 
     sourceDir = cygpath("-w", prefix)
     
     info = {
-        "AppName": package,
-        "AppVerName": package + " v" + version,
+        "AppName": name,
+        "AppVerName": name + " v" + version,
         "SourceDir": sourceDir,
         }
 
@@ -519,21 +557,43 @@
     return
 
 
+def installSource(pl, package, revision, url, workdir):
+    src = "src/" + package
+    spawn("rm", "-rf", src)
+    if False:
+        # This takes too long over a slow connection (the very reason
+        # we use 'copy' mode for the SourceStep).
+        spawn("svn", "export", "-" + revision, url, src)
+    elif False:
+        # This includes junk in .svn directories.
+        spawn("cp", "-r", workdir + "/../source", src)
+    else:
+        # This is just right.
+        spawn("svn", "export", workdir + "/../source", src)
+    pl.addDirectory(src)
+    return
+
+
 def mkpkg():
     buildnumber = int(sys.argv[1])
-    revision = sys.argv[2]
-    if revision:
-        revision = "r" + revision
-    else:
-        revision = "forced"
+
+    # WithProperties simply doesn't work in this case.
+    if False:
+        revision = sys.argv[2]
+        if revision:
+            revision = "r" + revision
+        else:
+            revision = "forced"
+    
+    url, revision = getSVNInfo()
     opSys = platform.system().lower()
     if opSys.startswith("cygwin"):
         opSys = "win"
     arch = opSys + "-" + platform.machine()
-    tag = "b%04d-%s" % (buildnumber, revision)
+    tag = "%s-b%04d" % (revision, buildnumber)
     python = os.environ['PYTHON']
     prefix = os.environ['PREFIX']
-    package, version = getPackageAndVersion()
+    name, package, version = getNamePackageAndVersion()
     distdir = package + "-" + version
     print "tag:", tag
     print "python:", python
@@ -556,11 +616,10 @@
 
     pl = PackingList(config, opSys, python)
 
-    print "strip", pl.stripList
-    print "pack", pl.all
-
     stripBinaries(pl, opSys)
     rewriteScripts(pl, prefix, opSys)
+    if url:
+        installSource(pl, package, revision, url, workdir)
 
     os.chdir(workdir)
 
@@ -569,7 +628,7 @@
         # No .dmg on Mac for now.
         os.system("rm " + distdir_arch)
         os.system("ln -s " + prefix + " " + distdir_arch)
-        packingList = [distdir_arch + "/" + m for m in pl.all]
+        packingList = [distdir_arch + "/" + m for m in pl.all()]
         archive = distdir_arch + ".tar.gz"
         taggedArchive = tag + "-" + archive
         status = os.system("tar cvzf " + archive + " " + " ".join(packingList))
@@ -578,7 +637,7 @@
 
         os.system("mv " + archive + " " + taggedArchive)
     elif opSys == "win":
-        createWindowsInstaller(python, prefix, package, version, pl,
+        createWindowsInstaller(python, prefix, name, package, version, pl,
                                tag + "-" + distdir_arch)
     else:
         sys.exit("unknown OS: " + opSys)

Modified: cs/buildbot/trunk/buildbot/scripts/shipper.py
===================================================================
--- cs/buildbot/trunk/buildbot/scripts/shipper.py	2007-06-25 07:54:54 UTC (rev 7465)
+++ cs/buildbot/trunk/buildbot/scripts/shipper.py	2007-06-25 08:37:22 UTC (rev 7466)
@@ -1,13 +1,22 @@
 
 import os, sys
+from buildbot.scripts.packager import getSVNInfo
 
 
 def ship():
     buildnumber = int(sys.argv[1])
-    revision = sys.argv[2]
-    if not revision:
-        revision = "forced"
-    tag = "b%04d-%s" % (buildnumber, revision)
+    
+    # WithProperties simply doesn't work in this case.
+    if False:
+        revision = sys.argv[2]
+        if revision:
+            revision = "r" + revision
+        else:
+            revision = "forced"
+    
+    url, revision = getSVNInfo()
+    tag = "%s-b%04d" % (revision, buildnumber)
+    
     files = tag + "*"
     # BuildBot sets restrictive umask.
     command = "chmod go+r " + files



More information about the cig-commits mailing list