Fix ubuntu debs (#320)

This commit is contained in:
paisley
2026-03-06 15:07:05 +08:00
committed by GitHub
Unverified
parent 01efd87642
commit e7d4cf73d5
7 changed files with 93 additions and 9 deletions

View File

@@ -8,6 +8,14 @@
!endif
!macro customCheckAppRunning
; Pre-emptively remove old shortcuts to prevent the Windows "Missing Shortcut"
; dialog during upgrades. The built-in NSIS uninstaller deletes ClawX.exe
; *before* removing shortcuts; Windows Shell link tracking can detect the
; broken target in that brief window and pop a resolver dialog.
; Delete is a silent no-op when the file doesn't exist (safe for fresh installs).
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}.lnk"
${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0
${if} $R0 == 0
@@ -73,7 +81,15 @@
; Add resources\cli to the current user's PATH for openclaw CLI.
; Read current PATH, skip if already present, append otherwise.
;
; ReadRegStr silently returns "" when the value exceeds the NSIS string
; buffer (8192 chars for the electron-builder large-strings build).
; Without an error-flag check we would overwrite the entire user PATH with
; only our CLI directory, destroying every other PATH entry.
ClearErrors
ReadRegStr $0 HKCU "Environment" "Path"
IfErrors _ci_readFailed
StrCmp $0 "" _ci_setNew
; Check if our CLI dir is already in PATH
@@ -94,6 +110,12 @@
WriteRegExpandStr HKCU "Environment" "Path" $0
; Broadcast WM_SETTINGCHANGE so running Explorer/terminals pick up the change
SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=500
Goto _ci_done
_ci_readFailed:
; PATH value could not be read (likely exceeds NSIS buffer).
; Skip modification to avoid destroying existing entries.
DetailPrint "Warning: Could not read user PATH (may exceed 8192 chars). Skipping PATH update."
_ci_done:
!macroend
@@ -137,7 +159,9 @@ FunctionEnd
!macro customUnInstall
; Remove resources\cli from user PATH
ClearErrors
ReadRegStr $0 HKCU "Environment" "Path"
IfErrors _cu_pathDone
StrCmp $0 "" _cu_pathDone
; Remove our entry (with leading or trailing semicolons)
@@ -145,8 +169,17 @@ FunctionEnd
Push "$INSTDIR\resources\cli"
Call un._cu_RemoveFromPath
Pop $0
; If PATH is now empty, delete the registry value instead of writing ""
StrCmp $0 "" _cu_deletePath
WriteRegExpandStr HKCU "Environment" "Path" $0
SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=500
Goto _cu_pathBroadcast
_cu_deletePath:
DeleteRegValue HKCU "Environment" "Path"
_cu_pathBroadcast:
SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=500
_cu_pathDone: