Skip to content

Instantly share code, notes, and snippets.

@Yoplitein
Created September 13, 2014 10:43
Show Gist options
  • Save Yoplitein/98eddf7e9f1f74e61b29 to your computer and use it in GitHub Desktop.
Save Yoplitein/98eddf7e9f1f74e61b29 to your computer and use it in GitHub Desktop.
Simple script to alert you, via email (through cron,) of packages with upgrades on Arch
#!/bin/bash
cacheFile=~/bin/updates.cache
cacheFileNew=~/bin/updates-new.cache
function getignores()
{
#list ignored packages here, like so:
#echo "packagename"
#TODO: actually parse pacman.conf
}
function getupdates()
{
res="$(checkupdates)"
for ignore in $(getignores); do
res="$(echo "$res" | grep -v "^$ignore$")"
done
for package in $res; do
echo $package
done
}
function getdiff()
{
echo "$(diff $cacheFile $cacheFileNew | grep "^>" | cut -d " " -f 2)"
}
function main()
{
echo "$(getupdates)" > $cacheFileNew
diff="$(getdiff)"
if [ "$diff" != "" ]; then
echo "The following packages are ready for upgrade:"
echo "$diff"
echo "$(cat $cacheFileNew)" > $cacheFile
fi
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment