Skip to content

Commit

Permalink
fix(deps): Update 7zip-bin to support Windows on ARM (#7829)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Nov 1, 2023
1 parent 5133b72 commit 1af7447
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 22 deletions.
8 changes: 8 additions & 0 deletions .changeset/quick-comics-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"app-builder-lib": patch
"builder-util": patch
"electron-builder-squirrel-windows": patch
"electron-builder": patch
---

fix(deps): Update 7zip-bin to support Windows on ARM
2 changes: 1 addition & 1 deletion packages/app-builder-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"bugs": "https://github.com/electron-userland/electron-builder/issues",
"homepage": "https://github.com/electron-userland/electron-builder",
"dependencies": {
"7zip-bin": "~5.1.1",
"7zip-bin": "~5.2.0",
"@develar/schema-utils": "~2.6.5",
"@electron/notarize": "2.1.0",
"@electron/osx-sign": "1.0.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/app-builder-lib/src/targets/FpmTarget.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { path7za } from "7zip-bin"
import { Arch, executeAppBuilder, getArchSuffix, log, TmpDir, toLinuxArchString, use, serializeToYaml, asArray } from "builder-util"
import { unlinkIfExists } from "builder-util/out/fs"
import { outputFile, stat } from "fs-extra"
import { chmod, outputFile, stat } from "fs-extra"
import { mkdir, readFile } from "fs/promises"
import * as path from "path"
import { smarten } from "../appInfo"
Expand Down Expand Up @@ -234,6 +234,7 @@ export default class FpmTarget extends Target {
return
}

await chmod(path7za, 0o755)
const env = {
...process.env,
SZA_PATH: path7za,
Expand Down
4 changes: 3 additions & 1 deletion packages/app-builder-lib/src/targets/archive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { path7za } from "7zip-bin"
import { debug7z, exec } from "builder-util"
import { exists, unlinkIfExists } from "builder-util/out/fs"
import { move } from "fs-extra"
import { chmod, move } from "fs-extra"
import * as path from "path"
import { create, CreateOptions, FileOptions } from "tar"
import { TmpDir } from "temp-file"
Expand Down Expand Up @@ -55,6 +55,7 @@ export async function tar(
compression,
})
args.push(outFile, tarFile)
await chmod(path7za, 0o755)
await exec(
path7za,
args,
Expand Down Expand Up @@ -180,6 +181,7 @@ export async function archive(format: string, outFile: string, dirToArchive: str
}

try {
await chmod(path7za, 0o755)
await exec(
path7za,
args,
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CURRENT_APP_INSTALLER_FILE_NAME, CURRENT_APP_PACKAGE_FILE_NAME, Package
import { exists, statOrNull, walk } from "builder-util/out/fs"
import _debug from "debug"
import * as fs from "fs"
import { readFile, stat, unlink } from "fs-extra"
import { chmod, readFile, stat, unlink } from "fs-extra"
import * as path from "path"
import { getBinFromUrl } from "../../binDownload"
import { Target } from "../../core"
Expand Down Expand Up @@ -250,7 +250,7 @@ export class NsisTarget extends Target {
await packager.dispatchArtifactCreated(file, this, arch)
packageFiles[Arch[arch]] = fileInfo
}

await chmod(path7za, 0o755)
const archiveInfo = (await exec(path7za, ["l", file])).trim()
// after adding blockmap data will be "Warnings: 1" in the end of output
const match = /(\d+)\s+\d+\s+\d+\s+files/.exec(archiveInfo)
Expand Down
2 changes: 1 addition & 1 deletion packages/builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"dependencies": {
"@types/debug": "^4.1.6",
"7zip-bin": "~5.1.1",
"7zip-bin": "~5.2.0",
"app-builder-bin": "4.0.0",
"bluebird-lst": "^1.0.9",
"builder-util-runtime": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion packages/builder-util/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { spawn as _spawn } from "cross-spawn"
import { createHash } from "crypto"
import _debug from "debug"
import { dump } from "js-yaml"
import { chmod } from "fs-extra"
import * as path from "path"
import { debug, log } from "./log"
import { install as installSourceMap } from "source-map-support"
Expand Down Expand Up @@ -349,13 +350,14 @@ export class InvalidConfigurationError extends Error {
}
}

export function executeAppBuilder(
export async function executeAppBuilder(
args: Array<string>,
childProcessConsumer?: (childProcess: ChildProcess) => void,
extraOptions: SpawnOptions = {},
maxRetries = 0
): Promise<string> {
const command = appBuilderPath
await chmod(path7za, 0o755)
const env: any = {
...process.env,
SZA_PATH: path7za,
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-squirrel-windows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@types/fs-extra": "9.0.13"
},
"optionalDependencies": {
"7zip-bin": "~5.1.1"
"7zip-bin": "~5.2.0"
},
"types": "./out/SquirrelWindowsTarget.d.ts"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { copyFile, walk } from "builder-util/out/fs"
import { compute7zCompressArgs } from "app-builder-lib/out/targets/archive"
import { execWine, prepareWindowsExecutableArgs as prepareArgs } from "app-builder-lib/out/wine"
import { WinPackager } from "app-builder-lib/out/winPackager"
import { createWriteStream, stat, unlink, writeFile } from "fs-extra"
import { chmod, createWriteStream, stat, unlink, writeFile } from "fs-extra"
import * as path from "path"
import * as archiver from "archiver"
import * as fs from "fs/promises"
Expand Down Expand Up @@ -126,6 +126,7 @@ export class SquirrelBuilder {

private async createEmbeddedArchiveFile(nupkgPath: string, dirToArchive: string) {
const embeddedArchiveFile = await this.packager.getTempFile("setup.zip")
await chmod(path7za, 0o755)
await exec(
path7za,
compute7zCompressArgs("zip", {
Expand Down Expand Up @@ -228,7 +229,8 @@ async function pack(options: SquirrelOptions, directory: string, updateFile: str
await archivePromise
}

function execSw(options: SquirrelOptions, args: Array<string>) {
async function execSw(options: SquirrelOptions, args: Array<string>) {
await chmod(path7za, 0o755)
return exec(process.platform === "win32" ? path.join(options.vendorPath, "Update.com") : "mono", prepareArgs(args, path.join(options.vendorPath, "Update-Mono.exe")), {
env: {
...process.env,
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"7zip-bin": "~5.1.1",
"7zip-bin": "~5.2.0",
"@electron/osx-sign": "^1.0.4",
"@jest/core": "^27.5.1",
"app-builder-lib": "workspace:*",
Expand Down
3 changes: 2 additions & 1 deletion test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { computeArchToTargetNamesMap } from "app-builder-lib/out/targets/targetF
import { getLinuxToolsPath } from "app-builder-lib/out/targets/tools"
import { convertVersion } from "electron-builder-squirrel-windows/out/squirrelPack"
import { PublishPolicy } from "electron-publish"
import { emptyDir, writeJson } from "fs-extra"
import { chmod, emptyDir, writeJson } from "fs-extra"
import * as fs from "fs/promises"
import { load } from "js-yaml"
import * as path from "path"
Expand Down Expand Up @@ -438,6 +438,7 @@ export async function getTarExecutable() {
}

async function getContents(packageFile: string) {
await chmod(path7x, 0o755)
const result = await execShell(`ar p '${packageFile}' data.tar.xz | ${await getTarExecutable()} -t -I'${path7x}'`, {
maxBuffer: 10 * 1024 * 1024,
env: {
Expand Down

0 comments on commit 1af7447

Please sign in to comment.