aboutsummaryrefslogtreecommitdiff
path: root/repos/outdated.sh
blob: 2dc1743ec0b03b5fdac588c2cd61752556c175c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh

fetchversion() {
	curl -s -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" https://repology.org/badge/latest-versions/$1.svg \
	| sed 's/, /,/g' \
	| tr ' ' '\n' \
	| grep -Eo 'central">.*<' \
	| sed 's/<.*//;s/.*>//' \
	| tr ',' '\n' \
	| tail -n1
}

while [ "$1" ]; do
	unset curver port
	[ -f $1/abuild ] && port=${1%/}
	[ "$port" ] || { shift; continue; }
	name=${1#*/}; name=${name%/}
	curver=$(grep ^version= $port/abuild | awk -F = '{print $2}')
	[ "$curver" ] || { shift; continue; }
	case $name in
		python-*) name=python:${name#python-};;
		perl-*) name=perl:${name#perl-};;
	esac
	# clear newver function
	unset -f newver
	if [ -s $port/outdated ]; then
		. $port/outdated
	fi
	printf " checking $1\033[0K\r"
	newver=$(fetchversion $name)
	if [ "$(command -v newver)" ]; then
		newver
	fi
	touch outdate.error outdate.list
	sed "\|^$port .*|d" -i outdate.error
	sed "\|^$port .*|d" -i outdate.list
	if [ ! "$newver" ] || [ "$newver" = '-' ]; then
		echo "$port $curver" >> outdate.error
	elif [ "$curver" != "$newver" ]; then
		echo "$port $newver ($curver)"
		echo "$port $newver ($curver)" >> outdate.list
	fi
	shift
done
printf "\033[0K"