Wire hermit_getenv across the engine, rebrand WebUI/systemd/docs, and add apps/desktop (Tauri 2 + React) with a DeepSeek-Harness-like UI. Qt app/ is frozen; full libcstcore FFI is scaffolded behind --features engine. Co-authored-by: Cursor <cursoragent@cursor.com>
152 lines
5.6 KiB
NSIS
152 lines
5.6 KiB
NSIS
; CST-Agent per-user installer (no admin rights).
|
|
; makensis -INPUTCHARSET UTF8 -DVERSION=0.8.5 -DSRCDIR=dist/windows-x86_64 -DOUTFILE=setup.exe cst-agent.nsi
|
|
; Installs the same files as the zip into %LOCALAPPDATA%\Programs\cst-agent,
|
|
; adds that folder to the user PATH and registers an uninstaller under HKCU.
|
|
Unicode true
|
|
SetCompressor /SOLID lzma
|
|
RequestExecutionLevel user
|
|
|
|
!ifndef VERSION
|
|
!error "pass -DVERSION=x.y.z"
|
|
!endif
|
|
!ifndef SRCDIR
|
|
!error "pass -DSRCDIR=<dist/windows-x86_64>"
|
|
!endif
|
|
!ifndef OUTFILE
|
|
!define OUTFILE "cst-agent-${VERSION}-windows-x86_64-setup.exe"
|
|
!endif
|
|
|
|
!define APP "Hermit"
|
|
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\hermit"
|
|
|
|
!include "MUI2.nsh"
|
|
!include "LogicLib.nsh"
|
|
!include "x64.nsh"
|
|
|
|
Name "${APP} ${VERSION}"
|
|
OutFile "${OUTFILE}"
|
|
InstallDir "$LOCALAPPDATA\Programs\cst-agent"
|
|
InstallDirRegKey HKCU "${UNINST_KEY}" "InstallLocation"
|
|
BrandingText "${APP} ${VERSION}"
|
|
|
|
VIProductVersion "${VERSION}.0"
|
|
VIAddVersionKey /LANG=1033 "ProductName" "${APP}"
|
|
VIAddVersionKey /LANG=1033 "ProductVersion" "${VERSION}"
|
|
VIAddVersionKey /LANG=1033 "FileVersion" "${VERSION}"
|
|
VIAddVersionKey /LANG=1033 "FileDescription" "${APP} installer"
|
|
VIAddVersionKey /LANG=1033 "LegalCopyright" "WHC"
|
|
|
|
!define MUI_ABORTWARNING
|
|
!define MUI_FINISHPAGE_RUN
|
|
!define MUI_FINISHPAGE_RUN_TEXT "$(RunWebUI)"
|
|
!define MUI_FINISHPAGE_RUN_FUNCTION LaunchWebUI
|
|
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_PAGE_FINISH
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
!insertmacro MUI_LANGUAGE "SimpChinese"
|
|
|
|
LangString NeedX64 ${LANG_ENGLISH} "${APP} needs 64-bit Windows."
|
|
LangString NeedX64 ${LANG_SIMPCHINESE} "${APP} 需要 64 位 Windows。"
|
|
LangString NeedBuild ${LANG_ENGLISH} "${APP} needs Windows 10 1903 (build 18362) or newer; this is build $0."
|
|
LangString NeedBuild ${LANG_SIMPCHINESE} "${APP} 需要 Windows 10 1903(内部版本 18362)或更新版本,当前为 $0。"
|
|
LangString RunWebUI ${LANG_ENGLISH} "Open the ${APP} WebUI"
|
|
LangString RunWebUI ${LANG_SIMPCHINESE} "打开 ${APP} WebUI"
|
|
LangString PathFail ${LANG_ENGLISH} "Could not add $INSTDIR to the user PATH; add it by hand."
|
|
LangString PathFail ${LANG_SIMPCHINESE} "未能把 $INSTDIR 加入用户 PATH,请手动添加。"
|
|
|
|
; PowerShell edits the user PATH: NSIS strings are capped at 1024 chars, and
|
|
; .NET broadcasts the change so new terminals see it. The folder is passed in
|
|
; the environment, so quotes in it cannot break the command.
|
|
!macro EditUserPath ACTION
|
|
System::Call 'Kernel32::SetEnvironmentVariable(t "CST_INSTDIR", t "$INSTDIR")'
|
|
nsExec::ExecToLog `powershell -NoProfile -ExecutionPolicy Bypass -Command "$$d = $$env:CST_INSTDIR.TrimEnd('\'); $$p = [Environment]::GetEnvironmentVariable('Path', 'User'); $$parts = @([string]$$p -split ';' | Where-Object { $$_ -and $$_.TrimEnd('\') -ine $$d }); if ('${ACTION}' -eq 'add') { $$parts += $$d }; [Environment]::SetEnvironmentVariable('Path', ($$parts -join ';'), 'User')"`
|
|
Pop $0
|
|
!macroend
|
|
|
|
; A running exe cannot be overwritten but can be renamed out of the way.
|
|
!macro MoveAside NAME
|
|
Delete "$INSTDIR\${NAME}.old"
|
|
ClearErrors
|
|
Delete "$INSTDIR\${NAME}"
|
|
${If} ${Errors}
|
|
Rename "$INSTDIR\${NAME}" "$INSTDIR\${NAME}.old"
|
|
${EndIf}
|
|
!macroend
|
|
|
|
Function .onInit
|
|
${IfNot} ${RunningX64}
|
|
MessageBox MB_ICONSTOP "$(NeedX64)"
|
|
Abort
|
|
${EndIf}
|
|
SetRegView 64
|
|
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentBuildNumber"
|
|
${If} $0 < 18362
|
|
MessageBox MB_ICONSTOP "$(NeedBuild)"
|
|
Abort
|
|
${EndIf}
|
|
FunctionEnd
|
|
|
|
Function LaunchWebUI
|
|
SetOutPath "$PROFILE"
|
|
Exec '"$INSTDIR\cst-agent.exe" --web --web-open'
|
|
FunctionEnd
|
|
|
|
Section "Install"
|
|
SetShellVarContext current
|
|
SetOutPath "$INSTDIR"
|
|
!insertmacro MoveAside "cst-agent.exe"
|
|
!insertmacro MoveAside "busybox.exe"
|
|
File "${SRCDIR}/cst-agent.exe"
|
|
File "${SRCDIR}/busybox.exe"
|
|
File "${SRCDIR}/LICENSE.busybox"
|
|
File "${SRCDIR}/README.md"
|
|
File "${SRCDIR}/cst-agent-update.cmd"
|
|
File "${SRCDIR}/install_windows.ps1"
|
|
File "${SRCDIR}/VERSION"
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
|
|
!insertmacro EditUserPath "add"
|
|
${If} $0 != 0
|
|
DetailPrint "$(PathFail)"
|
|
${EndIf}
|
|
|
|
; The WebUI's workspace is the shortcut's start folder.
|
|
SetOutPath "$PROFILE"
|
|
CreateShortCut "$SMPROGRAMS\${APP} WebUI.lnk" "$INSTDIR\cst-agent.exe" "--web --web-open" "$INSTDIR\cst-agent.exe" 0
|
|
SetOutPath "$INSTDIR"
|
|
|
|
WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${APP}"
|
|
WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
|
|
WriteRegStr HKCU "${UNINST_KEY}" "Publisher" "WHC"
|
|
WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\cst-agent.exe"
|
|
WriteRegStr HKCU "${UNINST_KEY}" "InstallLocation" "$INSTDIR"
|
|
WriteRegStr HKCU "${UNINST_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
|
WriteRegStr HKCU "${UNINST_KEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'
|
|
WriteRegStr HKCU "${UNINST_KEY}" "URLInfoAbout" "https://git.whcself.xyz/WHC/CST-agent"
|
|
WriteRegDWORD HKCU "${UNINST_KEY}" "NoModify" 1
|
|
WriteRegDWORD HKCU "${UNINST_KEY}" "NoRepair" 1
|
|
SectionEnd
|
|
|
|
Section "Uninstall"
|
|
SetShellVarContext current
|
|
!insertmacro EditUserPath "remove"
|
|
Delete "$SMPROGRAMS\${APP} WebUI.lnk"
|
|
Delete "$INSTDIR\cst-agent.exe"
|
|
Delete "$INSTDIR\cst-agent.exe.old"
|
|
Delete "$INSTDIR\busybox.exe"
|
|
Delete "$INSTDIR\busybox.exe.old"
|
|
Delete "$INSTDIR\LICENSE.busybox"
|
|
Delete "$INSTDIR\README.md"
|
|
Delete "$INSTDIR\cst-agent-update.cmd"
|
|
Delete "$INSTDIR\install_windows.ps1"
|
|
Delete "$INSTDIR\VERSION"
|
|
Delete "$INSTDIR\uninstall.exe"
|
|
RMDir "$INSTDIR"
|
|
DeleteRegKey HKCU "${UNINST_KEY}"
|
|
SectionEnd
|