Mon Dec 15 23:25:54 2014 UTC ()
Update 2.9 to 2.10
This update is proposed as
  http://mail-index.netbsd.org/tech-pkg/2014/12/08/msg013888.html
- (revbump) convert internal to two pass, and reduce fallout
- (replace-commonbump) new command to replace 'commonbump' to
  'commonbump.replaced'
- (check-cvs-diff) new command to check 'cvs diff -u' if py27,py34, ruby200
  and replace it if exists
  Thanks wiz@ and gdt@ for advice.


(mef)
diff -r1.31 -r1.32 pkgsrc/pkgtools/revbump/Makefile
diff -r1.3 -r1.4 pkgsrc/pkgtools/revbump/PLIST
diff -r0 -r1.1 pkgsrc/pkgtools/revbump/files/check-cvs-diff
diff -r0 -r1.1 pkgsrc/pkgtools/revbump/files/check-cvs-diff.1
diff -r0 -r1.1 pkgsrc/pkgtools/revbump/files/replace-commonbump
diff -r0 -r1.1 pkgsrc/pkgtools/revbump/files/replace-commonbump.1
diff -r1.6 -r1.7 pkgsrc/pkgtools/revbump/files/revbump
diff -r1.21 -r1.22 pkgsrc/pkgtools/revbump/files/revbump.1

cvs diff -r1.31 -r1.32 pkgsrc/pkgtools/revbump/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/revbump/Makefile 2014/10/09 14:06:50 1.31
+++ pkgsrc/pkgtools/revbump/Makefile 2014/12/15 23:25:54 1.32
@@ -1,34 +1,30 @@ @@ -1,34 +1,30 @@
1# $NetBSD: Makefile,v 1.31 2014/10/09 14:06:50 wiz Exp $ 1# $NetBSD: Makefile,v 1.32 2014/12/15 23:25:54 mef Exp $
2 2
3PKGNAME= revbump-2.9 3PKGNAME= revbump-2.10
4CATEGORIES= pkgtools 4CATEGORIES= pkgtools
5 5
6MAINTAINER= wiz@NetBSD.org 6MAINTAINER= wiz@NetBSD.org
7HOMEPAGE= http://www.pkgsrc.org/ 7HOMEPAGE= http://www.pkgsrc.org/
8COMMENT= Tools for bumping PKGREVISIONs (for pkgsrc developers) 8COMMENT= Tools for bumping PKGREVISIONs (for pkgsrc developers)
9LICENSE= modified-bsd 9LICENSE= modified-bsd
10 10
11WRKSRC= ${WRKDIR} 11WRKSRC= ${WRKDIR}
12NO_CONFIGURE= yes 12NO_CONFIGURE= yes
13USE_TOOLS+= perl:run 13USE_TOOLS+= perl:run
14USE_LANGUAGES= # empty 14USE_LANGUAGES= # empty
15 15
16INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 16INSTALLATION_DIRS= bin ${PKGMANDIR}/man1
17 17
18do-build: 18do-build:
 19.for i in blbump finddepends revbump replace-commonbump check-cvs-diff
19 ${SED} -e "s!@PERL@!${PERL5}!g" -e "s! make ! ${MAKE} !g" \ 20 ${SED} -e "s!@PERL@!${PERL5}!g" -e "s! make ! ${MAKE} !g" \
20 ${FILESDIR}/blbump > ${WRKDIR}/blbump 21 ${FILESDIR}/${i} > ${WRKDIR}/${i}
21 ${SED} -e "s!@PERL@!${PERL5}!g" -e "s! make ! ${MAKE} !g" \ 22.endfor
22 ${FILESDIR}/finddepends > ${WRKDIR}/finddepends 
23 ${SED} -e "s!@PERL@!${PERL5}!g" -e "s! make ! ${MAKE} !g" \ 
24 ${FILESDIR}/revbump > ${WRKDIR}/revbump 
25 23
26do-install: 24do-install:
27 ${INSTALL_SCRIPT} ${WRKDIR}/blbump ${DESTDIR}${PREFIX}/bin 25.for i in blbump finddepends revbump replace-commonbump check-cvs-diff
28 ${INSTALL_MAN} ${FILESDIR}/blbump.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1 26 ${INSTALL_SCRIPT} ${WRKDIR}/${i} ${DESTDIR}${PREFIX}/bin
29 ${INSTALL_SCRIPT} ${WRKDIR}/finddepends ${DESTDIR}${PREFIX}/bin 27 ${INSTALL_MAN} ${FILESDIR}/${i}.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
30 ${INSTALL_MAN} ${FILESDIR}/finddepends.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1 28.endfor
31 ${INSTALL_SCRIPT} ${WRKDIR}/revbump ${DESTDIR}${PREFIX}/bin 
32 ${INSTALL_MAN} ${FILESDIR}/revbump.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1 
33 29
34.include "../../mk/bsd.pkg.mk" 30.include "../../mk/bsd.pkg.mk"

cvs diff -r1.3 -r1.4 pkgsrc/pkgtools/revbump/PLIST (expand / switch to unified diff)

--- pkgsrc/pkgtools/revbump/PLIST 2006/03/05 23:35:49 1.3
+++ pkgsrc/pkgtools/revbump/PLIST 2014/12/15 23:25:54 1.4
@@ -1,7 +1,11 @@ @@ -1,7 +1,11 @@
1@comment $NetBSD: PLIST,v 1.3 2006/03/05 23:35:49 wiz Exp $ 1@comment $NetBSD: PLIST,v 1.4 2014/12/15 23:25:54 mef Exp $
2bin/blbump 2bin/blbump
 3bin/check-cvs-diff
3bin/finddepends 4bin/finddepends
 5bin/replace-commonbump
4bin/revbump 6bin/revbump
5man/man1/blbump.1 7man/man1/blbump.1
 8man/man1/check-cvs-diff.1
6man/man1/finddepends.1 9man/man1/finddepends.1
 10man/man1/replace-commonbump.1
7man/man1/revbump.1 11man/man1/revbump.1

File Added: pkgsrc/pkgtools/revbump/files/Attic/check-cvs-diff
#!@PERL@ -w
# -*- perl -*-
#
# read output of (cd /usr/pkgsrc; cvs diff -u ) and check if
# py{27,34} and ruby200 string are left in buildlink3.mk.
# They are then modified to Variable representation.
#"
use strict;
use Getopt::Std;
our(@ARGV);
my (%opts);

my($my_name) = $0;
$my_name =~ s#(.*)/##;

sub usage(){
    print <<HELP;
$my_name: 
    Read cvs diff -u output (of named file) and substitute
    if the string py27, py34 or ruby200 is found in the corresponding
    changes in diff.
Synopsys:
    $my_name  [-h] [-p pkgsrc_dir] [-v] [cvs-diff-u_output-file]
Where:
    -h  Show this help
    -p  pkgsrc directory other than /usr/pkgsrc
    -v  verbose (not actually implemented yet)
    cvs-diff-u_output_file:
        The name of input. Usually the file including 'cvs diff -u' 
        output (default cvs-diff) 
See Also:
    revbump(1) for how to use it.
HELP
}    

sub main() {
    my ($PKGSRCDIR) =  '/usr/pkgsrc';
    my ($CVS_DIFF)  = 'cvs-diff';
    my ($file_to_edit);
    my ($stay, $mod) = (0,0);
    my ($Makefile, $buildlink3, $other) = (0, 0, 0);

    getopts('hvp:',\%opts);
    if ($ARGV[0])   { $CVS_DIFF = $ARGV[0]}
    if ($opts{'p'}) { $PKGSRCDIR = $opts{'p'}; }
    if ($opts{'h'}) { usage() ; exit ;}

   # for using rename, unlink 
    chdir $PKGSRCDIR;
    
    open(CVS_DIFF, $CVS_DIFF) || die "Problem opening file $CVS_DIFF: $!\n";
    while(<CVS_DIFF>){
	# Looking for the +++ filename line in cvs diff (supposed to use 'cvs diff -u')
	$file_to_edit = '';
	if ( /^\+\+\+ (\S+)/) {
	    $file_to_edit = $1; }
	if ( $file_to_edit && -f $file_to_edit ) {
	    if    ( $file_to_edit =~ /Makefile$/ )      { $Makefile++;}
	    elsif ( $file_to_edit =~ /buildlink3.mk$/ ) { $buildlink3++;
		#	    print __LINE__, ' ', $file_to_edit,"\n";
		my ($new_file) = $file_to_edit. '.new';
		my ($edit) = 0;
		open(NEW,  "> $new_file" ) || print STDERR "Problem to write $edit: $! \n";
		open(EDIT, $file_to_edit ) || print STDERR "Problem opening file $file_to_edit: $! \n";
		while(<EDIT>) {
		    if ( /^BUILDLINK.*py27/ )    {  $_=~    s/py27/\${PYPKGPREFIX}/   ; $edit++;}
    		    if ( /^BUILDLINK.*py34/ )    {  $_=~    s/py34/\${PYPKGPREFIX}/   ;
						    print STDERR "   py34 found at $file_to_edit\n";
						    ; $edit++;}
		    if ( /^BUILDLINK.*ruby200/ ) {  $_=~ s/ruby200/\${RUBY_PKGPREFIX}/ ; $edit++;}
		    print NEW $_;
		}
		close(EDIT);
		close(NEW);
		if ($edit) { unlink $file_to_edit; 
			     rename $new_file, $file_to_edit;
			     $mod++;}
		else {
		    $stay++;
		    unlink $new_file; };
	    } else  { $other++; print STDERR "  (other) ", $file_to_edit,"\n"}
	    }
        }
	close(CVS_DIFF);
    printf STDERR "Makefile:      %4d\n", $Makefile;
    printf STDERR "buildlink3.mk: %4d\n", $buildlink3;
    printf STDERR "  Modified:    %4d\n", $mod;
    printf STDERR "  Untouched:   %4d\n", $stay;
    printf STDERR "Other:         %4d\n", $other;
}

main();
exit;


File Added: pkgsrc/pkgtools/revbump/files/Attic/check-cvs-diff.1
.\"	$NetBSD: check-cvs-diff.1,v 1.1 2014/12/15 23:25:54 mef Exp $
.\"
.\" Copyright (c) 2003, 2004, 2005 The NetBSD Foundation, Inc.
.\"
.\" This code was originally contributed to the NetBSD Foundation, Inc.
.\" by Makoto Fujiwara <mef@NetBSD.org>.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\" 3. Neither the name of author nor the names of its contributors may
.\"    be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 14, 2014    
.Dt CHECK-CVS-DIFF 1
.Os
.Sh NAME
.Nm check-cvs-diff
.Nd tool to check if revbump process described in revbump(1) results including py27, py34 or ruby200
in the files. And then replaces the strings by the variable notation.
.Sh SYNOPSIS
.Nm
.Op Fl h
.Op Fl p Ar pkgsrcdir
.Op Fl v
cvs-diff-u_output-file
.Sh DESCRIPTION
.Nm
is a perl script for pkgsrc developers that simplifies checking and replacing fixed
version number in revbump resultant tree, Makefile and buildlink3.mk files.
It reads `cvs diff -u' output written in named file, and if above mentioned strings found in the diff, replaces it in corresponding file by apropriate variable notation.
.Pp
.Nm Fl h
displays a short usage.
.Pp
If
.Fl p
is given,
.Ar pkgsrcdir
is used instead of the default
.Pa /usr/pkgsrc .
.Pp
If
.Fl v
is given,
it outputs some verbose information.

.Nm
prints the package name
(in
.Ar category/package
form) on stdout for each package where it failed, but usually none.

.Sh SEE ALSO
.Xr revbump 1 ,
.Xr finddepends 1 ,
.Xr replace-commonbump 1

File Added: pkgsrc/pkgtools/revbump/files/Attic/replace-commonbump
#!@PERL@ -w
# -*- perl -*-
# The process has two steps
# (1)
# Travers all the files (with some filtering) over /usr/pkgsrc
# pick up referenced -> referer relation and store them to %HASH 
#  (multiple files are concatinated by ';' )
# (2)
# read input (usually named 'commonbump'), and expand one line into
# replacement referer lines, which are referenced  -> referer relation.

use strict;
use Getopt::Std;
use File::Find;

my(%HASH);	  		# referenced -> referer relation hash, referer is delimitted by ;
my($PKGSRCDIR) = '/usr/pkgsrc';	# /usr/pkgsrc path, usually /usr/pkgsrc

my($TABLE) = 'commonbump';	# name of file, list-of-files to process
my(@TABLE);			# contents of file above

my($debug) = 0;
my($prefix) ;			# A part of path, top to pkgsrc, typically /usr/pkgsrc

my($common_bump) = 0;		# count, not used for now (yet)
my(%opts);
our(@ARGV);

my ($FILE)	= __FILE__;
    $FILE	=~ s,.*/([^/]+),$1,;	# pick leafname from __FILE__

my($replaced) = 'commonbump.replaced';

my($my_name) = $0;
$my_name =~ s#(.*)/##;

sub usage() {
    print <<HELP;
$my_name:
  This command is a part of revbump package and intended for pkgsrc developers.
  (1) Read entire pkgsrc tree and check referer -> referenced relation,
      then internally keeps (opposite) referenced -> referer relation table.
  (2) Read another file, named '$TABLE' or other name with -T, which
      usually lists Makefile.common or *common.mk files to expand.
  (3) Now expands those list in '$TABLE' into list of Makefiles by
      referenced -> refer relation. By default, it outputs to the file
      '$replaced' (currently the name is fixed).

Synopsys:
    $my_name [-a ] [-h] [-p pkgsrc_directory] [-T list_file] 
Where:
   -a	Check all, disregard to -T option. If "# used by" is 
    	included or not.
   -h	Show this help
   -p directory	
        pkgsrc directory to process (default $PKGSRCDIR)
   -T	the filename containing list of files (default commonbump)
See Also:
    revbump(1) for how to use it.
HELP
}

#  get value of variable by using make show-var
sub show_var($$){
    my($varname) = shift;
    my($pkgdir)  = shift;
    my($value);
    #chdir $pkgdir;
    open(MAKE, '-|', "cd $PKGSRCDIR/$pkgdir ; make show-var VARNAME=$varname");
    $value = <MAKE>;
    close(MAKE);
    chomp($value);
    if ($value =~ /know how to make/ ) { print STDERR $value, '(', $pkgdir,')',"\n";}
    return $value
}

sub GenerateHash ($$) {
    my ($pkgsrc) = shift;
    my ($prefix) = shift;

    # ----------------------------------------------------------------
    my ($wanted_closure) = sub () {
	my $dir   = $File::Find::dir ;
	my $fname = "$File::Find::dir/$_" ;

	# skip these directories and files ( as a files including something )
	if ($dir =~ m|CVS$| )		{$File::Find::prune = 1; return;}
	if ($dir =~ m|mk$| )		{$File::Find::prune = 1; return;}
	if ($dir =~ m|work$| )		{$File::Find::prune = 1; return;}
	if ($dir =~ m|patches$| )	{$File::Find::prune = 1; return;}
	if ($dir =~ m|files$| )		{$File::Find::prune = 1; return;}
	if ($dir =~ m|bootstrap$| )	{$File::Find::prune = 1; return;}
	if ($dir =~ m|pkgsrc/[^/]$| )	{$File::Find::prune = 1; return;}
	if ($dir =~ m|x11-links| ){$File::Find::prune = 1; return;}	
	if ($_ =~ m|^\.\#| )		{                        return;}
	if ($_ =~ m|~$| )		{                        return;}
	if ($_ =~ m|buildlink3.mk$| )	{                        return;}
	if ($_ =~ m|builtin.mk$| )	{                        return;}

	my($shortname) = $fname;
	$shortname =~ s|$prefix/||;
	my($shortdir)  = $dir;
	$shortdir  =~ s|$prefix/||;

	# pick only Makefile.* and .mk  ( as a files including something )
	if ($_ =~ m|Makefile| ||
	    $_ =~ m|\.mk$|          )	{
	    print STDERR __LINE__, ' ', $fname,' ', `pwd`, "\n" if $debug;
	    open(FNAME, $fname) || print STDERR __LINE__, " Problem opening file $fname:$!\n";
	    my ($included) = '';
	    while (<FNAME>){
		# now starts finding included file		
		# pick .include "../../
		if ( m|^\.\s*include\s+\"\.\./\.\./(.*)\"| ) { $included = $1;}
		# pick ".include "Makefile" etc (without leading ../../), this needs to add package dir.
		if ( m|^\.\s*include\s+\"(.*)\"|           ) { next;}	# including the same directory stuff, doesn't matter
		if ( m|^\.\s*include\s+\"(.*)\"|           ) { $included = $prefix .'/'. $1;}		
		if ( $included =~ m|/mk/| )       	{ next;}	# it is include line but for mk, skip this line
		if ( $included =~ m|version.mk| )	{ next;}
		if ( $included =~ m|tests/| )		{ next;}
		if ( $included =~ m|options.mk| )	{ next;}
		if ( $included =~ m|enigmail.mk| )	{ next;}		

		$included =~ s,\${.CURDIR},$shortname,;
		if ($included =~ /\${([^}]+)}/ ) { 
		    my($varname) = $1;
		    my($value) = show_var($varname, $shortdir);
		    $included =~ s/\${[^}]+}/$value/;
		    if ($value eq '') {
			print STDERR 
$FILE, ': ', __LINE__, ' Value ${', $varname, '} is emtpy at ', $shortdir, "\n";
		    }
		}
		print STDERR __LINE__ , ' ', $shortname, ' -> ', $included,': ',$_ ,"\n" if $debug;
		if ( $included eq '') 	   		{ next;}	# not include line, look at next line
		print STDERR __LINE__ , ' ', $shortname, ' -> ', $included,"\n" if $debug;
		if ( ! $HASH{$included} ) {
		    $HASH{$included} =  $shortname;
		} else {
		    my(@registered) = split ';',  $HASH{$included};
		    if (grep (/^$shortname$/, @registered) == 0 ) {
			$HASH{$included} .= ';'. $shortname;
			}
		}
	    } # end while
	    close(FNAME);
	} # if of (major process) ... starting with: if ($_ =~ m|Makefile| || 
    };  # end of my ($wanted_closure) = sub () {
    # ----------------------------------------------------------------    
    find($wanted_closure, $pkgsrc);
}

# Table is assumed to contain list of files to process, set up it in @TABLE here.
sub ReadTable($) {
    my ($table) = shift;
    if ($table eq '-') {
	@TABLE = <>;
    } else {
	open(TABLE, $table) || print STDERR "Problem reading file $table: $!\n";
	@TABLE = <TABLE>;
	close(TABLE);
	}
    }

sub ShowResults() {
    open(REPLACED, "> $replaced") || die "problem open to write: $replaced: $!\n";
    foreach my $file (@TABLE) {
	chomp($file);
	if ($file =~ /^\s*$/  ) { next; }	# Skip empty line, in case
	if ($HASH{$file} && 			# To avoid 'Use of uninitialized value in split at ..'
	    grep ($file, $HASH{$file}) > 0) {	# referer found ( separated with ';')
	    my(@list) = split ';', $HASH{$file};
	    foreach my $i (0..$#list) {	    
		print REPLACED "$list[$i]\n";	# write the list into REPLACED handle
	    }
	}
    }
}

# check the pkgsrc tree is healthy or not
sub CheckPkgsrcTree($){
    my ($pkgsrc) =	shift;
    
    if (! -d $pkgsrc || ! -d "$pkgsrc/doc" || ! -d "$pkgsrc/mk") {
	print STDERR "Invalid pkgsrc directory $pkgsrc\n";
	exit 1;
    }
}

# if -a option is applied, not using @TABLE, but scan whole thing.
sub CheckAll() {
    foreach my $i (sort keys %HASH) {	# for all the referenced
	if ($i =~ /buildlink3.mk/ ) { next;}

	# First collect the line of '# used by .*'
	open (REFERENCED, $i) || print '  *** ', __LINE__, " Unable to open $i $!\n";
	my (@referer) = {};
	while(<REFERENCED>){
	    if (/\# used by (.*)/) { push (@referer, $1);}
	}
	close(REFERENCED);
	my $number = 0;
	foreach my $referer (@referer) {
	    $number += grep $referer, $HASH{$i};
	}
	$#referer++; 	# conpensate -1 -> 0, 0 -> 1 etc
    	if ($#referer <  $number) { print $#referer . ' ? ' . $number .' .. ', $i,' <- ', $HASH{$i}, ' ... <', "\n";}
    	if ($#referer >  $number) { print $#referer . ' ? ' . $number .' .. ', $i,' <- ', $HASH{$i}, ' ... >', "\n";}	
    }
}
sub main() {
    my($check_all) = 0;
    my($prefix);
    getopts('ahp:T:', \%opts);

    if ($opts{'a'}) { $check_all = 1;  }
    if ($opts{'h'}) { usage(); exit 0;}
    if ($opts{'p'}) { $PKGSRCDIR = $opts{'p'};}
    if ($opts{'T'}) { $TABLE = $opts{'T'};}

    $prefix = $PKGSRCDIR;
    $prefix =~ s|.*/pkgsrc/(.*)|$1|;
    CheckPkgsrcTree($PKGSRCDIR);
    GenerateHash($PKGSRCDIR, $prefix);
    ReadTable($TABLE);
    if ($check_all) { CheckAll(); }
    else            { ShowResults();}
}

main();

exit;
__END__

File Added: pkgsrc/pkgtools/revbump/files/Attic/replace-commonbump.1
.\"	$NetBSD: replace-commonbump.1,v 1.1 2014/12/15 23:25:54 mef Exp $
.\"
.\" Copyright (c) 2014 The NetBSD Foundation, Inc.
.\"
.\" This code was originally contributed to the NetBSD Foundation, Inc.
.\" by Makoto Fujiwara <mef@NetBSD.org>.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\" 3. Neither the name of author nor the names of its contributors may
.\"    be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 14, 2014
.Dt REPLACE-COMMONBUMP 1
.Os
.Sh NAME
.Nm replace-commonbump
.Nd tool to help expanding (replacing) commonbump file to the real list of Makefile's.
.Sh SYNOPSIS
.Nm
.Op Fl a
.Op Fl h
.Op Fl p Ar pkgsrcdir
.Op Fl T Ar list_file
.Sh DESCRIPTION
.Nm
is a perl script for pkgsrc developers. It simplifies the process expanding
`commonbump' file into `commonbump-replace'. Commonbump file is to be created by the first stage of revbump process, as is described in revbump(1).
.Pp
.Nm Fl h
displays a short usage.
.Pp
If
.Fl p
is given,
.Ar pkgsrcdir
is used instead of the default
.Pa /usr/pkgsrc .
.Pp
If
.Fl a
is given,
check all pkgsrc tree, disregard neither to
.Fl T
option nor to the default `commonbump' file.
It will check if "# used by" is included or not, usually in Makefile.common in the package.
.Pp
If
.Fl T
is given,
.Ar list_file
is used instead of the default
.Pa `commonbump' .
.Pp
.Nm
prints the package name
(in
.Ar category/package
form) on stdout for each package where it failed, but usually none.

The internal process is divided into three stages.

.item
(1)
Read entire pkgsrc tree and check a
.Ar referer -> referenced
relation,
then internally keeps (opposite)
.Ar referenced -> referer
relation table.

.item
(2) Read a file, named `commonbump' or the other name given with -T, which
usually lists Makefile.common or *common.mk files to be expanded.

.item
(3) Now expands the filename listed in `commonbump' into the list of packagename/Makefile by
referenced -> referer relation. It then outputs to the file
`commonbump.replaced' (currently the name is fixed).

.Sh SEE ALSO
.Xr revbump 1 ,
.Xr blbump 1 ,
.Xr check-cvs-diff 1 ,
.Xr finddepends 1

cvs diff -r1.6 -r1.7 pkgsrc/pkgtools/revbump/files/Attic/revbump (expand / switch to unified diff)

--- pkgsrc/pkgtools/revbump/files/Attic/revbump 2014/10/09 13:51:42 1.6
+++ pkgsrc/pkgtools/revbump/files/Attic/revbump 2014/12/15 23:25:54 1.7
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1#!@PERL@ -w 1#!@PERL@ -w
2# -*- perl -*- 2# -*- perl -*-
3# 3#
4# $NetBSD: revbump,v 1.6 2014/10/09 13:51:42 wiz Exp $ 4# $NetBSD: revbump,v 1.7 2014/12/15 23:25:54 mef Exp $
5# 5#
6# Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. 6# Copyright (c) 2003, 2004 The NetBSD Foundation, Inc.
7# 7#
8# This code was originally contributed to the NetBSD Foundation, Inc. 8# This code was originally contributed to the NetBSD Foundation, Inc.
9# by Julio Merino <jmmv@NetBSD.org> and Thomas Klausner <wiz@NetBSD.org>. 9# by Julio Merino <jmmv@NetBSD.org> and Thomas Klausner <wiz@NetBSD.org>.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
17# notice, this list of conditions and the following disclaimer in 17# notice, this list of conditions and the following disclaimer in
@@ -46,65 +46,89 @@ if (! $PKGSRCDIR) { @@ -46,65 +46,89 @@ if (! $PKGSRCDIR) {
46} 46}
47 47
48sub usage { 48sub usage {
49 print STDERR "usage: revbump [-h] [-p pkgsrcdir] [cat1/pkg1 ... catN/pkgN]\n\n"; 49 print STDERR "usage: revbump [-h] [-p pkgsrcdir] [cat1/pkg1 ... catN/pkgN]\n\n";
50 print STDERR "If no packages are given as arguments, the list is read from stdin.\n"; 50 print STDERR "If no packages are given as arguments, the list is read from stdin.\n";
51 print STDERR "Packages for which revision cannot be bumped are written to stdout.\n"; 51 print STDERR "Packages for which revision cannot be bumped are written to stdout.\n";
52 exit 0; 52 exit 0;
53} 53}
54 54
55sub revbump { 55sub revbump {
56 my $pkgdir = shift; 56 my $pkgdir = shift;
57 my ($pkg, $oldpkgver, $pkgver, $done, $oldmk, $newmk, $backupmk); 57 my ($pkg, $oldpkgver, $pkgver, $done, $oldmk, $newmk, $backupmk);
58 local (*OLDMK, *MAKE); 58 local (*OLDMK, *MAKE);
 59 my (@OLD, @NEW, @NEW2); # two phase edit
59 60
60 $pkgdir =~ /\/(.*)$/; 61 $pkgdir =~ /\/(.*)$/;
61 $pkg = $1; 62 $pkg = $1;
62 63
63 $oldmk = "$PKGSRCDIR/$pkgdir/Makefile"; 64 $oldmk = "$PKGSRCDIR/$pkgdir/Makefile";
64 65
65 open(MAKE, '-|', "cd $PKGSRCDIR/$pkgdir ; make show-var VARNAME=PKGVERSION"); 66 open(MAKE, '-|', "cd $PKGSRCDIR/$pkgdir ; make show-var VARNAME=PKGVERSION");
66 $oldpkgver = <MAKE>; 67 $oldpkgver = <MAKE>;
67 close(MAKE); 68 close(MAKE);
68 chop $oldpkgver; 69 chop $oldpkgver;
69 70
70 open(OLDMK, $oldmk); 71 open(OLDMK, $oldmk);
71 $newmk = "$oldmk.new"; 72 @OLD = <OLDMK>;
72 open(NEWMK, ">$newmk"); 73 close(OLDMK);
73 74
 75 # first pass, check PKGREVISION line (only)
74 $done = 0; 76 $done = 0;
75 while (<OLDMK>) { 77 while ($_ = shift @OLD) {
76 if ($done == 0 && /^PKGREVISION=([ \t]+)([0-9]+)$/) { 78 if ($done == 0 && /^PKGREVISION=([ \t]+)([0-9]+)$/) {
77 $done = $2 + 1; 79 $done = $2 + 1;
78 print NEWMK "PKGREVISION=${1}${done}\n"; 80 push(@NEW, "PKGREVISION=${1}${done}\n");
79 } elsif ($done == 0 && /^CATEGORIES=([ \t]+)/) { 
80 print NEWMK "PKGREVISION=${1}1\n"; 
81 print NEWMK $_; 
82 $done = 1; 
83 } else { 81 } else {
84 print NEWMK $_; 82 push(@NEW, $_);
85 } 83 }
86 } 84 }
87 85 # if above is OK, just copy,
 86 if ( $done > 0 ){
 87 @NEW2 = @NEW;
 88 # or do second pass
 89 } else {
 90 while ($_ = shift @NEW) {
 91 if ($done == 0 && /^CATEGORIES=([ \t]+)/) {
 92 push(@NEW2,"PKGREVISION=${1}1\n");
 93 push(@NEW2, $_);
 94 $done = 1;
 95 } elsif ($done == 0 && /^PKGNAME=([ \t]+)/) {
 96 push (@NEW2, $_);
 97 push (@NEW2,"PKGREVISION=${1}1\n");
 98 $done = 1;
 99 } elsif ($done == 0 && /^COMMENT=([ \t]+)/) {
 100 push (@NEW2, $_);
 101 push (@NEW2,"PKGREVISION=${1}1\n");
 102 $done = 1;
 103 } elsif ($done == 0 && /^.\s*include([ \t]+)/) {
 104 push (@NEW2,"PKGREVISION=${1}1\n");
 105 push (@NEW2, $_);
 106 $done = 1;
 107 } else {
 108 push (@NEW2, $_);
 109 };
 110 }
 111 } # end else
 112 $newmk = "$oldmk.new";
 113 open(NEWMK, ">$newmk");
 114 print NEWMK @NEW2;
 115 close(NEWMK);
88 # no suitable place found 116 # no suitable place found
89 if ($done == 0) { 117 if ($done == 0) {
90 close(NEWMK); 
91 close(OLDMK); 
92 unlink "$newmk"; 118 unlink "$newmk";
93 return 0; 119 return 0;
94 } 120 }
95 121
96 close(NEWMK); 
97 close(OLDMK); 
98 $backupmk = "$oldmk.orig"; 122 $backupmk = "$oldmk.orig";
99 rename("$oldmk", "$backupmk"); 123 rename("$oldmk", "$backupmk");
100 rename("$newmk", "$oldmk"); 124 rename("$newmk", "$oldmk");
101 125
102 open(MAKE, '-|', "cd $PKGSRCDIR/$pkgdir ; make show-var VARNAME=PKGVERSION"); 126 open(MAKE, '-|', "cd $PKGSRCDIR/$pkgdir ; make show-var VARNAME=PKGVERSION");
103 $pkgver = <MAKE>; 127 $pkgver = <MAKE>;
104 close(MAKE); 128 close(MAKE);
105 chop $pkgver; 129 chop $pkgver;
106 130
107 # compare previous PKGVERSION and current PKGVERSION to see if update 131 # compare previous PKGVERSION and current PKGVERSION to see if update
108 # was successful 132 # was successful
109 if ($oldpkgver =~ /.*nb([0-9]+)$/) { 133 if ($oldpkgver =~ /.*nb([0-9]+)$/) {
110 $oldpkgver = $1; 134 $oldpkgver = $1;

cvs diff -r1.21 -r1.22 pkgsrc/pkgtools/revbump/files/Attic/revbump.1 (expand / switch to unified diff)

--- pkgsrc/pkgtools/revbump/files/Attic/revbump.1 2014/08/22 11:26:25 1.21
+++ pkgsrc/pkgtools/revbump/files/Attic/revbump.1 2014/12/15 23:25:54 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: revbump.1,v 1.21 2014/08/22 11:26:25 wiz Exp $ 1.\" $NetBSD: revbump.1,v 1.22 2014/12/15 23:25:54 mef Exp $
2.\" 2.\"
3.\" Copyright (c) 2003, 2004, 2005, 2006, 2010, 2012, 2013, 2014 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2003, 2004, 2005, 2006, 2010, 2012, 2013, 2014 The NetBSD Foundation, Inc.
4.\" 4.\"
5.\" This code was originally contributed to the NetBSD Foundation, Inc. 5.\" This code was originally contributed to the NetBSD Foundation, Inc.
6.\" by Julio Merino <jmmv@NetBSD.org> and Thomas Klausner <wiz@NetBSD.org>. 6.\" by Julio Merino <jmmv@NetBSD.org> and Thomas Klausner <wiz@NetBSD.org>.
7.\" 7.\"
8.\" Redistribution and use in source and binary forms, with or without 8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions 9.\" modification, are permitted provided that the following conditions
10.\" are met: 10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright 11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer. 12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in 14.\" notice, this list of conditions and the following disclaimer in
@@ -74,36 +74,34 @@ would bump the PKGREVISIONs of gmake and @@ -74,36 +74,34 @@ would bump the PKGREVISIONs of gmake and
74revbump \*[Lt]\*[Lt] EOF 74revbump \*[Lt]\*[Lt] EOF
75devel/gmake 75devel/gmake
76x11/glib2 76x11/glib2
77EOF 77EOF
78.Ed 78.Ed
79.Pp 79.Pp
80The complete procedure for a recursive dependency bump for 80The complete procedure for a recursive dependency bump for
81category/package using 81category/package using
82.Nm 82.Nm
83and 83and
84.Xr blbump 1 84.Xr blbump 1
85would be: 85would be:
86.Bd -literal -offset indent 86.Bd -literal -offset indent
87cd /usr/pkgsrc 87cd /usr/pkgsrc ;
88finddepends category/package | sort -u \*[Gt] allbump 88finddepends category/package | sort -u \*[Gt] allbump ;
89grep buildlink3.mk allbump | sed 's/.buildlink3.mk//' \*[Gt] bl3bump 89grep buildlink3.mk allbump | sed 's/.buildlink3.mk//' \*[Gt] bl3bump ;
90grep -e Makefile.common -e mk$ allbump | grep -v -e buildlink3.mk -e options.mk > commonbump 90grep -e Makefile.common -e mk$ allbump | grep -v -e buildlink3.mk -e options.mk > commonbump ;
91[read commonbump and replace entries with all packages including the 91replace-commonbump ;
92 corresponding Makefile.common or *.mk file] 92cat allbump commonbump.replaced | sed 's,/[^/]*$,,' | sort -u \*[Gt] makebump ;
93cat allbump commonbump | sed 's,/[^/]*$,,' | sort -u \*[Gt] makebump 93revbump \*[Lt] makebump | tee makebump.manual ;
94revbump \*[Lt] makebump \*[Gt] makebump.manual 94# [if a package is listed in makebump.manual, handle the PKGREVISION bump manually]
95[if a package is listed in makebump.manual, handle the PKGREVISION bump manually] 95blbump \*[Lt] bl3bump | tee bl3bump.manual ;
96blbump \*[Lt] bl3bump \*[Gt] bl3bump.manual 96# [handle the *ABI_DEPENDS* bumps in bl3bump.manual manually, usually none] ;
97[handle the *ABI_DEPENDS* bumps in bl3bump.manual manually, usually none] 97cvs diff -u `cat makebump` > cvs-diff ;
98cvs diff `cat makebump` | less 98check-cvs-diff ;
99[look for PYPKGPREFIX -\*[Gt] py27 99cvs diff `cat bl3bump makebump` | less
100 and RUBY_PKGPREFIX -\*[Gt] ruby200 expansions 
101 in buildlink files and any unrelated diffs you have in your 
102 local tree, and fix them] 
103cvs diff `cat bl3bump makebump` | less 
104cvs commit `cat bl3bump makebump` 100cvs commit `cat bl3bump makebump`
105rm allbump bl3bump* makebump* commonbump 101rm allbump bl3bump* makebump* commonbump* cvs-diff
106.Ed 102.Ed
107.Sh SEE ALSO 103.Sh SEE ALSO
108.Xr blbump 1 , 104.Xr blbump 1 ,
109.Xr finddepends 1 105.Xr finddepends 1 ,
 106.Xr replace-commonbump 1,
 107.Xr check-cvs-diff 1