Many people, especially newcomers, have wondered what is the best way to keep the EndeavourOS system updated. EndeavourOS contains three kinds of packages:
Arch packages
EndeavourOS packages
software from the AUR
The answer is not that simple, so I wrote a small bash script that uses the best practices for updating that I know of. Feel free to disagree about the practices!
And remember also the standard disclaimer: use this script on your own risk! I have tested it to the best of my knowledge, and it seems to work as expected. But no guarantees.
Usage instructions
You’ll find the script below. To use it, put the script contents into file
/usr/local/bin/SimpleSysUpdate
(or use a better name if you wish).
To put the file there, start an editor with root rights, and copy/paste the script contents there. Then save the file, and give the file the executable rights:
chmod +x /usr/local/bin/SimpleSysUpdate
Note: reboot is not required!
To use the script, simply run it on the command line like any other application (no sudo required, it will ask permissions if needed):
SimpleSysUpdate
And here’s the script (copy everything after this line!):
#!/bin/bash
# Do system update. Both Arch and AUR updates are checked.
#
# Note: your environment variable SIMPLE_SYSTEM_UPDATE_SUDOS may contain
# your preference list of sudo-like program names.
echo2() { echo "$@" >&2 ; }
printf2() { printf "$@" >&2 ; }
DIE() { echo2 "Error: $1" ; exit 1 ; }
CheckingFor() {
local update_source="$1"
printf2 "Checking updates from %-5s : " "$update_source"
}
Cmd() {
echo2 "$@"
"$@"
}
Usage() {
cat <&2
Check package updates from Arch and AUR.
Usage: $(basename $0)
EOF
}
SelectSudo() {
local xx
local sudos="su-c_wrapper pkexec sudo" # this line determines the order of preference
if [ -n "$SIMPLE_SYSTEM_UPDATE_SUDOS" ] ; then # this variable can set user specific preferences
sudos="$SIMPLE_SYSTEM_UPDATE_SUDOS $sudos"
fi
for xx in $sudos ; do
if [ -x /usr/bin/$xx ] ; then
sudo=$xx
return 0
fi
done
echo2 "None of the following programs exist: $sudos !"
return 1
}
ShowUpdates() {
local updates="$1"
printf "\n%s\n" "$updates" | sed 's|^| |' >&2
}
Main() {
local updates
local sudo
Usage
curl --silent --connect-timeout 8 https://8.8.8.8 >/dev/null || DIE "no internet connection!"
SelectSudo || DIE "no suitable sudo-like program found."
CheckingFor Arch
updates="$(checkupdates)"
if [ -n "$updates" ] ; then
ShowUpdates "$updates"
Cmd $sudo pacman -Syu
return # stop if we have Arch updates
fi
echo2 "no updates available."
CheckingFor AUR
updates="$(yay -Qua)"
if [ -n "$updates" ] ; then
ShowUpdates "$updates"
Cmd yay -Syua
return
fi
echo2 "no updates available."
}
Main "$@"
The script above updates the system like the eos-update-notifier. But it lacks some additional services, like timers etc.
That script is simple and fast to use on the command line. Just the update and no bling-bling.
This way maybe the command line can feel more useful for people who have a habit of not using it…
Here’s the output of a run:
$ SimpleSysUpdate
Check package updates from Arch and AUR.
Usage: SimpleSysUpdate
Checking updates from Arch : no updates available.
Checking updates from AUR : no updates available.
$
My $PATH include also /home/$USER/bin , for my scripts.
I am lazy to fade in - fade out the hidden folder and files.
#!/bin/bash
# Do system update. Both Arch and AUR updates are checked.
#
# Note: your environment variable SIMPLE_SYSTEM_UPDATE_SUDOS may contain
# your preference list of sudo-like program names.
echo2() { echo "$@" >&2 ; }
printf2() { printf "$@" >&2 ; }
DIE() { echo2 "Error: $1" ; exit 1 ; }
CheckingFor() {
local update_source="$1"
printf2 "Checking updates from %-5s : " "$update_source"
}
Cmd() {
echo2 "$@"
"$@"
}
Usage() {
cat <&2
Check package updates from Arch and AUR.
Usage: $(basename $0)
EOF
}
SelectSudo() {
local xx
local sudos="su-c_wrapper pkexec sudo" # this line determines the order of preference
if [ -n "$SIMPLE_SYSTEM_UPDATE_SUDOS" ] ; then # this variable can set user specific preferences
sudos="$SIMPLE_SYSTEM_UPDATE_SUDOS $sudos"
fi
for xx in $sudos ; do
if [ -x /usr/bin/$xx ] ; then
sudo=$xx
return 0
fi
done
echo2 "None of the following programs exist: $sudos !"
return 1
}
ShowUpdates() {
local updates="$1"
printf "\n%s\n" "$updates" | sed 's|^| |' >&2
}
Main() {
local updates
local sudo
Usage
curl --silent --connect-timeout 8 https://8.8.8.8 >/dev/null || DIE "no internet connection!"
SelectSudo || DIE "no suitable sudo-like program found."
CheckingFor Arch
updates="$(checkupdates)"
if [ -n "$updates" ] ; then
ShowUpdates "$updates"
Cmd $sudo pacman -Syu
return # stop if we have Arch updates
fi
echo2 "no updates available."
CheckingFor AUR
updates="$(yay -Qua)"
if [ -n "$updates" ] ; then
ShowUpdates "$updates"
Cmd yay -Syua
return
fi
echo2 "no updates available."
}
Main "$@"
And no, not exactly AFAIK. Topgrade does many more things than updating system packages. Also, topgrade tries to use yay directly, unlike my script. So there are some differences.
There are many ways to update system. This script simply shows the best practices that I know of.