]> git.street.me.uk Git - andy/viking.git/blobdiff - win32/installer/viking-installer.nsi
Some spelling fixes in a comment
[andy/viking.git] / win32 / installer / viking-installer.nsi
index 00af9414443a0b3e89f39047b1fc1fc667be77ed..771b0d3a0e56aadde5e4e68a55795fe51c7eceaa 100644 (file)
@@ -9,13 +9,22 @@ Var name
 
 ;--------------------------------
 ;Configuration
+;Needs to be 4 numbers:  W.X.Y.Z
+!define VIKING_VERSION  "1.6.1.0"
 
 ;The name var is set in .onInit
 Name $name
 
+;Allow overiding location of binary components for the install
+!ifndef BINARIES
+  !define BINARIES ".\bin"
+!endif
+
 OutFile "viking-${VIKING_VERSION}.exe"
 
-SetCompressor /SOLID lzma
+;NB Using /SOLID method on a mingw32 setup seems to generate an exe that fails the CRC check
+;So now don't set the compressor here - it can be set by the calling command/script if necessary.
+;SetCompressor /SOLID bzip2
 ShowInstDetails show
 ShowUninstDetails show
 SetDateSave on
@@ -26,6 +35,9 @@ SetDateSave on
 !include "Sections.nsh"
 !include "WinVer.nsh"
 !include "LogicLib.nsh"
+!include "x64.nsh"
+;; http://nsis.sourceforge.net/File_Association
+!include "FileAssociation.nsh"
 
 !include "FileFunc.nsh"
 !insertmacro GetParameters
@@ -46,8 +58,6 @@ SetDateSave on
 !define HKLM_APP_PATHS_KEY                     "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\viking.exe"
 !define VIKING_UNINST_EXE                      "viking-uninst.exe"
 
-!define DOWNLOADER_URL                         "http://downloads.sourceforge.net/viking/"
-
 ;--------------------------------
 ;Version resource
 VIProductVersion "${VIKING_VERSION}"
@@ -88,7 +98,7 @@ VIAddVersionKey "FileDescription" "Viking Installer"
 ;Pages
 
   !insertmacro MUI_PAGE_WELCOME
-  !insertmacro MUI_PAGE_LICENSE                        ".\bin\COPYING_GPL.txt"
+  !insertmacro MUI_PAGE_LICENSE                        "${BINARIES}\COPYING_GPL.txt"
   !insertmacro MUI_PAGE_COMPONENTS
 
   ; Viking install dir page
@@ -111,6 +121,7 @@ VIAddVersionKey "FileDescription" "Viking Installer"
 
   !insertmacro MUI_LANGUAGE "English"
   !insertmacro MUI_LANGUAGE "French"
+  !insertmacro MUI_LANGUAGE "Spanish"
 
 ;--------------------------------
 ;Translations
@@ -136,6 +147,9 @@ VIAddVersionKey "FileDescription" "Viking Installer"
 ;; Start Install Sections ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+LicenseData "${BINARIES}\COPYING_GPL.txt"
+LicenseForceSelection checkbox
+
 ;--------------------------------
 ;Uninstall any old version of Viking
 
@@ -196,6 +210,7 @@ Section -SecUninstallOldViking
   done:
 SectionEnd
 
+
 ;--------------------------------
 ;Viking Install Section
 
@@ -212,28 +227,12 @@ Section $(VIKING_SECTION_TITLE) SecViking
   viking_hklm:
     WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\viking.exe"
     WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$R1\bin"
-    WriteRegStr HKLM ${VIKING_REG_KEY} "" "$INSTDIR"
-    WriteRegStr HKLM ${VIKING_REG_KEY} "Version" "${VIKING_VERSION}"
-    WriteRegStr HKLM "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking"
-    WriteRegStr HKLM "${VIKING_UNINSTALL_KEY}" "DisplayVersion" "${VIKING_VERSION}"
-    WriteRegStr HKLM "${VIKING_UNINSTALL_KEY}" "HelpLink" "http://sourceforge.net/apps/mediawiki/viking/"
-    WriteRegDWORD HKLM "${VIKING_UNINSTALL_KEY}" "NoModify" 1
-    WriteRegDWORD HKLM "${VIKING_UNINSTALL_KEY}" "NoRepair" 1
-    WriteRegStr HKLM "${VIKING_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${VIKING_UNINST_EXE}"
     ; Sets scope of the desktop and Start Menu entries for all users.
     SetShellVarContext "all"
     Goto viking_install_files
 
     ;Install rights for Current User only 
   viking_hkcu:
-    WriteRegStr HKCU ${VIKING_REG_KEY} "" "$INSTDIR"
-    WriteRegStr HKCU ${VIKING_REG_KEY} "Version" "${VIKING_VERSION}"
-    WriteRegStr HKCU "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking"
-    WriteRegStr HKCU "${VIKING_UNINSTALL_KEY}" "DisplayVersion" "${VIKING_VERSION}"
-    WriteRegStr HKCU "${VIKING_UNINSTALL_KEY}" "HelpLink" "http://sourceforge.net/apps/mediawiki/viking/"
-    WriteRegDWORD HKCU "${VIKING_UNINSTALL_KEY}" "NoModify" 1
-    WriteRegDWORD HKCU "${VIKING_UNINSTALL_KEY}" "NoRepair" 1
-    WriteRegStr HKCU "${VIKING_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${VIKING_UNINST_EXE}"
     Goto viking_install_files
   
   ;No install rights!
@@ -243,7 +242,40 @@ Section $(VIKING_SECTION_TITLE) SecViking
     SetOutPath "$INSTDIR"
     SetOverwrite on
 
-    File /r .\bin\*.*
+    ; Common settings
+    WriteRegStr SHCTX ${VIKING_REG_KEY} "" "$INSTDIR"
+    WriteRegStr SHCTX ${VIKING_REG_KEY} "Version" "${VIKING_VERSION}"
+    ${If} ${RunningX64}
+      WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking (x86)"
+    ${Else}
+      WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking (x64)"
+    ${EndIf}
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayVersion" "${VIKING_VERSION}"
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\viking_icon.ico"
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "HelpLink" "http://sourceforge.net/p/viking/wikiallura"
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "URLInfoAbout" "http://sourceforge.net/projects/viking/"
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "Publisher" "The Viking developer community"
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "Comments" "$(VIKING_UNINSTALL_COMMENTS)"
+    WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "NoModify" 1
+    WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "NoRepair" 1
+    WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${VIKING_UNINST_EXE}"
+
+    ; Copy only specific items as now some components (e.g. GPSBabel) are optional.
+    ; This is mostly to get a more accurate install size value (especially as saved into the registry)
+    File ${BINARIES}\viking*
+    File ${BINARIES}\g*.exe
+    File ${BINARIES}\*.dll
+    File ${BINARIES}\*.txt
+    File ${BINARIES}\magic.mgc
+    File /r ${BINARIES}\data
+    File /r ${BINARIES}\locale
+    File /r ${BINARIES}\share
+    File /r ${BINARIES}\lib
+
+    ; Estimate install size based on files in $INSTDIR
+    ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
+    IntFmt $0 "0x%08X" $0
+    WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "EstimatedSize" "$0"
 
     ; If we don't have install rights we're done
     StrCmp $R0 "NONE" done
@@ -254,6 +286,8 @@ Section $(VIKING_SECTION_TITLE) SecViking
     WriteUninstaller "$INSTDIR\${VIKING_UNINST_EXE}"
     SetOverwrite off
 
+    ; Always associate Viking file type
+    ${registerExtension} "$INSTDIR\viking.exe" ".vik" "Viking File"
   done:
 SectionEnd ; end of default Viking section
 
@@ -278,16 +312,21 @@ SectionGroup /e $(VIKING_SHORTCUTS_SECTION_TITLE) SecShortcuts
   SectionEnd
 SectionGroupEnd
 
+;--------------------------------
+;File association
 
+Section $(VIKING_FILE_ASSOCIATION_SECTION_TITLE) SecFileAssociation
+  ${registerExtension} "$INSTDIR\viking.exe" ".gpx" "GPX File"
+SectionEnd
 
-
-
-
-
-
-
-
-
+;--------------------------------
+; GPSBabel Install Section
+;
+Section $(VIKING_GPSBABEL_SECTION_TITLE) SecGPSBabel
+  File "${BINARIES}\Optional\GPSBabel-1.5.2-Setup.exe"
+  ExecWait '"$INSTDIR\GPSBabel-1.5.2-Setup.exe" /SILENT'
+  Delete "$INSTDIR\GPSBabel-1.5.2-Setup.exe"
+SectionEnd
 
 ;--------------------------------
 ;Uninstaller Section
@@ -319,55 +358,38 @@ Section Uninstall
 
   cont_uninstall:
 
-    RMDir /r "$INSTDIR\etc"
-    RMDir /r "$INSTDIR\lib"
+    ; http://nsis.sourceforge.net/Docs/Chapter4.html
+    ; Don't use:
+    ;RMDir /r "$INSTDIR"
+    ; Warning: is not safe. Can delete entire Program Files directory!
+
+    ; TODO try this method instead:
+    ; http://nsis.sourceforge.net/Uninstall_only_installed_files
+
+    ; Specific remove files
+    ; Thus alsos leaves any files the user has saved (particularly .vik or .gpx) into the Viking directory
+    Delete "$INSTDIR\viking-cache.py"
+    Delete "$INSTDIR\viking.pdf"
+    Delete "$INSTDIR\viking_icon.ico"
+    Delete "$INSTDIR\*.exe"
+    Delete "$INSTDIR\*.dll"
+    Delete "$INSTDIR\*.txt"
+    Delete "$INSTDIR\magic.mgc"
+    Delete "$INSTDIR\data\*txt"
+    Delete "$INSTDIR\data\*xml"
+    RMDir "$INSTDIR\data"
     RMDir /r "$INSTDIR\locale"
+    RMDir /r "$INSTDIR\lib"
     RMDir /r "$INSTDIR\share"
-    Delete "$INSTDIR\AUTHORS.txt"
-    Delete "$INSTDIR\Changelog.txt"
-    Delete "$INSTDIR\COPYING_curl.txt"
-    Delete "$INSTDIR\COPYING_GPL.txt"
-    Delete "$INSTDIR\freetype6.dll"
-    Delete "$INSTDIR\gpsbabel.exe"
-    Delete "$INSTDIR\intl.dll"
-    Delete "$INSTDIR\libatk-1.0-0.dll"
-    Delete "$INSTDIR\libcairo-2.dll"
-    Delete "$INSTDIR\libcurl.dll"
-    Delete "$INSTDIR\libexif-12.dll"
-    Delete "$INSTDIR\libexpat.dll"
-    Delete "$INSTDIR\libexpat-1.dll"
-    Delete "$INSTDIR\libfontconfig-1.dll"
-    Delete "$INSTDIR\libgailutil-18.dll"
-    Delete "$INSTDIR\libgdk_pixbuf-2.0-0.dll"
-    Delete "$INSTDIR\libgdk-win32-2.0-0.dll"
-    Delete "$INSTDIR\libgio-2.0-0.dll"
-    Delete "$INSTDIR\libglib-2.0-0.dll"
-    Delete "$INSTDIR\libgmodule-2.0-0.dll"
-    Delete "$INSTDIR\libgobject-2.0-0.dll"
-    Delete "$INSTDIR\libgthread-2.0-0.dll"
-    Delete "$INSTDIR\libgtk-win32-2.0-0.dll"
-    Delete "$INSTDIR\libjpeg-7.dll"
-    Delete "$INSTDIR\libpango-1.0-0.dll"
-    Delete "$INSTDIR\libpangocairo-1.0-0.dll"
-    Delete "$INSTDIR\libpangoft2-1.0-0.dll"
-    Delete "$INSTDIR\libpangowin32-1.0-0.dll"
-    Delete "$INSTDIR\libpng12-0.dll"
-    Delete "$INSTDIR\libtiff-3.dll"
-    Delete "$INSTDIR\libtiffxx-3.dll"
-    Delete "$INSTDIR\NEWS.txt"
-    Delete "$INSTDIR\README.txt"
-    Delete "$INSTDIR\viking.exe"
-    Delete "$INSTDIR\viking.pdf"
-    Delete "$INSTDIR\zlib1.dll"
-    Delete "$INSTDIR\${VIKING_UNINST_EXE}"
-    Delete "$INSTDIR\install.log"
-
-    ;Try to remove Viking install dir (only if empty)
     RMDir "$INSTDIR"
 
     ; Shortcuts..
     Delete "$DESKTOP\Viking.lnk"
 
+    ; File association
+    ${unregisterExtension} ".vik" "Viking File"
+    ${unregisterExtension} ".gpx" "GPX File"
+
     Goto done
 
   cant_uninstall:
@@ -393,6 +415,10 @@ SectionEnd ; end of uninstall section
         $(VIKING_DESKTOP_SHORTCUT_DESC)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} \
         $(VIKING_STARTMENU_SHORTCUT_DESC)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} \
+        $(VIKING_FILE_ASSOCIATION_DESC)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecGPSBabel} \
+        $(VIKING_INSTALL_GPSBABEL_DESC)
 
 !insertmacro MUI_FUNCTION_DESCRIPTION_END
 
@@ -451,8 +477,8 @@ Function ${UN}RunCheck
 FunctionEnd
 !macroend
 
-!insertmacro RunCheckMacro ""
-!insertmacro RunCheckMacro "un."
+;!insertmacro RunCheckMacro ""
+;!insertmacro RunCheckMacro "un."
 
 ;Installer extra configuration at execution time: language, path, ...
 Function .onInit
@@ -462,7 +488,7 @@ Function .onInit
   Push $R2
 
   ;Check if viking is running
-  Call RunCheck
+  ;Call RunCheck
   StrCpy $name "Viking ${VIKING_VERSION}"
 
   ClearErrors
@@ -529,8 +555,12 @@ Function .onInit
   Pop $R0
 
   StrCmp $R0 "HKLM" 0 user_dir
-    StrCpy $INSTDIR "$PROGRAMFILES\Viking"
-    Goto instdir_done
+  ${If} ${RunningX64}
+    StrCpy $INSTDIR "$PROGRAMFILES64\Viking"
+  ${Else}
+    StrCpy $INSTDIR "$PROGRAMFILES\Viking" ; $PROGRAMFILES32 also works
+  ${EndIf}
+  Goto instdir_done
   user_dir:
     Push $SMPROGRAMS
     ${GetParent} $SMPROGRAMS $R2
@@ -546,7 +576,7 @@ FunctionEnd
 
 Function un.onInit
   ;Check if viking is running
-  Call un.RunCheck
+  ;Call un.RunCheck
   StrCpy $name "Viking ${VIKING_VERSION}"
 
   ; Get stored language preference