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

macOS pkg written to same filename for x64 and arm64 #5847

Closed
andersk opened this issue May 1, 2021 · 5 comments · Fixed by #5897
Closed

macOS pkg written to same filename for x64 and arm64 #5847

andersk opened this issue May 1, 2021 · 5 comments · Fixed by #5897

Comments

@andersk
Copy link

andersk commented May 1, 2021

  • Version: 22.10.5
  • Electron Version: 12.0.5
  • Electron Type (current, beta, nightly): current
  • Target: macOS pkg for x64 and arm64

electron-builder --mac pkg --x64 --arm64 builds both the x64 pkg and the arm64 pkg, but it writes them both to the same filename Zulip-5.6.0.pkg, so the latter immediately overwrites the former.

  • building        target=pkg arch=x64 file=dist/Zulip-5.6.0.pkg
…
  • building        target=pkg arch=arm64 file=dist/Zulip-5.6.0.pkg

I would expect the latter to go to Zulip-5.6.0-arm64.pkg, as already happens with DMG and zip.

andersk added a commit to zulip/zulip-desktop that referenced this issue May 1, 2021
Fixes #1076.

For now we only build a DMG and zip for arm64, because the arm64 pkg
would overwrite the x64 pkg
(electron-userland/electron-builder#5847).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
@mmaietta
Copy link
Collaborator

mmaietta commented May 2, 2021

Hi @andersk !
If you're specifying two separate archs, as opposed to using --universal, then you will need to provide an artifactName template that has the ${arch} macro in it.

@andersk
Copy link
Author

andersk commented May 2, 2021

@mmaietta We already have "build": { "mac": { "artifactName": "${productName}-${version}-${arch}.${ext}" } }, which works for DMG and zip.

@andersk
Copy link
Author

andersk commented May 2, 2021

Minimal reproduction: https://gist.github.com/andersk/590d4b064e9e07506d6747d7b3a6a977

$ git clone https://gist.github.com/andersk/590d4b064e9e07506d6747d7b3a6a977 empty-electron-app
$ cd empty-electron-app
$ yarn
$ yarn electron-builder --mac default --x64 --arm64

  • building        target=macOS zip arch=x64 file=dist/empty-electron-app-1.0.0.zip
  • building        target=DMG arch=x64 file=dist/empty-electron-app-1.0.0.dmg

  • building        target=macOS zip arch=arm64 file=dist/empty-electron-app-1.0.0-arm64.zip
  • building        target=DMG arch=arm64 file=dist/empty-electron-app-1.0.0-arm64.dmg
$ yarn electron-builder --mac pkg --x64 --arm64

  • building        target=pkg arch=x64 file=dist/empty-electron-app-1.0.0.pkg

  • building        target=pkg arch=arm64 file=dist/empty-electron-app-1.0.0.pkg

@mmaietta
Copy link
Collaborator

mmaietta commented May 3, 2021

Big thanks for the gist! Wish other tickets had those provided more often 🙂

I added the arch/pkg args to the build config and it repro'd there as well. Found the issue seems to only exist with pkg target. I tested zip and dmg too and both worked correctly.

I think I was able to identify the fix, can you try out this patch?
File: app-builder-lib+22.10.5.patch

diff --git a/node_modules/app-builder-lib/out/targets/pkg.js b/node_modules/app-builder-lib/out/targets/pkg.js
index 9a53e36..abd8215 100644
--- a/node_modules/app-builder-lib/out/targets/pkg.js
+++ b/node_modules/app-builder-lib/out/targets/pkg.js
@@ -115,7 +115,7 @@ class PkgTarget extends _core().Target {
     const options = this.options;
     const appInfo = packager.appInfo; // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg)
 
-    const artifactName = packager.expandArtifactNamePattern(options, "pkg");
+    const artifactName = packager.expandArtifactNamePattern(options, "pkg", arch);
     const artifactPath = path.join(this.outDir, artifactName);
     await packager.info.callArtifactBuildStarted({
       targetPresentableName: "pkg",

@andersk
Copy link
Author

andersk commented May 3, 2021

Yeah, that works for me.

  • building        target=pkg arch=x64 file=dist/Zulip-5.7.0.pkg
…
  • building        target=pkg arch=arm64 file=dist/Zulip-5.7.0-arm64.pkg

mmaietta pushed a commit to mmaietta/electron-builder that referenced this issue May 16, 2021
…for build name otherwise it'll try to build x64 and arm64 with the same name (electron-userland#5847)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants