summary refs log tree commit diff
path: root/xnuxnu
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2014-09-06 16:45:40 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2014-09-06 16:45:40 +0200
commitf8d40b409c4d341be1d7f574ef045f980d05416f (patch)
tree95fab4cd49cccf3adfb66fe243bd0b43336a8c7f /xnuxnu
parent3fe886613dd2d8ba1f8241ccfcf7a1f447d418ae (diff)
downloadxtools-f8d40b409c4d341be1d7f574ef045f980d05416f.tar.gz
xtools-f8d40b409c4d341be1d7f574ef045f980d05416f.tar.xz
xtools-f8d40b409c4d341be1d7f574ef045f980d05416f.zip
add xnuxnu
Diffstat (limited to 'xnuxnu')
-rwxr-xr-xxnuxnu30
1 files changed, 30 insertions, 0 deletions
diff --git a/xnuxnu b/xnuxnu
new file mode 100755
index 0000000..aaf0105
--- /dev/null
+++ b/xnuxnu
@@ -0,0 +1,30 @@
+#!/bin/sh
+# xnuxnu - upstream version checker for XBPS templates
+
+pkgname=$1
+IFS='
+'
+
+export LC_ALL=C
+
+./xbps-src show "$1" |
+	sed -n '/distfiles:/{s/[^:]*:[\t]*//;s|/[^/]*$|/|p};
+		/Upstream URL/s/[^:]*:[\t]*//p' |
+	while read url; do
+		rx="\b$pkgname[-_]((src|source)[-_])?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|t[bglx]z|tbz2|zip))\b"
+		case "$url" in
+			*sourceforge.net/sourceforge*)
+				url="http://sourceforge.net/projects/$pkgname/rss?limit=200";;
+			*cpan.org*)
+				pkgname=${pkgname#perl-};;
+			*github.com*)
+				githubname="$(echo $url | cut -d/ -f4,5)"
+				url="https://api.github.com/repos/$githubname/tags"
+				rx='"name":\s*"\K[^\d]*([\d\.]+)(?=")';;
+		esac
+
+		echo "fetching $url" 2>/dev/null
+		curl -A xnuxnu -Ls $url |
+			grep -Po -i "$rx" |
+		       	sort -Vu
+	done