[Greater-commits] r352 - trunk/packaging

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jul 5 15:15:04 CEST 2011


Author: aheinecke
Date: 2011-07-05 15:15:03 +0200 (Tue, 05 Jul 2011)
New Revision: 352

Added:
   trunk/packaging/makeinstaller.py
   trunk/packaging/run.py
Modified:
   trunk/packaging/greater-installer.nsi
   trunk/packaging/installer-options.ini
Log:
Switch to installer types installation system and add a script to call
makensis and generate the input files for the installer types


Modified: trunk/packaging/greater-installer.nsi
===================================================================
--- trunk/packaging/greater-installer.nsi	2011-07-05 11:33:35 UTC (rev 351)
+++ trunk/packaging/greater-installer.nsi	2011-07-05 13:15:03 UTC (rev 352)
@@ -96,10 +96,18 @@
   Name "${productname}"
   OutFile "${setupname}"
   InstallDir "$PROGRAMFILES\${productname_short}"
+  InstType full
+  InstType client
+  InstType server
 
 ;--------------------------------
 ;Interface Settings
 
+  InstTypeSetText 0 "Full Installation"
+  InstTypeSetText 1 "Client only (no Database)"
+  InstTypeSetText 2 "Server only"
+  SectionSetInstTypes ${full_section_id} 1
+
   !define MUI_ABORTWARNING
   BrandingText "GREAT-ER III - PostgreSQL"
   ; MUI Settings / Header
@@ -108,13 +116,16 @@
   The Geo-referenced Regional Exposure Assesment Tool for European Rivers\r\n
   using the Postges SQL Database backend."
   !define MUI_HEADERIMAGE
+  !define MUI_COMPONENTSPAGE_TEXT_TOP "Please select installation type"
 
+
 ;--------------------------------
 ;Pages
   !define MUI_PAGE_CUSTOMFUNCTION_SHOW PrintNonAdminWarning
   !insertmacro MUI_PAGE_WELCOME
   !insertmacro MUI_PAGE_LICENSE ${license}
   !insertmacro MUI_PAGE_DIRECTORY
+  !insertmacro MUI_PAGE_COMPONENTS
   Page custom CustomPageOptions
   !insertmacro MUI_PAGE_INSTFILES
   !insertmacro MUI_PAGE_FINISH
@@ -141,7 +152,7 @@
 ;--------------------------------
 ;Installer Sections
 
-Section ""
+Section full full_section_id
   SetOutPath "$INSTDIR"
 
   ; Store installation folder
@@ -151,7 +162,7 @@
   ; package all files, recursively, preserving attributes
   ; assume files are in the correct places
 
-  File /a /r /x "*.nsi" /x "${setupname}" "${srcdir}\*"
+  !include ${allfiles}
 
   ; Create uninstaller
   WriteUninstaller "$INSTDIR\Uninstall.exe"
@@ -168,7 +179,13 @@
   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.
@@ -179,7 +196,7 @@
   IntCmp $R0 0 no_start_menu
   # Create new Start menu entries
   CreateDirectory "$SMPROGRAMS\${productname}"
-  CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" "$INSTDIR\bin\greater.exe"
+  CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" "$INSTDIR\${executable}"
   no_start_menu:
 
   # ** Desktop Icon **
@@ -190,21 +207,9 @@
      "Field 3" "State"
   IntCmp $R0 0 no_desktop
   # Create new Desktop link
-  CreateShortCut "$DESKTOP\${productname_short}.lnk" "$INSTDIR\bin\kontact.exe"
+  CreateShortCut "$DESKTOP\${productname_short}.lnk" "$INSTDIR\${executable}"
 #  no_desktop:
 
-  # ** Quick Launch **
-  # Delete old Quick Launch Bar link
-  Delete "$QUICKLAUNCH\${productname_short}.lnk"
-  # Check if the quick launch bar entries where requested.
-# !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
-#   "Field 4" "State"
-#  IntCmp $R0 0 no_quick_launch
-#  StrCmp $QUICKLAUNCH $TEMP no_quick_launch
-  # Create new Quick Launch Bar link
-  CreateShortCut "$QUICKLAUNCH\${productname_short}.lnk" "$INSTDIR\bin\kontact.exe"
-#  no_quick_launch:
-
   ; Create killkde.bat 
   FileOpen $1 "$INSTDIR\bin\killgreater.bat" "w"
   FileWrite $1 '@echo off $\r$\n'
@@ -262,13 +267,13 @@
 
   # Note that the default selection is done in the ini file.
   !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-        "Field 1" "Text" "Install Components"
+        "Field 1" "Text" "Please select where ${productname_short} shall install shortcuts:"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-        "Field 2" "Text" "GREAT-ER Desktop"
+        "Field 2" "Text" "Start Menu"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-        "Field 3" "Text" "GREAT-ER Server"
+        "Field 3" "Text" "Desktop"
   !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
-        "Field 4" "Text" "PostgreSQL Database"
+        "Field 4" "Text" "Install for all users"
   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "installer-options.ini"
 FunctionEnd
 

Modified: trunk/packaging/installer-options.ini
===================================================================
--- trunk/packaging/installer-options.ini	2011-07-05 11:33:35 UTC (rev 351)
+++ trunk/packaging/installer-options.ini	2011-07-05 13:15:03 UTC (rev 352)
@@ -1,5 +1,5 @@
 [Settings]
-NumFields=3
+NumFields=6
 
 ; The number of the fields here is known in installer.nsi.
 ; The tags must be "[Field N]" with N=1..NumFields
@@ -10,7 +10,6 @@
 Right=-1
 Top=0
 Bottom=20
-;Install components
 
 [Field 2]
 Type=Checkbox
@@ -18,23 +17,24 @@
 Right=-1
 Top=30
 Bottom=40
-;GREAT-ER Desktop
+;Text=All Users Menu
 State=1
 
 [Field 3]
 Type=Checkbox
 Left=0
 Right=-1
-Top=50
-Bottom=60
-;GREAT-ER Server
+Top=30
+Bottom=40
+;Text=Start Menu
 State=1
 
 [Field 4]
 Type=Checkbox
 Left=0
 Right=-1
-Top=70
-Bottom=80
-;Text=PostgresSQL Database
-State=0
+Top=50
+Bottom=60
+;Text=Desktop
+State=1
+

Added: trunk/packaging/makeinstaller.py
===================================================================
--- trunk/packaging/makeinstaller.py	2011-07-05 11:33:35 UTC (rev 351)
+++ trunk/packaging/makeinstaller.py	2011-07-05 13:15:03 UTC (rev 352)
@@ -0,0 +1,94 @@
+# GREAT-ER Installer
+#(c)2011, Intevation GmbH
+#Authors:
+# Andre Heinecke aheinecke at intevation.de
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2,
+# or, at your option, any later version as published by the Free
+# Software Foundation
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Execute this script from the toplevel GREATER directory
+
+import time
+import os
+import run
+import os.path
+
+INSTALLER_OPTIONS = {
+        "executable" : os.path.join("GREAT-ER", "greater.exe"),
+        "company" : "Intevation GmbH",
+        "productname" : "GREAT-ER III PGSQL",
+        "setupname" : "Greater-Installer",
+        "license" : os.path.join("GREAT-ER", "COPYING"),
+        "copyright" : "Copyright (c) %s Intevation GmbH" % time.strftime("%Y"),
+        "productname_short" : "GREAT-ER",
+        "description" : ("Geo-referenced Regional Exposure "
+                         "Assessment Tool for European Rivers"),
+        "version_number" : "3.0.0.0",
+        "version_date" : time.strftime("%Y-%m-%d-%H-%M")}
+
+
+INSTALLER_OPTIONS["setupname" ] = INSTALLER_OPTIONS[ "setupname" ] + \
+                               "-%s.exe" % time.strftime("%Y-%m-%d-%H-%M")
+
+def traverse(self, directory, whitelist = lambda f: True):
+    '''
+        Traverse through a directory tree and return every
+        dirname and filename that the function whitelist returns as true
+    '''
+    dirs = [ directory ]
+    while dirs:
+        mypath = dirs.pop()
+        for f in os.listdir(mypath):
+            f = os.path.join(mypath, f)
+            if os.path.isdir(f):
+                dirs.append(f)
+                yield f
+            elif os.path.isfile(f) and whitelist(f):
+                yield f
+
+def generate_clientfiles():
+    pass
+
+def generate_serverfiles():
+    pass
+
+def generate_allfiles():
+    instdirs = ["GREAT-ER", "GREAT-ERModel", "GREAT-ER-DB"]
+
+    with fptr as open("allfiles.nsi", "w"):
+        for dir in instdirs:
+            dir = os.path.abspath(os.path.join("..", dir))
+        for fname in traverse(dir):
+            if os.path.isdir(fname):
+                fptr.write('${SetOutPath} "\%s"\r\n' % fname.replace(dir,
+                                                        "$INSTDIR"))
+            else:
+                fptr.write('${File} "%s"\r\n' % fname)
+
+    return os.path.abspath("allfiles.nsi")
+
+def main():
+    INSTALLER_OPTIONS["clientfiles"] = generate_clientfiles()
+    INSTALLER_OPTIONS["serverfiles"] = generate_serverfiles()
+    INSTALLER_OPTIONS["allfiles"] = generate_allfiles()
+
+    cmd = ["makensis"]
+    for key, value in INSTALLER_OPTIONS:
+        cmd.append("/D%s=%s" % key, value)
+    cmd.append(os.path.join("packaging", "greater-installer.nsi"))
+
+    run.call(cmd)
+
+if __name__ == '__main__':
+    main()

Added: trunk/packaging/run.py
===================================================================
--- trunk/packaging/run.py	2011-07-05 11:33:35 UTC (rev 351)
+++ trunk/packaging/run.py	2011-07-05 13:15:03 UTC (rev 352)
@@ -0,0 +1,86 @@
+# Copyright (C) 2007-2011 by Intevation GmbH
+# Authors:
+# Bernhard Herzog <bh at intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+"""Helper functions to run subprocesses in various ways"""
+
+import os
+import subprocess
+
+
+class SubprocessError(EnvironmentError):
+
+    def __init__(self, command, returncode, output=None):
+        EnvironmentError.__init__(self,
+                                  "Command %r finished with return code %d"
+                                  % (command, returncode))
+        self.returncode = returncode
+        self.output = output
+
+
+def call(command, suppress_output=False, extra_env=None, inputdata=None,
+         logfile=None, **kw):
+    """Run command as a subprocess and wait until it is finished.
+    The command should be given as a list of strings to avoid problems
+    with shell quoting.  If the command exits with a return code other
+    than 0, a SubprocessError is raised.
+    """
+    if inputdata is not None:
+        kw["stdin"] = subprocess.PIPE
+    if logfile:
+        logfile = open(logfile, "a")
+        kw["stdout"] = kw["stderr"] = logfile
+    elif suppress_output:
+        kw["stdout"] = open(os.devnull, "w")
+        kw["stderr"] = open(os.devnull, "w")
+    env = kw.pop("env", None)
+    if extra_env:
+        if env is None:
+            env = os.environ.copy()
+        env.update(extra_env)
+    try:
+        process = subprocess.Popen(command, env=env, **kw)
+    except OSError,e:
+        raise SubprocessError(command, e.errno, e.strerror)
+    finally:
+        if logfile:
+            logfile.close()
+
+    if inputdata is not None:
+        process.stdin.write(inputdata)
+        process.stdin.close()
+    ret = process.wait()
+    if ret != 0:
+        raise SubprocessError(command, ret)
+
+
+def capture_output(command, **kw):
+    """Return the stdout and stderr of the command as a string
+
+    The command should be given as a list of strings to avoid problems
+    with shell quoting.  If the command exits with a return code other
+    than 0, a SubprocessError is raised.
+    """
+    proc = subprocess.Popen(command, stdout=subprocess.PIPE,
+                            stderr=subprocess.STDOUT, **kw)
+    output = proc.communicate()[0]
+    if proc.returncode != 0:
+        raise SubprocessError(command, proc.returncode, output)
+    return output
+
+def capture_stdout(command, **kw):
+    """Return the stdout and stderr of the command as a string
+
+    The command should be given as a list of strings to avoid problems
+    with shell quoting.  If the command exits with a return code other
+    than 0, a SubprocessError is raised.
+    """
+    proc = subprocess.Popen(command, stdout=subprocess.PIPE,
+                            stderr=subprocess.PIPE, **kw)
+    output, error = proc.communicate()
+    if proc.returncode != 0:
+        raise SubprocessError(command, proc.returncode, error)
+    return output



More information about the Greater-commits mailing list