Subject: pkg RSS feed broken for pkgs with '-' in name
To: None <tech-pkg@NetBSD.org>
From: Hubert Feyrer <hubert@feyrer.de>
List: tech-pkg
Date: 05/17/2007 13:48:03
I have the NetBSD RSS feeds in my Slashdot sidebar and usually see changes 
in pkgsrc there. Looking closer yesterday, I found that some pkgs link to

 	ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc//README.html

instead of the

 	ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/category/pkg-name/README.html

that's expected. This is due to the pattern matching in the 
pkg-changes2rss script not allowing '-' as valid name in pkg names, which 
is of course not true.

The patch below fixes this, and also allows '/' in a few places that (i 
guess?) were forgotten last time. Results look good to me, but I'd 
appreciate feedback before committing.


  - Hubert


Index: pkg-changes2rss
===================================================================
RCS file: /cvsroot/htutils/changes/pkg-changes2rss,v
retrieving revision 1.2
diff -u -r1.2 pkg-changes2rss
--- pkg-changes2rss	6 Aug 2006 09:43:46 -0000	1.2
+++ pkg-changes2rss	17 May 2007 11:36:11 -0000
@@ -20,14 +20,14 @@
      $link="http://www.NetBSD.org/Changes/pkg-changes.html";

      $found=0;
-    if ( $msg =~ /Added\s*([a-zA-Z0-9-.+_]*)\s/ ) {
+    if ( $msg =~ /Added\s*([a-zA-Z0-9-.+_\/-]*)\s/ ) {
  	$name=$1;

  	$link="$pkgsrcbase/$name/README.html";

-    } elsif ( $msg =~ /Updated?\s*([a-zA-Z0-9-.+_\/]*)\s*to\s*([a-zA-Z0-9-.+_]*)/
-	      or $msg =~ /Upgraded?\s*([a-zA-Z0-9-.+_\/]*)\s*to\s*([a-zA-Z0-9-.+_]*)/
-	      or $msg =~ /Downgraded?\s*([a-zA-Z0-9-.+_\/]*)\s*to\s*([a-zA-Z0-9-.+_]*)/ ) {
+    } elsif ( $msg =~ /Updated?\s*([a-zA-Z0-9-.+_\/-]*)\s*to\s*([a-zA-Z0-9-.+_]*)/
+	      or $msg =~ /Upgraded?\s*([a-zA-Z0-9-.+_\/-]*)\s*to\s*([a-zA-Z0-9-.+_]*)/
+	      or $msg =~ /Downgraded?\s*([a-zA-Z0-9-.+_\/-]*)\s*to\s*([a-zA-Z0-9-.+_]*)/ ) {
  	$name=$1;
  	$vers=$2;

@@ -35,18 +35,18 @@

  	$link="$pkgsrcbase/$name/README.html";

-    } elsif ( $msg =~ /Replaced?\s*([a-zA-Z0-9-.+_\/]*)\s*with\s*([a-zA-Z0-9-.+_]*)/
-	      or $msg =~ /Moved?\s*([a-zA-Z0-9-.+_\/]*)\s*to\s*([a-zA-Z0-9-.+_]*)/
-	      or $msg =~ /Renamed?\s*([a-zA-Z0-9-.+_\/]*)\s*to\s*([a-zA-Z0-9-.+_]*)/ ) {
+    } elsif ( $msg =~ /Replaced?\s*([a-zA-Z0-9-.+_\/-]*)\s*with\s*([a-zA-Z0-9-.+_\/-]*)/
+	      or $msg =~ /Moved?\s*([a-zA-Z0-9-.+_\/-]*)\s*to\s*([a-zA-Z0-9-.+_\/-]*)/
+	      or $msg =~ /Renamed?\s*([a-zA-Z0-9-.+_\/-]*)\s*to\s*([a-zA-Z0-9-.+_\/-]*)/ ) {
  	$old=$1;
  	$name=$2;
  	$found++;

  	$link="$pkgsrcbase/$name/README.html";

-    } elsif ( $msg =~ m|^\s*([a-zA-Z0-9-._\/]*):| or
-	      $msg =~ /Deleted\s*([a-zA-Z0-9-.+_\/]*)\s/ or
-	      $msg =~ /Removed\s*([a-zA-Z0-9-.+_\/]*)\s/ ) {
+    } elsif ( $msg =~ m|^\s*([a-zA-Z0-9-._\/-]*):| or
+	      $msg =~ /Deleted\s*([a-zA-Z0-9-.+_\/-]*)\s/ or
+	      $msg =~ /Removed\s*([a-zA-Z0-9-.+_\/-]*)\s/ ) {
  	# Default link
  	$word=$1;