Subject: Re: using revbump.pl questions
To: Jeremy C. Reed <reed@reedmedia.net>
From: Quentin Garnier <netbsd@quatriemek.com>
List: tech-pkg
Date: 01/03/2004 12:41:24
This is a multi-part message in MIME format.

--Multipart=_Sat__3_Jan_2004_12_41_24_+0100_Z+vO9Ierk3wkKWHc
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Le Sat, 3 Jan 2004 00:52:00 -0800 (PST)
Jeremy C. Reed a ecrit :
[...]
> Then it had only a few left over:
> 
> chat/xchat-gnome
> devel/GConf2-ui
> games/rocksndiamonds-sdl
> graphics/p5-PerlMagick
> mail/sylpheed-claws-image-viewer
> print/ghostscript-esp
> print/php4-pdflib
> wm/icewm-gnome
> wm/icewm-imlib
> www/links-gui

If my reading of revbump.pl is correct, those packages lack both a
PKGREVISION line and a CATEGORIES line, presumably because the latter is
shared through a "Makefile.common"-like inclusion.  I think that if
revbump.pl is giving up for those packages, it is mostly because they
obviously don't pass pkglint, thus it doesn't know where to put the
PKGREVISION line.

> My question is: should I bump wm/icewm/Makefile.common even though it
> doesn't appear to use tiff because it is common for icewm-gnome and
> icewm-imlib?
> 
> Or should I just bump the icewm-gnome and icewm-imlib Makefiles?
> 
> It seems like later someone could use PKGREVISION in
> wm/icewm/Makefile.common and it will be different from icewm-gnome and
> icewm-imlib Makefiles.
> 
> What should I do?

I think PKGREVISION should never be shared by several packages (read
binary packages), because if there are differences between two packages,
then there are reasons for revision bump for one and not the other.

So my take is to bump revision for both icewm-gnome and icewm-imlib,
because then you might have to bump revision for only icewm-gnome the day
gnome-libs are updated.

About the location of the PKGREVISION line, following pkglint-ing strictly
seems like the right thing to do, but it means we should adopt a stricter
policy for Makefile, notably that CATEGORIES, too, is not shareable,
though sometimes it doesn't really make sense.

I think we can allow an automatic addition of the PKGREVISION line,
provided it is advertised, and when it is time for the maintainer to
change something in the Makefile, she will reformat the line correctly.

What do you think of the attached patch?

-- 
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.

--Multipart=_Sat__3_Jan_2004_12_41_24_+0100_Z+vO9Ierk3wkKWHc
Content-Type: text/plain;
 name="diff"
Content-Disposition: attachment;
 filename="diff"
Content-Transfer-Encoding: 7bit

--- revbump.pl	2004-01-03 12:38:14.000000000 +0100
+++ revbump.pl.new	2004-01-03 12:39:18.000000000 +0100
@@ -54,7 +54,7 @@
 
 sub revbump {
     my $pkgdir = shift;
-    my ($pkg, $pkgver, $error, $done, $rev, $oldmk, $newmk);
+    my ($pkg, $pkgver, $error, $done, $rev, $oldmk, $newmk, $state);
     local (*OLDMK, *MAKE);
 
     $pkgdir =~ /\/(.*)$/;
@@ -63,18 +63,13 @@
     $oldmk = "$PKGSRCDIR/$pkgdir/Makefile";
     open(OLDMK, $oldmk);
     $error = 0;
+    $state = 0; # Beginning of file, for second parsing
     while (<OLDMK>) {
-        last if (/^PKGREVISION/);
-        if (/^\.include.*Makefile\..*/) {
-            $error = 1;
+        if (/^PKGREVISION/) {
+            $state = -1; # To prevent any line addition
             last;
         }
     }
-    if ($error == 1) {
-        close(OLDMK);
-        newchanges($pkg, "FIXME");
-        return 0;
-    }
 
     seek(OLDMK, 0, 0);
     $newmk = "$oldmk.new";
@@ -82,6 +77,15 @@
 
     $done = 0;
     while (<OLDMK>) {
+        if ($state == 0) {
+            if (/^#/) {
+                print NEWMK $_;
+                next;
+            } else {
+               $state = 1; # First non comment line of the first block
+                           # If it is an empty line, it must be skipped
+            }
+        }
         if ($done == 0 && /^PKGREVISION=([ \t]+)([0-9]+)$/) {
             $done = $2 + 1;
             print NEWMK "PKGREVISION=${1}${done}\n";
@@ -89,8 +93,14 @@
             print NEWMK "PKGREVISION=${1}1\n";
             print NEWMK $_;
             $done = 1;
+        } elsif ($done == 0 && $state == 2 && /^$/) {
+            print NEWMK '# Added automatically by revbump.pl $Revision$'."\n";
+            print NEWMK "PKGREVISION=\t1\n";
+            print NEWMK $_;
+            $done = 1;
         } else {
             print NEWMK $_;
+            $state = 2 if ($state != -1); # At least first real block
         }
     }
 

--Multipart=_Sat__3_Jan_2004_12_41_24_+0100_Z+vO9Ierk3wkKWHc--