Skip to content

Instantly share code, notes, and snippets.

@sulincix
Last active January 15, 2024 13:27
Show Gist options
  • Save sulincix/b722bbf21daa75eb64d9129aefbc630c to your computer and use it in GitHub Desktop.
Save sulincix/b722bbf21daa75eb64d9129aefbc630c to your computer and use it in GitHub Desktop.
Check ymp latests from arch
#!/bin/bash
set +e
f=$(mktemp)
red="\033[31;1m"
yellow="\033[33;1m"
reset="\033[;0m"
check_out_of_date(){
link=$(curl https://archlinux.org/packages/?q=$1 | grep -v unstable | grep ">$1<" | grep "<td><a href=" | head -n1 | cut -f2 -d"\"")
if [[ $link == "" ]] ; then
return
fi
curl https://archlinux.org/$link > $f
# check outdate
ver=$(cat $f | grep "<h2>" | grep "$1" | head -n 1 \
| cut -f2 -d">" | cut -f1 -d"<" \
| cut -f2 -d" " | cut -f1 -d"-" | cut -f2 -d":")
if [[ "$ver" == "" ]] ; then
return
elif is_ood $ver $2 ; then
echo -e "${red}$1${reset}\t(${yellow}$ver - $2${reset}) out of date."
fi
}
is_ood(){
data=$(echo "$2\n$1" | sort -V)
[[ "$data" != "$1\n$2" ]]
return $?
}
get_ympbuild_ver(){
bash -c 'set +e; source '$1' &>/dev/null ; echo $version'
}
if [[ ! -d $1 ]] ; then
echo "Usage: check.sh <ymp-spec-repository>"
exit 1
fi
dir="$(realpath $1)"
find $dir/* -type f | grep ympbuild | xargs dirname | \
while read line ; do
name=$(basename $line)
name=$(echo $name | sed "s/py3-/python-/g")
echo "Check:" $(basename $line)
check_out_of_date ${name,,} $(get_ympbuild_ver $line/ympbuild) 2>/dev/null
done
rm -f $f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment