mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
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:
parent
1e9bb4ec3a
commit
af4cf20b46
|
@ -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…
Reference in a new issue