Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 12, 2017
Merged

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

merged 1 commit into from
Dec 12, 2017

Conversation

filippog
Copy link
Contributor

I found this case mostly on machines with "point release" upgrades pending, e.g. like the recent jessie and stretch updates. What do you think @SuperQ ?

@SuperQ
Copy link
Member

SuperQ commented Dec 10, 2017

Hrmm, do you have some sample output (just the Inst lines is fine)?

@SuperQ
Copy link
Member

SuperQ commented Dec 10, 2017

Ahh, ok, I found one:

Inst base-files [9.9+deb9u1] (9.9+deb9u3 Debian:9.3/stable [amd64])
Inst tzdata [2017b-1] (2017c-0+deb9u1 Debian:9.3/stable, Debian:stable-updates [all])

@SuperQ
Copy link
Member

SuperQ commented Dec 10, 2017

How about simplifying the 2nd awk with this first awk:

/usr/bin/apt-get --just-print upgrade \
  | /usr/bin/awk -F'[()]' '/^Inst/ { sub("^[^ ]+ ", "", $2); sub(" \\[", "|", $2); sub("\\]", "", $2);; print $2 }'

@filippog
Copy link
Contributor Author

Yup | as a separator would work too, though how the final awk would look like?

@SuperQ
Copy link
Member

SuperQ commented Dec 11, 2017

Right, how about we stick to a space separator, and just eliminate all the other spaces.

/usr/bin/awk -F'[()]' \
  '/^Inst/ {
    sub("^[^ ]+ ", "", $2);
    sub("\\[", " ", $2);
    sub(" ", "", $2);
    sub("\\]", "", $2);
    print $2
  }'

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.
@filippog
Copy link
Contributor Author

Indeed that's even simpler, PR updated, PTAL!

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SuperQ SuperQ merged commit af4cf20 into prometheus:master Dec 12, 2017
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants