40 Commits
Author SHA1 Message Date
Mike McQuaid 5cec100298 Add as-brew-user and support MDM deployment
- Run managed commands as the prefix owner without a console login.
- Share account switching with `as-console-user`.
- Allow package deployment without Xcode or Command Line Tools.
- Bootstrap missing Git without invoking Apple's installer stubs.
- Test package deployment and bottle use with a non-admin account.
- Document MDM provisioning, central policy and vulnerability updates.
2026-09-23 09:45:53 -05:00
Mike McQuaid bbfa5f865b Support Homebrew without sudo access
- Detect unavailable sudo conservatively and honour `HOMEBREW_NO_SUDO`.
- Retry optional filesystem operations only when elevation is needed.
- Reject casks requiring privileged installers before installation.
- Protect non-admin `staff` installations from other users' writes.
- Preserve stricter umasks in Homebrew and installer subprocesses.
- Let root switch users without sudo and preserve command failures.
- Skip optional system service probes when sudo is disabled.
- Document sudo-free operation and its limits.
2026-09-23 09:45:53 -05:00
Mike McQuaid 3a856d216a pkg: run Git as the installation user
- Run repository Git commands and any programs they launch as the
  selected installation user.
- Set ownership before Git runs and require a non-root account.
- Use a system `PATH` and omit the user's global Git configuration.
- Check command dispatch and root user rejection in tests.
- Document installation ownership and when packages need `sudo`.
2026-09-17 14:05:53 +01:00
Patrick Linnane 85ceb6aed3 Promote macOS Golden Gate 27 to full support
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-09-10 15:31:36 -07:00
Mike McQuaid f16dd17bdc Merge pull request #23779 from Homebrew/apple-silicon-only-pkg
Make macOS installer package Apple Silicon only
2026-09-05 07:56:42 +00:00
Douglas Eichelberger d895ee6b83 pkg: seed the API cache as the install user 2026-09-04 17:27:22 -07:00
Mike McQuaid c5715c4066 Make macOS installer package Apple Silicon only
- Intel macOS is a Tier 3 configuration without new bottles, so stop
  shipping and testing the `.pkg` installer there.
- `hostArchitectures="arm64"` makes Installer refuse to run on Intel
  Macs rather than warn, leaving the `/usr/local` relocation in
  `postinstall`, the Intel welcome and conclusion text and the
  `macos-15-intel` test runner as dead code.
2026-09-04 17:05:03 +01:00
Douglas Eichelberger 4248fe8cd1 pkg: reset installer Git config
- clear `.gitconfig` and `.config/git` alongside `.git/hooks` before
  privileged installer `git` operations, for both the prefix and
  `/usr/local/Homebrew`
- fail `release.yml` if a future installer `git` change clears hooks
  without also clearing both config paths
2026-09-02 18:19:32 -07:00
Mike McQuaid 624cf710bd Merge pull request #23720 from Homebrew/hardening-boundary-guards
Harden unsigned API, trust, installer and output boundaries
2026-09-01 07:41:01 +00:00
Patrick Linnane 170eed9f75 Harden unsigned API, trust, installer and output boundaries
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-08-31 21:12:33 -07:00
Patrick Linnane c0c92cc7b7 Reduce Intel macOS to Tier 3
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-08-31 20:54:56 +01:00
Mike McQuaid af3538d54d Add as-console-user command
- Support MDM/Munki/Jamf runs where the parent process is root but
  Homebrew must execute as the logged-in macOS console user.
- Keep the nested operation constrained to `HOMEBREW_BREW_FILE` so this
  helper cannot become a general-purpose root command launcher.
- Share `macos_user.sh` with installer scripts so no-user and package
  plist fallback behaviour cannot drift between install paths.
- Stage `macos_user.sh` for `pkgbuild` because `preinstall` needs the
  resolver before the Homebrew payload has been installed.
2026-05-20 19:35:06 +01:00
Mike McQuaid a8203e9428 Fix package API cache install
- Restore regular API cache files during package builds until
  `internal` API installs are the default.
- Merge packaged API cache contents so existing `api/internal`
  directories do not break package reinstalls.
2026-05-18 15:39:37 +01:00
Mike McQuaid d7ac00a722 pkg: disable installer Git hooks
- clear `.git/hooks` before privileged installer `git` operations
- run repository `git` calls through `git_no_hooks` to ignore
  `core.hooksPath`
- fail `release.yml` if future installer `git` calls skip that
  wrapper
2026-04-26 12:44:25 +01:00
Mike McQuaid 9421ad1399 pkg: clean Homebrew git state
- remove local Git hooks and `.gitconfig` during `.pkg` installs
- warn in `brew doctor` when the `Homebrew/brew` repo contains them
- avoid local Git customisations breaking installs or updates
2026-04-25 13:09:06 +01:00
Patrick Linnane e63c885033 Support Tahoe, drop Mojave and older
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-09-12 10:40:19 -07:00
Mike McQuaid a9faa2cd8e package/scripts/postinstall: add Homebrew to PATH.
This is automatic for `/usr/local/bin/brew` but let's do it manually
for `/opt/homebrew/bin/brew` too.
2025-06-23 15:16:49 +01:00
Eric Knibbe 78a326d832 pkg: fix existing installation not being upgraded 2025-03-04 23:42:47 -05:00
Francois-Xavier Coudert 4ab19e09da Make Sequoia supported 2024-09-11 09:00:37 +01:00
Eric Knibbe 90ac39998f pkg: adjust setting permissions on Intel 2024-06-13 17:32:38 -04:00
Ruoyu Zhong 8a0b4edd8a package/scripts/postinstall: simplify
It is safe to override `HOME` for the entire script as only Git uses it.
2024-04-11 20:37:37 +08:00
Ruoyu Zhong f76442837a package/scripts/postinstall: avoid writing to ~/.gitconfig
In this attempt we pretend that the "global" configs are in the
repository itself.

    $ XDG_CONFIG_HOME= HOME=$PWD git config --global section.key value
    $ XDG_CONFIG_HOME= HOME=$PWD git config --global section.key
    value
    $ git config --global section.key
    $ cat $PWD/.gitconfig
    [section]
      key = value
2024-04-11 04:15:59 +08:00
Ruoyu Zhong ad4a0800cc package/scripts/postinstall: handle /usr/local/Homebrew 2024-04-11 02:02:05 +08:00
Ruoyu Zhong b516fda8be package/scripts/postinstall: avoid writing to ~/.gitconfig
We can eliminate permission issues by not touching `~/.gitconfig` at
all.

Fixes #17067.
2024-04-11 01:12:03 +08:00
Ruoyu Zhong a16d74cf77 package: improve shellenv instructions
The existing instructions is perhaps not clear enough:

  To add Homebrew to your `PATH` run `brew shellenv` in your shell
  profile (e.g. `~/.bash_profile` or `~/.zprofile`)

Fixes #16803.
2024-03-04 06:48:34 +08:00
Ruoyu Zhong 005d76805a package/scripts/postinstall: fix permissions of opt
Fixes https://github.com/orgs/Homebrew/discussions/5052.
2024-01-15 11:19:15 +08:00
nstraussandMike McQuaid e0ac5459b3 Improve Mac package for enterprise install scenarios
- Allow specifying user through `/var/tmp/.homebrew_pkg_user.plist`
- Improve permission handling
- Correctly write API cache
- Add `preinstall` script to fail if we can't get a valid user

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-10-06 11:53:00 +01:00
Mike McQuaid 5c5ac49a39 More Homebrew .pkg improvements
- test on more macOS versions and improve the test names
- add a more resilient and less disruptive version of changing `git`'s
 `safe.directory` configuration
2023-10-04 18:32:08 +01:00
Mike McQuaid c95a26b917 Improve building Homebrew*.pkg
- split jobs into build/test/deploy
- test package on both macOS Intel and Apple Silicon
- cleanup some argument handling
- use `HOMEBREW_MACOS_OLDEST_SUPPORTED` naming to be consistent with
  `brew.sh`
- note in `brew.sh` that `Distribution.xml` also needs updated (and do
  so)
- various other little bits of style cleanup
2023-10-04 10:18:27 +01:00
Mike McQuaid 39dc5652aa package/Distribution: always require CLT.
We always require it in `install.sh` and we need it for all but the
latest version of macOS so this seems a simpler compromise.

Fixes #15802
2023-08-03 11:42:06 +01:00
Mike McQuaid 8819925af4 package/resources: improve text output.
- use the system font instead of Helvetica
- cleanup font definitions
- add extra newline to `CONCLUSION.rtf` to next steps not showing up
  without a click
- add actual hyperlinks to `CONCLUSION.rtf`

Fixes #15793
2023-07-31 14:56:40 +01:00
Mike McQuaid 2b0471c122 workflows/build-pkg: actually try to install package.
- This should help avoid this regressing
- Remove existing Homebrew installation(s)
- Install it twice to ensure that installing over the top of an existing
  installation works as expected
- Remove existing API cache to ensure we have the freshest files from
  the API in our package
2023-07-27 15:51:40 +01:00
Mike McQuaid b00a95b678 pkg installer: install cached API data.
Continuing with the goals of making the installer:
- more useful
- entirely offline

Let's pre-download the API data from a `brew update` run and install it
into the logged-in user's home directory.

While we're here, in the `postinstall` script:
- use longer arguments for various commands
- fix an issue with symlinking on Intel if `/usr/local/bin` doesn't
  already exist
- unset `bash -x` and use `-v` on more commands instead
2023-07-26 15:32:14 +01:00
ImgBotApp 26921f1f1f [ImgBot] Optimize images
/package/resources/Homebrew.png -- 130.54kb -> 65.15kb (50.09%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2023-07-25 17:13:39 +00:00
Mike McQuaid c5afd5d056 macOS .pkg improvements
- don't include GitHub Actions credentials
- generate and include RTF version of Homebrew BSD license
- create nicer installer with `productbuild`
- customise welcome/conclusion messages
- add Homebrew logo as a background image
- remove unnecessary `preinstall` script
- cleanup `postinstall` script to pass `brew doctor`
- use `Distribution.xml` for a nicer installer
- require CLT or Xcode rather than using our hacks to try and install
  CLT during installation
2023-07-25 15:47:34 +01:00
Sean Molenaar 76f4826ff7 package: fix ARM name and owner of prefix 2023-02-17 17:12:36 +01:00
Sean Molenaar f30779c6bf Update package/scripts/postinstall 2022-12-23 19:36:13 +01:00
Sean Molenaar d2aed31387 preinstall: correctly handle headless installs 2022-12-21 13:37:24 +01:00
Sean MolenaarandMike McQuaid f6a9980e49 fix: cleanup macOS packaging
Don't allow specifying target
Add `set -e` to shell scripts
Don't try and package on every PR

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2022-12-21 13:18:09 +01:00
Sean Molenaar 72b3348fb1 feature: generate macOS pkg files 2022-12-19 21:26:24 +01:00