-${STRIP:-strip} "$ROOT_DIR/src/yoink.exe"
-rm -rf "$DEST"
-mkdir -p "$DEST"
-
-
-#
-# Set installer definitions and strings.
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-HKLM_PATH='SOFTWARE\Games\Yoink'
-UNINSTALL_KEY='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yoink'
-APP_PATHS_KEY='SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\yoink.exe'
-START_RUN_KEY='SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
-
-
-PROMPT1="Not enough rights to install, aborting. :-("
-PROMPT2="Unable to uninstall the currently installed version of Yoink. The new version will be installed without removing the currently installed version."
-
-SEC_INSTALL="Install Yoink!"
-SEC_INSTALL_DESC="Installs Yoink to your computer."
-SEC_UNINSTALL="Uninstall previous version."
-SEC_SHORTCUTS="Install Shortcuts."
-SEC_SHORTCUTS_DESC="Install shortcuts at various locations."
-SEC_SHORTCUT1="Place a shortcut on the desktop."
-SEC_SHORTCUT2="Place a shortcut in the start menu."
-SEC_SHORTCUT3="Place an uninstall shortcut in the start menu."
-
-WEBSITE_LINK="Visit the Yoink website"
-
-
-#
-# Begin output of installer script.
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-cat > "$SCRIPT" <<EOF
-; based on MUI Welcome/Finish Page Example Script written by Joost Verburg
-!include "MUI2.nsh"
-!include "Sections.nsh"
-!include "LogicLib.nsh"
-!include "FileFunc.nsh"
-
-!insertmacro GetParent
-
-Name "Yoink"
-VIProductVersion "@PVERSION@"
-VIAddVersionKey "FileDescription" "Yoink Setup"
-VIAddVersionKey "ProductName" "Yoink"
-VIAddVersionKey "FileVersion" "@VERSION@"
-VIAddVersionKey "ProductVersion" "@VERSION@"
-VIAddVersionKey "LegalCopyright" "Copyright 2009 Charles McGarvey et al."
-
-;General
-OutFile "$ROOT_DIR/$OUT_FILE"
-SetCompressor $COMPRESSION
-ShowInstDetails show
-ShowUninstDetails show
-SetDateSave on
-RequestExecutionLevel highest
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Modern UI Configuration ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-!define MUI_ICON "$ROOT_DIR/src/setup.ico"
-!define MUI_UNICON "$ROOT_DIR/src/uninstall.ico"
-; Language
-!define MUI_LANGDLL_ALWAYSSHOW
-!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
-!define MUI_LANGDLL_REGISTRY_KEY "$HKLM_PATH"
-!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
-; Misc stuff
-!define MUI_COMPONENTSPAGE_SMALLDESC
-!define MUI_ABORTWARNING
-; Do not close dialogs, allow to check installation result
-!define MUI_FINISHPAGE_NOAUTOCLOSE
-!define MUI_UNFINISHPAGE_NOAUTOCLOSE
-;Finish Page config
-!define MUI_FINISHPAGE_RUN "\$INSTDIR\\yoink.exe"
-!define MUI_FINISHPAGE_RUN_NOTCHECKED
-!define MUI_FINISHPAGE_LINK "$WEBSITE_LINK"
-!define MUI_FINISHPAGE_LINK_LOCATION "http://www.dogcows.com/"
-
-;--------------------------------
-;Pages
-; Install
-!insertmacro MUI_PAGE_WELCOME
-!insertmacro MUI_PAGE_COMPONENTS
-!insertmacro MUI_PAGE_DIRECTORY
-!insertmacro MUI_PAGE_INSTFILES
-!insertmacro MUI_PAGE_FINISH
-; Uninstall
-!insertmacro MUI_UNPAGE_WELCOME
-!insertmacro MUI_UNPAGE_CONFIRM
-!insertmacro MUI_UNPAGE_INSTFILES
-!insertmacro MUI_UNPAGE_FINISH
-
-;--------------------------------
-;Languages
-!insertmacro MUI_LANGUAGE "English"
-
-;--------------------------------
-;Reserve Files
-;If you are using solid compression, files that are required before
-;the actual installation should be stored first in the data block,
-;because this will make your installer start faster.
-
-!insertmacro MUI_RESERVEFILE_LANGDLL
-
-;--------------------------------
-;Folder-selection page
-InstallDir "\$PROGRAMFILES\\Yoink"
-; Registry key to check for directory (so if you install again, it will
-; overwrite the old one automatically)
-InstallDirRegKey HKLM "$HKLM_PATH" "Path"
-AutoCloseWindow false
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Start Install Sections ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;-----------------------------------------
-;Create folder only if it doesnt exist yet
-!macro CreateDirectoryOnce FOLDER
- IfFileExists "\${FOLDER}\\*.*" +1
- CreateDirectory "\${FOLDER}"
-!macroend
-
-;--------------------------------
-;Check (un)install rights
-!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."
-
-;--------------------------------
-; Uninstall any old version of Yoink
-
-; Section hidden because automatically selected by the installer
-Section "$SEC_UNINSTALL" SecUninstallOldYoink
- ; Check install rights..
- StrCpy \$R3 $HKLM_PATH
- StrCpy \$R4 $UNINSTALL_KEY
- StrCpy \$R5 "uninstall.exe"
- Call CheckUserInstallRights
- Pop \$R0
- ; "NONE" case already handled at start
- StrCmp \$R0 "HKCU" _hkcu
- ReadRegStr \$R1 HKLM \$R3 ""
- ReadRegStr \$R2 HKLM "\$R4" "UninstallString"
- Goto try_uninstall
-
- _hkcu:
- ReadRegStr \$R1 HKCU \$R3 ""
- ReadRegStr \$R2 HKCU "\$R4" "UninstallString"
-
- ; If a previous version exists, remove it
- try_uninstall:
- ; If first string is unavailable, Yoink was probably not installed
- StrCmp \$R1 "" done
- ; Check if we have uninstall string..
- IfFileExists \$R2 0 no_file
- ; Have uninstall string, go ahead and uninstall.
- SetOverwrite on
- ; Need to copy uninstaller outside of the install dir
- ClearErrors
- CopyFiles /SILENT \$R2 "\$TEMP\\\$R5"
- SetOverwrite off
- IfErrors uninstall_problem
- ; Ready to uninstall..
- ClearErrors
- ExecWait '"\$TEMP\\\$R5" /S _?=\$R1'
- IfErrors exec_error
- Delete "\$TEMP\\\$R5"
- Goto done
-
- exec_error:
- Delete "\$TEMP\\\$R5"
- Goto uninstall_problem