Browse Source

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.
pull/762/head
Filippo Giunchedi 7 years ago committed by Ben Kochie
parent
commit
af4cf20b46
  1. 4
      text_collector_examples/apt.sh

4
text_collector_examples/apt.sh

@ -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);

Loading…
Cancel
Save