Hey, you've N outofdated packages (Part II)

I got some criticts about my previous post Hey, you’ve N outofdated packages!. People say it’s unsafe, but I think that if you know how the script works and you understand that you’ve to update the system before install everything the script isn’t really dangerous. Yes, that’s the issue.

Anyway, thanks to keenerd and falconindy today I’m writing the safe way to get notifications about outofdated packages on your system.

The first script must be changed with this, put it under /etc/cron.hourly/:



[[ ! -d $fakedb ]] && { mkdir -p "$fakedb/sync" || exit 1; }
[[ ! -L $fakedb/local ]] && { ln -s "$realdb/local" "$fakedb" || exit 2; }

exec fakeroot pacman --dbpath "$fakedb" -Sy

This script creates a temporary copy of your local pacman database and download the fresh package databases in it. It doesn’t touch your local pacman database then.

The second script to get the notifications remain the same as before, but this time we have to pass the $fakedb path as database path for pacman, here the script:



pkgs=$(pacman --dbpath "$fakedb" -Qqu | wc -l)
aurpkgs=$(cower -udf 2> /dev/null | wc -l)

unset msg1
unset msg2
unset packages

if [[ ${pkgs} -gt 0 ]]; then
    msg1="${pkgs} in pacman"

if [[ ${aurpkgs} -gt 0 ]]; then
    msg2=" ${aurpkgs} in AUR"

let packages=${pkgs}+${aurpkgs}
if [[ ${packages} -gt 0 ]]; then
    kdialog --title "Out-Of-Date packages" --passivepopup "There are ${packages} outofdated packages (${msg1}${msg2})" 10

Enjoy the safe way then :)

Tags: arch linux, howtos

By Andrea Scarpino on 2011-05-25