Created
May 13, 2022 10:07
-
-
Save tbruckmaier/4e80ddf163319349a24b3664b1be156c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bug report to introduce the feature in pamac: | |
# https://gitlab.manjaro.org/applications/pamac/-/issues/131 | |
# how many version parts shall be compared? Default to 1 (only major versions) | |
N=${1-1} | |
{ | |
pamac checkupdates | |
# cat "./pamac-checkupdates" | |
} | { | |
# only consider lines with a proper update | |
grep "\->" | |
} | { | |
# squeeze multiple whitespaces, so cut can properly detect the columns | |
# https://unix.stackexchange.com/questions/109835/how-do-i-use-cut-to-separate-by-multiple-whitespace | |
tr -s " " | |
} | { | |
# extract interesting columns, also ignore any non-matching lines | |
cut --only-delimited -d" " -f 1,2,3,4,5 | |
} | { | |
while read line; do | |
# https://stackoverflow.com/questions/10520623/how-to-split-one-string-into-multiple-variables-in-bash-shell | |
IFS=" " read name v1 sep v2 repository <<< "$line" | |
# get the first N parts of each version. Consider only lines where these | |
# two parts differ | |
v1_prefix=$(echo "$v1" | sed -r "s/(([0-9]+[\.\-\:]){$N}).*/\1/") | |
v2_prefix=$(echo "$v2" | sed -r "s/(([0-9]+[\.\-\:]){$N}).*/\1/") | |
test "$v1_prefix" != "$v2_prefix" && echo "$line" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Show pamac updates where the major version number has changed:
To compare the first two parts of the version: