Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Jul 27, 2023
1 parent e9ac1b8 commit 29ae8fa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/build-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT: 1
steps:
- name: Remove existing API cache (to force update)
run: rm -rf ~/Library/Caches/Homebrew/api
run: rm -rvf ~/Library/Caches/Homebrew/api

- name: Set up Homebrew
id: set-up-homebrew
Expand Down Expand Up @@ -123,14 +123,28 @@ jobs:
fi
- name: Remove existing Homebrew installations
run: sudo rm -rf brew /usr/local/bin/brew /usr/local/.??* /usr/local/Homebrew /usr/local/Caskroom /usr/local/Cellar
run: sudo rm -rf brew /usr/local/bin/brew /usr/local/.??* /usr/local/Homebrew /usr/local/Caskroom /usr/local/Cellar /opt/homebrew /home/linuxbrew/.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: Install Homebrew (again) from installer package
- name: Output installer logs
if: ${{ always() }}
run: sudo cat /var/log/install.log

- 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

- name: Upload installer to GitHub Actions
uses: actions/upload-artifact@v3
with:
Expand Down
16 changes: 15 additions & 1 deletion Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,6 @@ EOS
export HOMEBREW_UPDATE_AFTER"${TAP_VAR}"="${CURRENT_REVISION}"
else
merge_or_rebase "${DIR}" "${TAP_VAR}" "${UPSTREAM_BRANCH}"
[[ -n "${HOMEBREW_VERBOSE}" ]] && echo
fi
done

Expand All @@ -799,6 +798,11 @@ EOS
INITIAL_JSON_BYTESIZE="$(wc -c "${cache_path}")"
fi

if [[ -n "${HOMEBREW_VERBOSE}" ]]
then
echo "Checking if we need to fetch ${filename}..."
fi

JSON_URLS=()
if [[ -n "${HOMEBREW_API_DOMAIN}" && "${HOMEBREW_API_DOMAIN}" != "${HOMEBREW_API_DEFAULT_DOMAIN}" ]]
then
Expand Down Expand Up @@ -846,6 +850,11 @@ EOS
rm -f "${api_cache}/formula_aliases.txt"
fi
HOMEBREW_UPDATED="1"

if [[ -n "${HOMEBREW_VERBOSE}" ]]
then
echo "Updated ${filename}."
fi
fi
else
echo "Failed to download ${json_url}!" >>"${update_failed_file}"
Expand All @@ -855,6 +864,11 @@ EOS

# Not a typo, these are the files we used to download that no longer need so should cleanup.
rm -f "${HOMEBREW_CACHE}/api/formula.json" "${HOMEBREW_CACHE}/api/cask.json"
else
if [[ -n "${HOMEBREW_VERBOSE}" ]]
then
echo "HOMEBREW_NO_INSTALL_FROM_API set: skipping API JSON downloads."
fi
fi

if [[ -f "${update_failed_file}" ]]
Expand Down
14 changes: 8 additions & 6 deletions package/scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ 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
install -d "${homebrew_directory}" "/usr/local/Homebrew/"
sudo rm -rvf "${homebrew_directory}"

# 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 +49,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 29ae8fa

Please sign in to comment.