This site is now 100% read-only, and retired.

XML logo

Detecting upstream changes
Posted by mcortese on Fri 15 Oct 2010 at 11:15
Tags: none.
Waiting for Debian CUT, my upgrading scheme has always been: upgrade when there's and upstream change, don't upgrade when there's a Debian release adjustment. I can tell in which of the two situations I am by checking whether the major version number (the part before the dash) changes or not.

To make it automatic is just 3 steps away:

  1. Get from aptitude the list of packages ready for upgrade (aptitude search '~U'), complete with the current and new versions (-F '%p %V %v').
  2. Pass the list through awk, which splits the version strings at the dash (split($2,Cur,"-");split($3,New,"-")) and prints the package name only if the major versions differ (if (Cur[1] != New[1]) print $1).
  3. If the output is not empty ([ -s file ]) upgrade.

The final script (omitting sanity checks etc.) is following.

aptitude search '~U' -F '%p %?V %?v' | awk \
  '{split($2,Cur,"-");split($3,New,"-"); if (Cur[1] != New[1]) print $1}' >$tmp
[ -s $tmp ] && aptitude install $(<$tmp)
rm $tmp