Skip to content

Commit a4d31b0

Browse files
committed
refactor(brew): moved brew files to common and moved to tarball
1 parent 0e32967 commit a4d31b0

File tree

13 files changed

+25
-137
lines changed

13 files changed

+25
-137
lines changed

Containerfile

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

build_files/base/17-cleanup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ systemctl enable check-sb-key.service
2424
systemctl enable input-remapper.service
2525
systemctl enable flatpak-nuke-fedora.service
2626

27-
# Homebrew auto-update and upgrade timers
27+
# Homebrew setup (extracts tarball on first boot) and auto-update/upgrade timers
28+
systemctl enable brew-setup.service
2829
systemctl enable brew-update.timer
2930
systemctl enable brew-upgrade.timer
3031

build_files/base/20-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ done
6262
#fi
6363

6464
IMPORTANT_UNITS=(
65+
brew-setup.service
6566
brew-update.timer
6667
brew-upgrade.timer
6768
rpm-ostree-countme.timer

iso_files/configure_lts_iso_anaconda.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ glib-compile-schemas /usr/share/glib-2.0/schemas
3838
systemctl disable rpm-ostree-countme.service
3939
systemctl disable tailscaled.service
4040
systemctl disable bootloader-update.service
41-
# systemctl disable brew-upgrade.timer
42-
# systemctl disable brew-update.timer
43-
# systemctl disable brew-setup.service
41+
systemctl disable brew-upgrade.timer
42+
systemctl disable brew-update.timer
43+
systemctl disable brew-setup.service
4444
systemctl disable rpm-ostreed-automatic.timer
4545
systemctl disable uupd.timer
4646
systemctl disable ublue-system-setup.service

system_files/shared/etc/profile.d/brew-bash-completion.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

system_files/shared/etc/profile.d/brew.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

system_files/shared/etc/security/limits.d/30-brew-limits.conf

Lines changed: 0 additions & 9 deletions
This file was deleted.

system_files/shared/usr/lib/systemd/system/brew-update.service

Lines changed: 0 additions & 14 deletions
This file was deleted.

system_files/shared/usr/lib/systemd/system/brew-update.timer

Lines changed: 0 additions & 11 deletions
This file was deleted.

system_files/shared/usr/lib/systemd/system/brew-upgrade.service

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)