arch-update icon indicating copy to clipboard operation
arch-update copied to clipboard

Only show major updates

Open auipga opened this issue 3 years ago • 3 comments

Is there a way to only show major updates and hide the minor ones? I found nothing about this topic.

auipga avatar Nov 07 '22 22:11 auipga

One can easily make a little script to filter out whatever is shown and use it as "check command" instead of default checkupdates script. From the extension, there is no filter option.

RaphaelRochet avatar Nov 08 '22 07:11 RaphaelRochet

Ok, thanks. This is a first working example of checkupgrade-filter Usage:

  1. checkupgrade-filter like checkupgrade, unaltered
  2. checkupgrade-filter --major only major updates (X.x.x-x)
  3. checkupgrade-filter --minor only major updates (x.X.x-x)
  4. checkupgrade-filter --patch only major updates (x.x.X-x)
  5. checkupgrade-filter --release only major updates (x.x.x-X)
  6. combine previous arguments as you wish: checkupgrade-filter --major --release
  7. checkupgrade-filter --minor-up short for --major --minor
  8. checkupgrade-filter --patch-up short for --major --minor --patch In cases 6-8 the packages are grouped in this order: major, minor, patch, release.
#!/usr/bin/env bash

if [ -z $1 ]; then
	checkupdates
	exit $!
fi

major=""
minor=""
patch=""
release=""

while read line; do
	words=(${line// / }) # array ("cryptsetup", "2.5.0-3", "->", "2.5.0-4")
	pkg_name=${words[0]} # "cryptsetup"
	pkg_vold=${words[1]} # "2.5.0-3"
	pkg_vnew=${words[3]} # "2.5.0-4"

	vold_=( ${pkg_vold//./ } ) # array ("2", "5", "0-3")
	vnew_=( ${pkg_vnew//./ } ) # array ("2", "5", "0-4")
	
	if [[ ${vold_[0]} != ${vnew_[0]} ]]; then # "2"!="2"
		major+="${line}\n"
	elif [[ ${vold_[1]} != ${vnew_[1]} ]]; then # "5"!="5"
		minor+="${line}\n"
	elif [[ ${vold_[2]} != ${vnew_[2]} ]]; then # "0-3"!="0-4"
		if [[ ${pkg_vold##*-} == ${pkg_vnew##*-} ]]; then # "3"=="4"
			patch+="${line}\n"
		else
			release+="${line}\n" # example goes here
		fi
	fi
done < <(checkupdates)

if [ $1 == --patch-up ]; then
	echo -en ${major}
	echo -en ${minor}
	echo -en ${patch}
elif [ $1 == --minor-up ]; then
	echo -en ${major}
	echo -en ${minor}
else
	[[ "$*" =~ "--major" ]]    && echo -en ${major}
	[[ "$*" =~ "--minor" ]]    && echo -en ${minor}
	[[ "$*" =~ "--patch" ]]    && echo -en ${patch}
	[[ "$*" =~ "--release" ]]  && echo -en ${release}
fi

auipga avatar Nov 09 '22 15:11 auipga

You could add this to the wiki section, for others to find it ;)

RaphaelRochet avatar Nov 09 '22 15:11 RaphaelRochet