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

fix(flat): don't use pkgbuild for MAS distributions #340

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

erickzhao
Copy link
Member

@erickzhao erickzhao commented Dec 11, 2024

Fixes #327
Fixes #328
Fixes electron/forge#3782

Context

The flat function of @electron/osx-sign is used to generate .pkg archives for macOS. These archives can be installed on users' machines in two ways:

  • via OS X Installer (i.e. clicking the .pkg archive on your file system)
  • via the Mac App Store (MAS)

There are two underlying macOS tools that can be used to generate these archives: productbuild and pkgbuild.

Regression

#282 fixed the problem of not being to use pre/postinstall scripts in .pkg installers by adding an additional pkgbuild incantation to add those scripts and inserting that build into the final productbuild bundle.

It turns out that this created invalid output for MAS build targets. This is because pkgbuild isn't supposed to be used for Mac App Store builds according to the manpage:

A "component package" contains payload to be installed by the OS X Installer. Although a component package can be installed on its own, it is typically incorporated into a product archive, along with a "distribution" and localized resources, using productbuild(1).

To create a product archive for submission to the Mac App Store, do not use pkgbuild. Instead, use productbuild(1) directly.To create a product archive for submission to the Mac App Store, do not use pkgbuild. Instead, use productbuild(1) directly.

Solution

My proposed solution is to branch between the previous and current implementation based on the build target (MAS vs. OS X Installer). This will fix the regression for MAS builds while still preserving the ability to add pre/postinstall scripts for OS X Installer archives.

It turns out that pre/postinstall scripts are a non-feature for MAS builds anyways according to both Apple Developer Technical Support 1 and the productbuild manpage 2.

@erickzhao erickzhao requested a review from a team as a code owner December 11, 2024 23:40
@erickzhao erickzhao changed the title fix(flat): don't use pkgbuild for MAS distributions fix(flat): don't use pkgbuild for MAS distributions Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants