www/53386: [patch] Fix url.cgi problem with deleted pkg-descr files

Simon L. Nielsen simon at nitro.dk
Mon Jun 16 15:30:17 PDT 2003


>Number:         53386
>Category:       www
>Synopsis:       [patch] Fix url.cgi problem with deleted pkg-descr files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-www
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 16 15:30:15 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Simon L. Nielsen
>Release:        FreeBSD 5.1-BETA i386
>Organization:
>Environment:
>Description:
When a port's is pkg-descr file is deleted (cvs rm'ed), e.g. if the
port is changed into a slave port, it can occour that the description
link in ports.cgi does not work.  This is due to url.cgi not looking
for the description file in Attic/.

The next time INDEX is regenerated the problem should go away, since
the INDEX generation should correct the path to the real pkg-desc
file.

This has been reported for different ports a few times on the www
mailing list, last time by Jacob Atzen <jacob at aub.dk> with regards to
the mod_php4 port, which has been changed into a slave port.

The attach patch fixes this by making url.cgi look for pkg-descr in
Attic/ if it can't find the file in the expected directory.

This has been tested on 5.1-BETA with perl v5.6.1 and 4.8-STABLE with
perl v5.005_03.

>How-To-Repeat:
Go to
http://www.freebsd.org/cgi/ports.cgi?query=mod_php4&stype=all
and click the Description link.
>Fix:
--- www-urlcgi-attic.patch begins here ---
Index: url.cgi
===================================================================
RCS file: /home/ncvs/www/en/cgi/url.cgi,v
retrieving revision 1.31
diff -u -d -r1.31 url.cgi
--- url.cgi	2 May 2002 14:21:40 -0000	1.31
+++ url.cgi	16 Jun 2003 21:32:51 -0000
@@ -69,15 +69,26 @@
     print &short_html_header($file);
 }
 
+my $validfilename = $file =~ m%^ports/[\w-]+/\w[\w-+.]*/pkg-descr%;
+my $atticfile = $file;
+$atticfile =~ s%^(.*)/([^/]+)$%$1/Attic/$2%;
+
 # do cvs checkout 
 my($cvsroot) = '/usr/local/www/cvsroot/FreeBSD';
-if ($file =~ m%^ports/[\w-]+/\w[\w-+.]*/pkg-descr% && -f "$cvsroot/$file,v") {
-    open(CO, "-|") || 
-	exec ('/usr/bin/co', '-p', '-q', "$cvsroot/$file,v") ||
-	die "exec co -pq $cvsroot/$file,v: $!\n";
-} 
+my $realfile;
+if ($validfilename && -f "$cvsroot/$file,v") {
+    $realfile = $file;
+} elsif ($validfilename && -f "$cvsroot/$atticfile,v") {
+    $realfile = $atticfile;
+} else {
+    $validfilename = 0;
+}
 
-else {
+if($validfilename) {
+    open(CO, "-|") ||
+	exec ('/usr/bin/co', '-p', '-q', "$cvsroot/$realfile,v") ||
+	die "exec co -pq $cvsroot/$realfile,v: $!\n";
+} else {
     print "<p>The port specified does not exist, or has an invalid name: <p>",
 	  "<blockquote>$file</blockquote>\n";
 
--- www-urlcgi-attic.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-www mailing list