GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/patches/[email protected] at dev · erickwill/opencode 375 lines (358 loc) · 12.1 KB Copy path File metadata and controls375 lines (358 loc) · 12.1 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 diff --git a/templates/nsis/include/extractAppPackage.nsh b/templates/nsis/include/extractAppPackage.nsh index f5470bf52e923dc47266cea4684c76ef78ced451..ba5a7d92434351a7c7bea660c393288a1b9a88d7 100644 --- a/templates/nsis/include/extractAppPackage.nsh +++ b/templates/nsis/include/extractAppPackage.nsh @@ -1,4 +1,11 @@ !macro extractEmbeddedAppPackage + # OpenCode: the custom include can install an update the running app already unpacked, and sets + # $R0 to "installed" when it did. + !ifmacrodef customInstallStagedApp + !insertmacro customInstallStagedApp + StrCmp $R0 "installed" extractEmbeddedAppPackageDone + !endif + !ifdef COMPRESS SetCompress off !endif @@ -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,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 + 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..3ef8a89ec48d59fa0862ac6916f3097cdb9d99b5 100644 --- a/templates/nsis/include/installer.nsh +++ b/templates/nsis/include/installer.nsh @@ -90,7 +90,21 @@ ${if} $installMode == "all" SetShellVarContext current ${endif} - !insertmacro copyFile "$EXEPATH" "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}" + # OpenCode: an update runs from the updater's pending download next to this cache file, so hard + # link it instead of copying a few hundred MB. The updater replaces that download rather than + # rewriting it, so the link never changes under the cache. + ${StdUtils.GetParentPath} $R5 "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}" + StrLen $R6 "$R5\" + StrCpy $R6 $EXEPATH $R6 + ${if} $R6 == "$R5\" + Delete "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}" + System::Call 'kernel32::CreateHardLinkW(w "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}", w "$EXEPATH", p 0) i .R6' + ${else} + StrCpy $R6 0 + ${endIf} + ${if} $R6 == 0 + !insertmacro copyFile "$EXEPATH" "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}" + ${endIf} ${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}..." |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |