diff options
author | Jonas Smedegaard <dr@jones.dk> | 2017-06-23 12:31:11 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2017-06-23 13:05:35 +0200 |
commit | 0d419d1ab05ae63ca19c8ef00ab87fcc2c141ef5 (patch) | |
tree | c1399b6f29ef522a981893723c9849955229a05c | |
parent | 08a8d8f4cfdfa200861c650012dcb2f74edf7819 (diff) |
Tidy pkgarchs.sh: Use perl for essential parts, wrapped as function.
-rw-r--r-- | debian/pkgarchs.sh | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/debian/pkgarchs.sh b/debian/pkgarchs.sh index e8b15fb..c6e5fad 100644 --- a/debian/pkgarchs.sh +++ b/debian/pkgarchs.sh @@ -18,14 +18,13 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA. # -# Depends: devscripts liburi-perl curl ca-certificates +# Depends: libwww-perl set -e defaultsuite="unstable" pkgsuite="$(dpkg-parsechangelog -S Distribution)" -pkg="$1" suite="$pkgsuite" case "$pkgsuite" in @@ -41,12 +40,15 @@ case "$pkgsuite" in ;; esac -echo >&2 "INFO: Resolving architectures for package \"$pkg\" through rmadison Internet request." -dump="$(rmadison -s "$suite" "$pkg")" -archs="$(echo "$dump" \ - | awk -F'|' '{ print $4 }' \ - | sed 's/source,//;s/ //g;s/,/\n/g' \ - | LANG=C sort -u \ - | tr '\n' ' ' \ - | sed 's/^ //;s/ $/\n/;s/\ball\b/any/')" -echo "${archs:-none}" +pkgarchs() { + echo >&2 "INFO: Query Debian for package \"$1\" architectures..." + GET "https://qa.debian.org/madison.php?package=$1&table=debian&s=$suite&text=on" \ + | perl -MList::Util=uniq -F'\|\s*' \ + -E 'for (split(/[,\s]+/, pop @F)) {' \ + -E 'next if ($_ eq "source");' \ + -E '$_ = "any" if ($_ eq "all");' \ + -E 'push @a, $_};' \ + -E 'END{if (@a) {say join(" ", uniq sort @a)} else {say "none"}}' +} + +pkgarchs "$1" |