summary refs log tree commit diff
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
parent3fe886613dd2d8ba1f8241ccfcf7a1f447d418ae (diff)
downloadxtools-f8d40b409c4d341be1d7f574ef045f980d05416f.tar.gz
xtools-f8d40b409c4d341be1d7f574ef045f980d05416f.tar.xz
xtools-f8d40b409c4d341be1d7f574ef045f980d05416f.zip
add xnuxnu
-rw-r--r--README1
-rwxr-xr-xxnuxnu30
2 files changed, 31 insertions, 0 deletions
diff --git a/README b/README
index 5822c02..6905cf7 100644
--- a/README
+++ b/README
@@ -11,6 +11,7 @@ https://github.com/voidlinux/xbps
   xlocate PATTERN - locate files in all XBPS packages
   xlog PKG - open commit log for XBPS template
   xls PKGS... - list files contained in PKGS (including binpkgs)
+  xnuxnu PKG - upstream version checker for XBPS templates
   xq PKGS... - query information about XBPS package
   xsrc PKG - list source files for XBPS template
 
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