#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: "$(basename $0)" aur_package_dir"
echo
echo "This simple script when passed a directory where clones of AUR repositories are"
echo "will iterate over then directory by directory and if any of them contains"
echo "a PKGBUILD file then with pkgname will see if this package is installed"
echo "and if it is will perform git reset --hard + git pull, check for pkgver/pkgrel"
echo "against what is installedand call makepkg -sri in case they differ"
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 [ ! -z "$pkgname" ]; then
pkg_info=$(pacman -Qi $pkgname 2>&1)
if [ $? -eq 0 ]; then
installed_version=`echo "$pkg_info" | grep -m 1 Version | sed s'/Version ://g' | xargs`
echo "----- Found installed package "$pkgname" version: "$installed_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 [ "$installed_version" != "$git_ver" ]; then
echo "----- Package "$pkgname" version: "$installed_version" has git version: "$git_version" will reinstall"
makepkg -sri
fi
fi
fi
fi
popd > /dev/null
done
popd > /dev/null
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}