#!/bin/sh # xnuxnu - upstream version checker for XBPS templates pkgname=$1 orig_pkgname=$pkgname IFS=' ' 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 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";; *code.google.com*|*googlecode*) url="http://code.google.com/p/$pkgname/downloads/list";; *cpan.*) 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" 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