2018-05-02 10:29:49 +02:00
|
|
|
#!/usr/bin/env bash
|
2019-08-25 18:38:57 +02:00
|
|
|
|
|
|
|
# A simple script for updating all package managers simultaneously
|
|
|
|
|
|
|
|
# Show commands being executed
|
2018-05-02 10:29:49 +02:00
|
|
|
set -x
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2022-04-03 00:39:17 +02:00
|
|
|
# English (US) is generally installed everywhere, flatpak and packagekit use
|
|
|
|
# weird glyphs unavailable in C and C.utf8 is a RedHattism, which Debian
|
|
|
|
# side of the family doesn't recognise.
|
2022-04-03 00:40:07 +02:00
|
|
|
#export LANG=en_US.utf8
|
|
|
|
# This is said to be a poor practice that should only be used for debugging
|
|
|
|
export LC_ALL=en_US.utf8
|
2022-04-01 20:53:37 +02:00
|
|
|
|
2020-06-11 16:22:14 +02:00
|
|
|
# if hash checks that the command exists
|
2019-11-01 09:17:55 +01:00
|
|
|
if hash apt-get 2>/dev/null; then
|
2020-06-11 16:22:14 +02:00
|
|
|
# I am not sure if -y here even does anything, at least it won't work for
|
|
|
|
# accepting suite changes for Debian when testing becomes stable.
|
|
|
|
# Checking for updates or new packages.
|
2019-11-01 09:17:55 +01:00
|
|
|
apt-get -y update
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2020-06-11 16:22:14 +02:00
|
|
|
# If arguments like -y are passed to the script, they become "$@"
|
2019-11-01 09:17:55 +01:00
|
|
|
apt-get "$@" upgrade --with-new-pkgs
|
2020-06-10 22:37:54 +02:00
|
|
|
|
2020-06-11 16:22:14 +02:00
|
|
|
# potentially unsafe
|
2020-06-10 22:37:54 +02:00
|
|
|
apt-get "$@" autoremove
|
2019-11-01 09:17:55 +01:00
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2021-01-24 10:04:39 +01:00
|
|
|
if hash dnf 2>/dev/null; then
|
2021-02-01 09:26:53 +01:00
|
|
|
# I don't know if -y does anything here either and I think this may be
|
|
|
|
# useless, but I am used to it coming from apt and I think it will just
|
|
|
|
# say nothing to do or do nothing if mirrors haven't updated.
|
|
|
|
dnf check-update -y
|
|
|
|
|
2021-01-24 10:04:39 +01:00
|
|
|
# If arguments like -y are passed to the script, they become "$@"
|
2021-01-24 20:33:09 +01:00
|
|
|
dnf "$@" upgrade
|
2021-02-28 14:55:17 +01:00
|
|
|
|
|
|
|
# potentially unsafe
|
|
|
|
dnf "$@" autoremove
|
2021-01-24 10:04:39 +01:00
|
|
|
fi
|
|
|
|
|
2021-02-21 10:55:08 +01:00
|
|
|
if hash rpmconf 2>/dev/null; then
|
|
|
|
# Tests if there are rpmsave/rpmnew files, hopefully is non-interactive
|
|
|
|
rpmconf -a -t
|
|
|
|
fi
|
|
|
|
|
2019-11-01 09:17:55 +01:00
|
|
|
if hash flatpak 2>/dev/null; then
|
2020-06-11 16:22:14 +02:00
|
|
|
# Flatpak apps are sandboxed and should be safe to update automatically
|
2020-09-13 07:55:19 +02:00
|
|
|
flatpak update --assumeyes
|
2021-03-10 10:23:01 +01:00
|
|
|
# Note to self
|
|
|
|
echo '!!! In case of weird errors e.g. while trying to checkout, try running: flatpak repair'
|
2019-11-01 09:17:55 +01:00
|
|
|
# Flatpak's version of `apt autoremove`
|
2020-04-04 09:53:39 +02:00
|
|
|
flatpak uninstall --unused --assumeyes
|
2019-11-01 09:17:55 +01:00
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2019-11-01 09:17:55 +01:00
|
|
|
if hash snap 2>/dev/null; then
|
2020-06-11 16:22:14 +02:00
|
|
|
# Snap packages auto-update anyway though, but I like checking them while
|
|
|
|
# doing everything else too
|
2019-11-01 09:17:55 +01:00
|
|
|
snap refresh
|
|
|
|
# so I may have some sort of an idea when snap packages have been updated
|
|
|
|
# if they have auto-refreshed
|
|
|
|
snap changes
|
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2021-02-21 10:55:08 +01:00
|
|
|
if hash pkcon 2>/dev/null; then
|
|
|
|
# So PackageKit using KDE Plasma and possibly GNOME stop alerting about
|
|
|
|
# already installed updates. It has backends for all other package managers,
|
|
|
|
# so it needs to be after them.
|
|
|
|
pkcon refresh force
|
|
|
|
fi
|
|
|
|
|
2019-11-01 09:17:55 +01:00
|
|
|
if hash apt-file 2>/dev/null; then
|
2020-06-11 16:22:14 +02:00
|
|
|
# So the local apt-file database is up-to-date.
|
2019-11-01 09:17:55 +01:00
|
|
|
apt-file update
|
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
|
|
|
# I don't have flatpak or snap going to background, because I often do
|
|
|
|
# ./deb-update.bash && poweroff
|
|
|
|
|
2021-02-21 10:55:08 +01:00
|
|
|
if hash needrestart 2>/dev/null; then
|
|
|
|
# needrestart batch mode, should be visible on bottom of scrollback
|
|
|
|
# see https://github.com/liske/needrestart/blob/master/README.batch.md
|
|
|
|
needrestart -b
|
|
|
|
fi
|
|
|
|
|
2019-08-25 18:38:57 +02:00
|
|
|
# Hide commands being executed again
|
2018-05-02 10:29:49 +02:00
|
|
|
set +x
|