From 4a02b97f30823e851fcc0932f16b926b6f74b2c1 Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Wed, 13 Apr 2022 15:42:57 -0400 Subject: [PATCH 1/5] Use tar instead of 7zip to preserve file permissions in tar.gz packages --- packages/app-builder-lib/package.json | 2 + .../app-builder-lib/src/targets/archive.ts | 22 +++++--- pnpm-lock.yaml | 56 +++++++++++++++++++ 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/packages/app-builder-lib/package.json b/packages/app-builder-lib/package.json index 475e35b2692..78f95cd7a1f 100644 --- a/packages/app-builder-lib/package.json +++ b/packages/app-builder-lib/package.json @@ -71,6 +71,7 @@ "read-config-file": "6.2.0", "sanitize-filename": "^1.6.3", "semver": "^7.3.5", + "tar": "^6.1.11", "temp-file": "^3.4.0" }, "///": "babel in devDependencies for proton tests", @@ -101,6 +102,7 @@ "@types/is-ci": "3.0.0", "@types/js-yaml": "4.0.3", "@types/semver": "7.3.8", + "@types/tar": "^6.1.1", "dmg-builder": "workspace:*", "electron-builder-squirrel-windows": "workspace:*" }, diff --git a/packages/app-builder-lib/src/targets/archive.ts b/packages/app-builder-lib/src/targets/archive.ts index bf00283f21a..4dc1447e6d6 100644 --- a/packages/app-builder-lib/src/targets/archive.ts +++ b/packages/app-builder-lib/src/targets/archive.ts @@ -3,6 +3,7 @@ import { debug7z, exec } from "builder-util" import { exists, unlinkIfExists } from "builder-util/out/fs" import { move } from "fs-extra" import * as path from "path" +import { create, CreateOptions, FileOptions } from 'tar'; import { TmpDir } from "temp-file" import { CompressionLevel } from "../core" import { getLinuxToolsPath } from "./tools" @@ -17,20 +18,25 @@ export async function tar( tempDirManager: TmpDir ): Promise { const tarFile = await tempDirManager.getTempFile({ suffix: ".tar" }) - const tarArgs = debug7zArgs("a") - tarArgs.push(tarFile) - tarArgs.push(path.basename(dirToArchive)) + const tarArgs: CreateOptions & FileOptions = { + file: tarFile, + portable: true, + cwd: dirToArchive, + prefix: path.basename(outFile, `.${format}`), + } + let tarDirectory = '.'; + if (isMacApp) { + delete tarArgs.prefix; + tarArgs.cwd = path.dirname(dirToArchive); + tarDirectory = path.basename(dirToArchive); + } await Promise.all([ - exec(path7za, tarArgs, { cwd: path.dirname(dirToArchive) }), + create(tarArgs, [tarDirectory]), // remove file before - 7z doesn't overwrite file, but update unlinkIfExists(outFile), ]) - if (!isMacApp) { - await exec(path7za, ["rn", tarFile, path.basename(dirToArchive), path.basename(outFile, `.${format}`)]) - } - if (format === "tar.lz") { // noinspection SpellCheckingInspection let lzipPath = "lzip" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5fed7d0b224..75806e34f41 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,6 +96,7 @@ importers: '@types/is-ci': 3.0.0 '@types/js-yaml': 4.0.3 '@types/semver': 7.3.8 + '@types/tar': ^6.1.1 7zip-bin: ~5.1.1 async-exit-hook: ^2.0.1 bluebird-lst: ^1.0.9 @@ -119,6 +120,7 @@ importers: read-config-file: 6.2.0 sanitize-filename: ^1.6.3 semver: ^7.3.5 + tar: ^6.1.11 temp-file: ^3.4.0 dependencies: '@develar/schema-utils': 2.6.5 @@ -145,6 +147,7 @@ importers: read-config-file: 6.2.0 sanitize-filename: 1.6.3 semver: 7.3.5 + tar: 6.1.11 temp-file: 3.4.0 devDependencies: '@babel/core': 7.15.5 @@ -173,6 +176,7 @@ importers: '@types/is-ci': 3.0.0 '@types/js-yaml': 4.0.3 '@types/semver': 7.3.8 + '@types/tar': 6.1.1 dmg-builder: link:../dmg-builder electron-builder-squirrel-windows: link:../electron-builder-squirrel-windows @@ -2739,6 +2743,12 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true + /@types/minipass/3.1.2: + resolution: {integrity: sha512-foLGjgrJkUjLG/o2t2ymlZGEoBNBa/TfoUZ7oCTkOjP1T43UGBJspovJou/l3ZuHvye2ewR5cZNtp2zyWgILMA==} + dependencies: + '@types/node': 16.11.12 + dev: true + /@types/ms/0.7.31: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} @@ -2796,6 +2806,13 @@ packages: /@types/stack-utils/2.0.1: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} + /@types/tar/6.1.1: + resolution: {integrity: sha512-8mto3YZfVpqB1CHMaYz1TUYIQfZFbh/QbEq5Hsn6D0ilCfqRVCdalmc89B7vi3jhl9UYIk+dWDABShNfOkv5HA==} + dependencies: + '@types/minipass': 3.1.2 + '@types/node': 16.11.12 + dev: true + /@types/update-notifier/5.1.0: resolution: {integrity: sha512-aGY5pH1Q/DcToKXl4MCj1c0uDUB+zSVFDRCI7Q7js5sguzBTqJV/5kJA2awofbtWYF3xnon1TYdZYnFditRPtQ==} dependencies: @@ -3816,6 +3833,11 @@ packages: fsevents: 2.3.2 dev: false + /chownr/2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + dev: false + /chromium-pickle-js/0.2.0: resolution: {integrity: sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=} dev: false @@ -5774,6 +5796,13 @@ packages: universalify: 2.0.0 dev: false + /fs-minipass/2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.1.6 + dev: false + /fs-then-native/2.0.0: resolution: {integrity: sha1-GaEk2U2QwiyOBF8ujdbr6jbUjGc=} engines: {node: '>=4.0.0'} @@ -7915,6 +7944,21 @@ packages: /minimist/1.2.5: resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==} + /minipass/3.1.6: + resolution: {integrity: sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==} + engines: {node: '>=8'} + dependencies: + yallist: 4.0.0 + dev: false + + /minizlib/2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.1.6 + yallist: 4.0.0 + dev: false + /mixin-deep/1.3.2: resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} engines: {node: '>=0.10.0'} @@ -9486,6 +9530,18 @@ packages: readable-stream: 3.6.0 dev: false + /tar/6.1.11: + resolution: {integrity: sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==} + engines: {node: '>= 10'} + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 3.1.6 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + dev: false + /temp-dir/2.0.0: resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} engines: {node: '>=8'} From 66f74a5a896c43d4aaaaec637937e1e6ad71a041 Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Wed, 13 Apr 2022 15:43:56 -0400 Subject: [PATCH 2/5] Changeset --- .changeset/spotty-impalas-listen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/spotty-impalas-listen.md diff --git a/.changeset/spotty-impalas-listen.md b/.changeset/spotty-impalas-listen.md new file mode 100644 index 00000000000..5e6492eead2 --- /dev/null +++ b/.changeset/spotty-impalas-listen.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +Use tar instead of 7zip to preserve permissions in tar.gz builds From 9c1934f5135f6712f01b9211e60e1d816efc4a20 Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Wed, 13 Apr 2022 15:46:46 -0400 Subject: [PATCH 3/5] Lint fixes --- packages/app-builder-lib/src/targets/archive.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/app-builder-lib/src/targets/archive.ts b/packages/app-builder-lib/src/targets/archive.ts index 4dc1447e6d6..d96e6509d47 100644 --- a/packages/app-builder-lib/src/targets/archive.ts +++ b/packages/app-builder-lib/src/targets/archive.ts @@ -3,7 +3,7 @@ import { debug7z, exec } from "builder-util" import { exists, unlinkIfExists } from "builder-util/out/fs" import { move } from "fs-extra" import * as path from "path" -import { create, CreateOptions, FileOptions } from 'tar'; +import { create, CreateOptions, FileOptions } from "tar" import { TmpDir } from "temp-file" import { CompressionLevel } from "../core" import { getLinuxToolsPath } from "./tools" @@ -24,11 +24,11 @@ export async function tar( cwd: dirToArchive, prefix: path.basename(outFile, `.${format}`), } - let tarDirectory = '.'; + let tarDirectory = "." if (isMacApp) { - delete tarArgs.prefix; - tarArgs.cwd = path.dirname(dirToArchive); - tarDirectory = path.basename(dirToArchive); + delete tarArgs.prefix + tarArgs.cwd = path.dirname(dirToArchive) + tarDirectory = path.basename(dirToArchive) } await Promise.all([ From d32d4c78fdfda36cea5e9a63b8a3bef2a2172927 Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Thu, 14 Apr 2022 13:11:47 -0400 Subject: [PATCH 4/5] New changeset --- .changeset/swift-masks-appear.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/swift-masks-appear.md diff --git a/.changeset/swift-masks-appear.md b/.changeset/swift-masks-appear.md new file mode 100644 index 00000000000..1bd03f6ba9c --- /dev/null +++ b/.changeset/swift-masks-appear.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +feat: Use tar instead of 7zip to preserve file permissions in tar.gz packages From 6587a14f85c276eca2bf10c790a2c15b6af83d6f Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Thu, 14 Apr 2022 13:12:02 -0400 Subject: [PATCH 5/5] Revert "Changeset" This reverts commit 66f74a5a896c43d4aaaaec637937e1e6ad71a041. --- .changeset/spotty-impalas-listen.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/spotty-impalas-listen.md diff --git a/.changeset/spotty-impalas-listen.md b/.changeset/spotty-impalas-listen.md deleted file mode 100644 index 5e6492eead2..00000000000 --- a/.changeset/spotty-impalas-listen.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"app-builder-lib": patch ---- - -Use tar instead of 7zip to preserve permissions in tar.gz builds