2015-08-20 22:37:06 +02:00
#!/bin/bash
. ./lib
options=()
2018-07-22 17:25:41 +02:00
if [ -f /usr/bin/trizen ]; then
options+=("Upgrade with trizen" "trizen -Syu")
aurhelper=1
fi
2015-08-20 22:37:06 +02:00
if [ -f /usr/bin/yaourt ]; then
options+=("Upgrade with yaourt" "yaourt -Syua")
aurhelper=1
fi
if [ ! "$aurhelper" = "1" ]; then
2018-07-22 17:25:41 +02:00
options+=("Install trizen" "")
2015-08-20 22:37:06 +02:00
options+=("Install yaourt" "")
options+=("" "")
fi
options+=("Upgrade" "pacman -Syu")
2016-01-11 21:35:42 +01:00
options+=("Clean orphan" "pacman -Rns \$(pacman -Qqtd)")
2016-01-11 20:14:42 +01:00
options+=("Clean cache" "pacman -Sc")
2015-08-20 22:37:06 +02:00
options+=("" "")
options+=("Edit pacman.conf" "")
options+=("Edit mirrorlist" "")
options+=("" "")
2017-09-08 21:21:08 +02:00
options+=("Update keyring" "pacman -S archlinux-keyring")
2016-05-14 16:33:14 +02:00
options+=("Refresh pacman keys" "pacman-key --refresh-keys")
options+=("" "")
2015-12-19 20:16:33 +01:00
if [ -f /var/lib/pacman/db.lck ]; then
options+=("Remove db.lck" "rm /var/lib/pacman/db.lck")
options+=("" "")
fi
2015-08-20 22:37:06 +02:00
if [ "$aurhelper" = "1" ]; then
2018-07-22 17:25:41 +02:00
if [ ! -f /usr/bin/downgrade ]; then
options+=("Install downgrade" "")
fi
2017-02-03 19:37:56 +01:00
if [ ! -f /usr/bin/pkgstats ]; then
options+=("Install pkgstats" "")
fi
if [ ! -f /usr/bin/aurvote ]; then
options+=("Install aurvote" "")
fi
2018-07-22 17:25:41 +02:00
if [ ! -f /usr/bin/trizen ]; then
options+=("Install trizen" "")
fi
2017-02-03 19:40:34 +01:00
if [ ! -f /usr/bin/yaourt ]; then
options+=("Install yaourt" "")
fi
2015-08-20 22:37:06 +02:00
fi
sel=$(whiptail --backtitle "$apptitle" --title "Updates Menu :" --menu "" --cancel-button "Back" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
checkaurdependencies(){
if [ ! -f /usr/bin/automake ]; then
pacman -S --needed base-devel
fi
2018-06-05 01:08:04 +02:00
if [ ! -f /usr/bin/git ]; then
pacman -S --needed git
fi
2015-08-20 22:37:06 +02:00
if [ ! $(id -u "aurbuilder") ]; then
newpass=$(< /dev/urandom tr -dc "@#*%&_A-Z-a-z-0-9" | head -c16)
2018-07-22 17:25:41 +02:00
useradd -r -N -M -d /tmp/aurbuilder -s /usr/bin/nologin aurbuilder
2015-08-20 22:37:06 +02:00
echo -e "$newpass\n$newpass\n"|passwd aurbuilder
2015-10-13 21:52:44 +02:00
newpass=""
2018-07-22 17:25:41 +02:00
else
usermod -m -d /tmp/aurbuilder aurbuilder
2015-10-13 21:52:44 +02:00
fi
if [ ! -f /etc/sudoers.d/aurbuilder ]; then
2015-10-13 21:48:25 +02:00
echo "aurbuilder ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aurbuilder
echo "root ALL=(aurbuilder) NOPASSWD: ALL" >> /etc/sudoers.d/aurbuilder
2015-08-20 22:37:06 +02:00
fi
2018-07-22 17:25:41 +02:00
}
checkpackagequerydependencies(){
2018-06-05 01:11:59 +02:00
if [ ! -f /usr/bin/package-query ]; then
2018-07-22 17:25:41 +02:00
mkdir /tmp/aurbuilder
chmod 777 /tmp/aurbuilder
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/package-query.git
cd package-query
sudo -u aurbuilder makepkg -si
2018-06-05 01:11:59 +02:00
fi
2015-08-20 22:37:06 +02:00
}
checkarchlinuxfrrepo(){
if [ ! $(cat /etc/pacman.conf | grep "archlinuxfr") ]; then
echo "[archlinuxfr]" >> /etc/pacman.conf
echo "SigLevel = Never" >> /etc/pacman.conf
echo 'Server = http://repo.archlinux.fr/$arch' >> /etc/pacman.conf
pacman -Syy
fi
}
2015-09-01 02:49:08 +02:00
clear
2015-08-20 22:37:06 +02:00
case $sel in
'Upgrade') pacman -Syu;;
2018-07-22 17:25:41 +02:00
'Upgrade with trizen')
2015-10-13 21:53:20 +02:00
checkaurdependencies
2018-07-22 17:25:41 +02:00
sudo -u aurbuilder trizen -Syu
2015-10-13 21:53:20 +02:00
;;
2018-07-22 17:25:41 +02:00
'Upgrade with yaourt')
2015-10-13 21:53:20 +02:00
checkaurdependencies
2018-07-22 17:25:41 +02:00
sudo -u aurbuilder yaourt -Syua
2015-10-13 21:53:20 +02:00
;;
2016-01-11 20:14:42 +01:00
'Clean orphan') pacman -Rns $(pacman -Qqtd);;
'Clean cache') pacman -Sc;;
2015-08-20 22:37:06 +02:00
'Edit pacman.conf') nano /etc/pacman.conf;;
'Edit mirrorlist') nano /etc/pacman.d/mirrorlist;;
2017-09-08 21:21:08 +02:00
'Update keyring') pacman -S archlinux-keyring;;
2016-05-14 16:33:14 +02:00
'Refresh pacman keys') pacman-key --refresh-keys;;
2015-12-18 22:42:21 +01:00
'Remove db.lck') rm /var/lib/pacman/db.lck;;
2015-12-19 19:57:14 +01:00
'Install downgrade')
2018-07-22 17:25:41 +02:00
instpkg "" "downgrade"
2015-12-19 19:57:14 +01:00
;;
2018-07-22 17:25:41 +02:00
'Install trizen')
if(confirm "Yaourt allow you to access the AUR applications.\nBecause is not possible to compile applications as root,\nthis installer create an aurbuilder user.\n\nInstall trizen ?") then
2015-09-01 03:26:21 +02:00
clear
2015-08-20 22:37:06 +02:00
checkaurdependencies
2018-07-22 17:25:41 +02:00
mkdir /tmp/aurbuilder
chmod 777 /tmp/aurbuilder
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/trizen.git
cd trizen
sudo -u aurbuilder makepkg -si
2015-08-20 22:37:06 +02:00
fi
;;
2018-07-22 17:25:41 +02:00
'Install yaourt')
if(confirm "Yaourt allow you to access the AUR applications.\nBecause is not possible to compile applications as root,\nthis installer create an aurbuilder user.\n\nInstall yaourt ?") then
2015-09-01 03:26:21 +02:00
clear
2015-08-20 22:37:06 +02:00
checkaurdependencies
2018-07-22 17:25:41 +02:00
checkpackagequerydependencies
mkdir /tmp/aurbuilder
chmod 777 /tmp/aurbuilder
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/yaourt.git
cd yaourt
sudo -u aurbuilder makepkg -si
2015-08-20 22:37:06 +02:00
fi
;;
2017-02-03 19:37:56 +01:00
'Install pkgstats')
2018-07-22 17:25:41 +02:00
pacman -S --needed pkgstats
2017-02-03 19:37:56 +01:00
;;
'Install aurvote')
2018-07-22 17:25:41 +02:00
pacman -S --needed aurvote
2017-02-03 19:37:56 +01:00
;;
2015-08-20 22:37:06 +02:00
esac
exit 0