mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
fix(desktop): smooth Windows installer progress bar with live status and throughput (#66506)
This commit is contained in:
parent
63261c1c5d
commit
662002c557
3 changed files with 532 additions and 6 deletions
|
|
@ -134,6 +134,9 @@
|
|||
System::Call "kernel32::GetTickCount() i .R8"
|
||||
${EndIf}
|
||||
DetailPrint "$(appClosing)"
|
||||
!ifmacrodef setInstallStatus
|
||||
!insertmacro setInstallStatus "$(appClosing)"
|
||||
!endif
|
||||
${ElseIf} $1 >= 2000
|
||||
${If} ${Cmd} `MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(appCannotBeClosed)" /SD IDCANCEL IDCANCEL`
|
||||
Quit
|
||||
|
|
@ -141,6 +144,9 @@
|
|||
System::Call "kernel32::GetTickCount() i .R8"
|
||||
${EndIf}
|
||||
|
||||
!ifmacrodef advanceInstallProgress
|
||||
!insertmacro advanceInstallProgress 300 5400
|
||||
!endif
|
||||
Sleep 100
|
||||
${Loop}
|
||||
!macroend
|
||||
|
|
@ -226,6 +232,9 @@
|
|||
StrCpy $R0 ""
|
||||
StrCpy $R1 "${STAGED_PACKAGE_HASH}" 16
|
||||
${If} ${FileExists} "$INSTDIR.update-$R1\${APP_EXECUTABLE_FILENAME}"
|
||||
!ifmacrodef setInstallStatus
|
||||
!insertmacro setInstallStatus "$(applyingStaged)"
|
||||
!endif
|
||||
SetOutPath $PLUGINSDIR
|
||||
; Removes the directory only while it is empty, so the rename never mixes two versions.
|
||||
RMDir $INSTDIR
|
||||
|
|
@ -233,6 +242,9 @@
|
|||
Rename "$INSTDIR.update-$R1" $INSTDIR
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $R0 "installed"
|
||||
!ifmacrodef setInstallProgress
|
||||
!insertmacro setInstallProgress 22500
|
||||
!endif
|
||||
${EndIf}
|
||||
SetOutPath $INSTDIR
|
||||
${EndIf}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ SectionEnd
|
|||
return exe
|
||||
}
|
||||
|
||||
return { dir, run, compile, cleanup: () => rm(dir, { recursive: true, force: true }) }
|
||||
return { dir, run, compile, compiler, plugins, nsisTemplatesDir, config, cleanup: () => rm(dir, { recursive: true, force: true }) }
|
||||
}
|
||||
|
||||
windows(
|
||||
|
|
@ -279,10 +279,12 @@ windows(
|
|||
expect(await Bun.file(path.join(installer.dir, "instdir.txt")).text(), item.name).toBe(
|
||||
path.join(root, item.expected),
|
||||
)
|
||||
|
||||
const left = (await readdir(from, { recursive: true, withFileTypes: true }).catch(() => undefined))
|
||||
?.filter((entry) => entry.isFile())
|
||||
.map((entry) => path.relative(from, path.join(entry.parentPath, entry.name)).replaceAll("\\", "/"))
|
||||
.toSorted()
|
||||
|
||||
expect(left, item.name).toEqual(item.left)
|
||||
const query = await installer.run(["reg.exe", "query", `HKCU\\${uninstallKey}`, "/v", "UninstallString"])
|
||||
expect(query.code === 0, item.name).toBe(item.uninstallKept)
|
||||
|
|
@ -342,3 +344,210 @@ windows(
|
|||
},
|
||||
120_000,
|
||||
)
|
||||
|
||||
// One-click updates used to flicker backwards during CHECK_APP_RUNNING loops and reset to 0% when
|
||||
// Nsis7z::Extract ran. Verify the patched installer template compiles cleanly with zero warnings, and
|
||||
// deterministically verify the monotonic progress controller, control re-IDing, 64-bit extraction math,
|
||||
// and localized status updates against SpiderBanner without timing-sensitive window polling.
|
||||
windows(
|
||||
"one-click installer progress controller stays strictly monotonic with localized status text",
|
||||
async () => {
|
||||
const installer = await harness()
|
||||
const { NsisScriptGenerator } = await import("app-builder-lib/out/targets/nsis/nsisScriptGenerator")
|
||||
|
||||
const { LangConfigurator, addCustomMessageFileInclude, createAddLangsMacro } = await import(
|
||||
"app-builder-lib/out/targets/nsis/nsisLang"
|
||||
)
|
||||
|
||||
const langEn = "$" + "{LANG_ENGLISH}"
|
||||
const flags = new NsisScriptGenerator()
|
||||
flags.flags(["updated", "force-run", "delete-app-data", "no-desktop-shortcut"])
|
||||
|
||||
const compileStdin = async (script: string) => {
|
||||
const proc = Bun.spawn([installer.compiler.path, "-"], {
|
||||
cwd: installer.nsisTemplatesDir,
|
||||
env: { ...process.env, ...installer.compiler.env },
|
||||
stdin: new TextEncoder().encode(script),
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
})
|
||||
|
||||
const [stdout, stderr, code] = await Promise.all([
|
||||
new Response(proc.stdout).text(),
|
||||
new Response(proc.stderr).text(),
|
||||
proc.exited,
|
||||
])
|
||||
|
||||
expect(code, `${stdout}\n${stderr}`).toBe(0)
|
||||
|
||||
return stdout
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. Real patched ONE_CLICK installer + messages.yml compile cleanly with zero warnings.
|
||||
const dummyPayload = path.join(installer.dir, "app.7z")
|
||||
const uninstExe = path.join(installer.dir, "uninst.exe")
|
||||
const instExe = path.join(installer.dir, "inst.exe")
|
||||
await Bun.write(dummyPayload, new Uint8Array([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]))
|
||||
await compileStdin(
|
||||
["Unicode true", "RequestExecutionLevel user", "SilentInstall silent", `OutFile "${uninstExe}"`, "Section", "SectionEnd"].join(
|
||||
"\n",
|
||||
),
|
||||
)
|
||||
|
||||
const langConfig = new LangConfigurator({ multiLanguageInstaller: false })
|
||||
const langGen = new NsisScriptGenerator()
|
||||
createAddLangsMacro(langGen, langConfig)
|
||||
await addCustomMessageFileInclude(
|
||||
"messages.yml",
|
||||
{ getTempFile: async (name: string) => path.join(installer.dir, name) },
|
||||
langGen,
|
||||
langConfig,
|
||||
)
|
||||
|
||||
const compileOut = await compileStdin(
|
||||
[
|
||||
"Unicode true",
|
||||
`OutFile "${instExe}"`,
|
||||
`InstallDir "${path.join(installer.dir, "app")}"`,
|
||||
"!define ONE_CLICK",
|
||||
'!define PRODUCT_NAME "OpenCode"',
|
||||
'!define PRODUCT_FILENAME "OpenCode"',
|
||||
'!define VERSION "2.0.0"',
|
||||
'!define APP_ID "ai.opencode.desktop.progress-test"',
|
||||
'!define APP_FILENAME "opencode-progress-test"',
|
||||
'!define SHORTCUT_NAME "OpenCode Progress Test"',
|
||||
`!define INSTALL_REGISTRY_KEY "${uninstallKey}"`,
|
||||
`!define UNINSTALL_REGISTRY_KEY "${uninstallKey}"`,
|
||||
'!define UNINSTALL_APP_KEY "opencode-progress-test"',
|
||||
'!define UNINSTALL_DISPLAY_NAME "OpenCode Progress Test"',
|
||||
`!define UNINSTALLER_OUT_FILE "${uninstExe}"`,
|
||||
'!define APP_GUID "opencode-progress-test"',
|
||||
`!define APP_64 "${dummyPayload}"`,
|
||||
`!define APP_64_HASH "${payloadHash}"`,
|
||||
"!define APP_64_UNPACKED_SIZE 3000",
|
||||
"!define ESTIMATED_SIZE 3000",
|
||||
'!define APP_INSTALLER_STORE_FILE "opencode-progress-test.exe"',
|
||||
'!define COMPRESSION_METHOD "7z"',
|
||||
"!define DO_NOT_CREATE_START_MENU_SHORTCUT",
|
||||
"!define DO_NOT_CREATE_DESKTOP_SHORTCUT",
|
||||
`!addplugindir /x86-unicode "${path.join(installer.plugins, "x86-unicode")}"`,
|
||||
`!addincludedir "${installer.nsisTemplatesDir}"`,
|
||||
`!addincludedir "${path.join(installer.nsisTemplatesDir, "include")}"`,
|
||||
"!include LogicLib.nsh",
|
||||
"!include StdUtils.nsh",
|
||||
"!include FileFunc.nsh",
|
||||
"!include MUI2.nsh",
|
||||
flags.build(),
|
||||
langGen.build(),
|
||||
`!include "${installer.config.nsis?.include}"`,
|
||||
'!include "installer.nsi"',
|
||||
].join("\n"),
|
||||
)
|
||||
|
||||
expect(compileOut.split("\n").filter((line) => /warning/i.test(line))).toEqual([])
|
||||
|
||||
// 2. Deterministic runtime check of the real patched progress functions against SpiderBanner.
|
||||
// Extract the patched progress block directly from installer.nsi so we test production code as shipped.
|
||||
const nsiSource = await Bun.file(path.join(installer.nsisTemplatesDir, "installer.nsi")).text()
|
||||
const start = nsiSource.indexOf("Var /GLOBAL progressBarHwnd")
|
||||
const end = nsiSource.indexOf("Function runInstallSection")
|
||||
expect(start).toBeGreaterThan(-1)
|
||||
expect(end).toBeGreaterThan(start)
|
||||
const progressBlock = nsiSource.slice(start, end)
|
||||
|
||||
const traceFile = path.join(installer.dir, "trace.txt")
|
||||
const checkExe = path.join(installer.dir, "check-progress.exe")
|
||||
await compileStdin(
|
||||
[
|
||||
"Unicode true",
|
||||
"RequestExecutionLevel user",
|
||||
`OutFile "${checkExe}"`,
|
||||
`!addplugindir /x86-unicode "${path.join(installer.plugins, "x86-unicode")}"`,
|
||||
`!addincludedir "${path.join(installer.nsisTemplatesDir, "include")}"`,
|
||||
"!include MUI2.nsh",
|
||||
"!include LogicLib.nsh",
|
||||
"!insertmacro MUI_PAGE_INSTFILES",
|
||||
'!insertmacro MUI_LANGUAGE "English"',
|
||||
`LangString extracting ${langEn} "Extracting..."`,
|
||||
progressBlock,
|
||||
"Var LogH",
|
||||
"Var BannerPb",
|
||||
"Function Record",
|
||||
" Exch $0",
|
||||
" Push $1",
|
||||
" Push $2",
|
||||
" SendMessage $BannerPb 0x0408 0 0 $1",
|
||||
' System::Call "user32::GetWindowTextW(p $bannerTextHwnd, t .r2, i 256)"',
|
||||
' FileWrite $LogH "$0|$1|$2$\\r$\\n"',
|
||||
" Pop $2",
|
||||
" Pop $1",
|
||||
" Pop $0",
|
||||
"FunctionEnd",
|
||||
"Function RunCheck",
|
||||
` FileOpen $LogH "${traceFile}" w`,
|
||||
" SpiderBanner::Show /MODERN",
|
||||
' FindWindow $0 "#32770" "" $HWNDPARENT',
|
||||
' FindWindow $1 "#32770" "" $HWNDPARENT $0',
|
||||
' System::Call "user32::SetWindowPos(p $1, p 0, i -32000, i -32000, i 0, i 0, i 0x15)"',
|
||||
' FindWindow $BannerPb "msctls_progress32" "" $1',
|
||||
" Call initInstallProgress",
|
||||
// Verify original control ID 1004 is gone so Nsis7z cannot look it up and reset the bar.
|
||||
" GetDlgItem $2 $0 1004",
|
||||
' FileWrite $LogH "id1004|$2|$\\r$\\n"',
|
||||
" !insertmacro setInstallProgress 13500",
|
||||
' Push "set13500"',
|
||||
" Call Record",
|
||||
// Backwards update must be ignored.
|
||||
" !insertmacro setInstallProgress 6000",
|
||||
' Push "back6000"',
|
||||
" Call Record",
|
||||
// Monotonic creep respects cap.
|
||||
" !insertmacro advanceInstallProgress 300 14000",
|
||||
' Push "adv1"',
|
||||
" Call Record",
|
||||
" !insertmacro advanceInstallProgress 300 14000",
|
||||
' Push "adv2"',
|
||||
" Call Record",
|
||||
// 64-bit extraction callback: 350 MiB of 700 MiB -> exact midpoint 19500 (13500 + 6000).
|
||||
" Push 734003200",
|
||||
" Push 367001600",
|
||||
" Call onExtractProgress",
|
||||
' Push "extract50"',
|
||||
" Call Record",
|
||||
// Upper clamp at 30000.
|
||||
" !insertmacro setInstallProgress 99999",
|
||||
' Push "clamp"',
|
||||
" Call Record",
|
||||
" FileClose $LogH",
|
||||
" SetErrorLevel 0",
|
||||
" Quit",
|
||||
"FunctionEnd",
|
||||
"Section",
|
||||
" Call RunCheck",
|
||||
"SectionEnd",
|
||||
].join("\n"),
|
||||
)
|
||||
|
||||
expect((await installer.run([checkExe])).code).toBe(0)
|
||||
|
||||
const rows = (await Bun.file(traceFile).text())
|
||||
.trim()
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.split("|"))
|
||||
|
||||
expect(rows).toEqual([
|
||||
["id1004", "0", ""],
|
||||
["set13500", "13500", "Installing, Please Wait..."],
|
||||
["back6000", "13500", "Installing, Please Wait..."],
|
||||
["adv1", "13800", "Installing, Please Wait..."],
|
||||
["adv2", "14000", "Installing, Please Wait..."],
|
||||
["extract50", "19500", "Extracting... 350 / 700 MB"],
|
||||
["clamp", "30000", "Extracting... 350 / 700 MB"],
|
||||
])
|
||||
} finally {
|
||||
await installer.cleanup()
|
||||
}
|
||||
},
|
||||
120_000,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
diff --git a/templates/nsis/include/extractAppPackage.nsh b/templates/nsis/include/extractAppPackage.nsh
|
||||
index f5470bf52e923dc47266cea4684c76ef78ced451..6c4a4c193a2ca1dc2413482606b9be5c1c2aa1a9 100644
|
||||
index f5470bf52e923dc47266cea4684c76ef78ced451..ba5a7d92434351a7c7bea660c393288a1b9a88d7 100644
|
||||
--- a/templates/nsis/include/extractAppPackage.nsh
|
||||
+++ b/templates/nsis/include/extractAppPackage.nsh
|
||||
@@ -1,4 +1,11 @@
|
||||
|
|
@ -14,35 +14,76 @@ index f5470bf52e923dc47266cea4684c76ef78ced451..6c4a4c193a2ca1dc2413482606b9be5c
|
|||
!ifdef COMPRESS
|
||||
SetCompress off
|
||||
!endif
|
||||
@@ -13,6 +20,10 @@
|
||||
@@ -13,6 +20,16 @@
|
||||
!endif
|
||||
|
||||
!insertmacro decompress
|
||||
+
|
||||
+ !ifmacrodef customInstallStagedApp
|
||||
+ extractEmbeddedAppPackageDone:
|
||||
+ !endif
|
||||
+ !ifmacrodef setInstallProgress
|
||||
+ !insertmacro setInstallProgress 25500
|
||||
+ !endif
|
||||
+ !ifmacrodef setInstallStatus
|
||||
+ !insertmacro setInstallStatus "$(finishingInstall)"
|
||||
+ !endif
|
||||
!insertmacro custom_files_post_decompression
|
||||
!macroend
|
||||
|
||||
@@ -90,6 +101,15 @@
|
||||
@@ -90,11 +107,23 @@
|
||||
!macroend
|
||||
|
||||
!macro extractUsing7za FILE
|
||||
+ # OpenCode: extract straight into an empty install directory. The copy through $PLUGINSDIR below
|
||||
+ # only protects files that a running old version still holds, and an empty directory has none,
|
||||
+ # so it would write the whole app a second time and delete it again on exit.
|
||||
+ StrCpy $extractStartMs 0
|
||||
+ ${DirState} $OUTDIR $R0
|
||||
+ ${if} $R0 != 1
|
||||
+ Nsis7z::Extract "${FILE}"
|
||||
+ GetFunctionAddress $R9 onExtractProgress
|
||||
+ Nsis7z::ExtractWithCallback "${FILE}" $R9
|
||||
+ Goto DoneExtract7za
|
||||
+ ${endIf}
|
||||
+
|
||||
Push $OUTDIR
|
||||
CreateDirectory "$PLUGINSDIR\7z-out"
|
||||
ClearErrors
|
||||
SetOutPath "$PLUGINSDIR\7z-out"
|
||||
- Nsis7z::Extract "${FILE}"
|
||||
+ GetFunctionAddress $R9 onExtractProgress
|
||||
+ Nsis7z::ExtractWithCallback "${FILE}" $R9
|
||||
Pop $R0
|
||||
SetOutPath $R0
|
||||
|
||||
@@ -124,7 +153,9 @@
|
||||
# much disk space.
|
||||
RMDir /r "$PLUGINSDIR\7z-out"
|
||||
|
||||
- Nsis7z::Extract "${FILE}"
|
||||
+ StrCpy $extractStartMs 0
|
||||
+ GetFunctionAddress $R9 onExtractProgress
|
||||
+ Nsis7z::ExtractWithCallback "${FILE}" $R9
|
||||
Goto DoneExtract7za
|
||||
|
||||
AbortExtract7za:
|
||||
diff --git a/templates/nsis/include/installUtil.nsh b/templates/nsis/include/installUtil.nsh
|
||||
index 47367741632726ba0886ac516461dbe98b7aea58..5f8e08e87fc3411afbf05efbe09d4a8fb4c9dc7a 100644
|
||||
--- a/templates/nsis/include/installUtil.nsh
|
||||
+++ b/templates/nsis/include/installUtil.nsh
|
||||
@@ -209,6 +209,10 @@ Function uninstallOldVersion
|
||||
StrCpy $uninstallerFileNameTemp "$PLUGINSDIR\old-uninstaller.exe"
|
||||
!insertmacro copyFile "$uninstallerFileName" "$uninstallerFileNameTemp"
|
||||
|
||||
+ !ifmacrodef setInstallStatus
|
||||
+ !insertmacro setInstallStatus "$(removingPrevious)"
|
||||
+ !endif
|
||||
+
|
||||
# Retry counter
|
||||
StrCpy $R5 0
|
||||
|
||||
diff --git a/templates/nsis/include/installer.nsh b/templates/nsis/include/installer.nsh
|
||||
index 300ef3dd699d0f5a081b1934fcc22dbe12025bdb..6bc1c7f368208024c52aff9ae53f299ce4b632f3 100644
|
||||
index 300ef3dd699d0f5a081b1934fcc22dbe12025bdb..3ef8a89ec48d59fa0862ac6916f3097cdb9d99b5 100644
|
||||
--- a/templates/nsis/include/installer.nsh
|
||||
+++ b/templates/nsis/include/installer.nsh
|
||||
@@ -90,7 +90,21 @@
|
||||
|
|
@ -68,3 +109,267 @@ index 300ef3dd699d0f5a081b1934fcc22dbe12025bdb..6bc1c7f368208024c52aff9ae53f299c
|
|||
${if} $installMode == "all"
|
||||
SetShellVarContext all
|
||||
${endif}
|
||||
diff --git a/templates/nsis/installSection.nsh b/templates/nsis/installSection.nsh
|
||||
index 053772f55ca6ece52f0a34c4fa0f05c9a5f07bd2..6974ebfbcbcd2bf2cb4eb45067e5754cd626d5d4 100644
|
||||
--- a/templates/nsis/installSection.nsh
|
||||
+++ b/templates/nsis/installSection.nsh
|
||||
@@ -30,12 +30,18 @@ StrCpy $appExe "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
|
||||
StrCpy $1 $hwndparent
|
||||
System::Call 'user32::ShutdownBlockReasonCreate(${SYSTYPE_PTR}r1, w "$(installing)")'
|
||||
${endif}
|
||||
+ Call initInstallProgress
|
||||
+ !insertmacro setInstallProgress 1500
|
||||
!insertmacro CHECK_APP_RUNNING
|
||||
!else
|
||||
+ Call initInstallProgress
|
||||
+ !insertmacro setInstallProgress 1500
|
||||
${ifNot} ${UAC_IsInnerInstance}
|
||||
!insertmacro CHECK_APP_RUNNING
|
||||
${endif}
|
||||
!endif
|
||||
+!insertmacro setInstallProgress 6000
|
||||
+!insertmacro setInstallStatus "$(installing)"
|
||||
|
||||
Var /GLOBAL keepShortcuts
|
||||
StrCpy $keepShortcuts "false"
|
||||
@@ -56,6 +62,7 @@ ${if} $installMode == "all"
|
||||
!insertmacro uninstallOldVersion HKEY_CURRENT_USER
|
||||
!insertmacro handleUninstallResult HKEY_CURRENT_USER
|
||||
${endIf}
|
||||
+!insertmacro setInstallProgress 13500
|
||||
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
@@ -64,6 +71,8 @@ SetOutPath $INSTDIR
|
||||
!endif
|
||||
|
||||
!insertmacro installApplicationFiles
|
||||
+!insertmacro setInstallProgress 26700
|
||||
+!insertmacro setInstallStatus "$(finishingInstall)"
|
||||
!insertmacro registryAddInstallInfo
|
||||
!insertmacro addStartMenuLink $keepShortcuts
|
||||
!insertmacro addDesktopLink $keepShortcuts
|
||||
@@ -77,10 +86,18 @@ ${endIf}
|
||||
!ifmacrodef registerFileAssociations
|
||||
!insertmacro registerFileAssociations
|
||||
!endif
|
||||
+!insertmacro setInstallProgress 27900
|
||||
|
||||
!ifmacrodef customInstall
|
||||
+ !insertmacro setInstallStatus "$(settingPermissions)"
|
||||
!insertmacro customInstall
|
||||
!endif
|
||||
+!insertmacro setInstallProgress 30000
|
||||
+!insertmacro setInstallStatus "$(launchingApp)"
|
||||
+${IfNot} ${Silent}
|
||||
+ # Give Windows's smooth progress bar animation a moment to settle at 100% before hiding the banner.
|
||||
+ Sleep 120
|
||||
+${EndIf}
|
||||
|
||||
!macro doStartApp
|
||||
# otherwise app window will be in background
|
||||
diff --git a/templates/nsis/installer.nsi b/templates/nsis/installer.nsi
|
||||
index 4b1f42e4e96ba2b3e7d6d8d2f9ee19b46779a422..777ae1f2e7b40bfb426c6e1c96eabba7611a968c 100644
|
||||
--- a/templates/nsis/installer.nsi
|
||||
+++ b/templates/nsis/installer.nsi
|
||||
@@ -89,6 +89,168 @@ FunctionEnd
|
||||
|
||||
!ifndef BUILD_UNINSTALLER
|
||||
!include "installUtil.nsh"
|
||||
+
|
||||
+ # OpenCode: drive the install progress bar monotonically inside a Function instead of letting NSIS
|
||||
+ # update IDC_PROGRESS from section instruction offsets (which causes loops like CHECK_APP_RUNNING
|
||||
+ # to flicker backwards and staged-update skips or Nsis7z::Extract to reset/jump the bar).
|
||||
+ Var /GLOBAL progressBarHwnd
|
||||
+ Var /GLOBAL progressBarPos
|
||||
+ Var /GLOBAL bannerTextHwnd
|
||||
+ Var /GLOBAL extractStartMs
|
||||
+ Var /GLOBAL extractLastTextMs
|
||||
+
|
||||
+ Function initInstallProgress
|
||||
+ StrCpy $progressBarHwnd 0
|
||||
+ StrCpy $progressBarPos 0
|
||||
+ StrCpy $bannerTextHwnd 0
|
||||
+ StrCpy $extractStartMs 0
|
||||
+ StrCpy $extractLastTextMs 0
|
||||
+ ${IfNot} ${Silent}
|
||||
+ FindWindow $0 "#32770" "" $HWNDPARENT
|
||||
+ ${If} $0 != 0
|
||||
+ GetDlgItem $progressBarHwnd $0 1004
|
||||
+ ${If} $progressBarHwnd != 0
|
||||
+ # Change the hidden control ID (1004 -> 1099) after SpiderBanner subclasses it so plugins
|
||||
+ # such as Nsis7z cannot look up IDC_PROGRESS and reset the bar back to 0%.
|
||||
+ System::Call 'user32::SetWindowLongW(p $progressBarHwnd, i -12, i 1099)'
|
||||
+ ${EndIf}
|
||||
+ FindWindow $1 "#32770" "" $HWNDPARENT $0
|
||||
+ ${If} $1 != 0
|
||||
+ GetDlgItem $bannerTextHwnd $1 1000
|
||||
+ ${EndIf}
|
||||
+ ${EndIf}
|
||||
+ ${EndIf}
|
||||
+ FunctionEnd
|
||||
+
|
||||
+ Function setInstallStatus
|
||||
+ Exch $0
|
||||
+ ${If} $bannerTextHwnd != 0
|
||||
+ SendMessage $bannerTextHwnd ${WM_SETTEXT} 0 "STR:$0"
|
||||
+ ${EndIf}
|
||||
+ Pop $0
|
||||
+ FunctionEnd
|
||||
+
|
||||
+ !macro setInstallStatus TEXT
|
||||
+ Push `${TEXT}`
|
||||
+ Call setInstallStatus
|
||||
+ !macroend
|
||||
+
|
||||
+ Function setInstallProgress
|
||||
+ Exch $0
|
||||
+ ${If} $progressBarHwnd != 0
|
||||
+ ${If} $0 > 30000
|
||||
+ StrCpy $0 30000
|
||||
+ ${EndIf}
|
||||
+ ${If} $0 > $progressBarPos
|
||||
+ StrCpy $progressBarPos $0
|
||||
+ SendMessage $progressBarHwnd 0x0402 $0 0
|
||||
+ ${EndIf}
|
||||
+ ${EndIf}
|
||||
+ Pop $0
|
||||
+ FunctionEnd
|
||||
+
|
||||
+ Function advanceInstallProgress
|
||||
+ Exch $0
|
||||
+ Exch
|
||||
+ Exch $1
|
||||
+ Push $2
|
||||
+ ${If} $progressBarHwnd != 0
|
||||
+ IntOp $2 $progressBarPos + $1
|
||||
+ ${If} $2 > $0
|
||||
+ StrCpy $2 $0
|
||||
+ ${EndIf}
|
||||
+ Push $2
|
||||
+ Call setInstallProgress
|
||||
+ ${EndIf}
|
||||
+ Pop $2
|
||||
+ Pop $1
|
||||
+ Pop $0
|
||||
+ FunctionEnd
|
||||
+
|
||||
+ !macro setInstallProgress POS
|
||||
+ Push ${POS}
|
||||
+ Call setInstallProgress
|
||||
+ !macroend
|
||||
+
|
||||
+ !macro advanceInstallProgress STEP CAP
|
||||
+ Push ${STEP}
|
||||
+ Push ${CAP}
|
||||
+ Call advanceInstallProgress
|
||||
+ !macroend
|
||||
+
|
||||
+ !ifndef ZIP_COMPRESSION
|
||||
+ !ifndef APP_BUILD_DIR
|
||||
+ Function onExtractProgress
|
||||
+ Pop $R8
|
||||
+ Pop $R9
|
||||
+ Push $0
|
||||
+ Push $1
|
||||
+ Push $2
|
||||
+ Push $3
|
||||
+ ${If} $R9 != 0
|
||||
+ # Map 7z extraction progress linearly into 45%..85% (13500..25500, span 12000).
|
||||
+ System::Int64Op $R8 * 12000
|
||||
+ Pop $0
|
||||
+ System::Int64Op $0 / $R9
|
||||
+ Pop $0
|
||||
+ IntOp $0 $0 + 13500
|
||||
+ Push $0
|
||||
+ Call setInstallProgress
|
||||
+
|
||||
+ ${If} $bannerTextHwnd != 0
|
||||
+ System::Call "kernel32::GetTickCount() i .r0"
|
||||
+ ${If} $extractStartMs == 0
|
||||
+ StrCpy $extractStartMs $0
|
||||
+ StrCpy $extractLastTextMs 0
|
||||
+ ${EndIf}
|
||||
+ IntOp $1 $0 - $extractLastTextMs
|
||||
+ ${If} $extractLastTextMs == 0
|
||||
+ ${OrIf} $1 >= 80
|
||||
+ ${OrIf} $R8 == $R9
|
||||
+ StrCpy $extractLastTextMs $0
|
||||
+ IntOp $1 $0 - $extractStartMs
|
||||
+ System::Int64Op $R9 / 1048576
|
||||
+ Pop $2
|
||||
+ ${If} $2 > 0
|
||||
+ System::Int64Op $R8 / 1048576
|
||||
+ Pop $3
|
||||
+ ${If} $1 >= 150
|
||||
+ System::Int64Op $R8 * 1000
|
||||
+ Pop $0
|
||||
+ System::Int64Op $1 * 1048576
|
||||
+ Pop $1
|
||||
+ System::Int64Op $0 / $1
|
||||
+ Pop $0
|
||||
+ ${If} $0 > 0
|
||||
+ Push "$(extracting) $3 / $2 MB ($0 MB/s)"
|
||||
+ ${Else}
|
||||
+ Push "$(extracting) $3 / $2 MB"
|
||||
+ ${EndIf}
|
||||
+ ${Else}
|
||||
+ Push "$(extracting) $3 / $2 MB"
|
||||
+ ${EndIf}
|
||||
+ ${Else}
|
||||
+ System::Int64Op $R9 / 1024
|
||||
+ Pop $2
|
||||
+ System::Int64Op $R8 / 1024
|
||||
+ Pop $3
|
||||
+ Push "$(extracting) $3 / $2 KB"
|
||||
+ ${EndIf}
|
||||
+ Call setInstallStatus
|
||||
+ ${EndIf}
|
||||
+ ${EndIf}
|
||||
+ ${EndIf}
|
||||
+ Pop $3
|
||||
+ Pop $2
|
||||
+ Pop $1
|
||||
+ Pop $0
|
||||
+ FunctionEnd
|
||||
+ !endif
|
||||
+ !endif
|
||||
+
|
||||
+ Function runInstallSection
|
||||
+ !include "installSection.nsh"
|
||||
+ FunctionEnd
|
||||
!endif
|
||||
|
||||
Section "install" INSTALL_SECTION_ID
|
||||
@@ -119,7 +281,7 @@ Section "install" INSTALL_SECTION_ID
|
||||
${endIf}
|
||||
!endif
|
||||
!endif
|
||||
- !include "installSection.nsh"
|
||||
+ Call runInstallSection
|
||||
!endif
|
||||
SectionEnd
|
||||
|
||||
diff --git a/templates/nsis/messages.yml b/templates/nsis/messages.yml
|
||||
index 982e1b09e424c4f07ce7c1152fe5ce8b703f5f57..e8195a6646be9047f11b9574b1ac356ef25ba42e 100644
|
||||
--- a/templates/nsis/messages.yml
|
||||
+++ b/templates/nsis/messages.yml
|
||||
@@ -235,6 +235,18 @@ uninstallFailed:
|
||||
sv: Det gick inte att avinstallera gamla programfiler. Försök att köra installationsprogrammet igen.
|
||||
uk: Не вдалось видалити старі файли застосунку. Будь ласка, спробуйте запустити встановлювач знов.
|
||||
zh_TW: 無法俺安裝舊的應用程式檔案。 請嘗試再次執行安裝程式。
|
||||
+removingPrevious:
|
||||
+ en: "Removing previous version..."
|
||||
+applyingStaged:
|
||||
+ en: "Applying staged update..."
|
||||
+extracting:
|
||||
+ en: "Extracting..."
|
||||
+finishingInstall:
|
||||
+ en: "Finishing installation..."
|
||||
+settingPermissions:
|
||||
+ en: "Setting permissions..."
|
||||
+launchingApp:
|
||||
+ en: "Launching ${PRODUCT_NAME}..."
|
||||
appClosing:
|
||||
en: "Closing running ${PRODUCT_NAME}..."
|
||||
cs: "Ukončuji aplikaci ${PRODUCT_NAME}..."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue