apt.sh: handle multiple origins in apt-get output (#757)

It might happen that a given upgrade comes from multiple origins, in
which case the origins are separated by ", " and thus breaking
whitespace-based split. For example:

Inst package [1.2.3] (1.2.4 Debian:8.10/oldstable, Debian-Security:8/oldstable [amd64])

To workaround this case, mangle the apt-get output to remove whitespaces from
the origins list.
This commit is contained in:
Filippo Giunchedi 2017-12-12 10:45:59 +01:00 committed by Ben Kochie
parent 1e9bb4ec3a
commit af4cf20b46

View file

@ -5,7 +5,9 @@
# Author: Ben Kochie <superq@gmail.com>
upgrades="$(/usr/bin/apt-get --just-print upgrade \
| /usr/bin/awk '/^Inst/ {print $5, $6}' \
| /usr/bin/awk -F'[()]' \
'/^Inst/ { sub("^[^ ]+ ", "", $2); sub("\\[", " ", $2);
sub(" ", "", $2); sub("\\]", "", $2); print $2 }'
| /usr/bin/sort \
| /usr/bin/uniq -c \
| awk '{ gsub(/\\\\/, "\\\\", $2); gsub(/\"/, "\\\"", $2);