-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ublue-brew): add update/upgrade services and timers #296
Conversation
ExecStart=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew upgrade" | ||
# Prevent Brew from overriding important system binaries like: | ||
# systemctl, loginctl, dbus-* | ||
ExecStartPost=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew unlink systemd dbus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If systemd
or dbus
is not installed in brew
, service will report status as failed.
This fixes it.
ExecStartPost=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew unlink systemd dbus" | |
ExecStartPost=/usr/bin/bash -c "if [[ -n \"\$(/home/linuxbrew/.linuxbrew/bin/brew list --formulae | awk '/(^|\\s)(dbus)($|\\s)/')\" ]]; then /home/linuxbrew/.linuxbrew/bin/brew unlink dbus; fi; if [[ -n \"\$(/home/linuxbrew/.linuxbrew/bin/brew list --formulae | awk '/(^|\\s)(systemd)($|\\s)/')\" ]]; then /home/linuxbrew/.linuxbrew/bin/brew unlink systemd; fi"``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
systemd
ordbus
is not installed inbrew
, service will report status as failed.
This fixes it.Suggested change
ExecStartPost=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew unlink systemd dbus" ExecStartPost=/usr/bin/bash -c "if [[ -n \"\$(/home/linuxbrew/.linuxbrew/bin/brew list --formulae | awk '/(^|\\s)(dbus)($|\\s)/')\" ]]; then /home/linuxbrew/.linuxbrew/bin/brew unlink dbus; fi; if [[ -n \"\$(/home/linuxbrew/.linuxbrew/bin/brew list --formulae | awk '/(^|\\s)(systemd)($|\\s)/')\" ]]; then /home/linuxbrew/.linuxbrew/bin/brew unlink systemd; fi"```
We can get away with a simpler || true
at the end
Co-authored-by: Zeglius <[email protected]>
|
||
[Timer] | ||
OnBootSec=10min | ||
OnUnitInactiveSec=6h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is inline with existing update timers (flatpak and bootc) but it seems a bit frequent to update every 6 hours.
Probably not a problem, but do we have an easy way to disable these for users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users can disable this timer completely with systemctl disable brew-update.timer
or they can override the frequency with a drop-in config file
cat <<EOF > /etc/systemd/system/brew-update.timer.conf.d/override.conf
[Timer]
OnUnitInactiveSec=24h
EOF
Note that brew update
doesn't actually upgrade any packages, but rather just does a git pull
on Brew's repo to pull in new formulae.
ExecStart=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew upgrade" | ||
# Prevent Brew from overriding important system binaries like: | ||
# systemctl, loginctl, dbus-* | ||
ExecStartPost=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew unlink systemd dbus || true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this addresses the concern about brew supplanting system services. It may need to be expanded if other problems are found, but if we're committed to providing brew for users, I think we do need this kind of d of safeguard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also instead of running this in a shell. Have the full path prefixed with a - then the service unit will not be marked failed.
Running things in a shell like this is usually not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, running in a shell is not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I updated the unit to not spawn a shell.
Environment=HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar | ||
Environment=HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew | ||
Environment=HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew | ||
ExecStart=/usr/bin/bash -c "/home/linuxbrew/.linuxbrew/bin/brew update" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, do we need to spawn a shell here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, worst case we can do a follow up as this is kinda hard to test
These services and timers are taken directly from Aurora, with the exception of adding the unlink logic from #269 (comment) to
brew-upgrade.service
.Closes #269.