about summary refs log tree commit diff
path: root/xnuxnu
blob: e0195236696f554a2e278b3732fba5a1fa7306d7 (plain) (blame)
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
46
47
48
49
50
51
#!/bin/sh
# xnuxnu PKG - upstream version checker for XBPS templates

pkgname=$1
orig_pkgname=$pkgname
nl='
'

export LC_ALL=C

void_version=$(./xbps-src show "$1" | sed -n '/^version/s/[^:]*:[\t]*//p')

./xbps-src show "$1" |
	sed -n '/^distfiles:/{s/[^:]*:[\t]*//;s|/[^/]*$|/|p};
		/^Upstream URL/s/[^:]*:[\t]*//p' |
	while IFS=$nl read url; do
		rx="(?<!-)\b$pkgname[-_]?((src|source)[-_])?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|shar|t[bglx]z|tbz2|zip))\b"
		case "$url" in
			*sourceforge.net/sourceforge*)
				url="http://sourceforge.net/projects/$pkgname/rss?limit=200";;
			*code.google.com*|*googlecode*)
				url="http://code.google.com/p/$pkgname/downloads/list";;
			*launchpad.net*)
				url="https://launchpad.net/$pkgname/+download";;
			*cpan.*)
				pkgname=${pkgname#perl-};;
			*pypi.python.org*)
				pkgname=${pkgname#python-};;
			*github.com*)
				githubname="$(echo $url | cut -d/ -f4,5)"
				url="https://api.github.com/repos/$githubname/tags"
				rx='"name":\s*"(v|'"$pkgname"'-)?\K[^\d]*([\d\.]+)(?=")';;
		esac

		set -- $(grep "^${orig_pkgname} " xnuxnu-override)
		url=${2:-$url}
		rx=${3:-$rx}

		echo "fetching $url" 1>&2
		curl -A xnuxnu -Ls "$url" |
			grep -Po -i "$rx" |
		       	sort -Vu
	done |
	{ tee /dev/stderr | grep . || echo "NO VERSION found for $orig_pkgname" 1>&2; } |
	while read version; do
		xbps-uhelper cmpver "$orig_pkgname-${void_version}_1" "$orig_pkgname-${version}_1"
		if [ $? = 255 ]; then
			echo "NEWER VERSION $orig_pkgname-$version (have $orig_pkgname-${void_version})"
		fi
	done