Misc. changes to installer including:
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Mar 2011 15:52:12 +0000 (15:52 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Mar 2011 15:52:12 +0000 (15:52 +0000)
1 - Fix profile manager links
2 - Add tag at top (currently "Trunk") for easy changing
3 - Add optional extras.nsi for easy additions of extra install/uninstall lines
4 - Run uninstaller if installing to a directory with one (old style OR new style)
5 - Allow license override and only show license page if one defined
    Ex. With NSIS_EXTRAOPTS set to "-DPRODUCT_LICENSE=some/path"
    Or to disable use "-DPRODUCT_LICENSE"
6 - Similar to devbuild, allow for registration per-machine by default
    This includes needing to not wipe out the folder this is stored in
7 - Make "Everyone" able to write to the install folder when:
    Autoupdate is an option
    Per-machine registration is an option
8 - Make silent uninstall function

Author: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19750 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/Makefile.am
Open-ILS/xul/staff_client/external/aa_per_machine.js [new file with mode: 0644]
Open-ILS/xul/staff_client/external/make_updates.sh
Open-ILS/xul/staff_client/extras.example.nsi [new file with mode: 0644]
Open-ILS/xul/staff_client/windowssetup.nsi

index fe74bdd..40d6265 100644 (file)
@@ -25,6 +25,7 @@ export NSIS_EXTRAOPTS
 export NSIS_WICON=$$(if [ -f client/evergreen.ico ]; then echo '-DWICON'; fi)
 export NSIS_AUTOUPDATE=$$([ -f client/defaults/preferences/autoupdate.js ] && echo '-DAUTOUPDATE')
 export NSIS_DEV=$$([ -f client/defaults/preferences/developers.js ] && echo '-DDEVELOPER')
+export NSIS_PERMACHINE=$$([ -f client/defaults/preferences/aa_per_machine.js ] && echo '-DPERMACHINE')
 
 #------------------------------
 # Build ILS XUL CLIENT/SERVER
@@ -40,6 +41,10 @@ devbuild: build
        @echo ' * Copying in developer preferences'
        @cp external/developers.js build/defaults/preferences/
 
+permachine: build
+       @echo ' * Copying in default to machine level registration file'
+       @cp external/aa_per_machine.js build/defaults/preferences/
+
 build: build_dir chrome2remote localize_manifest generated custom_skins open-ils stamp 
        @echo To test the staff client:
        @echo "  cd build/"
@@ -246,7 +251,7 @@ linux-xulrunner: client_app
 
 win-client: win-xulrunner
        @echo 'Building installer'
-       @makensis -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_EXTRAOPTS} windowssetup.nsi
+       @makensis -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_PERMACHINE} ${NSIS_EXTRAOPTS} windowssetup.nsi
        @echo 'Done'
 
 # For linux, just build a tar.bz2 archive
diff --git a/Open-ILS/xul/staff_client/external/aa_per_machine.js b/Open-ILS/xul/staff_client/external/aa_per_machine.js
new file mode 100644 (file)
index 0000000..863d023
--- /dev/null
@@ -0,0 +1,2 @@
+// Write to install directory instead of profile directory
+pref("open-ils.write_in_user_chrome_directory", false);
index 73f4c64..7ba79d2 100755 (executable)
@@ -119,7 +119,8 @@ function prep_update
 function check_file
 {
        CHECK_FILE="${1#$NEW/}"
-       if [ $CHECK_FILE == "update.manifest" ]; then
+       if [ $CHECK_FILE == "update.manifest" -o $CHECK_FILE == "defaults/preferences/developers.js" -o $CHECK_FILE == "defaults/preferences/aa_per_machine.js" ]; then
+        echo "Skipping $CHECK_FILE";
                return;
        fi
        DIR=$(dirname "$WORK/$CHECK_FILE")
@@ -165,7 +166,7 @@ function check_file
 function remove_file
 {
        RM_FILE="${1#$OLD/}"
-       if [ $RM_FILE != "update.manifest" ]; then
+       if [ $RM_FILE != "update.manifest" -a $RM_FILE != "defaults/preferences/developers.js" -a $RM_FILE != "defaults/preferences/aa_per_machine.js" -a $RM_FILE != "defaults/preferences/autoupdate.js" -a $RM_FILE != "defaults/preferences/autochannel.js" ]; then
                echo "remove \"$RM_FILE\"" >> "$MANIFEST"
        fi
 }
diff --git a/Open-ILS/xul/staff_client/extras.example.nsi b/Open-ILS/xul/staff_client/extras.example.nsi
new file mode 100644 (file)
index 0000000..7d0574c
--- /dev/null
@@ -0,0 +1,24 @@
+; Examples for extras file
+
+!ifdef EXTERNAL_EXTRAS_SECMAIN ; Main install block
+  ; Anything here will be done during install. Intended for shortcuts.
+
+  ; Useful examples include having an exe in the branding directory
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\My Program.lnk" "$INSTDIR\file.exe" "-somearg" "$INSTDIR\file.exe"
+
+  ; Or perhaps wanting a special link to start evergreen? You can even auto-detect icon usage:
+  !ifdef WICON
+    CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Something.lnk" "$INSTDIR\evergreen.exe" "-something" "$INSTDIR\evergreen.ico"
+  !else
+    CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Something.lnk" "$INSTDIR\evergreen.exe" "-something"
+  !endif
+!else ifdef EXTERNAL_EXTRAS_UNINSTALL ; Uninstall block
+  ; Anything you have added that you want removed may need uninstall lines
+
+  ; Such as that extra exe? Left a file and a link.
+  Delete "$INSTDIR\file.exe" 
+  Delete "$SMPROGRAMS\$ICONS_GROUP\My Program.lnk"
+
+  ; Or perhaps your extra start shortcuts?
+  Delete "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Something.lnk"
+!endif
index 1a7c038..6e1e08c 100644 (file)
@@ -1,15 +1,19 @@
 ; Script generated by the HM NIS Edit Script Wizard.
 
 ; HM NIS Edit Wizard helper defines
-!define PRODUCT_NAME "Evergreen Staff Client Trunk"
 ; Old versions of makensis don't like this, moved to Makefile
 ;!define /file PRODUCT_VERSION "client/VERSION"
+!define PRODUCT_TAG "Trunk"
+!define PRODUCT_NAME "Evergreen Staff Client ${PRODUCT_TAG}"
 !define PRODUCT_PUBLISHER "Evergreen Community"
 !define PRODUCT_WEB_SITE "http://evergreen-ils.org/"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\evergreen.exe"
 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
 !define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
+!ifndef PRODUCT_LICENSE
+  !define PRODUCT_LICENSE "..\..\..\LICENSE.txt"
+!endif
 
 ; MUI 1.67 compatible ------
 !include "MUI.nsh"
 
 ; Welcome page
 !insertmacro MUI_PAGE_WELCOME
-; License page
-!insertmacro MUI_PAGE_LICENSE "..\..\..\LICENSE.txt"
+; License page, if we have one
+!if "${PRODUCT_LICENSE}" != ""
+  !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE}"
+!endif
 ; Components page
-!ifdef AUTOUPDATE | DEVELOPER
+!ifdef AUTOUPDATE | DEVELOPER | PERMACHINE
 !insertmacro MUI_PAGE_COMPONENTS
 !endif
 ; Directory page
@@ -40,7 +46,7 @@
 ; Start menu page
 var ICONS_GROUP
 !define MUI_STARTMENUPAGE_NODISABLE
-!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Evergreen Staff Client Trunk"
+!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Evergreen Staff Client ${PRODUCT_TAG}"
 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
@@ -63,32 +69,58 @@ var ICONS_GROUP
 
 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
 OutFile "evergreen_staff_client_setup.exe"
-InstallDir "$PROGRAMFILES\Evergreen Staff Client Trunk"
+InstallDir "$PROGRAMFILES\Evergreen Staff Client ${PRODUCT_TAG}"
 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
 ShowInstDetails show
 ShowUnInstDetails show
 RequestExecutionLevel admin
 
 Section "Staff Client" SECMAIN
+  ; Uninstall old (inno) variant?
+  IfFileExists "$INSTDIR/unin000.exe" 0 +3
+    ExecWait '"$INSTDIR/unins000.exe" /VERYSILENT'
+    Sleep 5000 ; Wait five seconds in case the uninstaller returned before it was done
+  ; Uninstall old (nsis) version?
+  IfFileExists "$INSTDIR/uninst.exe" 0 +4
+    ExecWait '"$INSTDIR/uninst.exe" /S _?="$INSTDIR"'
+    Sleep 5000 ; Wait five seconds in case the uninstaller returned before it was done
+    Delete "$INSTDIR/uninst.exe"
   SetOutPath "$INSTDIR"
-  File /r /x "autoupdate.js" /x "autochannel.js" /x "developers.js" "client\*"
+  File /r /x "autoupdate.js" /x "autochannel.js" /x "developers.js" /x "aa_per_machine.js" "client\*"
 
-; Shortcuts
+  ; Shortcuts
   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
   CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
   !ifdef WICON
   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe" "" "$INSTDIR\evergreen.ico"
   !ifdef PROFILES
-  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTRDIR\evergreen.exe -profilemanager" "" "$INSTDIR\evergreen.ico"
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTDIR\evergreen.exe" "-profilemanager" "$INSTDIR\evergreen.ico"
   !endif
   !else
   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe"
   !ifdef PROFILES
-  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTRDIR\evergreen.exe -profilemanager"
+  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTDIR\evergreen.exe" "-profilemanager"
   !endif
   !endif
-  CreateShortCut "$DESKTOP\Evergreen Staff Client Trunk.lnk" "$INSTDIR\evergreen.exe"
+  CreateShortCut "$DESKTOP\Evergreen Staff Client ${PRODUCT_TAG}.lnk" "$INSTDIR\evergreen.exe"
+  
+  ; External script for extra things.
+  !define EXTERNAL_EXTRAS_SECMAIN
+  !include /NONFATAL "extras.nsi"
+  !undef EXTERNAL_EXTRAS_SECMAIN
+
   !insertmacro MUI_STARTMENU_WRITE_END
+
+  !ifdef AUTOUPDATE | PERMACHINE
+  ; For autoupdate and/or registering per machine, make sure we can write to the install directory.
+  ; If the AccessControl plugin was packaged or part of nsis we would use it instead.
+  ; Also, as cacls.exe is depreciated when icacls.exe exists, try icacls.exe first.
+  IfFileExists "$SYSDIR/icacls.exe" 0 +3
+  ExecWait '"$SYSDIR/icacls.exe" "$INSTDIR" /grant Everyone:(OI)(CI)F'  
+  Goto +3
+  IfFileExists "$SYSDIR/cacls.exe" 0 +2
+  ExecWait '"$SYSDIR/cacls.exe" "$INSTDIR" /E /G Everyone:F'
+  !endif
 SectionEnd
 
 !ifdef AUTOUPDATE
@@ -108,12 +140,19 @@ Section /o "Developer Options" SECDEV
 SectionEnd
 !endif
 
+!ifdef PERMACHINE
+Section /o "Registration Per Machine" SECPERMAC
+  SetOutPath "$INSTDIR\defaults\preferences"
+  File "client\defaults\preferences\aa_per_machine.js"
+  SetOutPath "$INSTDIR"
+SectionEnd
+!endif
 
 Function .onInit
   !insertmacro MUI_LANGDLL_DISPLAY
   SectionSetFlags ${SECMAIN} 17
   ; This is mainly for silent installs
-  !ifdef AUTOUPDATE | DEVELOPER
+  !ifdef AUTOUPDATE | DEVELOPER | PERMACHINE
     Var /GLOBAL CMD_ARGS
     StrCpy $CMD_ARGS ""
     ${GetParameters} $CMD_ARGS
@@ -127,6 +166,16 @@ Function .onInit
       !endif
       SectionSetFlags ${SECAUTO} 1
     !endif
+    !ifdef PERMACHINE
+      !ifdef PERMACHINE_NODEFAULT
+        ${GetOptions} $CMD_ARGS "/permachine" $0
+        IfErrors +2 0
+      !else
+        ${GetOptions} $CMD_ARGS "/nopermachine" $0
+        IfErrors 0 +2
+      !endif
+      SectionSetFlags ${SECPERMAC} 1
+    !endif
     !ifdef DEVELOPER
       ${GetOptions} $CMD_ARGS "/developer" $0
       IfErrors +2 0
@@ -163,20 +212,32 @@ SectionEnd
   !ifdef DEVELOPER
   !insertmacro MUI_DESCRIPTION_TEXT ${SECDEV}  "Developer Options"
   !endif
+  !ifdef PERMACHINE
+  !insertmacro MUI_DESCRIPTION_TEXT ${SECPERMAC}  "Default registration and offline storage to per machine instead of per user"
+  !endif
 !insertmacro MUI_FUNCTION_DESCRIPTION_END
 
 
 Function un.onUninstSuccess
   HideWindow
-  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
+  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
 FunctionEnd
 
 Function un.onInit
 !insertmacro MUI_UNGETLANGUAGE
-  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
+  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" /SD IDYES IDYES +2
   Abort
 FunctionEnd
 
+Function "un.RemoveFileCheck"
+  StrCmp $R7 "open_ils_staff_client" +5
+  StrCmp $R6 "" +3
+  Delete "$R9"
+  Goto +2
+  RmDir /r "$R9"
+  Push $0
+FunctionEnd
+
 Section Uninstall
   !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
   Delete "$INSTDIR\${PRODUCT_NAME}.url"
@@ -191,19 +252,32 @@ Section Uninstall
   Delete "$INSTDIR\chrome.manifest"
   Delete "$INSTDIR\updates.xml"
   Delete "$INSTDIR\log.txt"
+  Delete "$INSTDIR\evergreen.ico"
 
   Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
   Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
-  Delete "$DESKTOP\Evergreen Staff Client Trunk.lnk"
+  Delete "$DESKTOP\Evergreen Staff Client ${PRODUCT_TAG}.lnk"
   Delete "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk"
 
+  ; External script for removing extra files before we wipe out the install directory
+  !define EXTERNAL_EXTRAS_UNINSTALL
+  !include /NONFATAL "extras.nsi"
+  !undef EXTERNAL_EXTRAS_UNINSTALL
+
   RMDir "$SMPROGRAMS\$ICONS_GROUP"
   RMDir /r "$INSTDIR\updates"
   RMDir /r "$INSTDIR\xulrunner"
   RMDir /r "$INSTDIR\extensions"
-  RMDir /r "$INSTDIR\chrome"
+;  RMDir /r "$INSTDIR\chrome" ; We can't wipe out the chrome directory normally. Per-machine info would be lost on upgrade.
   RMDir /r "$INSTDIR\components"
   RMDir /r "$INSTDIR\defaults"
+
+  ; Basically, we want to remove everything but "open_ils_staff_client" from the chrome dir
+  ; So we pass over every file and folder in it. If it matches, we leave it alone.
+  ${Locate} "$INSTDIR\chrome" "/G=0" "un.RemoveFileCheck"
+  ; Then, we remove the folder non-recursively, which won't wipe out the folder if it is still there.
+  RMDir "$INSTDIR\chrome"
+
   RMDir "$INSTDIR"
 
   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"