From 2b0471c122df43950960eff801b336bee0b6c3c8 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 27 Jul 2023 15:51:40 +0100 Subject: [PATCH] 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 --- .github/workflows/build-pkg.yml | 39 ++++++++++++++++++++++++++++++++- package/scripts/postinstall | 13 ++++++----- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-pkg.yml b/.github/workflows/build-pkg.yml index 463d08e2ca33b..23c2ad3a27428 100644 --- a/.github/workflows/build-pkg.yml +++ b/.github/workflows/build-pkg.yml @@ -3,7 +3,7 @@ on: push: paths: - .github/workflows/build-pkg.yml - - package/scripts + - package/ release: types: - published @@ -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 @@ -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 }} diff --git a/package/scripts/postinstall b/package/scripts/postinstall index fcd62930f2f51..8d9f1c22d0391 100755 --- a/package/scripts/postinstall +++ b/package/scripts/postinstall @@ -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 @@ -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