From dd0d8a097d4cd300016684469a61c6e8f01034aa Mon Sep 17 00:00:00 2001 From: Esteban Carnevale Date: Tue, 16 Dec 2014 12:27:13 -0300 Subject: libredbdiff-standalone: Improve options, change for expac 4-2.parabola1 with expac version test --- libredbdiff-standalone | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libredbdiff-standalone b/libredbdiff-standalone index 4ca81c0..25f7ebe 100755 --- a/libredbdiff-standalone +++ b/libredbdiff-standalone @@ -27,7 +27,7 @@ error() { echo -e "Error. $@" > /dev/stderr ; exit 1; } if [[ $# == 1 ]] ; then [[ $1 == -n ]] && UPDATE=0 - [[ $1 == -h ]] && { echo -e "${name}. Show [libre] packages that need to be updated from Arch repositories.\n\nUsage:\nlibredbdiff\t\tInitialize (first run) or update pacman databases\nlibredbdiff -n\t\tPrint results" ; exit 0 ; } + [[ $1 =~ ^(-h|--help)$ ]] && { echo -e "${name}. Show [libre] packages that need to be updated from Arch repositories.\n\nUsage:\nlibredbdiff\t\tInitialize (first run) or update pacman databases\nlibredbdiff -n\t\tPrint results" ; exit 0 ; } elif [[ $# != 0 ]] ; then error "Bad arguments. Nothing done." else @@ -118,6 +118,23 @@ fi unset provides ver verarch declare -Ax provides ver verarch +expac_version_test() { +if ! pkgname="$(pacman -Qoq expac)" ; then + echo "The command expac could not be found installed. The package pcr/expac-relative 4-2.parabola1 (or later) must be installed." >&2 + exit 1 + elif [[ $pkgname == expac-git ]] ; then + true + elif [[ $pkgname == expac-relative ]] ; then + if [[ $(vercmp "$(expac %v expac-relative)" 4-2.parabola1) != -1 ]] ; then + echo "The version of expac-relative installed on the system is lower than needed." >&2 + exit 1 + fi + else + echo "expac command must be provided by pcr/expac-relative version 4-2.parabola1 (or later). This package must be installed." >&2 + exit 1 + fi +} + comparepkgs() { if [[ ${verarch["$pkgname"]} ]] ; then cmp=$(vercmp ${ver["$pkgname"]} ${verarch["$pkgname"]}) @@ -134,11 +151,13 @@ comparepkgs() { fi } +expac_version_test + while read -a line ; do verarch["${line[0]}"]="${line[1]}" done < <(pacman --dbpath "${dbpatharch}" --config "${conffilearch}" -Ss | grep -v '^ ' | awk -F/ '{print $2}') -expac -b "${dbpath}" -c "${conffile}" -Ss '%r/%n %v %S' | awk -F/ '$1 == "libre" {print $2}' | while read -a line ; do +expac --config "${conffile}" -S '%r/%n %v %S' | awk -F/ '$1 == "libre" {print $2}' | while read -a line ; do ver["${line[0]}"]="${line[1]}" provides[${line[0]}]="${line[@]:2}" pkgname=${line[0]} -- cgit v1.2.3