; DarkRoom — Windows installer ; ; Built by docker/windows/package.sh with makensis on Linux; see docs/dev/windows.md ; §5 for every decision below. Nothing here is Windows-specific to *write* — ; NSIS has always compiled on POSIX hosts. ; ; makensis -DVERSION=0.12.0 -DSTAGE=/path/to/staging -DOUT=/path/to/setup.exe darkroom.nsi ; ; STAGE holds exactly what §5.2 installs: darkroom.exe, models\ and LICENSE. ; package.sh assembles it and applies the LFS-pointer guard before this runs. ; A 64-bit installer, not NSIS's default 32-bit stub. The application is ; x86_64 only, so nothing is lost; and it means the smoke test runs under a ; 64-bit-only Wine rather than needing an i386 multiarch: the 32-bit stub ; cannot load the WoW64 ntdll there and dies before showing a page. Target amd64-unicode Unicode true SetCompressor /SOLID lzma !ifndef VERSION !error "pass -DVERSION=x.y.z" !endif !ifndef STAGE !error "pass -DSTAGE=" !endif !ifndef OUT !error "pass -DOUT=" !endif !define NAME "DarkRoom" !define PUBLISHER "Duncan Tourolle" !define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" Name "${NAME} ${VERSION}" OutFile "${OUT}" ; Per-user, no elevation (docs/dev/windows.md §5.1). An unsigned installer that ; also asks for administrator rights is the most alarming thing Windows can ; show, and a per-user install keeps the binaries under the same account as ; the library the application builds. RequestExecutionLevel user InstallDir "$LOCALAPPDATA\Programs\${NAME}" InstallDirRegKey HKCU "${UNINST_KEY}" "InstallLocation" ; The resource block the executable itself carries (`winresource` in ; darkroom-desktop's build.rs) is what Explorer shows for the application; ; this is what it shows for the installer. VIProductVersion "${VERSION}.0" VIAddVersionKey "ProductName" "${NAME}" VIAddVersionKey "ProductVersion" "${VERSION}" VIAddVersionKey "FileVersion" "${VERSION}" VIAddVersionKey "CompanyName" "${PUBLISHER}" VIAddVersionKey "LegalCopyright" "GPL-3.0-or-later" VIAddVersionKey "FileDescription" "${NAME} installer" !include "MUI2.nsh" !define MUI_ABORTWARNING ; The GPL, shown rather than linked, for the same reason faces.md §2.2 gives ; for the model grant: the moment it can still change a decision. !insertmacro MUI_PAGE_LICENSE "${STAGE}\LICENSE" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" Section "DarkRoom" SecMain SectionIn RO SetOutPath "$INSTDIR" File "${STAGE}\darkroom.exe" File "${STAGE}\LICENSE" ; The ten model files (seven face, three scene), beside the executable, ; which is where `library::system_face_models_dirs` looks on Windows — ; last, after the user's own directories, exactly as /usr/share is on Linux. SetOutPath "$INSTDIR\models" File /r "${STAGE}\models\*" WriteUninstaller "$INSTDIR\uninstall.exe" ; Add/Remove Programs. HKCU, to match the per-user install. WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${NAME}" WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${VERSION}" WriteRegStr HKCU "${UNINST_KEY}" "Publisher" "${PUBLISHER}" WriteRegStr HKCU "${UNINST_KEY}" "InstallLocation" "$INSTDIR" WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\darkroom.exe" WriteRegStr HKCU "${UNINST_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKCU "${UNINST_KEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S' WriteRegDWORD HKCU "${UNINST_KEY}" "NoModify" 1 WriteRegDWORD HKCU "${UNINST_KEY}" "NoRepair" 1 CreateDirectory "$SMPROGRAMS\${NAME}" CreateShortcut "$SMPROGRAMS\${NAME}\${NAME}.lnk" "$INSTDIR\darkroom.exe" CreateShortcut "$SMPROGRAMS\${NAME}\Uninstall ${NAME}.lnk" "$INSTDIR\uninstall.exe" SectionEnd Section "Desktop shortcut" SecDesktop CreateShortcut "$DESKTOP\${NAME}.lnk" "$INSTDIR\darkroom.exe" SectionEnd ; Off by default: a desktop icon is the user's to ask for. Function .onInit SectionSetFlags ${SecDesktop} 0 FunctionEnd Section "Uninstall" ; What the installer wrote, and nothing the application wrote ; (docs/dev/windows.md §5.3): %LOCALAPPDATA%\darkroom and %APPDATA%\darkroom — ; the catalog, the thumbnails, the face index, the settings — stay. An ; uninstaller that deletes a library index the user spent two hours ; building is the destructive default this project argues against ; everywhere else, so the confirm page says where those directories are. Delete "$INSTDIR\darkroom.exe" Delete "$INSTDIR\LICENSE" Delete "$INSTDIR\uninstall.exe" RMDir /r "$INSTDIR\models" RMDir "$INSTDIR" Delete "$SMPROGRAMS\${NAME}\${NAME}.lnk" Delete "$SMPROGRAMS\${NAME}\Uninstall ${NAME}.lnk" RMDir "$SMPROGRAMS\${NAME}" Delete "$DESKTOP\${NAME}.lnk" DeleteRegKey HKCU "${UNINST_KEY}" SectionEnd Function un.onInit MessageBox MB_OKCANCEL|MB_ICONINFORMATION \ "This removes the ${NAME} program.$\r$\n$\r$\nYour library index and settings are kept, in:$\r$\n $LOCALAPPDATA\darkroom$\r$\n $APPDATA\darkroom" \ /SD IDOK IDOK done Abort done: FunctionEnd