fix(app): installer removes only its own files and stops on failed steps
- installer.sh lists every packaged file for the uninstaller, and folders are removed only when empty, so a chosen folder keeps other files. - A virtual monitor driver removal that fails stops the uninstall with everything kept (silent exit code 4); the elevated half exits 2 when there is no driver of ours to remove, which the uninstaller accepts. - WebView2 is installed before any file is copied; when it is still missing the installer asks to retry, or silently stops with code 3 without installing or starting anything. - The installer holds Global\JarvisBotSetup while it runs; jarvis.exe started meanwhile shows a message and exits before any window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
; The Jarvis installer (admin.spec.md, "Installer"). Built on Linux by installer.sh with makensis:
|
||||
; makensis -DVERSION=0.1.0 -DSRC=<Jarvis folder> -DOUT=<setup.exe> -DICON=<icon.ico> -DWEBVIEW2=<bootstrapper> installer.nsi
|
||||
; makensis -DVERSION=0.1.0 -DSRC=<Jarvis folder> -DOUT=<setup.exe> -DICON=<icon.ico> -DWEBVIEW2=<bootstrapper>
|
||||
; -DUNINSTALL_LIST=<the Delete/RMDir lines of the installed files> installer.nsi
|
||||
; Program Files, one administrator prompt; the data folder is chosen by the app's first-run wizard
|
||||
; and never touched here. /S installs silently (the app's updates: /S /RUN starts the app afterwards).
|
||||
|
||||
@@ -11,7 +12,9 @@ SetCompressor /SOLID lzma
|
||||
!include "FileFunc.nsh"
|
||||
|
||||
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\JarvisBot"
|
||||
!define WEBVIEW2_KEY "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
|
||||
!ifndef WEBVIEW2_KEY ; a test build points it elsewhere to act as a PC without the runtime
|
||||
!define WEBVIEW2_KEY "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
|
||||
!endif
|
||||
|
||||
Name "Jarvis"
|
||||
OutFile "${OUT}"
|
||||
@@ -95,6 +98,12 @@ FunctionEnd
|
||||
${Loop}
|
||||
!macroend
|
||||
|
||||
; The installer's lock: Jarvis does not start while it is held (app/src/setup_lock.rs); taken
|
||||
; before waiting for a running Jarvis, held until the installer ends.
|
||||
!macro TakeLock
|
||||
System::Call 'kernel32::CreateMutexW(p 0, i 1, w "Global\JarvisBotSetup") p .r9'
|
||||
!macroend
|
||||
|
||||
Function .onInit
|
||||
${IfNot} ${RunningX64}
|
||||
MessageBox MB_ICONSTOP "Jarvis는 64비트 Windows 10/11에서만 실행됩니다."
|
||||
@@ -103,15 +112,61 @@ Function .onInit
|
||||
SetRegView 64
|
||||
; Shortcuts for every user of the PC, like the Program Files install itself.
|
||||
SetShellVarContext all
|
||||
!insertmacro TakeLock
|
||||
!insertmacro WaitClosed ""
|
||||
FunctionEnd
|
||||
|
||||
Function un.onInit
|
||||
SetRegView 64
|
||||
SetShellVarContext all
|
||||
!insertmacro TakeLock
|
||||
!insertmacro WaitClosed "un."
|
||||
FunctionEnd
|
||||
|
||||
; The window needs the WebView2 runtime (Windows 11 has it; an older Windows 10 may not). Checked
|
||||
; before any file is copied: without it nothing is installed (and /RUN starts nothing).
|
||||
Function WebView2Present
|
||||
ReadRegStr $0 HKLM "${WEBVIEW2_KEY}" "pv"
|
||||
ReadRegStr $1 HKCU "${WEBVIEW2_KEY}" "pv"
|
||||
StrCpy $2 0
|
||||
${If} $0 != ""
|
||||
${AndIf} $0 != "0.0.0.0"
|
||||
StrCpy $2 1
|
||||
${EndIf}
|
||||
${If} $1 != ""
|
||||
${AndIf} $1 != "0.0.0.0"
|
||||
StrCpy $2 1
|
||||
${EndIf}
|
||||
Push $2
|
||||
FunctionEnd
|
||||
|
||||
Function EnsureWebView2
|
||||
Call WebView2Present
|
||||
Pop $2
|
||||
${If} $2 == 1
|
||||
Return
|
||||
${EndIf}
|
||||
SetOutPath "$PLUGINSDIR"
|
||||
File "/oname=webview2.exe" "${WEBVIEW2}"
|
||||
${Do}
|
||||
DetailPrint "WebView2 런타임 설치"
|
||||
ExecWait '"$PLUGINSDIR\webview2.exe" /silent /install' $0
|
||||
Call WebView2Present
|
||||
Pop $2
|
||||
${If} $2 == 1
|
||||
Return
|
||||
${EndIf}
|
||||
DetailPrint "WebView2 런타임을 설치하지 못했습니다 (결과 $0)"
|
||||
${If} ${Silent}
|
||||
SetErrorLevel 3
|
||||
Abort "WebView2 런타임을 설치하지 못했습니다."
|
||||
${EndIf}
|
||||
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "Jarvis 창에 필요한 WebView2 런타임을 설치하지 못했습니다. 인터넷 연결을 확인하고 다시 시도해 주세요." IDRETRY +3
|
||||
SetErrorLevel 3
|
||||
Abort "WebView2 런타임이 없어 설치하지 않았습니다."
|
||||
${Loop}
|
||||
FunctionEnd
|
||||
|
||||
; Started from this elevated installer the app would run as administrator; Explorer starts it as
|
||||
; the signed-in user.
|
||||
Function RunAsUser
|
||||
@@ -120,6 +175,9 @@ FunctionEnd
|
||||
|
||||
Section "Jarvis (필수)" SecMain
|
||||
SectionIn RO
|
||||
; Again right before changing anything: a Jarvis started since the first look closes first.
|
||||
!insertmacro WaitClosed ""
|
||||
Call EnsureWebView2
|
||||
SetOutPath "$INSTDIR"
|
||||
File "${SRC}/jarvis.exe"
|
||||
File "${SRC}/WebView2Loader.dll"
|
||||
@@ -138,21 +196,6 @@ Section "Jarvis (필수)" SecMain
|
||||
WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1
|
||||
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
|
||||
WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" $0
|
||||
; The window needs the WebView2 runtime (Windows 11 has it; an older Windows 10 may not).
|
||||
ReadRegStr $0 HKLM "${WEBVIEW2_KEY}" "pv"
|
||||
ReadRegStr $1 HKCU "${WEBVIEW2_KEY}" "pv"
|
||||
${If} $0 == ""
|
||||
${OrIf} $0 == "0.0.0.0"
|
||||
${If} $1 == ""
|
||||
${OrIf} $1 == "0.0.0.0"
|
||||
DetailPrint "WebView2 런타임 설치"
|
||||
SetOutPath "$PLUGINSDIR"
|
||||
File "/oname=webview2.exe" "${WEBVIEW2}"
|
||||
ExecWait '"$PLUGINSDIR\webview2.exe" /silent /install' $0
|
||||
DetailPrint "WebView2 설치 결과: $0"
|
||||
SetOutPath "$INSTDIR"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
; Silent updates (/S /RUN) start the app again when done.
|
||||
${GetParameters} $0
|
||||
ClearErrors
|
||||
@@ -193,15 +236,31 @@ LangString DESC_Driver ${LANG_KOREAN} "봇용 크롬창을 실제 모니터에
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
||||
Section "Uninstall"
|
||||
; The virtual monitor's driver goes with the app when this app installed it (the elevated half
|
||||
; refuses another program's copy and does nothing when there is none).
|
||||
ExecWait '"$INSTDIR\jarvis.exe" --display-driver uninstall --result "$TEMP\jarvis-vdd-uninstall.txt"'
|
||||
!insertmacro WaitClosed "un."
|
||||
; The virtual monitor's driver goes with the app when this app installed it (code 0). Code 2:
|
||||
; nothing of this app's to remove (none, or another program's copy). Anything else: it stays,
|
||||
; so the uninstall stops here and keeps the app, which can remove it or try again.
|
||||
ExecWait '"$INSTDIR\jarvis.exe" --display-driver uninstall --result "$TEMP\jarvis-vdd-uninstall.txt"' $0
|
||||
${If} $0 != 0
|
||||
${AndIf} $0 != 2
|
||||
StrCpy $2 ""
|
||||
FileOpen $1 "$TEMP\jarvis-vdd-uninstall.txt" r
|
||||
FileRead $1 $2
|
||||
FileClose $1
|
||||
Delete "$TEMP\jarvis-vdd-uninstall.txt"
|
||||
DetailPrint "가상 모니터 드라이버를 지우지 못했습니다 ($0): $2"
|
||||
${IfNot} ${Silent}
|
||||
MessageBox MB_ICONSTOP "가상 모니터 드라이버를 지우지 못해 제거를 멈췄습니다. Jarvis의 기능 화면에서 드라이버를 제거한 뒤 다시 시도해 주세요.$\r$\n$2"
|
||||
${EndIf}
|
||||
SetErrorLevel 4
|
||||
Abort "가상 모니터 드라이버를 지우지 못했습니다."
|
||||
${EndIf}
|
||||
Delete "$TEMP\jarvis-vdd-uninstall.txt"
|
||||
; Only what the installer put there: a folder the person chose may hold other things.
|
||||
; Only the files the installer put there (the list is made from the package at build time): a
|
||||
; folder the person chose may hold other things; folders go only when empty.
|
||||
Delete "$INSTDIR\jarvis.exe"
|
||||
Delete "$INSTDIR\WebView2Loader.dll"
|
||||
RMDir /r "$INSTDIR\python-src"
|
||||
RMDir /r "$INSTDIR\display-driver"
|
||||
!include "${UNINSTALL_LIST}"
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
RMDir "$INSTDIR"
|
||||
Delete "$SMPROGRAMS\Jarvis.lnk"
|
||||
|
||||
@@ -11,8 +11,13 @@ sh "$here/package.sh" "$out" >/dev/null
|
||||
# The WebView2 runtime's bootstrapper (Microsoft, about 2 MB), run only on a PC without the runtime.
|
||||
wv2="$target/MicrosoftEdgeWebview2Setup.exe"
|
||||
[ -s "$wv2" ] || curl -fsSL -o "$wv2" "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
|
||||
# What the uninstaller removes: exactly the files installed under python-src and display-driver,
|
||||
# then their folders, deepest first, each only when empty.
|
||||
list="$target/uninstall-list.nsh"
|
||||
(cd "$out/Jarvis" && find python-src display-driver -type f | sort | sed 's|/|\\|g; s|^| Delete "$INSTDIR\\|; s|$|"|'
|
||||
cd "$out/Jarvis" && find python-src display-driver -type d | sort -r | sed 's|/|\\|g; s|^| RMDir "$INSTDIR\\|; s|$|"|') > "$list"
|
||||
setup="$out/Jarvis-Setup-$version.exe"
|
||||
makensis -V2 -DVERSION="$version" -DSRC="$out/Jarvis" -DOUT="$setup" -DICON="$here/icons/icon.ico" \
|
||||
-DWEBVIEW2="$wv2" "$here/installer.nsi"
|
||||
-DWEBVIEW2="$wv2" -DUNINSTALL_LIST="$list" ${NSIS_EXTRA:-} "$here/installer.nsi"
|
||||
(cd "$out" && sha256sum "Jarvis-Setup-$version.exe" > "Jarvis-Setup-$version.exe.sha256")
|
||||
echo "$setup"
|
||||
|
||||
@@ -41,6 +41,11 @@ fn main() {
|
||||
if let Some(code) = jarvis_app::vdisplay::elevated_main(&std::env::args().collect::<Vec<_>>()) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
// Not while an installer installs, updates or removes Jarvis (admin.spec.md, "Installer").
|
||||
if jarvis_app::setup_lock::held() {
|
||||
jarvis_app::setup_lock::tell();
|
||||
std::process::exit(3);
|
||||
}
|
||||
let location = arg("--location").map(PathBuf::from).or_else(jarvis_app::datadir::default_location_file)
|
||||
.expect("no location file path: pass --location");
|
||||
// Log files go to the data folder once there is one; until then memory only.
|
||||
|
||||
Reference in New Issue
Block a user