Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use tar instead of 7zip to preserve file permissions in tar.gz packages #6791

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.