tAdd basic NSIS installer script; closes #46 - 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
       ---
 (DIR) commit 38af4f8c4110903d71d6ede391d300329cea9bc3
 (DIR) parent 4e62725c65b6d2dcac3bb4b390bf468a2552a2f2
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Thu, 12 Nov 2020 00:32:28 -0800
       
       Add basic NSIS installer script; closes #46
       
       Diffstat:
         M .gitignore                          |       1 +
         M configure.ac                        |       1 +
         A win32/install.nsi.in                |     188 +++++++++++++++++++++++++++++++
       
       3 files changed, 190 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/.gitignore b/.gitignore
       t@@ -1,5 +1,6 @@
        po/*.gmo
        po/stamp-po
       +win32/install.nsi
        *.o
        *.a
        *.la
 (DIR) diff --git a/configure.ac b/configure.ac
       t@@ -427,6 +427,7 @@ doc/Makefile
        doc/help/Makefile
        dopewars.spec
        doc/dopewars.6
       +win32/install.nsi
        po/Makefile.in],
        [])
        
 (DIR) diff --git a/win32/install.nsi.in b/win32/install.nsi.in
       t@@ -0,0 +1,188 @@
       +; NSIS (http://nsis.sf.net/) install script
       +
       +!include "MUI2.nsh"
       +!include "FileFunc.nsh"
       +!include "WinVer.nsh"
       +!include "LogicLib.nsh"
       +
       +; Use solid LZMA compression
       +SetCompressor /SOLID lzma
       +
       +Var STARTMENU_FOLDER
       +Var MUI_TEMP
       +
       +!define PRODUCT "dopewars"
       +!define VERSION "@PACKAGE_VERSION@"
       +!define PRODVER "${PRODUCT}${VERSION}"
       +
       +!define MUI_ICON "setup.ico"
       +!define MUI_UNICON "setup.ico"
       +
       +!if "@host@" == "i686-w64-mingw32"
       +  ; 32-bit build; no special setup
       +!else if "@host@" == "x86_64-w64-mingw64"
       +  ; 64-bit build
       +  !define DOPEWARS_64BIT
       +!else
       +  !error "Supported only for 32-bit and 64-bit Windows"
       +!endif
       +
       +Name ${PRODVER}
       +
       +!ifdef DOPEWARS_64BIT
       +  Caption "${PRODUCT} ${VERSION} (64 bit) Setup"
       +  OutFile "dopewars-${VERSION}-64bit.exe"
       +  InstallDir "$PROGRAMFILES64\${PRODVER}"
       +  # Note that we don't use InstallDirRegKey on x64 since it ignores SetRegView
       +  !define FULL_PRODVER "${PRODUCT} ${VERSION} (64 bit)"
       +!else
       +  Caption "${PRODUCT} ${VERSION} (32 bit) Setup"
       +  OutFile "dopewars-${VERSION}-32bit.exe"
       +  InstallDir "$PROGRAMFILES\${PRODVER}"
       +  InstallDirRegKey HKLM "Software\${PRODVER}" ""
       +  !define FULL_PRODVER "${PRODUCT} ${VERSION} (32 bit)"
       +!endif
       +
       +!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
       +!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODVER}"
       +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
       +
       +!define MUI_TEMP $R0
       +
       +!define MUI_ABORTWARNING
       +
       +!define MUI_WELCOMEPAGE_TITLE "Welcome to the ${FULL_PRODVER} Setup Wizard"
       +!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."
       +
       +!define MUI_FINISHPAGE_LINK "https://dopewars.sourceforge.io/"
       +!define MUI_FINISHPAGE_LINK_LOCATION "https://dopewars.sourceforge.io/"
       +
       +!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODVER}"
       +
       +;Pages
       +!insertmacro MUI_PAGE_WELCOME
       +!insertmacro MUI_PAGE_DIRECTORY
       +!insertmacro MUI_PAGE_STARTMENU ${PRODVER} $STARTMENU_FOLDER
       +!insertmacro MUI_PAGE_INSTFILES
       +!insertmacro MUI_PAGE_FINISH
       +
       +!insertmacro MUI_UNPAGE_CONFIRM
       +!insertmacro MUI_UNPAGE_INSTFILES
       +
       +!insertmacro MUI_LANGUAGE "English"
       +
       +Section ""
       +  SetOutPath "$INSTDIR"
       +  File "..\LICENCE"
       +
       +  File "..\doc\*.html"
       +
       +  File "..\src\dopewars.exe"
       +  File "/etc/pki/tls/certs/ca-bundle.crt"
       +
       +!ifdef DOPEWARS_64BIT
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/iconv.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libcrypto-1_1-x64.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libcurl-4.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libidn2-0.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libintl-8.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libpcre-1.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssh2-1.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssl-1_1-x64.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll"
       +  File "/usr/x86_64-w64-mingw32/sys-root/mingw/bin/zlib1.dll"
       +!else
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/iconv.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libcrypto-1_1.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libcurl-4.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_dw2-1.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libidn2-0.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libintl-8.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libpcre-1.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libssh2-1.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libssl-1_1.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll"
       +  File "/usr/i686-w64-mingw32/sys-root/mingw/bin/zlib1.dll"
       +!endif
       +
       +  SetOutPath "$INSTDIR\locale\pt_BR\LC_MESSAGES"
       +  File /oname=dopewars.mo "..\po\pt_BR.gmo"
       +
       +  SetOutPath "$INSTDIR\sounds\19.5degs"
       +  File "..\sounds\19.5degs\*.wav"
       +
       +  WriteRegStr HKLM "Software\${PRODVER}" "" $INSTDIR
       +  WriteUninstaller "$INSTDIR\Uninstall.exe"
       +  WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${FULL_PRODVER}"
       +  WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
       +  WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
       +  WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "Ben Webb"
       +  WriteRegStr HKLM "${UNINST_KEY}" "URLInfoAbout" "https://dopewars.sourceforge.io/"
       +  WriteRegDWORD HKLM "${UNINST_KEY}" "NoModify" 1
       +  WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1
       +
       +  !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODVER}
       +    CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
       +    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\dopewars.lnk" "$INSTDIR\dopewars.exe"
       +    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\text-mode dopewars.lnk" "$INSTDIR\dopewars.exe -t"
       +    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
       +  !insertmacro MUI_STARTMENU_WRITE_END
       +SectionEnd
       +
       +Section "Uninstall"
       +!ifdef DOPEWARS_64BIT
       +  SetRegView 64
       +!endif
       +  Delete "$INSTDIR\Uninstall.exe"
       +  Delete "$INSTDIR\dopewars.exe"
       +  Delete "$INSTDIR\*.dll"
       +  Delete "$INSTDIR\*.html"
       +  Delete "$INSTDIR\ca-bundle.crt"
       +  RMDir /r "$INSTDIR\locale"
       +  RMDir /r "$INSTDIR\sounds"
       +  RMDir "$INSTDIR"
       +
       +  ReadRegStr $MUI_TEMP HKLM "Software\${PRODVER}" "Start Menu Folder"
       +
       +  StrCmp $MUI_TEMP "" noshortcuts
       +    ReadRegStr $0 HKLM "Software\${PRODVER}" "ShellVarContext"
       +    StrCmp $0 "all" 0 +2
       +      SetShellVarContext all
       +    Delete "$SMPROGRAMS\$MUI_TEMP\dopewars.lnk"
       +    RMDir "$SMPROGRAMS\$MUI_TEMP" ;Only if empty, so it won't delete other shortcuts
       +    
       +  noshortcuts:
       +
       +  DeleteRegKey /ifempty HKLM "Software\${PRODVER}"
       +  DeleteRegKey HKLM "${UNINST_KEY}"
       + 
       +SectionEnd
       +
       +Function .onInit
       +!ifdef DOPEWARS_64BIT
       +  SetRegView 64
       +!endif
       +
       +  ClearErrors
       +
       +  UserInfo::GetAccountType
       +  IfErrors add_reg_keys
       +  Pop $0
       +  StrCmp $0 "Admin" add_reg_keys
       +  IfSilent silent_not_admin
       +  MessageBox MB_YESNO|MB_ICONEXCLAMATION \
       +      "You do not appear to be a computer administrator; \
       +       this installer may not function correctly. \
       +       Do you want to continue anyway?" /SD IDYES IDYES acccheck_done
       +    Quit
       +  silent_not_admin:
       +    Abort "This installer must be run by the administrator"
       +  add_reg_keys:
       +    SetShellVarContext all ; install for all users
       +    WriteRegStr HKLM "Software\${PRODVER}" "ShellVarContext" "all"
       +  acccheck_done:
       +FunctionEnd