[release] Write fresh-install breadcrumb from installers

Installers write a .fresh-install breadcrumb on fresh installs only and
delete stale breadcrumbs on upgrade; none of them writes login items or
registry Run keys. Windows NSIS detects upgrades via the uninstall
registry entry or an existing installed executable; the macOS pkg via the
previous pkgutil receipt; Linux deb/rpm via the standard postinstall
arguments. Post-update GUI relaunches (macOS open, Linux
ui-post-install.sh) pass --post-update so the first-run autostart default
cannot fire on updates.
This commit is contained in:
mlsmaycon
2026-07-12 12:42:25 +02:00
parent 416ecd90ec
commit e0737f94dc
3 changed files with 93 additions and 8 deletions
+26 -2
View File
@@ -75,6 +75,8 @@ OutFile "..\..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the i
InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
ShowInstDetails show # This will always show the installation details.
Var FreshInstall
Function .onInit
!insertmacro wails.checkArchitecture
FunctionEnd
@@ -84,16 +86,38 @@ Section
!insertmacro wails.webview2runtime
# Fresh-vs-upgrade detection must run before any file is written. An
# existing uninstall registry entry or an already-installed executable
# means upgrade; only a true fresh install gets the breadcrumb the GUI
# uses to enable launch-on-login by default. The installer itself never
# writes login items or Run keys.
StrCpy $FreshInstall "1"
ReadRegStr $0 HKLM "${UNINST_KEY}" "UninstallString"
StrCmp $0 "" +2 0
StrCpy $FreshInstall "0"
IfFileExists "$INSTDIR\${PRODUCT_EXECUTABLE}" 0 +2
StrCpy $FreshInstall "0"
SetOutPath $INSTDIR
!insertmacro wails.files
# On upgrade, delete any stale breadcrumb (covers a fresh install where
# the GUI never launched before the first update).
StrCmp $FreshInstall "1" 0 removeBreadcrumb
FileOpen $0 "$INSTDIR\.fresh-install" w
FileClose $0
Goto breadcrumbDone
removeBreadcrumb:
Delete "$INSTDIR\.fresh-install"
breadcrumbDone:
CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
!insertmacro wails.associateFiles
!insertmacro wails.associateCustomProtocols
!insertmacro wails.writeUninstaller
SectionEnd