[cig-commits] [commit] baagaard/binary-packaging: Completed initial implementation of make_package script. (28eef5e)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Oct 21 12:16:08 PDT 2013


Repository : ssh://geoshell/pylith

On branch  : baagaard/binary-packaging
Link       : https://github.com/geodynamics/pylith/compare/a6dec97f3e070f4c39956e089e891598e9daad34...28eef5e234f462f7746de393840d1e5ef486448f

>---------------------------------------------------------------

commit 28eef5e234f462f7746de393840d1e5ef486448f
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Mon Oct 21 12:18:10 2013 -0700

    Completed initial implementation of make_package script.
    
    cygwin stuff not tested.


>---------------------------------------------------------------

28eef5e234f462f7746de393840d1e5ef486448f
 packager/cig.ico         | Bin 0 -> 1078 bytes
 packager/cygwin.py       | 343 ++++++++++++++++++++++++++++++++++++
 packager/make_package.py | 439 ++++++-----------------------------------------
 packager/packinglist.cfg |   8 +-
 4 files changed, 400 insertions(+), 390 deletions(-)

diff --git a/packager/cig.ico b/packager/cig.ico
new file mode 100644
index 0000000..34896de
Binary files /dev/null and b/packager/cig.ico differ
diff --git a/packager/cygwin.py b/packager/cygwin.py
new file mode 100644
index 0000000..618a8a3
--- /dev/null
+++ b/packager/cygwin.py
@@ -0,0 +1,343 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2013 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+# Functions used in creating PyLith binary with cygwin for windows.
+#
+# Usage: make_package.py
+
+import os, sys
+from os.path import basename, dirname, isabs, isdir, isfile, join
+import shutil
+
+def installCigIcon(prefix):
+    cigIco = "cig.ico"
+    os.system("cp %s %s" % (cigIco, prefix))
+    return
+
+
+def minCygwin(python):
+    # Minimal set of Cygwin binaries, as determined while preparing for CFEM 2006.
+    l = [
+        "[.exe",
+        "bash.exe",
+        "cat.exe",
+        "cp.exe",
+        "env.exe",
+        "cygattr-1.dll",
+        "cygiconv-2.dll",
+        "cygintl-8.dll",
+        "cygncurses-9.dll",
+        "cygpath.exe",
+        "cygcheck.exe",
+        "cygreadline7.dll",
+        "cyggfortran-3.dll",
+        "cyggcc_s-1.dll",
+        "cygstdc++-6.dll",
+        "cygncursesw-10.dll",
+        # This is given special treatment.
+        "cygwin1.dll",
+        "cygz.dll", # for HDF5 (used by Cigma)
+        "echo.exe",
+        "gunzip",
+        "gzip.exe",
+        "lib" + python + ".dll",
+        "ln.exe",
+        "ls.exe",
+        "ldd.exe",
+        "pwd.exe",
+        "python",
+        python + ".exe",
+        "rm.exe",
+        "sed.exe",
+        "sh.exe",
+        "tar.exe",
+        "vim-nox.exe",
+        "which.exe",
+        ]
+    l = ["/bin/" + b for b in l]
+
+    # Additional Python stuff.
+    l.extend([
+        "/lib/" + python,
+        "/usr/include/" + python,
+        ])
+
+    # Lapack libraries (used by numpy) now placed in own location.
+    l.extend([
+        "/lib/lapack",
+        ])
+
+    return l
+
+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.
+
+    # Therefore, we install a munged copy of "cygwin1.dll", performing
+    # the following transformations:
+    #     Cygnus Solutions -> Cigwin Solutions
+    #     cygwin1S4 -> cigwin1S4
+    # These are the registry key name and the shared memory object
+    # name, respectively.
+
+    # N.B.: It is significant that the replacement string is the same
+    # length as the original string.  Otherwise, the DLL would become
+    # corrupted.
+
+    # This gives us the freedom to create our own chrooted environment
+    # using Cygwin's mounts, without messing-up the Cygwin registry on
+    # systems that do have Cygwin installed.  Registry clean-up at
+    # uninstall is also made easy.
+
+    # Ugly, yes; but so much easier than building a custom Cygwin from
+    # source...
+    status = os.system("""sed -b """
+                       """-e "s/Cygnus Solutions/Cigwin Solutions/g" """
+                       """-e s/cygwin1S4/cigwin1S4/g """
+                       """/bin/cygwin1.dll > %s""" % munged)
+    if status != 0:
+        sys.exit("sed: exit %d" % status)
+    return
+
+
+def installMinimalCygwin(python, prefix):
+    cygwin = minCygwin(python)
+    copyAll(cygwin, prefix)
+    installMungedCygwinDLL("bin/cygwin1.dll")
+    return
+
+
+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."
+    
+    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 -v -d -b 0x70000000 -o 0x100000 %s""" % dlls)
+    if status != 0:
+        sys.exit("rebase: exit %d" % status)
+    return
+
+
+def stageInstallation(prefix, workdir, python, pl):
+    
+    stage = join(workdir, "buildbot-win-stage")
+    shutil.rmtree(stage, ignore_errors=True)
+    os.mkdir(stage)
+    os.chdir(stage)
+
+    print "Copying packing list to %s." % stage
+    copyAll(pl.files(), prefix)
+    
+    print "Installing minimal cygwin."
+    installMinimalCygwin(python, prefix)
+    
+    rebaseDLLs(stage)
+    
+    return stage
+
+
+def generateISS(workdir, sourceDir, info, pl, bashrc, python, stage=None):
+    s = open(workdir + "/buildbot.iss", "w")
+
+
+    # [Setup]
+    s.write(
+"""; Inno Setup Script generated by BuildBot
+
+[Setup]
+AppName=%(AppName)s
+AppVerName=%(AppVerName)s
+AppPublisher=Computational Infrastructure for Geodynamics
+AppPublisherURL=http://www.geodynamics.org/
+AppSupportURL=http://www.geodynamics.org/
+AppUpdatesURL=http://www.geodynamics.org/
+DefaultDirName={pf}\\%(AppName)s
+DefaultGroupName=%(AppName)s
+SourceDir=%(SourceDir)s
+
+""" % info
+    )
+
+
+    # [Tasks]
+    s.write(
+"""
+[Tasks]
+Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"
+
+""")
+
+
+    # [Files]
+    #  NOTE: Don't use "Flags: ignoreversion" on any shared system files
+    s.write(
+"""
+[Files]
+"""
+    )
+    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]
+    s.write(
+"""
+[Dirs]
+; Cygwin demands a /tmp directory
+Name: "{app}\\tmp"
+; for our /usr mounts
+Name: "{app}\\usr"
+Name: "{app}\\usr\\bin"
+Name: "{app}\\usr\\lib"
+
+"""
+    )
+
+
+    # [Registry]
+    s.write(
+"""
+[Registry]
+Root: HKLM; Subkey: "Software\\Cigwin Solutions"; Flags: uninsdeletekey noerror
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin"; Flags: uninsdeletekey noerror
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2"; Flags: uninsdeletekey noerror
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: uninsdeletekey noerror
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: noerror; ValueType: string; ValueName: "native"; ValueData: "{app}"
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: noerror; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: uninsdeletekey noerror
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: noerror; ValueType: string; ValueName: "native"; ValueData: "{app}\\bin"
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: noerror; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: uninsdeletekey noerror
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: noerror; ValueType: string; ValueName: "native"; ValueData: "{app}\\lib"
+Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: noerror; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
+; for non-admin install
+Root: HKCU; Subkey: "Software\\Cigwin Solutions"; Flags: uninsdeletekey
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin"; Flags: uninsdeletekey
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2"; Flags: uninsdeletekey
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: uninsdeletekey
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; ValueType: string; ValueName: "native"; ValueData: "{app}"
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: uninsdeletekey
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; ValueType: string; ValueName: "native"; ValueData: "{app}\\bin"
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: uninsdeletekey
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; ValueType: string; ValueName: "native"; ValueData: "{app}\\lib"
+Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
+
+"""
+    )
+
+
+    # [INI]
+    s.write("""[INI]\n""")
+    for name, filename, url in pl.urls:
+        s.write("""Filename: "{app}\\%(filename)s.url"; Section: "InternetShortcut"; Key: "URL"; String: "%(url)s"\n""" %
+                {'filename': filename, 'url': url})
+
+
+    # [Icons]
+    s.write(
+"""
+[Icons]
+Name: "{group}\\%(AppName)s"; Filename: "{app}\\bin\\bash.exe"; Parameters: "--init-file %(bashrc)s -i"; WorkingDir: "{app}"; IconFilename: "{app}\\cig.ico"
+Name: "{userdesktop}\\%(AppName)s"; Filename: "{app}\\bin\\bash.exe"; Tasks: desktopicon; Parameters: "--init-file %(bashrc)s -i"; WorkingDir: "{app}"; IconFilename: "{app}\\cig.ico"
+""" % {'AppName': info['AppName'], 'bashrc': bashrc}
+    )
+    for name, filename, url in pl.urls:
+        s.write("""Name: "{group}\\%s"; Filename: "{app}\\%s.url"\n""" % (name, filename))
+    s.write("""Name: "{group}\Uninstall %(AppName)s"; Filename: "{uninstallexe}"\n""" % info)
+
+
+    # [Run]
+    s.write(
+"""
+[Run]
+Filename: "{app}\\bin\\bash.exe"; Description: "Launch %(AppName)s"; Parameters: "--init-file %(bashrc)s -i"; WorkingDir: "{app}"; Flags: nowait postinstall skipifsilent
+
+""" % {'AppName': info['AppName'], 'bashrc': bashrc}
+    )
+
+
+    # [UninstallDelete]
+    s.write("""[UninstallDelete]\n""")
+    for name, filename, url in pl.urls:
+        s.write("""Type: files; Name: "{app}\%s.url"\n""" % filename)
+    for filename in [".bash_history"]:
+        s.write("""Type: files; Name: "{app}\%s"\n""" % filename)
+
+    s.write("\n; end of file\n")
+
+    return
+
+
+def createInstaller(python, stage, workdir, name, package, version, pl,
+                           installer):
+
+    sourceDir = cygpath("-w", stage)
+    
+    info = {
+        "AppName": name,
+        "AppVerName": name + " v" + version,
+        "SourceDir": sourceDir,
+        }
+
+    installCigIcon(stage)
+    bashrc = generateBashrc(stage, package, info)
+
+    generateISS(workdir, sourceDir, info, pl, bashrc, python, stage)
+
+    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" % (stage, installer))
+    if status != 0:
+        sys.exit("mv: exit %d" % status)
+
+    return
+
+
diff --git a/packager/make_package.py b/packager/make_package.py
old mode 100644
new mode 100755
index d6d9879..a1be441
--- a/packager/make_package.py
+++ b/packager/make_package.py
@@ -26,6 +26,7 @@ from os.path import basename, dirname, isabs, isdir, isfile, join
 import shutil
 from distutils.sysconfig import parse_makefile
 from ConfigParser import ConfigParser
+import cygwin
 
 
 class Packaging(object):
@@ -49,7 +50,8 @@ class Config(object):
     def readPackingList(cls):
 
         parser = ConfigParser()
-        parser.read("packinglist.cfg")
+        curdir = dirname(__file__)
+        parser.read(join(curdir, "packinglist.cfg"))
 
         config = Config()
 
@@ -68,16 +70,20 @@ class Config(object):
     readPackingList = classmethod(readPackingList)
 
 
-def getNamePackageAndVersion():
+def getMakeInfo():
     # NYI: This is Autotools-specific.
     makefile = parse_makefile("Makefile")
-    return makefile['PACKAGE_NAME'], makefile['PACKAGE'], makefile['VERSION']
+    info = {'package_name': makefile['PACKAGE_NAME'],
+            'package': makefile['PACKAGE'],
+            'version': makefile['VERSION'],
+            'srcdir': makefile['abs_top_srcdir'],
+            'prefix': makefile['prefix'],
+            'python_version': makefile['PYTHON_VERSION'],
+            }
+    return info
 
 
 
-from buildbot.meta import Config, getNamePackageAndVersion
-
-
 def walkDirTree(dirname):
     """
     Get list of files in tree under dirname.
@@ -250,28 +256,17 @@ def 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 getGitInfo():
-    url, revision = None, "unknown"
-    output = ospawn("git", "show")
+def getGitInfo(srcdir):
+    workdir = os.getcwd()
+    os.chdir(srcdir)
+    output = ospawn("git", "branch", "-v")
+    os.chdir(workdir)
+    revision = "unknown"
     for line in output:
         if line[0] == "*":
             values = line.split()
             revision = values[2]
-    return url, revision
+    return revision
 
 
 def itwindirs(l, sourceDir):
@@ -326,13 +321,6 @@ def copyAll(srcList, prefix):
     return
 
 
-def installCigIcon(prefix):
-    import buildbot
-    cigIco = dirname(buildbot.__file__) + "/cig.ico"
-    os.system("cp %s %s" % (cigIco, prefix))
-    return
-
-
 def generateBashrc(prefix, package, info):
     bashrc = "." + package.lower() + "rc"
     s = open(prefix + "/" + bashrc, "w")
@@ -358,318 +346,6 @@ PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
     return bashrc
 
 
-def minCygwin(python):
-    # Minimal set of Cygwin binaries, as determined while preparing for CFEM 2006.
-    l = [
-        "[.exe",
-        "bash.exe",
-        "cat.exe",
-        "cp.exe",
-        "env.exe",
-        "cygattr-1.dll",
-        "cygiconv-2.dll",
-        "cygintl-8.dll",
-        "cygncurses-9.dll",
-        "cygpath.exe",
-        "cygcheck.exe",
-        "cygreadline7.dll",
-        "cyggfortran-3.dll",
-        "cyggcc_s-1.dll",
-        "cygstdc++-6.dll",
-        "cygncursesw-10.dll",
-        # This is given special treatment.
-        "cygwin1.dll",
-        "cygz.dll", # for HDF5 (used by Cigma)
-        "echo.exe",
-        "gunzip",
-        "gzip.exe",
-        "lib" + python + ".dll",
-        "ln.exe",
-        "ls.exe",
-        "ldd.exe",
-        "pwd.exe",
-        "python",
-        python + ".exe",
-        "rm.exe",
-        "sed.exe",
-        "sh.exe",
-        "tar.exe",
-        "vim-nox.exe",
-        "which.exe",
-        ]
-    l = ["/bin/" + b for b in l]
-
-    # Additional Python stuff.
-    l.extend([
-        "/lib/" + python,
-        "/usr/include/" + python,
-        ])
-
-    # Lapack libraries (used by numpy) now placed in own location.
-    l.extend([
-        "/lib/lapack",
-        ])
-
-    return l
-
-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.
-
-    # Therefore, we install a munged copy of "cygwin1.dll", performing
-    # the following transformations:
-    #     Cygnus Solutions -> Cigwin Solutions
-    #     cygwin1S4 -> cigwin1S4
-    # These are the registry key name and the shared memory object
-    # name, respectively.
-
-    # N.B.: It is significant that the replacement string is the same
-    # length as the original string.  Otherwise, the DLL would become
-    # corrupted.
-
-    # This gives us the freedom to create our own chrooted environment
-    # using Cygwin's mounts, without messing-up the Cygwin registry on
-    # systems that do have Cygwin installed.  Registry clean-up at
-    # uninstall is also made easy.
-
-    # Ugly, yes; but so much easier than building a custom Cygwin from
-    # source...
-    status = os.system("""sed -b """
-                       """-e "s/Cygnus Solutions/Cigwin Solutions/g" """
-                       """-e s/cygwin1S4/cigwin1S4/g """
-                       """/bin/cygwin1.dll > %s""" % munged)
-    if status != 0:
-        sys.exit("sed: exit %d" % status)
-    return
-
-
-def installMinimalCygwin(python, prefix):
-    cygwin = minCygwin(python)
-    copyAll(cygwin, prefix)
-    installMungedCygwinDLL("bin/cygwin1.dll")
-    return
-
-
-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."
-    
-    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 -v -d -b 0x70000000 -o 0x100000 %s""" % dlls)
-    if status != 0:
-        sys.exit("rebase: exit %d" % status)
-    return
-
-
-def stageWindowsInstallation(prefix, workdir, python, pl):
-    
-    stage = join(workdir, "buildbot-win-stage")
-    shutil.rmtree(stage, ignore_errors=True)
-    os.mkdir(stage)
-    os.chdir(stage)
-
-    print "Copying packing list to %s." % stage
-    copyAll(pl.files(), prefix)
-    
-    print "Installing minimal cygwin."
-    installMinimalCygwin(python, prefix)
-    
-    rebaseDLLs(stage)
-    
-    return stage
-
-
-def generateISS(workdir, sourceDir, info, pl, bashrc, python, stage=None):
-    s = open(workdir + "/buildbot.iss", "w")
-
-
-    # [Setup]
-    s.write(
-"""; Inno Setup Script generated by BuildBot
-
-[Setup]
-AppName=%(AppName)s
-AppVerName=%(AppVerName)s
-AppPublisher=Computational Infrastructure for Geodynamics
-AppPublisherURL=http://www.geodynamics.org/
-AppSupportURL=http://www.geodynamics.org/
-AppUpdatesURL=http://www.geodynamics.org/
-DefaultDirName={pf}\\%(AppName)s
-DefaultGroupName=%(AppName)s
-SourceDir=%(SourceDir)s
-
-""" % info
-    )
-
-
-    # [Tasks]
-    s.write(
-"""
-[Tasks]
-Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"
-
-""")
-
-
-    # [Files]
-    #  NOTE: Don't use "Flags: ignoreversion" on any shared system files
-    s.write(
-"""
-[Files]
-"""
-    )
-    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]
-    s.write(
-"""
-[Dirs]
-; Cygwin demands a /tmp directory
-Name: "{app}\\tmp"
-; for our /usr mounts
-Name: "{app}\\usr"
-Name: "{app}\\usr\\bin"
-Name: "{app}\\usr\\lib"
-
-"""
-    )
-
-
-    # [Registry]
-    s.write(
-"""
-[Registry]
-Root: HKLM; Subkey: "Software\\Cigwin Solutions"; Flags: uninsdeletekey noerror
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin"; Flags: uninsdeletekey noerror
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2"; Flags: uninsdeletekey noerror
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: uninsdeletekey noerror
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: noerror; ValueType: string; ValueName: "native"; ValueData: "{app}"
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: noerror; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: uninsdeletekey noerror
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: noerror; ValueType: string; ValueName: "native"; ValueData: "{app}\\bin"
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: noerror; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: uninsdeletekey noerror
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: noerror; ValueType: string; ValueName: "native"; ValueData: "{app}\\lib"
-Root: HKLM; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: noerror; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
-; for non-admin install
-Root: HKCU; Subkey: "Software\\Cigwin Solutions"; Flags: uninsdeletekey
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin"; Flags: uninsdeletekey
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2"; Flags: uninsdeletekey
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; Flags: uninsdeletekey
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; ValueType: string; ValueName: "native"; ValueData: "{app}"
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/"; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; Flags: uninsdeletekey
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; ValueType: string; ValueName: "native"; ValueData: "{app}\\bin"
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/bin"; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; Flags: uninsdeletekey
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; ValueType: string; ValueName: "native"; ValueData: "{app}\\lib"
-Root: HKCU; Subkey: "Software\\Cigwin Solutions\\Cygwin\\mounts v2\\/usr/lib"; ValueType: dword; ValueName: "flags"; ValueData: "00000002"
-
-"""
-    )
-
-
-    # [INI]
-    s.write("""[INI]\n""")
-    for name, filename, url in pl.urls:
-        s.write("""Filename: "{app}\\%(filename)s.url"; Section: "InternetShortcut"; Key: "URL"; String: "%(url)s"\n""" %
-                {'filename': filename, 'url': url})
-
-
-    # [Icons]
-    s.write(
-"""
-[Icons]
-Name: "{group}\\%(AppName)s"; Filename: "{app}\\bin\\bash.exe"; Parameters: "--init-file %(bashrc)s -i"; WorkingDir: "{app}"; IconFilename: "{app}\\cig.ico"
-Name: "{userdesktop}\\%(AppName)s"; Filename: "{app}\\bin\\bash.exe"; Tasks: desktopicon; Parameters: "--init-file %(bashrc)s -i"; WorkingDir: "{app}"; IconFilename: "{app}\\cig.ico"
-""" % {'AppName': info['AppName'], 'bashrc': bashrc}
-    )
-    for name, filename, url in pl.urls:
-        s.write("""Name: "{group}\\%s"; Filename: "{app}\\%s.url"\n""" % (name, filename))
-    s.write("""Name: "{group}\Uninstall %(AppName)s"; Filename: "{uninstallexe}"\n""" % info)
-
-
-    # [Run]
-    s.write(
-"""
-[Run]
-Filename: "{app}\\bin\\bash.exe"; Description: "Launch %(AppName)s"; Parameters: "--init-file %(bashrc)s -i"; WorkingDir: "{app}"; Flags: nowait postinstall skipifsilent
-
-""" % {'AppName': info['AppName'], 'bashrc': bashrc}
-    )
-
-
-    # [UninstallDelete]
-    s.write("""[UninstallDelete]\n""")
-    for name, filename, url in pl.urls:
-        s.write("""Type: files; Name: "{app}\%s.url"\n""" % filename)
-    for filename in [".bash_history"]:
-        s.write("""Type: files; Name: "{app}\%s"\n""" % filename)
-
-    s.write("\n; end of file\n")
-
-    return
-
-
-def createWindowsInstaller(python, stage, workdir, name, package, version, pl,
-                           installer):
-
-    sourceDir = cygpath("-w", stage)
-    
-    info = {
-        "AppName": name,
-        "AppVerName": name + " v" + version,
-        "SourceDir": sourceDir,
-        }
-
-    installCigIcon(stage)
-    bashrc = generateBashrc(stage, package, info)
-
-    generateISS(workdir, sourceDir, info, pl, bashrc, python, stage)
-
-    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" % (stage, installer))
-    if status != 0:
-        sys.exit("mv: exit %d" % status)
-
-    return
-
-
 def stripBinaries(pl, opSys):
     strip = "strip"
     if opSys == "darwin":
@@ -711,28 +387,17 @@ def rewriteScripts(pl, prefix, opSys):
     return
 
 
-def installSource(pl, package, revision, url, workdir):
-    src = "src/" + package
+def installSource(pl, taggedArchive):
+    src = "src"
     shutil.rmtree(src, ignore_errors=True)
-    if not isdir("src"):
-        os.makedirs("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)
+    if not isdir(src):
+        os.makedirs(src)
+    spawn("tar", "-C", src, "-xf", taggedArchive)
     pl.addDirectory(src)
     return
 
 
 def mkpkg():
-    buildnumber = int(sys.argv[1])
-
     # WithProperties simply doesn't work in this case.
     if False:
         revision = sys.argv[2]
@@ -741,36 +406,36 @@ def mkpkg():
         else:
             revision = "forced"
     
-    url, revision = getGitInfo()
+    makeinfo = getMakeInfo()
+    python = "python"+makeinfo['python_version']
+    distdir = makeinfo['package'] + "-" + makeinfo['version']
+    prefix = makeinfo['prefix']
+    package = makeinfo['package']
+    print "version:", makeinfo['version']
+    print "python:", python
+    print "prefix:", prefix
+    print "distdir:", distdir
+    
+    revision = getGitInfo(makeinfo['srcdir'])
     opSys = platform.system().lower()
     if opSys.startswith("cygwin"):
         opSys = "win"
     if opSys=="darwin":
-        arch = opSys + "-" + (platform.mac_ver()[0] or '10.4')
+        arch = opSys + "-" + platform.mac_ver()[0]
     else:
         arch = opSys + "-" + (platform.processor() or platform.machine()) # Why does every last detail have to be painful?
-    tag = "%s-b%04d" % (revision, buildnumber)
-    python = os.environ['PYTHON']
-    prefix = os.environ['PREFIX']
-    name, package, version = getNamePackageAndVersion()
-    distdir = package + "-" + version
-    print "tag:", tag
-    print "python:", python
-    print "prefix:", prefix
-    print "distdir:", distdir
 
-    config = Config.readConfigFromSubversionProp()
+    config = Config.readPackingList()
     if config.packaging is None:
-        sys.exit('no packaging configuation; try "svn propedit buildbot:config ."')
+        sys.exit("ERROR: No packaging configuation.")
 
-    if opSys == "linux":
-        # We only need one of these; do it on Linux only.
-        archive = distdir + ".tar.gz"
-        taggedArchive = tag + "-" + archive
-        status = os.system("make dist")
-        if status != 0:
-            sys.exit("make: exit %d" % status)
-        os.system("mv " + archive + " " + taggedArchive)
+    # Make source distribution (also extracted into binary package)
+    archive = distdir + ".tar.gz"
+    taggedArchive = revision + "-" + archive
+    status = os.system("make dist")
+    if status != 0:
+        sys.exit("make: exit %d" % status)
+    os.system("mv " + archive + " " + taggedArchive)
 
     workdir = os.getcwd()
     os.chdir(prefix)
@@ -779,8 +444,7 @@ def mkpkg():
 
     stripBinaries(pl, opSys)
     rewriteScripts(pl, prefix, opSys)
-    if url:
-        installSource(pl, package, revision, url, workdir)
+    installSource(pl, join(workdir, taggedArchive))
 
     distdir_arch = distdir + "-" + arch
     if opSys == "darwin" or opSys == "linux":
@@ -795,16 +459,19 @@ def mkpkg():
         plfile.close()
 
         archive = distdir_arch + ".tar.gz"
-        taggedArchive = tag + "-" + archive
+        taggedArchive = revision + "-" + archive
         status = os.system("tar cvzf " + archive + " -T tar_list")
         if status != 0:
             sys.exit("tar: exit %d" % status)
 
         os.system("mv " + archive + " " + taggedArchive)
+        os.system("rm tar_list " + distdir_arch)
+        shutil.rmtree("src", ignore_errors=True)
+
     elif opSys == "win":
-        stage = stageWindowsInstallation(prefix, workdir, python, pl)
-        createWindowsInstaller(python, stage, workdir, name, package, version, pl,
-                               tag + "-" + distdir_arch)
+        stage = cygwin.stageInstallation(prefix, workdir, python, pl)
+        cygwin.createInstaller(python, stage, workdir, name, package, version, pl,
+                               revision + "-" + distdir_arch)
     else:
         sys.exit("unknown OS: " + opSys)
 
diff --git a/packager/packinglist.cfg b/packager/packinglist.cfg
index 86828f4..2d84ab8 100644
--- a/packager/packinglist.cfg
+++ b/packager/packinglist.cfg
@@ -1,5 +1,4 @@
 # -*- cfg -*-
-
 [packaging]
 
 bin_dirs =
@@ -82,9 +81,10 @@ scripts =
     pylith
     pylithinfo
     pylith_genxdmf
-    pyconvert.py
-    gensimpledb.py
-    powerlaw_gendb.py
+
+#    pyconvert.py
+#    gensimpledb.py
+#    powerlaw_gendb.py
 
 
 



More information about the CIG-COMMITS mailing list