#!/bin/bash # ------- # File: version-candidate-check # Description: Compares current source version with apt-cache policy candidate # The intended use is to detect Ubuntu version upgrades of mod(ified) packages # Author: Luis Garcia Gisbert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- . /usr/share/lliurex/llxcfg-dev/llxcfg-dev.sh test_dir(){ [ "$1" ] || return 1 [ -d "$1" ] || return 1 [ -r "$1/debian/control" ] || return 1 return 0 } get_candidate(){ REG_EXP="^[[:blank:]]\+Candidate:[[:blank:]]\+" LANG=C apt-cache policy "$1" 2>/dev/null |sed -ne "/$REG_EXP/s%$REG_EXP%%p" } test_version(){ CURDIR="$(pwd)" cd "$1" CURRENT_V="$(dl_get_version)" for p in $(dl_list_binpkgs) ; do CANDIDATE_V="$(get_candidate "$p")" printf "Source: $(dl_show_field Source SOURCE) . Package: $p ... " if [ "$CANDIDATE_V" ] ; then rc=0 dpkg --compare-versions "$CANDIDATE_V" eq "$CURRENT_V" || rc=$? if [ $rc -eq 0 ] ; then echo "OK (Current version is equal to candidate)" else rc=0 dpkg --compare-versions "$CANDIDATE_V" lt "$CURRENT_V" || rc=$? if [ $rc -eq 0 ] ; then echo "OK (Current version greather than candidate)" else echo "WARNING: candidate version ($CANDIDATE_V) is greater than current ($CURRENT_V)" fi fi else echo "OK (no candidate)" fi done cd "$CURDIR" } # main if test_dir "./" ; then echo "Working in current directory" test_version "./" else echo "Searching subdirectories" for d in $(find ./ -maxdepth 1 -mindepth 1 -xtype d) ; do if test_dir "$d" ; then test_version "$d" else echo "Skipping directory $d" fi done fi exit 0