about summary refs log tree commit diff
diff options
context:
space:
mode:
-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