]> git.street.me.uk Git - andy/viking.git/commitdiff
Add Windows Installer (NSIS)
authorMathieu Albinet <mathieu17@gmail.com>
Sat, 10 Sep 2011 10:51:25 +0000 (11:51 +0100)
committerRob Norris <rw_norris@hotmail.com>
Sat, 10 Sep 2011 10:51:25 +0000 (11:51 +0100)
\bin : where all the viking+gtk binaries (exe, dll, ...) go (it's exactly what will be copied to your installation directory)
\pixmaps : contains only a viking icon in .ico format (we can add also a banner in the installer)
\translations : at the moment it contains two files: english.nsh and french.nsh,
  that translates the installer UI (we should ask for more translations)
langmacros.nsh : macro file that deal withe the translations of the UI
viking-installer.nsi : the installer script,
  heavily modified/simplified from the pidgin installer (has to be compiled with a recent release of NSIS)

Further information on the installer see: http://nsis.sourceforge.net/

Signed-off-by: Rob Norris <rw_norris@hotmail.com>
win32/README
win32/installer/bin/.gitignore [new file with mode: 0644]
win32/installer/langmacros.nsh [new file with mode: 0644]
win32/installer/pixmaps/viking_icon.ico [new file with mode: 0644]
win32/installer/translations/english.nsh [new file with mode: 0644]
win32/installer/translations/french.nsh [new file with mode: 0644]
win32/installer/viking-installer.nsi [new file with mode: 0644]

index e2b1a69bf5543815453fdc7dfbcc97ff48b77613..109426812923cd935215f8b721a7e3a91cad5d8f 100644 (file)
@@ -1,4 +1,8 @@
-I don't think you need to use this anymore (just use the regular makefile), but I'm leaving it in so I know how to compile Viking on Windows ;)
+Files of this directory are probably not needed anymore (just use the regular makefile),
+but are left as reference for the old compile method on Windows ;)
+
+However the installer directory is used for the named purpose.
+Instructions on how to use the installer will follow in due course (probably on the Wiki first).
 
 ----
 If your GTK path isn't c:\gtk and/or your mingw path isn't c:\mingw, you will have to edit the scripts to compile.
diff --git a/win32/installer/bin/.gitignore b/win32/installer/bin/.gitignore
new file mode 100644 (file)
index 0000000..93aad36
--- /dev/null
@@ -0,0 +1,6 @@
+# This directory is delibrately 'empty'
+# It possibly could be created by the installation but ATM it's not.
+#
+# This where all the viking+gtk binaries (exe, dll, ...) go (it's exactly what  will be copied to your installation directory)
+*
+!.gitignore
diff --git a/win32/installer/langmacros.nsh b/win32/installer/langmacros.nsh
new file mode 100644 (file)
index 0000000..509d1e7
--- /dev/null
@@ -0,0 +1,66 @@
+;;
+;; Windows Viking NSIS installer language macros
+;; Based on Win32 Pidgin installer
+
+!macro VIKING_MACRO_DEFAULT_STRING LABEL VALUE
+  !ifndef "${LABEL}"
+    !define "${LABEL}" "${VALUE}"
+    !ifdef INSERT_DEFAULT
+      !warning "${LANG} lang file missing ${LABEL}, using default..."
+    !endif
+  !endif
+!macroend
+
+!macro VIKING_MACRO_LANGSTRING_INSERT LABEL LANG
+  LangString "${LABEL}" "${LANG_${LANG}}" "${${LABEL}}"
+  !undef "${LABEL}"
+!macroend
+
+!macro VIKING_MACRO_LANGUAGEFILE_BEGIN LANG
+  !define CUR_LANG "${LANG}"
+!macroend
+
+!macro VIKING_MACRO_LANGUAGEFILE_END
+  !define INSERT_DEFAULT
+  !include "${VIKING_DEFAULT_LANGFILE}"
+  !undef INSERT_DEFAULT
+
+  ; Viking Language file Version 3
+  ; String labels should match those from the default language file.
+
+  ; Startup checks
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT INSTALLER_IS_RUNNING             ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_IS_RUNNING                        ${CUR_LANG}
+
+  ; License Page
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_LICENSE_BUTTON                    ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_LICENSE_BOTTOM_TEXT               ${CUR_LANG}
+
+  ; Components Page
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_SECTION_TITLE                     ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_SHORTCUTS_SECTION_TITLE   ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_DESKTOP_SHORTCUT_SECTION_TITLE ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_STARTMENU_SHORTCUT_SECTION_TITLE  ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_SECTION_DESCRIPTION               ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_SHORTCUTS_SECTION_DESCRIPTION     ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_DESKTOP_SHORTCUT_DESC             ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_STARTMENU_SHORTCUT_DESC   ${CUR_LANG}
+
+  ; Installer Finish Page
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_FINISH_VISIT_WEB_SITE             ${CUR_LANG}
+
+  ; Viking Section Prompts and Texts
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT VIKING_PROMPT_CONTINUE_WITHOUT_UNINSTALL ${CUR_LANG}
+
+  ; Uninstall Section Prompts
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT un.VIKING_UNINSTALL_ERROR_1              ${CUR_LANG}
+  !insertmacro VIKING_MACRO_LANGSTRING_INSERT un.VIKING_UNINSTALL_ERROR_2              ${CUR_LANG}
+
+  !undef CUR_LANG
+!macroend
+
+!macro VIKING_MACRO_INCLUDE_LANGFILE LANG FILE
+  !insertmacro VIKING_MACRO_LANGUAGEFILE_BEGIN "${LANG}"
+  !include "${FILE}"
+  !insertmacro VIKING_MACRO_LANGUAGEFILE_END
+!macroend
diff --git a/win32/installer/pixmaps/viking_icon.ico b/win32/installer/pixmaps/viking_icon.ico
new file mode 100644 (file)
index 0000000..50e8b00
Binary files /dev/null and b/win32/installer/pixmaps/viking_icon.ico differ
diff --git a/win32/installer/translations/english.nsh b/win32/installer/translations/english.nsh
new file mode 100644 (file)
index 0000000..4bb354d
--- /dev/null
@@ -0,0 +1,42 @@
+;;
+;;  english.nsh
+;;
+;;  Default language strings for the Windows Viking NSIS installer.
+;;  Windows Code page: 1252
+;;
+;;  Version 3
+;;  Note: If translating this file, replace '!insertmacro VIKING_MACRO_DEFAULT_STRING'
+;;  with '!define'.
+
+; Make sure to update the VIKING_MACRO_LANGUAGEFILE_END macro in
+; langmacros.nsh when updating this file
+
+; Startup Checks
+!insertmacro VIKING_MACRO_DEFAULT_STRING INSTALLER_IS_RUNNING                  "The installer is already running."
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_IS_RUNNING                     "An instance of Viking is currently running.  Please exit Viking and try again."
+
+; License Page
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_LICENSE_BUTTON                 "Next >"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_LICENSE_BOTTOM_TEXT            "$(^Name) is released under the GNU General Public License (GPL). The license is provided here for information purposes only. $_CLICK"
+
+; Components Page
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_SECTION_TITLE                  "Viking GPS data editor and analyzer (required)"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_SHORTCUTS_SECTION_TITLE                "Shortcuts"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_DESKTOP_SHORTCUT_SECTION_TITLE "Desktop"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_STARTMENU_SHORTCUT_SECTION_TITLE       "Start Menu"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_SECTION_DESCRIPTION            "Core Viking files and dlls"
+!insertmacro VIKING_MACRO_DEFAULT_STRING GTK_SECTION_DESCRIPTION               "A multi-platform GUI toolkit, used by Viking"
+
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_SHORTCUTS_SECTION_DESCRIPTION  "Shortcuts for starting Viking"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_DESKTOP_SHORTCUT_DESC          "Create a shortcut to Viking on the Desktop"
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_STARTMENU_SHORTCUT_DESC                "Create a Start Menu entry for Viking"
+
+; Installer Finish Page
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_FINISH_VISIT_WEB_SITE          "Visit the Viking Web Page"
+
+; Viking Section Prompts and Texts
+!insertmacro VIKING_MACRO_DEFAULT_STRING VIKING_PROMPT_CONTINUE_WITHOUT_UNINSTALL      "Unable to uninstall the currently installed version of Viking. The new version will be installed without removing the currently installed version."
+
+; Uninstall Section Prompts
+!insertmacro VIKING_MACRO_DEFAULT_STRING un.VIKING_UNINSTALL_ERROR_1           "The uninstaller could not find registry entries for Viking.$\rIt is likely that another user installed this application."
+!insertmacro VIKING_MACRO_DEFAULT_STRING un.VIKING_UNINSTALL_ERROR_2           "You do not have permission to uninstall this application."
diff --git a/win32/installer/translations/french.nsh b/win32/installer/translations/french.nsh
new file mode 100644 (file)
index 0000000..02f8ce3
--- /dev/null
@@ -0,0 +1,43 @@
+;;  vim:syn=winbatch:fileencoding=cp1252:
+;;
+;;  french.nsh
+;;
+;;  French language strings for the Windows Viking NSIS installer.
+;;  Windows Code page: 1252
+;;
+;;  Based on Win32 Pidgin installer french translation file by
+;;  Author: Eric Boumaour <zongo_fr@users.sourceforge.net>, 2003-2007.
+;;
+;; Modified for Viking by Mathieu Albinet <mathieu_a@users.sourceforge.net>
+
+; Make sure to update the VIKING_MACRO_LANGUAGEFILE_END macro in
+; langmacros.nsh when updating this file
+
+; Startup Checks
+!define INSTALLER_IS_RUNNING                   "Le programme d'installation est déjà en cours d'exécution."
+!define VIKING_IS_RUNNING                              "Une instance de Viking est en cours d'exécution. Veuillez quitter Viking et réessayer."
+
+; License Page
+!define VIKING_LICENSE_BUTTON                  "Suivant >"
+!define VIKING_LICENSE_BOTTOM_TEXT             "$(^Name) est disponible sous licence GNU General Public License (GPL). Le texte de licence suivant est fourni uniquement à titre informatif. $_CLICK" 
+
+; Components Page
+!define VIKING_SECTION_TITLE                   "Viking, logiciel d'édition et d'analyse de données GPS (obligatoire)"
+!define VIKING_SHORTCUTS_SECTION_TITLE         "Raccourcis"
+!define VIKING_DESKTOP_SHORTCUT_SECTION_TITLE  "Bureau"
+!define VIKING_STARTMENU_SHORTCUT_SECTION_TITLE        "Menu Démarrer"
+!define VIKING_SECTION_DESCRIPTION             "Fichiers et DLLs de base de Viking"
+
+!define VIKING_SHORTCUTS_SECTION_DESCRIPTION   "Raccourcis pour lancer Viking"
+!define VIKING_DESKTOP_SHORTCUT_DESC           "Créer un raccourci pour Viking sur le bureau"
+!define VIKING_STARTMENU_SHORTCUT_DESC         "Créer un raccourci pour Viking dans le menu Démarrer"
+
+; Installer Finish Page
+!define VIKING_FINISH_VISIT_WEB_SITE           "Visitez la page web de Viking" 
+
+; Viking Section Prompts and Texts
+!define VIKING_PROMPT_CONTINUE_WITHOUT_UNINSTALL       "Impossible de désinstaller la version de Viking en place. La nouvelle version sera installée sans supprimer la version en place."
+
+; Uninstall Section Prompts
+!define un.VIKING_UNINSTALL_ERROR_1            "Le programme de désinstallation n'a pas retrouvé les entrées de Viking dans la base de registres.$\rL'application a peut-être été installée par un utilisateur différent."
+!define un.VIKING_UNINSTALL_ERROR_2            "Vous n'avez pas les permissions pour supprimer cette application."
diff --git a/win32/installer/viking-installer.nsi b/win32/installer/viking-installer.nsi
new file mode 100644 (file)
index 0000000..83ac631
--- /dev/null
@@ -0,0 +1,553 @@
+; Installer script for win32 Viking
+; Based on Win32 Pidgin installer by Herman Bloggs <hermanator12002@yahoo.com>
+; and Daniel Atallah <daniel_atallah@yahoo.com>
+; Heavily modified for Viking by Mathieu Albinet <mathieu_a@users.sourceforge.net>
+
+;--------------------------------
+;Global Variables
+Var name
+
+;--------------------------------
+;Configuration
+
+;The name var is set in .onInit
+Name $name
+
+OutFile "viking-${VIKING_VERSION}.exe"
+
+SetCompressor /SOLID lzma
+ShowInstDetails show
+ShowUninstDetails show
+SetDateSave on
+
+; $name and $INSTDIR are set in .onInit function..
+
+!include "MUI.nsh"
+!include "Sections.nsh"
+!include "WinVer.nsh"
+!include "LogicLib.nsh"
+
+!include "FileFunc.nsh"
+!insertmacro GetParameters
+!insertmacro GetOptions
+!insertmacro GetParent
+
+!include "WordFunc.nsh"
+
+;--------------------------------
+;Defines
+
+!define VIKING_NSIS_INCLUDE_PATH               "."
+
+; Remove these and the stuff that uses them at some point
+!define VIKING_REG_KEY                         "SOFTWARE\viking"
+!define VIKING_UNINSTALL_KEY                   "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\viking"
+
+!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}"
+VIAddVersionKey "ProductName" "Viking"
+VIAddVersionKey "FileVersion" "${VIKING_VERSION}"
+VIAddVersionKey "ProductVersion" "${VIKING_VERSION}"
+VIAddVersionKey "LegalCopyright" ""
+VIAddVersionKey "FileDescription" "Viking Installer"
+
+;--------------------------------
+;Modern UI Configuration
+
+  !define MUI_ICON                             ".\pixmaps\viking_icon.ico"
+  !define MUI_UNICON                           ".\pixmaps\viking_icon.ico"
+;  !define MUI_WELCOMEFINISHPAGE_BITMAP                ".\pixmaps\viking-intro.bmp"
+;  !define MUI_HEADERIMAGE
+;  !define MUI_HEADERIMAGE_BITMAP              ".\pixmaps\viking-header.bmp"
+
+  ; Alter License section
+  !define MUI_LICENSEPAGE_BUTTON               $(VIKING_LICENSE_BUTTON)
+  !define MUI_LICENSEPAGE_TEXT_BOTTOM          $(VIKING_LICENSE_BOTTOM_TEXT)
+
+  !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
+  !define MUI_LANGDLL_REGISTRY_KEY ${VIKING_REG_KEY}
+  !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
+
+  !define MUI_COMPONENTSPAGE_SMALLDESC
+  !define MUI_ABORTWARNING
+
+  ;Finish Page config
+  !define MUI_FINISHPAGE_NOAUTOCLOSE
+  !define MUI_FINISHPAGE_RUN                   "$INSTDIR\viking.exe"
+  !define MUI_FINISHPAGE_RUN_NOTCHECKED
+  !define MUI_FINISHPAGE_LINK                  $(VIKING_FINISH_VISIT_WEB_SITE)
+  !define MUI_FINISHPAGE_LINK_LOCATION         "http://viking.sourceforge.net"
+
+;--------------------------------
+;Pages
+
+  !insertmacro MUI_PAGE_WELCOME
+  !insertmacro MUI_PAGE_LICENSE                        ".\bin\COPYING_GPL.txt"
+  !insertmacro MUI_PAGE_COMPONENTS
+
+  ; Viking install dir page
+  !insertmacro MUI_PAGE_DIRECTORY
+
+  !insertmacro MUI_PAGE_INSTFILES
+  !insertmacro MUI_PAGE_FINISH
+
+  !insertmacro MUI_UNPAGE_WELCOME
+  !insertmacro MUI_UNPAGE_CONFIRM
+  !insertmacro MUI_UNPAGE_INSTFILES
+  !insertmacro MUI_UNPAGE_FINISH
+
+;--------------------------------
+;Languages
+
+  ;; English goes first because its the default. The rest are
+  ;; in alphabetical order (at least the strings actually displayed
+  ;; will be).
+
+  !insertmacro MUI_LANGUAGE "English"
+  !insertmacro MUI_LANGUAGE "French"
+
+;--------------------------------
+;Translations
+
+  !define VIKING_DEFAULT_LANGFILE "${VIKING_NSIS_INCLUDE_PATH}\translations\english.nsh"
+
+  !include "${VIKING_NSIS_INCLUDE_PATH}\langmacros.nsh"
+
+  !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "ENGLISH"         "${VIKING_NSIS_INCLUDE_PATH}\translations\english.nsh"
+  !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "FRENCH"          "${VIKING_NSIS_INCLUDE_PATH}\translations\french.nsh"
+
+;--------------------------------
+;Reserve Files
+  ; Only need this if using bzip2 compression
+
+  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
+  !insertmacro MUI_RESERVEFILE_LANGDLL
+  ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Start Install Sections ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;--------------------------------
+;Uninstall any old version of Viking
+
+Section -SecUninstallOldViking
+  ; Check install rights..
+  Call CheckUserInstallRights
+  Pop $R0
+
+  ;First try to uninstall Viking
+  StrCpy $R4 ${VIKING_REG_KEY}
+  StrCpy $R5 ${VIKING_UNINSTALL_KEY}
+  StrCpy $R6 ${VIKING_UNINST_EXE}
+  StrCpy $R7 "Viking"
+
+  ;Determine user install rights
+  StrCmp $R0 "HKLM" compare_hklm
+  StrCmp $R0 "HKCU" compare_hkcu done
+
+  compare_hkcu:
+      ReadRegStr $R1 HKCU $R4 ""
+      ReadRegStr $R2 HKCU $R4 "Version"
+      ReadRegStr $R3 HKCU "$R5" "UninstallString"
+      Goto try_uninstall
+
+  compare_hklm:
+      ReadRegStr $R1 HKLM $R4 ""
+      ReadRegStr $R2 HKLM $R4 "Version"
+      ReadRegStr $R3 HKLM "$R5" "UninstallString"
+
+  ; If a previous version exists, remove it
+  try_uninstall:
+    StrCmp $R1 "" done
+      StrCmp $R2 "" uninstall_problem
+        ; Check if we have uninstall string..
+        IfFileExists $R3 0 uninstall_problem
+          ; Have uninstall string, go ahead and uninstall.
+          SetOverwrite on
+          ; Need to copy uninstaller outside of the install dir
+          ClearErrors
+          CopyFiles /SILENT $R3 "$TEMP\$R6"
+          SetOverwrite off
+          IfErrors uninstall_problem
+            ; Ready to uninstall..
+            ClearErrors
+            ExecWait '"$TEMP\$R6" /S _?=$R1'
+            IfErrors exec_error
+              Delete "$TEMP\$R6"
+            Goto done
+
+            exec_error:
+              Delete "$TEMP\$R6"
+              Goto uninstall_problem
+
+        uninstall_problem:
+          ; We can't uninstall.  Either the user must manually uninstall or we ignore and reinstall over it.
+          MessageBox MB_OKCANCEL $(VIKING_PROMPT_CONTINUE_WITHOUT_UNINSTALL) /SD IDOK IDOK done
+          Quit
+  done:
+SectionEnd
+
+;--------------------------------
+;Viking Install Section
+
+Section $(VIKING_SECTION_TITLE) SecViking
+  SectionIn 1 RO
+
+  ; Check install rights..
+  Call CheckUserInstallRights
+  Pop $R0
+  StrCmp $R0 "NONE" viking_none
+  StrCmp $R0 "HKLM" viking_hklm viking_hkcu
+
+  ;Install rights for Local Machine
+  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!
+  viking_none:
+
+  viking_install_files:
+    SetOutPath "$INSTDIR"
+    SetOverwrite on
+
+    File /r .\bin\*.*
+
+    ; If we don't have install rights we're done
+    StrCmp $R0 "NONE" done
+    SetOverwrite off
+
+    ; write out uninstaller
+    SetOverwrite on
+    WriteUninstaller "$INSTDIR\${VIKING_UNINST_EXE}"
+    SetOverwrite off
+
+  done:
+SectionEnd ; end of default Viking section
+
+;--------------------------------
+;Shortcuts
+
+SectionGroup /e $(VIKING_SHORTCUTS_SECTION_TITLE) SecShortcuts
+  ;Desktop shortcuts
+  Section /o $(VIKING_DESKTOP_SHORTCUT_SECTION_TITLE) SecDesktopShortcut
+    SetOverwrite on
+    CreateShortCut "$DESKTOP\Viking.lnk" "$INSTDIR\viking.exe"
+    SetOverwrite off
+  SectionEnd
+  ;Start menu shortcuts
+  Section $(VIKING_STARTMENU_SHORTCUT_SECTION_TITLE) SecStartMenuShortcut
+    SetOverwrite on
+    CreateDirectory "$SMPROGRAMS\Viking"
+    CreateShortCut "$SMPROGRAMS\Viking\Viking.lnk" "$INSTDIR\viking.exe"
+    CreateShortCut "$SMPROGRAMS\Viking\User Manual.lnk" "$INSTDIR\viking.pdf"
+    CreateShortCut "$SMPROGRAMS\Viking\Uninstall.lnk" "$INSTDIR\viking-uninst.exe"
+    SetOverwrite off
+  SectionEnd
+SectionGroupEnd
+
+
+
+
+
+
+
+
+
+
+
+
+;--------------------------------
+;Uninstaller Section
+
+
+Section Uninstall
+  Call un.CheckUserInstallRights
+  Pop $R0
+  StrCmp $R0 "NONE" no_rights
+  StrCmp $R0 "HKCU" try_hkcu try_hklm
+
+  try_hkcu:
+    ReadRegStr $R0 HKCU ${VIKING_REG_KEY} ""
+    StrCmp $R0 $INSTDIR 0 cant_uninstall
+      ; HKCU install path matches our INSTDIR so uninstall
+      DeleteRegKey HKCU ${VIKING_REG_KEY}
+      DeleteRegKey HKCU "${VIKING_UNINSTALL_KEY}"
+      Goto cont_uninstall
+
+  try_hklm:
+    ReadRegStr $R0 HKLM ${VIKING_REG_KEY} ""
+    StrCmp $R0 $INSTDIR 0 try_hkcu
+      ; HKLM install path matches our INSTDIR so uninstall
+      DeleteRegKey HKLM ${VIKING_REG_KEY}
+      DeleteRegKey HKLM "${VIKING_UNINSTALL_KEY}"
+      DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
+      ; Sets start menu and desktop scope to all users..
+      SetShellVarContext "all"
+
+  cont_uninstall:
+
+    RMDir /r "$INSTDIR\etc"
+    RMDir /r "$INSTDIR\lib"
+    RMDir /r "$INSTDIR\locale"
+    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\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"
+
+    Goto done
+
+  cant_uninstall:
+    MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_1) /SD IDOK
+    Quit
+
+  no_rights:
+    MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_2) /SD IDOK
+    Quit
+
+  done:
+SectionEnd ; end of uninstall section
+
+;--------------------------------
+;Descriptions
+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecViking} \
+        $(VIKING_SECTION_DESCRIPTION)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} \
+        $(VIKING_SHORTCUTS_SECTION_DESCRIPTION)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} \
+        $(VIKING_DESKTOP_SHORTCUT_DESC)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} \
+        $(VIKING_STARTMENU_SHORTCUT_DESC)
+
+!insertmacro MUI_FUNCTION_DESCRIPTION_END
+
+;--------------------------------
+;Functions
+
+;Macro to determine user install rights
+;Will be used to determine where to install the program, shortcuts, ...
+!macro CheckUserInstallRightsMacro UN
+Function ${UN}CheckUserInstallRights
+  Push $0
+  Push $1
+  ClearErrors
+  UserInfo::GetName
+  IfErrors Win9x
+  Pop $0
+  UserInfo::GetAccountType
+  Pop $1
+
+  StrCmp $1 "Admin" 0 +3
+    StrCpy $1 "HKLM"
+    Goto done
+  StrCmp $1 "Power" 0 +3
+    StrCpy $1 "HKLM"
+    Goto done
+  StrCmp $1 "User" 0 +3
+    StrCpy $1 "HKCU"
+    Goto done
+  StrCmp $1 "Guest" 0 +3
+    StrCpy $1 "NONE"
+    Goto done
+  ; Unknown error
+  StrCpy $1 "NONE"
+  Goto done
+
+  Win9x:
+    StrCpy $1 "HKLM"
+
+  done:
+    Exch $1
+    Exch
+    Pop $0
+FunctionEnd
+!macroend
+!insertmacro CheckUserInstallRightsMacro ""
+!insertmacro CheckUserInstallRightsMacro "un."
+
+;Macro to determine if Viking is running before installation/unistallation
+!macro RunCheckMacro UN
+Function ${UN}RunCheck
+  FindProcDLL::FindProc "viking.exe"
+  IntCmp $R0 1 0 notRunning
+    MessageBox MB_OK|MB_ICONEXCLAMATION $(VIKING_IS_RUNNING) /SD IDOK
+    Abort
+  notRunning:
+FunctionEnd
+!macroend
+
+!insertmacro RunCheckMacro ""
+!insertmacro RunCheckMacro "un."
+
+;Installer extra configuration at execution time: language, path, ...
+Function .onInit
+  ;Check if viking installer is already running
+  Push $R0
+  Push $R1
+  Push $R2
+
+  ;Check if viking is running
+  Call RunCheck
+  StrCpy $name "Viking ${VIKING_VERSION}"
+
+  ClearErrors
+  ;Make sure that there was a previous installation
+  ReadRegStr $R0 HKCU "${VIKING_REG_KEY}" "Installer Language"
+  
+  ;Preselect the "shortcuts" checkboxes according to the previous installation
+  !insertmacro SelectSection ${SecDesktopShortcut}
+  !insertmacro selectSection ${SecStartMenuShortcut}
+  
+  ;Read command line parameters
+  
+  ;Read language command line parameters
+  ${GetParameters} $R0
+  ClearErrors
+  ${GetOptions} "$R0" "/L=" $R1
+  IfErrors +3
+  StrCpy $LANGUAGE $R1
+  Goto skip_lang
+
+  ; Select Language
+    ; Display Language selection dialog
+    !insertmacro MUI_LANGDLL_DISPLAY
+    skip_lang:
+
+  ;Read desktop shortcut command line options
+  ClearErrors
+  ${GetOptions} "$R0" "/DS=" $R1
+  IfErrors +8
+  SectionGetFlags ${SecDesktopShortcut} $R2
+  StrCmp "1" $R1 0 +2
+  IntOp $R2 $R2 | ${SF_SELECTED}
+  StrCmp "0" $R1 0 +3
+  IntOp $R1 ${SF_SELECTED} ~
+  IntOp $R2 $R2 & $R1
+  SectionSetFlags ${SecDesktopShortcut} $R2
+
+  ;Read start menu shortcuts command line options
+  ClearErrors
+  ${GetOptions} "$R0" "/SMS=" $R1
+  IfErrors +8
+  SectionGetFlags ${SecStartMenuShortcut} $R2
+  StrCmp "1" $R1 0 +2
+  IntOp $R2 $R2 | ${SF_SELECTED}
+  StrCmp "0" $R1 0 +3
+  IntOp $R1 ${SF_SELECTED} ~
+  IntOp $R2 $R2 & $R1
+  SectionSetFlags ${SecStartMenuShortcut} $R2
+
+  ; If install path was set on the command, use it.
+  StrCmp $INSTDIR "" 0 instdir_done
+
+  ;  If viking is currently installed, we should default to where it is currently installed
+  ClearErrors
+  ReadRegStr $INSTDIR HKCU "${VIKING_REG_KEY}" ""
+  IfErrors +2
+  StrCmp $INSTDIR "" 0 instdir_done
+  ClearErrors
+  ReadRegStr $INSTDIR HKLM "${VIKING_REG_KEY}" ""
+  IfErrors +2
+  StrCmp $INSTDIR "" 0 instdir_done
+
+  Call CheckUserInstallRights
+  Pop $R0
+
+  StrCmp $R0 "HKLM" 0 user_dir
+    StrCpy $INSTDIR "$PROGRAMFILES\Viking"
+    Goto instdir_done
+  user_dir:
+    Push $SMPROGRAMS
+    ${GetParent} $SMPROGRAMS $R2
+    ${GetParent} $R2 $R2
+    StrCpy $INSTDIR "$R2\Viking"
+
+  instdir_done:
+;LogSet on
+  Pop $R2
+  Pop $R1
+  Pop $R0
+FunctionEnd
+
+Function un.onInit
+  ;Check if viking is running
+  Call un.RunCheck
+  StrCpy $name "Viking ${VIKING_VERSION}"
+
+  ; Get stored language preference
+  !insertmacro MUI_UNGETLANGUAGE
+
+FunctionEnd