74 lines
3.0 KiB
Bash
Executable File
74 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
cd "$(dirname "$0")"
|
|
|
|
#Check if script has been run as root and exit if so, prompting the user to run as normal user
|
|
if [ $(id -u) -eq 0 ]; then
|
|
echo "Please do not run this script as root or with sudo, it will prompt for your password and elevate as necessary"
|
|
exit
|
|
fi
|
|
|
|
|
|
#Check if ~/.config/ArchUpdater exists and create it if not
|
|
if [ ! -d "$HOME/.config/ArchUpdater" ]; then
|
|
mkdir -p $HOME/.config/ArchUpdater
|
|
fi
|
|
|
|
#Check to make sure colordiff installed for the pacdiff step, install it if not, and export it as the editor
|
|
#export DIFFPROG=colordiff
|
|
colordiff_installed=$(which colordiff)
|
|
|
|
if [ -z "$colordiff_installed" ]; then
|
|
echo "Installing colordiff for the pacdiff step later, this will only run the first time you use this script"
|
|
sudo pacman -S colordiff
|
|
fi
|
|
|
|
if [ -z $(which pacdiff) ]; then
|
|
echo "Installing pacman-contrib for the pacdiff step later, this will only run the first time you run this script"
|
|
sudo pacman -S pacman-contrib
|
|
fi
|
|
|
|
#Create list of -git packages from the aur
|
|
gitlist=$(pacman -Qqm | grep git | grep -v debug | grep -v sooperlooper-git)
|
|
|
|
#Run normal repo updates
|
|
echo "Running sudo pacman -Syu to update repo packages"
|
|
sudo pacman -Syu
|
|
|
|
#Run aur updates
|
|
echo "Running yay -Syu to update aur packages"
|
|
yay -Syu
|
|
echo "Running pacdiff to check for any pacnew files that need to be dealt with"
|
|
|
|
#Pacdiff to check for pacnews to deal with
|
|
sudo DIFFPROG=colordiff pacdiff
|
|
|
|
#Update flatpaks
|
|
echo "Running sudo update flatpak"
|
|
sudo flatpak update
|
|
|
|
|
|
#Check if its been more than two weeks since the last rebuild of AUR -git packages
|
|
if [ ! -f $HOME/.config/ArchUpdater/last-git.txt ]; then
|
|
echo "It looks like this is the first time you have run this script or you have said no to this question before. AUR -git packages should occasionally be rebuilt as generally they will build from the most current HEAD of the git project but the maintainer may not update the AUR package as frequently, to get the latest version it is recommended to run yay -S <pkgname> every now and then. Would you like this script to do so now? In the future you will only be prompted to do this if it has been more than 2 weeks since the previous run, as AUR packages are often built from source it can be time consuming"
|
|
while true; do
|
|
read -p "Would you like to update your -git aur packages? (y/n) " yn
|
|
case $yn in
|
|
[Yy]* ) yay -S $gitlist; echo $(date +%s) > $HOME/.config/ArchUpdater/last-git.txt; break;;
|
|
[Nn]* ) exit;;
|
|
* ) echo "Please answer yes or no.";;
|
|
esac
|
|
done
|
|
elif [ $(($(date +%s)-$(<$HOME/.config/ArchUpdater/last-git.txt))) -gt 1209600 ]; then
|
|
echo "It looks like it has been more than two weeks since you updated your -git AUR packages"
|
|
while true; do
|
|
read -p "Would you like to do so now? (y/n) " yn
|
|
case $yn in
|
|
[Yy]* ) yay -S $gitlist; echo $(date +%s) > $HOME/.config/ArchUpdater/last-git.txt; break;;
|
|
[Nn]* ) exit;;
|
|
* ) echo "Please answer yes or no.";;
|
|
esac
|
|
done
|
|
fi
|
|
|
|
|