[Greater-commits] r3773 - trunk/packaging

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 4 17:05:03 CEST 2011


Author: aheinecke
Date: 2011-10-04 17:05:03 +0200 (Tue, 04 Oct 2011)
New Revision: 3773

Modified:
   trunk/packaging/greater-installer.nsi
   trunk/packaging/makeinstaller.py
Log:
Package greater pre-processing


Modified: trunk/packaging/greater-installer.nsi
===================================================================
--- trunk/packaging/greater-installer.nsi	2011-10-04 15:04:19 UTC (rev 3772)
+++ trunk/packaging/greater-installer.nsi	2011-10-04 15:05:03 UTC (rev 3773)
@@ -232,6 +232,39 @@
   Return
 SectionEnd
 
+;--------------------------
+; Greater pre processing Section
+Section "Greater Preprocessing" gpp_section_id
+  SetOutPath "$INSTDIR"
+  !include ${gpp-in}
+  ; Set Path to $PROFILE
+  SetOutPath "%HOMEDRIVE%%HOMEPATH%"
+
+  # 'all users' shell folder is used (for $DESKTOP, $SMPROGRAMS, $QUICKLAUNCH,...)
+  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
+    "Field 4" "State"
+  SetShellVarContext all
+  IntCmp $R0 0 just_current_user all_users
+  just_current_user:
+      SetShellVarContext current
+  all_users:
+
+  # ** Start menu **
+  # Delete old Start menu entries.
+  RMDir /R  "$SMPROGRAMS\${productname_short} ${version_number}"
+  # Check if the start menu entries where requested.
+  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
+    "Field 2" "State"
+  IntCmp $R0 0 no_start_menu
+  # Create new Start menu entries
+  CreateDirectory "$SMPROGRAMS\${productname}"
+  CreateShortCut "$SMPROGRAMS\${productname}\${productname_short} USF.lnk" \
+                 "$PYTHON_PATH" '"$INSTDIR\greater-pre-processing\upload-catchment.py"' \
+                 "$INSTDIR\GREAT-ER\Resources\greater2.ico"
+  no_start_menu:
+  Return
+SectionEnd
+
 ;-----------------------------
 ; Client sections
 Section "Client (USF)" usf_section_id
@@ -390,12 +423,14 @@
   SectionSetInstTypes ${SecPostgreSQL} 5
   SectionSetInstTypes ${SecPython} 3
   SectionSetInstTypes ${admin_section_id} 5
+  SectionSetInstTypes ${gpp_section_id} 1
   SectionSetFlags ${client_section_id} 1
   SectionSetFlags ${SecPostgreSQL} 1
   SectionSetFlags ${SecPython} 1
   SectionSetFlags ${admin_section_id} 1
   SectionSetFlags ${usf_section_id} 1
   SectionSetFlags ${sediment_section_id} 1
+  SectionSetFlags ${gpp_section_id} 1
 
   SectionSetSize ${SecPostgreSQL} "207330"
   SectionSetSize ${SecPython} "55279"
@@ -418,9 +453,9 @@
   ClearErrors
   Push $0
   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "UninstallString"
-  IfErrors leave 0
+  IfErrors overwrite 0
     MessageBox MB_YESNO|MB_ICONEXCLAMATION "${productname_short} \
-    $(T_AlreadyInstalled)" IDYES leave
+    $(T_AlreadyInstalled)" IDYES leave IDNO overwrite
   leave:
     ExecWait '$0 _?=$INSTDIR'
   overwrite:
@@ -575,6 +610,7 @@
   !include ${usf-un}
   !include ${sediment-un}
   !include ${admin-un}
+  !include ${gpp-un}
   ; Delete Registry keys
   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}"
   DeleteRegKey HKLM "Software\${productname_short}"
@@ -647,6 +683,8 @@
     GREAT-ER Database."
   !insertmacro MUI_DESCRIPTION_TEXT ${SecPython} "Installs Python Version 2.7.2 necessary for \
     GREAT-ER"
+  !insertmacro MUI_DESCRIPTION_TEXT ${gpp_section_id} "Installs the catchment preprocessing and \
+      upload tools."
 
 !insertmacro MUI_FUNCTION_DESCRIPTION_END
 

Modified: trunk/packaging/makeinstaller.py
===================================================================
--- trunk/packaging/makeinstaller.py	2011-10-04 15:04:19 UTC (rev 3772)
+++ trunk/packaging/makeinstaller.py	2011-10-04 15:05:03 UTC (rev 3773)
@@ -27,6 +27,7 @@
 
 
 ADMINTOOL_PATH = "../bin"
+CYGWIN_PATH = "/cygwin/bin"
 
 INSTALLER_OPTIONS = {
         "executable" : "GREAT-ER.pyw",
@@ -93,22 +94,8 @@
 
 def generate_administration():
     admintool_files = ["greater.dtd", "greater.xsl", "administration.pdf"]
-    cmd = ["depends",
-           "/c", # Console mode
-           "/a:1", # Expand dependencies = on
-           "/oc:admintool-dependencies.txt"]
-    cmd.append(os.path.abspath(os.path.join(ADMINTOOL_PATH,
-                               "Administration.exe")))
-    try:
-        run.call(cmd, shell=True)
-    except run.SubprocessError , s:
-        # Depends likes to return with nonzero
-        pass
-
-    with open("admintool-dependencies.txt", "r") as fptr:
-        for line in fptr:
-            if line.startswith("Status"): continue
-            admintool_files.append(line.split(",")[1].lower().replace('"',''))
+    admintool_files += walk_dependencies(
+            os.path.join(ADMINTOOL_PATH, "Administration.exe"))
     outfiles = generate_files([ADMINTOOL_PATH], "admin-in.nsi", "admin-un.nsi",
                  lambda f: os.path.basename(f).lower() in admintool_files,
                  keep_subdirs=False)
@@ -173,7 +160,70 @@
         return True
     return generate_files(instdirs, "usf-in.nsi", "usf-un.nsi", whitelist)
 
+def walk_dependencies(executable):
+    """ Returns a list of all the files the executable depends on
+        The parameter executable has to be absolute
+    """
+    outfile = "%s-dependencies.txt" % os.path.basename(executable)
+    cmd = ["depends",
+           "/c", # Console mode
+           "/a:1", # Expand dependencies = on
+           "/oc:%s" % outfile]
+    cmd.append(executable)
+    try:
+        run.call(cmd, shell=True)
+    except run.SubprocessError , s:
+        # Depends likes to return with nonzero
+        pass
+
+    filelist = []
+    with open(outfile, "r") as fptr:
+        for line in fptr:
+            if line.startswith("Status"): continue
+            filelist.append(line.split(",")[1].lower().replace('"',''))
+    os.remove(outfile)
+    return filelist
+
+def generate_pre_processing_dependencies():
+    gpp_files = ["awk"]
+    cygwin_exectables = ["gawk", "sh", "rm", "sort", "join", "cut", "paste", "echo"]
+    for exc in [os.path.abspath(os.path.join(CYGWIN_PATH, "%s.exe" % name)) \
+            for name in cygwin_exectables]:
+        gpp_files += walk_dependencies(exc)
+
+    outfiles = generate_files([CYGWIN_PATH], "gpp-dep-in.nsi", "gpp-dep-un.nsi",
+                 lambda f: os.path.basename(f).lower() in gpp_files,
+                 keep_subdirs=False)
+    prefix_subdir("greater-pre-processing\\bin", outfiles)
+    return outfiles
+
+
+def join_files(input, output):
+    open(output, "a").write("\r\n" + open(input, "r").read())
+    os.remove(input)
+
+def generate_pre_processing():
+    instdirs = ["greater-pre-processing"]
+    for idir in instdirs:
+        compileall.compile_dir(idir, quiet = True)
+    def whitelist(f):
+        for bad in [".svn", "test_", ".log"]:
+            if bad in f:
+                return False
+        if os.path.basename(f).startswith("."):
+            return False
+        if "GREAT-ER-DB" in f and not "GreaterDB" in f:
+            return False
+        return True
+    files = generate_files(instdirs, "gpp-in.nsi", "gpp-un.nsi", whitelist)
+    deps = generate_pre_processing_dependencies()
+    join_files(deps[0], files[0])
+    join_files(deps[1], files[1])
+    return files
+
 def main():
+    (INSTALLER_OPTIONS["gpp-in"],
+     INSTALLER_OPTIONS["gpp-un"]) = generate_pre_processing()
     (INSTALLER_OPTIONS["client-in"],
      INSTALLER_OPTIONS["client-un"]) = generate_clientfiles()
     (INSTALLER_OPTIONS["admin-in"],



More information about the Greater-commits mailing list