Skip to content

Commit

Permalink
Merge pull request #15773 from Homebrew/build_pkg_install
Browse files Browse the repository at this point in the history
workflows/build-pkg: actually try to install package.
  • Loading branch information
MikeMcQuaid authored Jul 27, 2023
2 parents f4760ed + 2b0471c commit f56f27b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/build-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
paths:
- .github/workflows/build-pkg.yml
- package/scripts
- package/
release:
types:
- published
Expand All @@ -23,6 +23,9 @@ jobs:
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT: 1
steps:
- name: Remove existing API cache (to force update)
run: rm -rvf ~/Library/Caches/Homebrew/api

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand Down Expand Up @@ -101,6 +104,40 @@ jobs:
--package-path Homebrew.pkg Homebrew-${{ steps.print-version.outputs.version }}.pkg
--sign "${PKG_APPLE_DEVELOPER_TEAM_ID}"

- name: Remove existing Homebrew installations
run: |
sudo rm -rf brew /{usr/local,opt/homebrew}/{Cellar,Caskroom,Homebrew/Library/Taps}
brew cleanup --prune-prefix
sudo rm -rf /usr/local/{bin/brew,Homebrew} /opt/homebrew /home/linuxbrew
- name: Zero existing installer logs
run: echo | sudo tee /var/log/install.log

- name: Install Homebrew from installer package
run: sudo installer -verbose -pkg Homebrew-${{ steps.print-version.outputs.version }}.pkg -target /

- name: Output installer logs
if: ${{ always() }}
run: sudo cat /var/log/install.log

- run: brew config

- run: brew doctor

- name: Zero existing installer logs (again)
run: echo | sudo tee /var/log/install.log

- name: Reinstall Homebrew from installer package
run: sudo installer -verbose -pkg Homebrew-${{ steps.print-version.outputs.version }}.pkg -target /

- name: Output installer logs (again)
if: ${{ always() }}
run: sudo cat /var/log/install.log

- run: brew config

- run: brew doctor

- name: Notarize Homebrew installer package
env:
PKG_APPLE_ID_USERNAME: ${{ secrets.PKG_APPLE_ID_USERNAME }}
Expand Down
13 changes: 7 additions & 6 deletions package/scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ git config --global --add safe.directory "${homebrew_directory}"
git reset --hard
git checkout --force master
git branch | grep -v '\*' | xargs -n 1 git branch --delete --force
git config --global --unset safe.directory
git config --global --unset safe.directory "${homebrew_directory}"

# move to /usr/local if on x86_64
if [[ $(uname -m) == "x86_64" ]]
then
mv -v "${homebrew_directory}" "/usr/local/Homebrew"
sudo mkdir -vp /usr/local/bin /usr/local/Homebrew
cp -a "${homebrew_directory}"/* "${homebrew_directory}/".??* "/usr/local/Homebrew/"

# create symlink to /usr/local/bin/brew
sudo mkdir -vp /usr/local/bin
ln -svf "../Homebrew/bin/brew" "/usr/local/bin/brew"

homebrew_directory="/usr/local"
cd "${homebrew_directory}"
homebrew_directory="/usr/local/Homebrew"
cd /usr/local
fi

# create missing directories
Expand All @@ -47,7 +48,7 @@ sudo mkdir -vp Cellar Frameworks etc include lib opt sbin share var/homebrew/lin
# set permissions
logged_in_user=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }')
group=$(id -gn "${logged_in_user}")
if [[ "${homebrew_directory}" == "/usr/local" ]]
if [[ "${homebrew_directory}" == "/usr/local/Homebrew" ]]
then
chown -R "${logged_in_user}:${group}" Cellar Frameworks Homebrew bin etc include lib sbin share var/homebrew/linked
else
Expand Down

0 comments on commit f56f27b

Please sign in to comment.