tinstall.nsi.in - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tinstall.nsi.in (8322B)
       ---
            1 ; NSIS (http://nsis.sf.net/) install script
            2 
            3 !include "MUI2.nsh"
            4 !include "FileFunc.nsh"
            5 !include "WinVer.nsh"
            6 !include "LogicLib.nsh"
            7 
            8 ; Use solid LZMA compression
            9 SetCompressor /SOLID lzma
           10 
           11 Var STARTMENU_FOLDER
           12 Var MUI_TEMP
           13 
           14 Unicode true
           15 
           16 !define PRODUCT "dopewars"
           17 !define VERSION "@PACKAGE_VERSION@"
           18 !define PRODVER "${PRODUCT}-${VERSION}"
           19 
           20 !if "@host@" == "i686-w64-mingw32"
           21   ; 32-bit build; no special setup
           22 !else if "@host@" == "x86_64-w64-mingw32"
           23   ; 64-bit build
           24   !define DOPEWARS_64BIT
           25 !else
           26   !error "Supported only for 32-bit and 64-bit Windows"
           27 !endif
           28 
           29 Name ${PRODVER}
           30 
           31 !ifdef DOPEWARS_64BIT
           32   Caption "${PRODUCT} ${VERSION} (64 bit) Setup"
           33   OutFile "dopewars-${VERSION}-64bit.exe"
           34   InstallDir "$PROGRAMFILES64\${PRODVER}"
           35   # Note that we don't use InstallDirRegKey on x64 since it ignores SetRegView
           36   !define FULL_PRODVER "${PRODUCT} ${VERSION} (64 bit)"
           37 !else
           38   Caption "${PRODUCT} ${VERSION} (32 bit) Setup"
           39   OutFile "dopewars-${VERSION}-32bit.exe"
           40   InstallDir "$PROGRAMFILES\${PRODVER}"
           41   InstallDirRegKey HKLM "Software\${PRODVER}" ""
           42   !define FULL_PRODVER "${PRODUCT} ${VERSION} (32 bit)"
           43 !endif
           44 
           45 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
           46 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODVER}"
           47 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
           48 
           49 !define MUI_TEMP $R0
           50 
           51 !define MUI_ABORTWARNING
           52 
           53 !define MUI_WELCOMEPAGE_TITLE "Welcome to the ${FULL_PRODVER} Setup Wizard"
           54 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${FULL_PRODVER}, a game simulating the life of a drug dealer in New York."
           55 
           56 !define MUI_FINISHPAGE_LINK "https://dopewars.sourceforge.io/"
           57 !define MUI_FINISHPAGE_LINK_LOCATION "https://dopewars.sourceforge.io/"
           58 
           59 !define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODVER}"
           60 
           61 ;Pages
           62 !insertmacro MUI_PAGE_WELCOME
           63 !insertmacro MUI_PAGE_DIRECTORY
           64 !insertmacro MUI_PAGE_STARTMENU ${PRODVER} $STARTMENU_FOLDER
           65 !insertmacro MUI_PAGE_INSTFILES
           66 !insertmacro MUI_PAGE_FINISH
           67 
           68 !insertmacro MUI_UNPAGE_CONFIRM
           69 !insertmacro MUI_UNPAGE_INSTFILES
           70 
           71 !insertmacro MUI_LANGUAGE "English"
           72 
           73 Section ""
           74   SetOutPath "$INSTDIR"
           75   File "..\LICENCE"
           76 
           77   File "..\src\dopewars.exe"
           78   File "/etc/pki/tls/certs/ca-bundle.crt"
           79 
           80 !ifdef DOPEWARS_64BIT
           81   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/iconv.dll"
           82   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libcrypto-1_1-x64.dll"
           83   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libcurl-4.dll"
           84   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll"
           85   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libidn2-0.dll"
           86   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libintl-8.dll"
           87   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libpcre-1.dll"
           88   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssh2-1.dll"
           89   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssl-1_1-x64.dll"
           90   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
           91   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll"
           92   File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/zlib1.dll"
           93 !else
           94   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/iconv.dll"
           95   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libcrypto-1_1.dll"
           96   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libcurl-4.dll"
           97   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_dw2-1.dll"
           98   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll"
           99   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libidn2-0.dll"
          100   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libintl-8.dll"
          101   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libpcre-1.dll"
          102   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libssh2-1.dll"
          103   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libssl-1_1.dll"
          104   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
          105   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll"
          106   File "/usr/i686-w64-mingw32/sys-root/mingw/bin/zlib1.dll"
          107 !endif
          108 
          109   SetOutPath "$INSTDIR\doc"
          110   File "..\doc\*.html"
          111 
          112   SetOutPath "$INSTDIR\doc\help"
          113   File "..\doc\help\*.html"
          114 
          115   SetOutPath "$INSTDIR\locale\de\LC_MESSAGES"
          116   File /oname=dopewars.mo "..\po\de.gmo"
          117 
          118   SetOutPath "$INSTDIR\locale\es\LC_MESSAGES"
          119   File /oname=dopewars.mo "..\po\es.gmo"
          120 
          121   SetOutPath "$INSTDIR\locale\en_GB\LC_MESSAGES"
          122   File /oname=dopewars.mo "..\po\en_GB.gmo"
          123 
          124   SetOutPath "$INSTDIR\locale\es_ES\LC_MESSAGES"
          125   File /oname=dopewars.mo "..\po\es_ES.gmo"
          126 
          127   SetOutPath "$INSTDIR\locale\fr\LC_MESSAGES"
          128   File /oname=dopewars.mo "..\po\fr.gmo"
          129 
          130   SetOutPath "$INSTDIR\locale\fr_CA\LC_MESSAGES"
          131   File /oname=dopewars.mo "..\po\fr_CA.gmo"
          132 
          133   SetOutPath "$INSTDIR\locale\nn\LC_MESSAGES"
          134   File /oname=dopewars.mo "..\po\nn.gmo"
          135 
          136   SetOutPath "$INSTDIR\locale\pl\LC_MESSAGES"
          137   File /oname=dopewars.mo "..\po\pl.gmo"
          138 
          139   SetOutPath "$INSTDIR\locale\pt_BR\LC_MESSAGES"
          140   File /oname=dopewars.mo "..\po\pt_BR.gmo"
          141 
          142   SetOutPath "$INSTDIR\sounds\19.5degs"
          143   File "..\sounds\19.5degs\*.wav"
          144 
          145   WriteRegStr HKLM "Software\${PRODVER}" "" $INSTDIR
          146   WriteUninstaller "$INSTDIR\Uninstall.exe"
          147   WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${FULL_PRODVER}"
          148   WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
          149   WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
          150   WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "Ben Webb"
          151   WriteRegStr HKLM "${UNINST_KEY}" "URLInfoAbout" "https://dopewars.sourceforge.io/"
          152   WriteRegDWORD HKLM "${UNINST_KEY}" "NoModify" 1
          153   WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1
          154 
          155   !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODVER}
          156     CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
          157     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars.lnk" "$INSTDIR\dopewars.exe"
          158     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars public server.lnk" "$INSTDIR\dopewars.exe" "-s"
          159     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars private server.lnk" "$INSTDIR\dopewars.exe" "-S"
          160     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\text-mode dopewars.lnk" "$INSTDIR\dopewars.exe" "-t"
          161     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars AI player.lnk" "$INSTDIR\dopewars.exe" "-c"
          162     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars command line options.lnk" "$INSTDIR\dopewars.exe" "-h"
          163     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars help.lnk" "$INSTDIR\doc\index.html"
          164     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
          165   !insertmacro MUI_STARTMENU_WRITE_END
          166 SectionEnd
          167 
          168 Section "Uninstall"
          169 !ifdef DOPEWARS_64BIT
          170   SetRegView 64
          171 !endif
          172   Delete "$INSTDIR\Uninstall.exe"
          173   Delete "$INSTDIR\dopewars.exe"
          174   Delete "$INSTDIR\*.dll"
          175   Delete "$INSTDIR\LICENCE"
          176   Delete "$INSTDIR\ca-bundle.crt"
          177   RMDir /r "$INSTDIR\doc"
          178   RMDir /r "$INSTDIR\locale"
          179   RMDir /r "$INSTDIR\sounds"
          180   RMDir "$INSTDIR"
          181 
          182   ReadRegStr $MUI_TEMP HKLM "Software\${PRODVER}" "Start Menu Folder"
          183 
          184   StrCmp $MUI_TEMP "" noshortcuts
          185     ReadRegStr $0 HKLM "Software\${PRODVER}" "ShellVarContext"
          186     StrCmp $0 "all" 0 +2
          187       SetShellVarContext all
          188     Delete "$SMPROGRAMS\$MUI_TEMP\dopewars.lnk"
          189     Delete "$SMPROGRAMS\$MUI_TEMP\dopewars public server.lnk"
          190     Delete "$SMPROGRAMS\$MUI_TEMP\dopewars private server.lnk"
          191     Delete "$SMPROGRAMS\$MUI_TEMP\text-mode dopewars.lnk"
          192     Delete "$SMPROGRAMS\$MUI_TEMP\dopewars AI player.lnk"
          193     Delete "$SMPROGRAMS\$MUI_TEMP\dopewars command line options.lnk"
          194     Delete "$SMPROGRAMS\$MUI_TEMP\dopewars help.lnk"
          195     Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
          196     RMDir "$SMPROGRAMS\$MUI_TEMP" ;Only if empty, so it won't delete other shortcuts
          197     
          198   noshortcuts:
          199 
          200   DeleteRegKey /ifempty HKLM "Software\${PRODVER}"
          201   DeleteRegKey HKLM "${UNINST_KEY}"
          202  
          203 SectionEnd
          204 
          205 Function .onInit
          206 !ifdef DOPEWARS_64BIT
          207   SetRegView 64
          208 !endif
          209 
          210   ClearErrors
          211 
          212   UserInfo::GetAccountType
          213   IfErrors add_reg_keys
          214   Pop $0
          215   StrCmp $0 "Admin" add_reg_keys
          216   IfSilent silent_not_admin
          217   MessageBox MB_YESNO|MB_ICONEXCLAMATION \
          218       "You do not appear to be a computer administrator; \
          219        this installer may not function correctly. \
          220        Do you want to continue anyway?" /SD IDYES IDYES acccheck_done
          221     Quit
          222   silent_not_admin:
          223     Abort "This installer must be run by the administrator"
          224   add_reg_keys:
          225     SetShellVarContext all ; install for all users
          226     WriteRegStr HKLM "Software\${PRODVER}" "ShellVarContext" "all"
          227   acccheck_done:
          228 FunctionEnd