@@ -31,29 +31,26 @@ RUN --mount=type=cache,dst=/var/cache/libdnf5 \
3131 --mount=type=secret,id=GITHUB_TOKEN \
3232 /ctx/build_files/shared/build.sh
3333
34- # Install Homebrew
35- RUN --mount=type=cache,dst=/var/cache/homebrew,uid=1000,gid=1000 \
36- --mount=type=bind,from=ctx,source=/,target=/ctx \
34+ # Download Homebrew tarball (extracted at first boot by brew-setup.service)
35+ RUN --mount=type=bind,from=ctx,source=/,target=/ctx \
36+ --mount=type=secret,id=GITHUB_TOKEN \
3737 set -eoux pipefail && \
38- useradd -u 1000 -m -s /bin/bash -c "Homebrew Build User" linuxbrew && \
39- mkdir -p /var/home/linuxbrew/.linuxbrew && \
40- chown -R 1000:1000 /var/home/linuxbrew && \
41- mkdir -p /var/cache/homebrew /var/lib/homebrew && \
42- chown -R 1000:1000 /var/cache/homebrew /var/lib/homebrew && \
43- su - linuxbrew -c "bash -c ' \
44- export NONINTERACTIVE=1 && \
45- export HOMEBREW_BREW_GIT_REMOTE=https://github.com/Homebrew/brew && \
46- export HOMEBREW_CORE_GIT_REMOTE=https://github.com/Homebrew/homebrew-core && \
47- export HOMEBREW_NO_AUTO_UPDATE=1 && \
48- /ctx/build_files/shared/utils/ghcurl https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh --retry 3 | bash \
49- '" && \
50- su - linuxbrew -c "git config --global gc.auto 0" && \
51- test -x /var/home/linuxbrew/.linuxbrew/bin/brew && \
52- /var/home/linuxbrew/.linuxbrew/bin/brew --version && \
53- test -d /var/home/linuxbrew/.linuxbrew/Homebrew && \
54- chown -R root:root /var/home/linuxbrew /var/cache/homebrew /var/lib/homebrew && \
55- userdel linuxbrew && \
56- dnf clean all
38+ ARCH=$(uname -m) && \
39+ # Get latest homebrew release tag from GitHub API
40+ HOMEBREW_RELEASE=$(curl -sL \
41+ -H "Accept: application/vnd.github+json" \
42+ -H "X-GitHub-Api-Version: 2022-11-28" \
43+ "https://api.github.com/repos/ublue-os/packages/releases" | \
44+ jq -r '[.[] | select(.tag_name | startswith("homebrew-"))][0].tag_name' ) && \
45+ echo "Using Homebrew release: ${HOMEBREW_RELEASE}" && \
46+ HOMEBREW_BASE_URL="https://github.com/ublue-os/packages/releases/download/${HOMEBREW_RELEASE}" && \
47+ # Download tarball to /usr/share
48+ /ctx/build_files/shared/utils/ghcurl "${HOMEBREW_BASE_URL}/homebrew-${ARCH}.tar.zst" --retry 3 -o /usr/share/homebrew.tar.zst && \
49+ # Download and verify checksum
50+ EXPECTED_SHA=$(/ctx/build_files/shared/utils/ghcurl "${HOMEBREW_BASE_URL}/homebrew-${ARCH}.sha256" --retry 3 | awk '{print $1}' ) && \
51+ echo "${EXPECTED_SHA} /usr/share/homebrew.tar.zst" | sha256sum -c && \
52+ # Verify tarball exists
53+ test -f /usr/share/homebrew.tar.zst
5754
5855# Makes `/opt` writeable by default
5956# Needs to be here to make the main image build strict (no /opt there)
0 commit comments