Skip to content

Commit

Permalink
Merge pull request #12 from ublue-os/m2giles-bluefin-wolfi-patch
Browse files Browse the repository at this point in the history
fix: Make brew work without relinking.
  • Loading branch information
castrojo authored Jan 20, 2024
2 parents a29a1a9 + 6c752b5 commit c731eb5
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 63 deletions.
13 changes: 4 additions & 9 deletions quadlets/bluefin-cli/bluefin-cli-distrobox-quadlet.container
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ Description=Bluefin CLI, leveraging Wolfi to provide you brew
[Container]
Annotation=run.oci.keep_original_groups=1
AutoUpdate=registry
ContainerName=bluefin-cli-distrobox-quadlet
ContainerName=bluefin-cli-quadlet
Environment=SHELL=%s
Environment=HOME=%h
Environment=XDG_RUNTIME_DIR=%t
Environment=USER=%u
Environment=USERNAME=%u
Environment=container=podman
Exec=--verbose --name %u --user %U --group %G --home %h --init "0" --nvidia "1" --pre-init-hooks "" --additional-packages "" -- ""
Exec=--verbose --name %u --user %U --group %G --home %h --init "0" --nvidia "1" --pre-init-hooks " " --additional-packages " " -- " "
Image=ghcr.io/ublue-os/bluefin-cli:latest
HostName=bluefin-cli-distrobox-quadlet.%l
HostName=bluefin-cli-quadlet.%l
Network=host
PodmanArgs=--entrypoint /usr/bin/entrypoint
PodmanArgs=--ipc host
PodmanArgs=--label com.github.containers.toolbox=true
PodmanArgs=--label manager=distrobox
PodmanArgs=--no-hosts
PodmanArgs=--privileged
PodmanArgs=--security-opt label=disable
Expand All @@ -28,9 +26,6 @@ User=root:root
UserNS=keep-id
Volume=/:/run/host:rslave
Volume=/tmp:/tmp:rslave
Volume=/usr/bin/distrobox-init:/usr/bin/entrypoint:ro
Volume=/usr/bin/distrobox-export:/usr/bin/distrobox-export:ro
Volume=/usr/bin/distrobox-host-exec:/usr/bin/distrobox-host-exec:ro
Volume=%h:%h:rslave
Volume=/dev:/dev:rslave
Volume=/sys:/sys:rslave
Expand All @@ -42,4 +37,4 @@ Volume=/var/home/%u:/var/home/%u:rslave
Volume=%t:%t:rslave
Volume=/etc/hosts:/etc/hosts:ro
Volume=/etc/resolv.conf:/etc/resolv.conf:ro
Volume=bluefin-cli-Cellar.volume:/home/linuxbrew/.linuxbrew/Cellar
Volume=bluefin-cli-linuxbrew.volume:/home/linuxbrew
11 changes: 3 additions & 8 deletions quadlets/wolfi-toolbox/wolfi-distrobox-quadlet.container
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ Description=Wolfi Toolbox for your distrobox fun
[Container]
Annotation=run.oci.keep_original_groups=1
AutoUpdate=registry
ContainerName=wofli-distrobox-quadlet
ContainerName=wolfi-quadlet
Environment=SHELL=%s
Environment=HOME=%h
Environment=XDG_RUNTIME_DIR=%t
Environment=USER=%u
Environment=USERNAME=%u
Environment=container=podman
Exec=--verbose --name %u --user %U --group %G --home %h --init "0" --nvidia "1" --pre-init-hooks "" --additional-packages "" -- ""
Exec=--verbose --name %u --user %U --group %G --home %h --init "0" --nvidia "1" --pre-init-hooks " " --additional-packages " " -- " "
Image=ghcr.io/ublue-os/wolfi-toolbox:latest
HostName=wolfi-toolbox.%l
HostName=wolfi-quadlet.%l
Network=host
PodmanArgs=--entrypoint /usr/bin/entrypoint
PodmanArgs=--ipc host
PodmanArgs=--label com.github.containers.toolbox=true
PodmanArgs=--label manager=distrobox
PodmanArgs=--no-hosts
PodmanArgs=--privileged
PodmanArgs=--security-opt label=disable
Expand All @@ -28,9 +26,6 @@ User=root:root
UserNS=keep-id
Volume=/:/run/host:rslave
Volume=/tmp:/tmp:rslave
Volume=/usr/bin/distrobox-init:/usr/bin/entrypoint:ro
Volume=/usr/bin/distrobox-export:/usr/bin/distrobox-export:ro
Volume=/usr/bin/distrobox-host-exec:/usr/bin/distrobox-host-exec:ro
Volume=%h:%h:rslave
Volume=/dev:/dev:rslave
Volume=/sys:/sys:rslave
Expand Down
36 changes: 6 additions & 30 deletions toolboxes/bluefin-cli/Containerfile.bluefin-cli
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
FROM ghcr.io/ublue-os/wolfi-toolbox

LABEL com.github.containers.toolbox="true" \
usage="This image is meant to be used with the toolbox or distrobox command" \
LABEL usage="This image is meant to be used with the Toolbox or Distrobox commands" \
summary="A new cloud-native terminal experience powered by Wolfi and Homebrew" \
maintainer="[email protected]"

COPY ./toolboxes/bluefin-cli/packages.bluefin-cli /toolbox-packages
COPY ./toolboxes/bluefin-cli/files/etc /etc

# Update image
# Update image, Install Packages, and move /home/linuxbrew
RUN apk update && \
apk upgrade

# Add optional packages
RUN grep -v '^#' /toolbox-packages | xargs apk add

RUN rm /toolbox-packages

# Have Linuxbrew owned by UID = 1000
RUN chown -R 1000 /home/linuxbrew

# Give UID = 1000 sudo
RUN echo "#1000 ALL = (root) NOPASSWD:ALL" >> /etc/sudoers

# Get Distrobox-host-exec and host-spawn
RUN git clone https://github.com/89luca89/distrobox.git --single-branch /tmp/distrobox && \
cp /tmp/distrobox/distrobox-host-exec /usr/bin/distrobox-host-exec && \
wget https://github.com/1player/host-spawn/releases/download/$(cat /tmp/distrobox/distrobox-host-exec | grep host_spawn_version= | cut -d "\"" -f 2)/host-spawn-$(uname -m) -O /usr/bin/host-spawn && \
chmod +x /usr/bin/host-spawn && \
rm -drf /tmp/distrobox && \
ln -fs /bin/sh /usr/bin/sh

# Make some symlinks
RUN mkdir -p /usr/local/bin && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/docker && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/flatpak && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/podman && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/rpm-ostree
apk upgrade && \
grep -v '^#' /toolbox-packages | xargs apk add && \
mv /home/linuxbrew /home/homebrew && \
rm /toolbox-packages

# Change root shell to BASH
RUN sed -i -e '/^root/s/\/bin\/ash/\/bin\/bash/' /etc/passwd
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
if test "$(id -u)" -gt "0" && test ! -f /home/linuxbrew/.firstrun && test -d /home/linuxbrew/.linuxbrew/Cellar; then
touch /home/linuxbrew/.firstrun
if test -n "$(ls -A /home/linuxbrew/.linuxbrew/Cellar)"; then
echo "Relinking Homebrew Cellar"
/home/linuxbrew/.linuxbrew/bin/brew list -1 | while read line
do
/home/linuxbrew/.linuxbrew/bin/brew unlink $line
/home/linuxbrew/.linuxbrew/bin/brew link $line
done
echo "Reinstalling explicictly installed Homebrew packages"
/home/linuxbrew/.linuxbrew/bin/brew leaves | while read line
do
/home/linuxbrew/.linuxbrew/bin/brew reinstall $line
done
if test "$(id -u)" -gt "0" && test ! -f /etc/linuxbrew.firstrun; then
echo "First Run Setup"
if test -d /home/linuxbrew; then
echo "Getting newest repo version of brew"
su-exec root cp -R /home/homebrew/.linuxbrew /home/linuxbrew/
echo "Making sure linuxbrew is owned by ${USER}"
su-exec root chown -R $UID /home/linuxbrew
fi
echo "Setting up sudo for ${USER}"
echo "#${UID} ALL = (root) NOPASSWD:ALL" | su-exec root tee -a /etc/sudoers > /dev/null
su-exec root touch /etc/linuxbrew.firstrun
fi
21 changes: 19 additions & 2 deletions toolboxes/wolfi-toolbox/Containerfile.wolfi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM cgr.dev/chainguard/wolfi-base
# Thanks to Nuno do Carmo for the initial prototype

LABEL com.github.containers.toolbox="true" \
usage="This image is meant to be used with the toolbox or distrobox command" \
LABEL usage="This image is meant to be used with the Toolbox or Distrobox command" \
summary="A blank Wolfi distrobox, suitable for development" \
maintainer="[email protected]"

Expand All @@ -17,5 +16,23 @@ RUN grep -v '^#' /toolbox-packages | xargs apk add

RUN rm /toolbox-packages


# Get Distrobox-host-exec and host-spawn
RUN git clone https://github.com/89luca89/distrobox.git --single-branch /tmp/distrobox && \
cp /tmp/distrobox/distrobox-host-exec /usr/bin/distrobox-host-exec && \
cp /tmp/distrobox/distrobox-export /usr/bin/distrobox-export && \
cp /tmp/distrobox/distrobox-init /usr/bin/entrypoint && \
wget https://github.com/1player/host-spawn/releases/download/$(cat /tmp/distrobox/distrobox-host-exec | grep host_spawn_version= | cut -d "\"" -f 2)/host-spawn-$(uname -m) -O /usr/bin/host-spawn && \
chmod +x /usr/bin/host-spawn && \
rm -drf /tmp/distrobox && \
ln -fs /bin/sh /usr/bin/sh

# Make some symlinks
RUN mkdir -p /usr/local/bin && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/docker && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/flatpak && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/podman && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/rpm-ostree

# Change root shell to BASH
RUN sed -i -e '/^root/s/\/bin\/ash/\/bin\/bash/' /etc/passwd
12 changes: 12 additions & 0 deletions toolboxes/wolfi-toolbox/packages.wolfi
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ curl
diffutils
findmnt
findutils
git
gnupg
gpg
iproute2
iputils
keyutils
libcap=2.68-r0
libsm
libx11
libxau
libxcb
libxdmcp
libxext
libice
libxmu
libxt
mount
ncurses
ncurses-terminfo
Expand All @@ -25,9 +35,11 @@ tcpdump
tree
tzdata
umount
unzip
util-linux
util-linux-misc
wget
xauth
xz
zip
vulkan-loader

0 comments on commit c731eb5

Please sign in to comment.