[Greater-commits] r361 - trunk/packaging

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jul 6 18:50:31 CEST 2011


Author: aheinecke
Date: 2011-07-06 18:50:30 +0200 (Wed, 06 Jul 2011)
New Revision: 361

Modified:
   trunk/packaging/greater-installer.nsi
   trunk/packaging/installer-options.ini
   trunk/packaging/makeinstaller.py
Log:
Add python packaging


Modified: trunk/packaging/greater-installer.nsi
===================================================================
--- trunk/packaging/greater-installer.nsi	2011-07-06 15:15:14 UTC (rev 360)
+++ trunk/packaging/greater-installer.nsi	2011-07-06 16:50:30 UTC (rev 361)
@@ -24,10 +24,6 @@
   !include "MUI.nsh"
 
 ;--------------------------------
-; Plugins
-  !addplugindir plugins
-
-;--------------------------------
 ; Variable declarations
   Var POSTGRESQL_INSTALLED
 ;--------------------------------
@@ -105,29 +101,24 @@
 Section "PostgreSQL 9.0.4" SecPostgreSQL
   SetOutPath "$TEMP"
   File "postgresql-9.0.4-1-windows.exe"
-  DetailPrint "PostgreSQL wird installiert..."
+  DetailPrint "Installing PostgreSQL..."
   ExecWait '"$TEMP\postgresql-9.0.4-1-windows.exe --mode unattended"' $0
 SectionEnd
 
-Section "Administration Tool" admin_section_id
-;  !include ${adminfiles}
+Section "Python 2.7.2" SecPython
+  SetOutPath "$TEMP"
+  File "python-2.7.2.msi"
+  DetailPrint "Installing Python..."
+  ExecWait '"msiexec" /i $TEMP\python-2.7.2-msi TARGETDIR=$INSTDIR\Python' $0
 SectionEnd
+;---------------------------
+; General Section
+Section ""
+  ; Create uninstaller
+  WriteUninstaller "$INSTDIR\Uninstall.exe"
 
-Section "GREAT-ER Client" client_section_id
-  SetOutPath "$INSTDIR"
-
   ; Store installation folder
   WriteRegStr HKLM "Software\${productname_short}" "" $INSTDIR
-
-  ; Include the input files
-  ; package all files, recursively, preserving attributes
-  ; assume files are in the correct places
-
-  !include ${client-in}
-
-  ; Create uninstaller
-  WriteUninstaller "$INSTDIR\Uninstall.exe"
-
   ; Create Registry keys
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "DisplayName" "${productname_short} ${version_date}"
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "Displayversion_number" "${version_number}"
@@ -135,7 +126,11 @@
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "UninstallString" '"$INSTDIR\uninstall.exe"'
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "NoModify" 1
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "NoRepair" 1
+SectionEnd
 
+Section "Administration Tool" admin_section_id
+  SetOutPath "$INSTDIR"
+  !include ${admin-in}
   ; Set Path to $PROFILE
   SetOutPath "%HOMEDRIVE%%HOMEPATH%"
 
@@ -157,9 +152,45 @@
   IntCmp $R0 0 no_start_menu
   # Create new Start menu entries
   CreateDirectory "$SMPROGRAMS\${productname}"
-  CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" "$INSTDIR\${executable}"
+  CreateShortCut "$SMPROGRAMS\${productname}\GREAT-ER Administration.lnk" "$INSTDIR\Administration\bin\Administration.exe"
   no_start_menu:
+  Return
+SectionEnd
 
+Section "GREAT-ER Client" client_section_id
+
+
+  ; Include the input files
+  ; package all files, recursively, preserving attributes
+  ; assume files are in the correct places
+
+  !include ${client-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}.lnk" \
+                  "$INSTDIR\${executable}" "" "$INSTDIR\GREAT-ER\Greater1.ico"
+  no_start_menu:
+
   # ** Desktop Icon **
   # Delete old Desktop link
   Delete "$DESKTOP\${productname_short}.lnk"
@@ -171,18 +202,10 @@
   CreateShortCut "$DESKTOP\${productname_short}.lnk" "$INSTDIR\${executable}"
   no_desktop:
 
-  ; Create killkde.bat 
-  FileOpen $1 "$INSTDIR\bin\killgreater.bat" "w"
-  FileWrite $1 '@echo off $\r$\n'
-  FileWrite $1 'kdeinit4 --terminate'
-  FileClose $1
-
   Return
 
 SectionEnd
 
-
-
 ;--------------------------------
 ;Install Functions
 Function ".onInit"
@@ -191,6 +214,7 @@
   InstTypeSetText 2 "Server only"
   SectionSetInstTypes ${client_section_id} 3
   SectionSetSize ${SecPostgreSQL} "207330"
+  SectionSetSize ${SecPython} "55279"
   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer-options.ini"
   call CheckExistingVersion
   CALL DetectPostgreSQL
@@ -209,13 +233,13 @@
 Function CheckExistingVersion
   ClearErrors
   Push $0
-  ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "Displayversion_number"
+  ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "UninstallString"
   IfErrors leave 0
-    MessageBox MB_YESNO|MB_ICONEXCLAMATION "${productname_short} $0 \
+    MessageBox MB_YESNO|MB_ICONEXCLAMATION "${productname_short} \
     $(T_AlreadyInstalled)" IDYES leave
     Abort
   leave:
-
+    ExecWait '$0 _?=$INSTDIR'
 FunctionEnd
 
 # PrintNonAdminWarning
@@ -275,6 +299,13 @@
 ;--------------------------------
 ;Uninstaller
 
+Section "un."
+  !include ${client-un}
+  !include ${admin-un}
+  ; Delete Registry keys
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}"
+  DeleteRegKey HKLM "Software\${productname_short}"
+SectionEnd
 
 Section "un.PostgreSQL" UnSecPostgreSQL
   MessageBox MB_YESNO|MB_ICONQUESTION "Do you really wish to uninstall PostgreSQL?\
@@ -285,14 +316,16 @@
    ; TODO find path from registry and uninstall
    ExecWait '"uninstall-postgresql.exe --unattended"'
    Banner::destroy 
-  no: 
+  no:
 SectionEnd
 
-Section "un."
-!include ${client-un}
+Section "un.Python"
+   Banner::show /NOUNLOAD /set 76 "Uninstalling Python..."
+   SetOutPath "$TEMP" 
+   File "python-2.7.2.msi"
+   ExecWait '"msiexec" /uninstall $TEMP\python-2.7.2.msi'
+   Banner::destroy 
 SectionEnd
-
-
 ;--------------------------------
 ;Uninstall Functions
 
@@ -338,7 +371,7 @@
 # From Function CheckExistingVersion
 LangString T_AlreadyInstalled ${LANG_ENGLISH} \
     "has already been installed.$\r$\nDo you want to \
-    uninstall it and continue the installation of\r\n\
+    uninstall it and continue the installation of:$\r$\n\
     ${productname_short} ${version_date}?"
 # From Custom Welcome Page
 #
@@ -349,7 +382,7 @@
 # From Function CustomPageOptions
 # English
 LangString T_InstallOptions ${LANG_ENGLISH} "Install Options"
-LangString T_InstallOptLinks ${LANG_ENGLISH} "Start links"
+LangString T_InstallOptLinks ${LANG_ENGLISH} "Shortcut Options"
 LangString T_InstOptLabelA  ${LANG_ENGLISH} "Please select where ${productname_short} shall install links:"
 LangString T_InstOptFieldA  ${LANG_ENGLISH} "Start Menu"
 LangString T_InstOptFieldB  ${LANG_ENGLISH} "Desktop"

Modified: trunk/packaging/installer-options.ini
===================================================================
--- trunk/packaging/installer-options.ini	2011-07-06 15:15:14 UTC (rev 360)
+++ trunk/packaging/installer-options.ini	2011-07-06 16:50:30 UTC (rev 361)
@@ -15,26 +15,23 @@
 Type=Checkbox
 Left=0
 Right=-1
-Top=30
-Bottom=40
-;Text=All Users Menu
+Top=20
+Bottom=30
 State=1
 
 [Field 3]
 Type=Checkbox
 Left=0
 Right=-1
-Top=30
-Bottom=40
-;Text=Start Menu
+Top=40
+Bottom=50
 State=1
 
 [Field 4]
 Type=Checkbox
 Left=0
 Right=-1
-Top=50
-Bottom=60
-;Text=Desktop
+Top=60
+Bottom=70
 State=1
 

Modified: trunk/packaging/makeinstaller.py
===================================================================
--- trunk/packaging/makeinstaller.py	2011-07-06 15:15:14 UTC (rev 360)
+++ trunk/packaging/makeinstaller.py	2011-07-06 16:50:30 UTC (rev 361)
@@ -24,8 +24,11 @@
 import run
 import os.path
 
+
+ADMINTOOL_PATH = "../bin"
+
 INSTALLER_OPTIONS = {
-        "executable" : os.path.join("GREAT-ER", "greater.exe"),
+        "executable" : os.path.join("GREAT-ER", "Greater.pyw"),
         "company" : "Intevation GmbH",
         "productname" : "GREAT-ER III PGSQL",
         "setupname" : "Greater-Installer",
@@ -56,29 +59,64 @@
             elif os.path.isfile(f) and whitelist(f):
                 yield f
 
-def generate_files(dirs, in_name, un_name, whitelist = lambda f: True):
+def generate_files(dirs, in_name, un_name, whitelist = lambda f: True, keep_subdirs = True):
     curoutpath = None
     dirlist = []
     fptr, unptr = (open(in_name, "w"), open(un_name, "w"))
     for dir in dirs:
-        dir = os.path.abspath(dir)
-        for fname in traverse(dir, whitelist):
+        absdir = os.path.abspath(dir)
+        if not keep_subdirs:
+            dir = ""
+        for fname in traverse(absdir, whitelist):
             if os.path.dirname(fname) != curoutpath:
                 curoutpath = os.path.dirname(fname)
                 fptr.write('SetOutPath "%s"\r\n' % \
-                            curoutpath.replace(dir, "$INSTDIR"))
-                dirlist.insert(0, curoutpath.replace(dir, "$INSTDIR"))
-            else:
-                fptr.write('File "%s"\r\n' % fname)
-                unptr.write('Delete "%s"\r\n' % \
-                        fname.replace(dir, "$INSTDIR"))
+                            curoutpath.replace(absdir, "$INSTDIR\%s" % dir))
+                dirlist.insert(0, curoutpath.replace(absdir,
+                                                     "$INSTDIR\%s" % dir))
+            fptr.write('File "%s"\r\n' % fname)
+            unptr.write('Delete "%s"\r\n' % \
+                    fname.replace(dir, "$INSTDIR%s" % dir))
     for dir in dirlist:
         unptr.write('RMDir "%s"\r\n' % dir)
-
+    unptr.write('RMDir "$INSTDIR"')
     fptr.close()
     unptr.close()
     return (os.path.abspath(in_name), os.path.abspath(un_name))
 
+def generate_administration():
+    admintool_files = ["greater.dtd", "greater.xsl"]
+    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('"',''))
+    outfiles = generate_files([ADMINTOOL_PATH], "admin-in.nsi", "admin-un.nsi",
+                 lambda f: os.path.basename(f).lower() in admintool_files,
+                 keep_subdirs=False)
+    prefix_subdir("Administration", outfiles)
+    return outfiles
+
+def prefix_subdir(prefix, files):
+    for fname in files:
+        output = ""
+        with open(fname, "r") as fptr:
+            for line in fptr:
+                output += line.replace("$INSTDIR", "$INSTDIR\%s" % prefix)
+        with open(fname, "w") as fptr:
+            fptr.write(output)
+
 def generate_clientfiles():
     instdirs = ["GREAT-ER", "GREAT-ERModel", "GREAT-ER-DB"]
     def whitelist(f):
@@ -89,13 +127,14 @@
     return generate_files(instdirs, "client-in.nsi", "client-un.nsi", whitelist)
 
 def generate_serverfiles():
+
     pass
 
 def main():
     (INSTALLER_OPTIONS["client-in"],
      INSTALLER_OPTIONS["client-un"]) = generate_clientfiles()
-#     INSTALLER_OPTIONS["admin-in"]
-#     INSTALLER_OPTIONS["serverfiles"]) = generate_serverfiles()
+    (INSTALLER_OPTIONS["admin-in"],
+     INSTALLER_OPTIONS["admin-un"]) = generate_administration()
 #    INSTALLER_OPTIONS["allfiles"],
 #    INSTALLER_OPTIONS["un-allfiles"] = generate_allfiles()
 



More information about the Greater-commits mailing list