Skip to content

Commit

Permalink
feat: Use tar instead of 7zip to preserve file permissions in tar.gz …
Browse files Browse the repository at this point in the history
…packages (#6791)
  • Loading branch information
devinbinnie authored Apr 15, 2022
1 parent 758f8b4 commit 95910f8
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-masks-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

feat: Use tar instead of 7zip to preserve file permissions in tar.gz packages
2 changes: 2 additions & 0 deletions packages/app-builder-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:*"
},
Expand Down
22 changes: 14 additions & 8 deletions packages/app-builder-lib/src/targets/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -17,20 +18,25 @@ export async function tar(
tempDirManager: TmpDir
): Promise<void> {
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"
Expand Down
56 changes: 56 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 95910f8

Please sign in to comment.