From 3be0181514b88f16386aab1b7645d7e89d493147 Mon Sep 17 00:00:00 2001 From: develar Date: Thu, 4 Apr 2019 11:41:52 +0200 Subject: [PATCH] feat(portable): constant unpack path across all launches of the same executable Close #3799 --- .idea/dictionaries/develar.xml | 3 +++ package.json | 2 +- packages/app-builder-lib/package.json | 2 +- .../src/targets/AppImageTarget.ts | 1 - .../src/targets/nsis/NsisTarget.ts | 3 ++- .../templates/nsis/portable.nsi | 5 ++-- packages/builder-util-runtime/src/uuid.ts | 23 +++++++++++-------- packages/builder-util/package.json | 2 +- yarn.lock | 8 +++---- 9 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index 7eee2b74386..22794b7d862 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -114,6 +114,8 @@ epipe evolvehq exdev + exedir + exepath exitdialogoptionalcheckbox exitdialogoptionalcheckboxtext extname @@ -187,6 +189,7 @@ kext keyserver keytar + ksuid langs launchui lcid diff --git a/package.json b/package.json index c38949b1961..04d578f9bbc 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "dependencies": { "7zip-bin": "~4.1.0", "@types/is-ci": "^1.1.0", - "app-builder-bin": "2.6.5", + "app-builder-bin": "2.6.6", "archiver": "^3.0.0", "async-exit-hook": "^2.0.1", "bluebird-lst": "^1.0.7", diff --git a/packages/app-builder-lib/package.json b/packages/app-builder-lib/package.json index 079fecd3906..88de7ea53ac 100644 --- a/packages/app-builder-lib/package.json +++ b/packages/app-builder-lib/package.json @@ -42,7 +42,7 @@ "homepage": "https://github.com/electron-userland/electron-builder", "dependencies": { "7zip-bin": "~4.1.0", - "app-builder-bin": "2.6.5", + "app-builder-bin": "2.6.6", "async-exit-hook": "^2.0.1", "bluebird-lst": "^1.0.7", "chromium-pickle-js": "^0.2.0", diff --git a/packages/app-builder-lib/src/targets/AppImageTarget.ts b/packages/app-builder-lib/src/targets/AppImageTarget.ts index b05fe44a6da..23dd70b5171 100644 --- a/packages/app-builder-lib/src/targets/AppImageTarget.ts +++ b/packages/app-builder-lib/src/targets/AppImageTarget.ts @@ -19,7 +19,6 @@ export default class AppImageTarget extends Target { constructor(ignored: string, private readonly packager: LinuxPackager, private readonly helper: LinuxTargetHelper, readonly outDir: string) { super("appImage") - // we add X-AppImage-BuildId to ensure that new desktop file will be installed this.desktopEntry = new Lazy(() => helper.computeDesktopEntry(this.options, "AppRun", { "X-AppImage-Version": `${packager.appInfo.buildVersion}`, })) diff --git a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts index 52242fd5e54..fca2baa7a3c 100644 --- a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts +++ b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts @@ -1,6 +1,6 @@ import { path7za } from "7zip-bin" import BluebirdPromise from "bluebird-lst" -import { Arch, asArray, AsyncTaskManager, getPlatformIconFileName, InvalidConfigurationError, log, spawnAndWrite, use, exec } from "builder-util" +import { executeAppBuilder, Arch, asArray, AsyncTaskManager, getPlatformIconFileName, InvalidConfigurationError, log, spawnAndWrite, use, exec } from "builder-util" import { PackageFileInfo, UUID, CURRENT_APP_PACKAGE_FILE_NAME, CURRENT_APP_INSTALLER_FILE_NAME } from "builder-util-runtime" import { getBinFromGithub } from "../../binDownload" import { statOrNull, walk } from "builder-util/out/fs" @@ -228,6 +228,7 @@ export class NsisTarget extends Target { this.configureDefinesForAllTypeOfInstaller(defines) if (isPortable) { defines.REQUEST_EXECUTION_LEVEL = (options as PortableOptions).requestExecutionLevel || "user" + defines.UNPACK_DIR_NAME = await executeAppBuilder(["ksuid"]) } else { await this.configureDefines(oneClick, defines) diff --git a/packages/app-builder-lib/templates/nsis/portable.nsi b/packages/app-builder-lib/templates/nsis/portable.nsi index 1e1deaf5c7c..8b5106fe237 100644 --- a/packages/app-builder-lib/templates/nsis/portable.nsi +++ b/packages/app-builder-lib/templates/nsis/portable.nsi @@ -12,7 +12,8 @@ Function .onInit FunctionEnd Section - StrCpy $INSTDIR $PLUGINSDIR\app + StrCpy $INSTDIR "$TEMP\${UNPACK_DIR_NAME}" + RMDir /r $INSTDIR SetOutPath $INSTDIR !ifdef APP_DIR_64 @@ -38,7 +39,7 @@ Section System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("PORTABLE_EXECUTABLE_APP_FILENAME", "${APP_FILENAME}").r0' ${StdUtils.GetAllParameters} $R0 0 ExecWait "$INSTDIR\${APP_EXECUTABLE_FILENAME} $R0" $0 - SetErrorlevel $0 + SetErrorLevel $0 SetOutPath $PLUGINSDIR RMDir /r $INSTDIR diff --git a/packages/builder-util-runtime/src/uuid.ts b/packages/builder-util-runtime/src/uuid.ts index 1a8454bcee1..253d209c539 100644 --- a/packages/builder-util-runtime/src/uuid.ts +++ b/packages/builder-util-runtime/src/uuid.ts @@ -119,16 +119,19 @@ export class UUID { // according to rfc4122#section-4.1.1 function getVariant(bits: number) { - switch (bits) { - case 0: case 1: case 3: - return "ncs" - case 4: case 5: - return "rfc4122" - case 6: - return "microsoft" - default: - return "future" - } + switch (bits) { + case 0: + case 1: + case 3: + return "ncs" + case 4: + case 5: + return "rfc4122" + case 6: + return "microsoft" + default: + return "future" + } } enum UuidEncoding { diff --git a/packages/builder-util/package.json b/packages/builder-util/package.json index 3af280de6f3..dcff2984889 100644 --- a/packages/builder-util/package.json +++ b/packages/builder-util/package.json @@ -11,7 +11,7 @@ "out" ], "dependencies": { - "app-builder-bin": "2.6.5", + "app-builder-bin": "2.6.6", "temp-file": "^3.3.2", "fs-extra-p": "^7.0.1", "is-ci": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index 973aa242474..ae15e0dd079 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1319,10 +1319,10 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -app-builder-bin@2.6.5: - version "2.6.5" - resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-2.6.5.tgz#f763464aea3b4bed406e270d218cf7bc9d11c42e" - integrity sha512-6e0Zj0lTTZ1UpB8Tc1V0uUwuCiosdfyo+xMIwY5ASveyRU8Gy3Ge6wVmdalPtqySKcZc8AvXmEa7irFLcOCGMQ== +app-builder-bin@2.6.6: + version "2.6.6" + resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-2.6.6.tgz#904b0576a510047d03f63c8a02c38eef47871180" + integrity sha512-G0Ee6xkbxV+fvM/7xXWIgSDjWAD4E/d/aNbxerq/TVsCyBIau/0VPmrEqBMyZv0NbTwLDW5aF/yHG+0ZEY77kA== append-transform@^1.0.0: version "1.0.0"