Skip to content

Commit

Permalink
fix: Allow brew-install to escalate when needed, fixes permission iss…
Browse files Browse the repository at this point in the history
…ue. (#952)
  • Loading branch information
KyleGospo authored Feb 27, 2024
1 parent 2f9f5ad commit f973f1f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ RUN wget https://copr.fedorainfracloud.org/coprs/ublue-os/staging/repo/fedora-"$
systemctl enable dconf-update.service && \
systemctl enable ublue-update.timer && \
systemctl enable ublue-system-setup.service && \
systemctl enable ublue-system-flatpak-manager.service && \
systemctl --global enable ublue-user-flatpak-manager.service && \
systemctl enable ublue-system-networked-tasks.service && \
systemctl enable brew-install-workaround.service && \
systemctl --global enable ublue-user-networked-tasks.service && \
systemctl --global enable ublue-user-setup.service && \
fc-cache -f /usr/share/fonts/ubuntu && \
fc-cache -f /usr/share/fonts/inter && \
Expand Down
20 changes: 20 additions & 0 deletions usr/lib/systemd/system/brew-install-workaround.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Unit]
Description=Workaround brew-install not having the correct caps
ConditionFileIsExecutable=/usr/libexec/brew-install
After=local-fs.target

[Service]
Type=oneshot
# Copy if it doesn't exist
ExecStartPre=/usr/bin/bash -c "[ -x /usr/local/libexec/.brew-install ] || /usr/bin/cp /usr/libexec/brew-install /usr/local/libexec/.brew-install"
# This is faster than using .mount unit. Also allows for the previous line/cleanup
ExecStartPre=/usr/bin/mount --bind /usr/local/libexec/.brew-install /usr/libexec/brew-install
# Fix caps
ExecStart=/usr/sbin/setcap 'cap_sys_admin+p' /usr/libexec/brew-install
# Clean-up after ourselves
ExecStop=/usr/bin/umount /usr/libexec/brew-install
ExecStop=/usr/bin/rm /usr/local/libexec/.brew-install
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Unit]
Description=Manage system flatpaks
Description=Manage tasks that require network access (Flatpaks)
Documentation=https://github.com/ublue-os/endlish-oesque/issues/10
Wants=network-online.target
After=network-online.target ublue-system-setup.service

[Service]
Type=oneshot
ExecStart=/usr/libexec/ublue-system-flatpak-manager
ExecStart=/usr/libexec/ublue-system-networked-tasks
Restart=on-failure
RestartSec=30
StartLimitInterval=0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Unit]
Description=Manage user flatpaks
Description=Manage user activities that require network access (Flatpaks, Brew)
Documentation=https://github.com/ublue-os/endlish-oesque/issues/10
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/libexec/ublue-user-flatpak-manager
ExecStart=/usr/libexec/ublue-user-networked-tasks
Restart=on-failure
RestartSec=30
StartLimitInterval=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# Script Version
VER=3
VER_FILE="/etc/ublue/flatpak_manager_version"
VER_FILE="/etc/ublue/networked_tasks_version"
VER_RAN=$(cat $VER_FILE)

# Run script if updated
if [[ -f $VER_FILE && $VER = $VER_RAN ]]; then
echo "Flatpak manager v$VER has already ran. Exiting..."
echo "Networked tasks v$VER has already ran. Exiting..."
exit 0
fi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

# Script Version
VER=3
VER_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/ublue/flatpak_manager_version"
VER=4
VER_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/ublue/networked_tasks_version"
VER_RAN=$(cat $VER_FILE)

mkdir -p "$(dirname "$VER_FILE")" || exit 1
Expand All @@ -11,7 +11,7 @@ mkdir -p "$(dirname "$VER_FILE")" || exit 1
# Exit if v1 file is present.
VER_1_FILE="$HOME/.ublue_flatpak_manager_version"
if [[ -f $VER_1_FILE ]]; then
echo "Flatpak manager v1 has already ran. Exiting..."
echo "Networked tasks v$VER has already ran. Exiting..."
rm $VER_1_FILE
echo $VER > $VER_FILE
exit 0
Expand Down Expand Up @@ -50,4 +50,11 @@ fi

notify-send "Flatpak installer" "Finished installing user flatpaks" --app-name="Flatpak installer" -u NORMAL

# Install brew
if [[ ! -x /var/home/linuxbrew/.linuxbrew/bin/brew ]]; then
NONINTERACTIVE=1 /usr/libexec/brew-install
fi

notify-send "Brew installer" "Finished installing brew package manager" --app-name="Brew installer" -u NORMAL

echo $VER > $VER_FILE
7 changes: 1 addition & 6 deletions usr/libexec/ublue-user-setup
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# SCRIPT VERSION
USER_SETUP_VER=4
USER_SETUP_VER=5
USER_SETUP_VER_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/ublue/user-setup"
USER_SETUP_VER_RAN=$(cat $USER_SETUP_VER_FILE)

Expand Down Expand Up @@ -36,11 +36,6 @@ if [[ ! -f "$PTYXIS_DIR/catppuccin-dynamic.palette" ]]; then
cp "$PTYXIS_THEME_DIR/catppuccin-dynamic.palette" "$PTYXIS_DIR/catppuccin-dynamic.palette"
fi

# Install brew
if [[ ! -x /var/home/linuxbrew/.linuxbrew/bin/brew ]]; then
NONINTERACTIVE=1 /usr/libexec/brew-install
fi

# Handle privileged tasks
pkexec /usr/libexec/ublue-privileged-user-setup

Expand Down

0 comments on commit f973f1f

Please sign in to comment.