Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ "$#" -ne 1 ]; then
- echo "Usage: "$(basename $0)" aur_package_dir"
- echo
- echo "This is a stupid and simple AUR package upgrader"
- echo
- echo "When passed a directory where clones of AUR repositories are this script"
- echo "will iterate over them directory by directory and if any contains"
- echo "a PKGBUILD file with pkgbase/pkgname will see if this package is installed."
- echo "If it is will perform git reset --hard + git pull, check for pkgver/pkgrel"
- echo "against what is installed and call makepkg -sri in case they differ"
- echo
- echo 'Unfortunately you still have to type your sudo password when installing'
- echo 'packages and I still do not know how to workaround this'a
- exit 1
- fi
- pushd $1 > /dev/null
- for dir in */; do
- pushd $dir > /dev/null
- if [ -f PKGBUILD ]; then
- pkgbase=$(grep -m 1 pkgbase PKGBUILD | cut -d '=' -f 2)
- pkgname=$(grep -m 1 pkgname PKGBUILD | cut -d '=' -f 2)
- # If we have a base package, check for it, using makepkg -sri anyway to install everything
- if [ ! -z $pkgbase ]; then
- pkgname=$pkgbase
- fi
- # In split packages "If pkgbase is not specified, the first element in the pkgname array is used."
- # (c) https://wiki.archlinux.org/index.php/PKGBUILD#Package_name
- # so get the first element of an array if needed
- if echo $pkgname | grep "^("; then
- pkgname=`echo $pkgname | cut -d ' ' -f 1`
- pkgname=${pkgname:2}
- fi
- if [ ! -z "$pkgname" ]; then
- pkg_info=$(pacman -Qi $pkgname 2>&1)
- if [ $? -eq 0 ]; then
- inst_version=`echo "$pkg_info" | grep -m 1 Version | sed s'/Version ://g' | xargs`
- if echo $inst_version | grep ':'; then
- inst_version=`echo $inst_version | rev | cut -d ':' -f 1 | rev`
- fi
- echo "--- Found installed package "$pkgname" version: "$inst_version
- git reset --hard
- git pull
- pkgver=$(grep -m 1 pkgver PKGBUILD | cut -d '=' -f 2 | xargs)
- pkgrel=$(grep -m 1 pkgrel PKGBUILD | cut -d '=' -f 2 | xargs)
- git_version=${pkgver}"-"${pkgrel}
- echo "------ Git version of this package is "$git_version
- if [ "$inst_version" != "$git_version" ]; then
- echo "--------- Package "$pkgname" installed version "$inst_version" has git version "$git_version", will reinstall"
- makepkg --noconfirm -sri
- fi
- fi
- fi
- fi
- popd > /dev/null
- done
- popd > /dev/null
Advertisement
Add Comment
Please, Sign In to add comment