Skip to content

Instantly share code, notes, and snippets.

@amennelet
Created July 31, 2012 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amennelet/3215172 to your computer and use it in GitHub Desktop.
Save amennelet/3215172 to your computer and use it in GitHub Desktop.
Searh package from AUR and update if needed
#!/bin/sh
AUR_URL="https://aur.archlinux.org"
echo search aur package
# list all package explicitly installed
for package in `pacman -Qe|sed -e "s/\([^\ ]*\)\ .*/\1/"`; do
# search for package with "Unknown Packager" (because install from makepgk not correctly setup)
if [[ `pacman -Qi $package|grep "Unknown Packager"` == *"Unknown Packager" ]]; then
# get the current version installed
version_cur=`pacman -Q $package|cut -d" " -f2`
# get the AUR version and url
package_info=`curl -s "$AUR_URL/rpc.php?type=info&arg=$package"`
version_new=`echo $package_info|sed -e "s/.*\"Version\":\"\([^\"]*\)\".*/\1/"`
package_url=`echo $package_info|sed -e "s/.*\"URLPath\":\"\([^\"]*\)\".*/\1/"|sed -e "s,\\\\\\,,g"`
printf "found %s (%s)\t%s\t%s\n" $package $package_url $version_cur $version_new
# if version differ, then ask for installation
if [[ $version_cur != $version_new ]];then
read -p "Update $package from $version_cur to $version_new ?(y/n)"
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo do update $package
# get the tar.gz from AUR
curl $AUR_URL$package_url -o $package.tar.gz
# unzip
tar zxvf $package.tar.gz
# makepkg -s
cd $package
makepkg -s
sudo pacman -U $package*
# delete the tar.gz
cd ..
rm -r $package
rm $package.tar.gz
fi
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment