obosdi-pkg/updates/menu

233 lines
7.1 KiB
Text
Raw Permalink Normal View History

2015-08-20 14:37:06 -06:00
#!/bin/bash
. ./lib
options=()
2018-07-22 09:25:41 -06:00
if [ -f /usr/bin/trizen ]; then
options+=("Upgrade with trizen" "trizen -Syu")
aurhelper=1
fi
2018-07-22 10:30:02 -06:00
if [ -f /usr/bin/yay ]; then
options+=("Upgrade with yay" "yay -Syu")
aurhelper=1
fi
if [ -f /usr/bin/aurman ]; then
options+=("Upgrade with aurman" "aurman -Syu")
aurhelper=1
fi
2018-09-29 19:21:57 -06:00
2022-11-17 15:28:46 -07:00
if [ -f /usr/bin/lynx ] || [ -f /usr/bin/elinks ] || [ -f /usr/bin/links ]; then
options+=("Latestt News" "")
options+=("" "")
fi
2015-08-20 14:37:06 -06:00
options+=("Upgrade" "pacman -Syu")
2016-01-11 13:35:42 -07:00
options+=("Clean orphan" "pacman -Rns \$(pacman -Qqtd)")
2016-01-11 12:14:42 -07:00
options+=("Clean cache" "pacman -Sc")
2015-08-20 14:37:06 -06:00
options+=("" "")
options+=("Edit pacman.conf" "")
options+=("Edit mirrorlist" "")
options+=("" "")
2017-09-08 13:21:08 -06:00
options+=("Update keyring" "pacman -S archlinux-keyring")
2016-05-14 08:33:14 -06:00
options+=("Refresh pacman keys" "pacman-key --refresh-keys")
2018-09-15 15:27:02 -06:00
options+=("Add GPG key" "gpg --recv-keys")
2016-05-14 08:33:14 -06:00
options+=("" "")
2015-12-19 12:16:33 -07:00
if [ -f /var/lib/pacman/db.lck ]; then
options+=("Remove db.lck" "rm /var/lib/pacman/db.lck")
options+=("" "")
fi
2022-10-15 17:30:53 -06:00
if [ "$aurhelper" = "1" ]; then
if [ ! -f /usr/bin/downgrade ]; then
2022-10-15 17:32:37 -06:00
options+=("Install downgrade" "(AUR)")
2022-10-15 17:30:53 -06:00
options+=("" "")
fi
if [ ! -f /usr/bin/pkgstats ]; then
2022-10-15 17:32:37 -06:00
options+=("Install pkgstats" "(AUR)")
2022-10-15 17:30:53 -06:00
fi
if [ ! -f /usr/bin/aurvote ]; then
options+=("Install aurvote" "(AUR)")
fi
options+=("" "")
fi
2022-10-15 17:26:57 -06:00
if [ ! -f /usr/bin/trizen ]; then
options+=("Install trizen" "")
fi
if [ ! -f /usr/bin/yay ]; then
options+=("Install yay" "")
fi
if [ ! -f /usr/bin/aurman ]; then
options+=("Install aurman" "")
fi
if [ ! -f /usr/bin/pacdiff ]; then
options+=("" "")
2022-10-15 17:30:53 -06:00
options+=("Install pacman-contrib" "")
2015-08-20 14:37:06 -06:00
fi
2022-11-10 14:27:23 -07:00
sel=$(dialog --backtitle "$apptitle" --title "Updates Menu :" --cancel-button "Back" --menu "" 0 0 0 \
2015-08-20 14:37:06 -06:00
"${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-04 17:08:04 -06:00
if [ ! -f /usr/bin/git ]; then
pacman -S --needed git
fi
2015-08-20 14:37:06 -06:00
if [ ! $(id -u "aurbuilder") ]; then
newpass=$(< /dev/urandom tr -dc "@#*%&_A-Z-a-z-0-9" | head -c16)
2018-07-22 09:25:41 -06:00
useradd -r -N -M -d /tmp/aurbuilder -s /usr/bin/nologin aurbuilder
2015-08-20 14:37:06 -06:00
echo -e "$newpass\n$newpass\n"|passwd aurbuilder
newpass=""
2018-08-01 11:50:35 -06:00
mkdir /tmp/aurbuilder 1&>/dev/null
chmod 777 /tmp/aurbuilder
2018-07-22 09:25:41 -06:00
else
2018-07-22 10:39:19 -06:00
mkdir /tmp/aurbuilder 1&>/dev/null
2018-07-22 10:48:37 -06:00
chmod 777 /tmp/aurbuilder
2018-07-22 10:49:50 -06:00
usermod -d /tmp/aurbuilder aurbuilder
fi
if [ ! -f /etc/sudoers.d/aurbuilder ]; then
echo "aurbuilder ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aurbuilder
echo "root ALL=(aurbuilder) NOPASSWD: ALL" >> /etc/sudoers.d/aurbuilder
2015-08-20 14:37:06 -06:00
fi
2018-07-22 09:25:41 -06:00
}
checkpackagequerydependencies(){
2018-06-04 17:11:59 -06:00
if [ ! -f /usr/bin/package-query ]; then
2018-07-22 09:25:41 -06:00
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-04 17:11:59 -06:00
fi
2015-08-20 14:37:06 -06:00
}
2015-08-31 18:49:08 -06:00
clear
2015-08-20 14:37:06 -06:00
case $sel in
2022-11-17 15:28:46 -07:00
'Latestt News')
2022-11-17 15:31:49 -07:00
newsurl='https://archlinux.org/news/'
2022-11-17 15:28:46 -07:00
if [ -f /usr/bin/lynx ]; then
2022-11-17 15:31:49 -07:00
/usr/bin/lynx ${newsurl}
2022-11-17 15:28:46 -07:00
else
if [ -f /usr/bin/elinks ]; then
2022-11-17 15:31:49 -07:00
/usr/bin/elinks ${newsurl}
2022-11-17 15:28:46 -07:00
else
if [ -f /usr/bin/links ]; then
2022-11-17 15:31:49 -07:00
/usr/bin/links ${newsurl}
2022-11-17 15:28:46 -07:00
fi
fi
fi
;;
2015-08-20 14:37:06 -06:00
'Upgrade') pacman -Syu;;
2018-07-22 09:25:41 -06:00
'Upgrade with trizen')
checkaurdependencies
2018-07-22 09:25:41 -06:00
sudo -u aurbuilder trizen -Syu
;;
2018-07-22 10:30:02 -06:00
'Upgrade with aurman')
checkaurdependencies
sudo -u aurbuilder aurman -Syu
;;
'Upgrade with yay')
checkaurdependencies
sudo -u aurbuilder yay -Syu
;;
2018-07-22 09:25:41 -06:00
'Upgrade with yaourt')
checkaurdependencies
2018-07-22 09:25:41 -06:00
sudo -u aurbuilder yaourt -Syua
;;
2016-01-11 12:14:42 -07:00
'Clean orphan') pacman -Rns $(pacman -Qqtd);;
'Clean cache') pacman -Sc;;
2018-09-15 19:36:14 -06:00
'Edit pacman.conf') editfile /etc/pacman.conf;;
'Edit mirrorlist') editfile /etc/pacman.d/mirrorlist;;
2017-09-08 13:21:08 -06:00
'Update keyring') pacman -S archlinux-keyring;;
2016-05-14 08:33:14 -06:00
'Refresh pacman keys') pacman-key --refresh-keys;;
2018-09-15 15:27:02 -06:00
'Add GPG key')
gpgservers=()
gpgservers+=("pool.sks-keyservers.net" "")
gpgservers+=("Other" "")
2022-11-10 14:27:23 -07:00
sel=$(dialog --backtitle "$apptitle" --title "Add GPG key" --menu "GPG key server" 0 0 0 "${gpgservers[@]}" 3>&1 1>&2 2>&3)
2018-09-15 15:27:02 -06:00
if [ "$?" = "0" ]; then
case $sel in
"Other")
2022-11-10 14:27:23 -07:00
gpgserver=$(dialog --backtitle "$apptitle" --title "Add GPG key" --inputbox "Enter the GPG key server :" 0 0 "" 3>&1 1>&2 2>&3)
2018-09-15 15:27:02 -06:00
if [ "$?" = "0" ]; then
2022-11-10 14:27:23 -07:00
gpgkey=$(dialog --backtitle "$apptitle" --title "Add GPG key" --inputbox "Enter the GPG key :" 0 0 3>&1 1>&2 2>&3)
2018-09-15 15:27:02 -06:00
if [ "$?" = "0" ]; then
echo "sudo -u aurbuilder gpg --keyserver "$gpgserver" --recv-keys "$gpgkey
sudo -u aurbuilder gpg --keyserver $gpgserver --recv-keys $gpgkey
pressanykey
fi
fi
;;
*)
gpgserver=$sel
2022-11-10 14:27:23 -07:00
gpgkey=$(dialog --backtitle "$apptitle" --title "Add GPG key" --inputbox "Enter the GPG key :" 0 0 3>&1 1>&2 2>&3)
2018-09-15 15:27:02 -06:00
if [ "$?" = "0" ]; then
echo "sudo -u aurbuilder gpg --keyserver "$gpgserver" --recv-keys "$gpgkey
sudo -u aurbuilder gpg --keyserver $gpgserver --recv-keys $gpgkey
pressanykey
fi
;;
esac
fi
;;
2015-12-18 14:42:21 -07:00
'Remove db.lck') rm /var/lib/pacman/db.lck;;
2018-09-29 19:21:57 -06:00
'Install pacman-contrib')
instpkg "pacman-contrib" ""
;;
2015-12-19 11:57:14 -07:00
'Install downgrade')
2018-07-22 09:25:41 -06:00
instpkg "" "downgrade"
2015-12-19 11:57:14 -07:00
;;
2018-07-22 09:25:41 -06:00
'Install trizen')
2018-07-22 10:30:02 -06:00
if(confirm "Trizen 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-08-31 19:26:21 -06:00
clear
2015-08-20 14:37:06 -06:00
checkaurdependencies
2018-07-22 09:25:41 -06:00
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/trizen.git
cd trizen
sudo -u aurbuilder makepkg -si
2015-08-20 14:37:06 -06:00
fi
;;
2018-07-22 10:30:02 -06:00
'Install aurman')
if(confirm "Aurman allow you to access the AUR applications.\nBecause is not possible to compile applications as root,\nthis installer create an aurbuilder user.\n\nInstall aurman ?") then
clear
checkaurdependencies
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/aurman.git
cd aurman
sudo -u aurbuilder gpg --recv-key 465022E743D71E39
sudo -u aurbuilder makepkg -si
#sudo -u aurbuilder makepkg -si --skippgpcheck
fi
;;
'Install yay')
if(confirm "Yay allow you to access the AUR applications.\nBecause is not possible to compile applications as root,\nthis installer create an aurbuilder user.\n\nInstall yay ?") then
clear
checkaurdependencies
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/yay.git
cd yay
sudo -u aurbuilder makepkg -si
fi
;;
2018-07-22 09:25:41 -06: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-08-31 19:26:21 -06:00
clear
2015-08-20 14:37:06 -06:00
checkaurdependencies
2018-07-22 09:25:41 -06:00
checkpackagequerydependencies
cd /tmp/aurbuilder
sudo -u aurbuilder git clone https://aur.archlinux.org/yaourt.git
cd yaourt
sudo -u aurbuilder makepkg -si
2015-08-20 14:37:06 -06:00
fi
;;
2017-02-03 11:37:56 -07:00
'Install pkgstats')
2018-07-22 09:25:41 -06:00
pacman -S --needed pkgstats
2017-02-03 11:37:56 -07:00
;;
'Install aurvote')
2019-03-16 13:07:02 -06:00
instpkg "" "aurvote"
2017-02-03 11:37:56 -07:00
;;
2015-08-20 14:37:06 -06:00
esac
exit 0