Files
DarkRoom/packaging/windows/darkroom.nsi
T
dtourolle 2836ec2881 Build the Windows installer in a container, and run it under Wine
docs/windows.md specified it; this is §9 steps 1, 2 and 4 run, and the
report in §10. A Debian trixie image with rustup, the MinGW cross
compiler, NSIS and Wine; a build.sh in the shape of the Android one;
a package.sh that stages the executable and the seven models behind
the same LFS-pointer guard every other packager carries, then runs
makensis; and the .nsi itself — per-user, no elevation, an uninstaller
that leaves the library alone.

Measured: the executable links first time once the link flags were
right, imports only Windows system DLLs, prints its version under
Wine, and the installer installs and uninstalls silently under Wine
with the registry key and the models where §5.2 says. What Wine
cannot show is the Start Menu shortcut: CreateShortcut is IShellLink
and does nothing headless.

Four claims in the spec's first draft were wrong and are corrected in
place with the reasoning kept: the whole-archive winpthread flag
breaks the link and was never needed; build scripts need a host gcc;
bookworm's Wine lacks the bcryptprimitives.dll rustc's std imports,
so the image is trixie; and NSIS's default stub is 32-bit, so the
installer says amd64-unicode and needs no i386 Wine.
2026-09-12 00:54:11 +02:00

134 lines
5.1 KiB
NSIS

; DarkRoom — Windows installer
;
; Built by docker/windows/package.sh with makensis on Linux; see docs/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 and models\.
; package.sh assembles it and applies the LFS-pointer guard before this runs.
;
; No licence page yet: the repository carries no LICENSE file (the Arch package
; points at the system's shared GPL text), and a page needs a file to show.
; Adding one at the root is the whole change; `!insertmacro MUI_PAGE_LICENSE`
; then goes before the directory page.
; 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=<staging directory>"
!endif
!ifndef OUT
!error "pass -DOUT=<installer path>"
!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/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
!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"
; The seven model files (four 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/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\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