From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Jun 26 20:30:06 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D465C1065678 for ; Thu, 26 Jun 2008 20:30:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A3EBC8FC0A for ; Thu, 26 Jun 2008 20:30:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m5QKU6l8081207 for ; Thu, 26 Jun 2008 20:30:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m5QKU6Yv081204; Thu, 26 Jun 2008 20:30:06 GMT (envelope-from gnats) Resent-Date: Thu, 26 Jun 2008 20:30:06 GMT Resent-Message-Id: <200806262030.m5QKU6Yv081204@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Philip M. Gollucci" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F42291065672 for ; Thu, 26 Jun 2008 20:27:18 +0000 (UTC) (envelope-from pgollucci@riderwayinc.com) Received: from riderwayinc.com (riderwayinc.com [74.93.213.161]) by mx1.freebsd.org (Postfix) with ESMTP id 8FD518FC20 for ; Thu, 26 Jun 2008 20:27:18 +0000 (UTC) (envelope-from pgollucci@riderwayinc.com) Received: from riderwayinc.com (localhost [127.0.0.1]) by riderwayinc.com (8.14.2/8.14.2) with ESMTP id m5QKRFbW016754 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Thu, 26 Jun 2008 20:27:15 GMT (envelope-from pgollucci@riderwayinc.com) Received: (from pgollucci@localhost) by riderwayinc.com (8.14.2/8.14.2/Submit) id m5QKR9ng016753; Thu, 26 Jun 2008 20:27:09 GMT (envelope-from pgollucci) Message-Id: <200806262027.m5QKR9ng016753@riderwayinc.com> Date: Thu, 26 Jun 2008 20:27:09 GMT From: "Philip M. Gollucci" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: edwin@FreeBSD.org Subject: ports/125025: [PATCH] Tools/scripts: Some cleanups, additions to bump_version.pl X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2008 20:30:06 -0000 >Number: 125025 >Category: ports >Synopsis: [PATCH] Tools/scripts: Some cleanups, additions to bump_version.pl >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jun 26 20:30:06 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Philip M. Gollucci >Release: FreeBSD 7.0-RELEASE amd64 >Organization: Riderway Inc. >Environment: System: FreeBSD riderwayinc.com 7.0-RELEASE FreeBSD 7.0-RELEASE #2: Thu Feb 28 21:20:48 UTC 2008 >Description: - added -c, doesn't change anything - added -n, deal with an already checkouted tree - removed negative logic in favor of 'unless' - switch to 3 arg form of open() - don't use globs for filehandles, this is been obsolete since at least 5.6.1 - handle possible errors in close() - allow CVSROOT to be overriden in the ENV Generated with FreeBSD Port Tools 0.77 >How-To-Repeat: >Fix: --- .patch begins here --- Index: bump_revision.pl =================================================================== RCS file: /home/ncvs/ports/Tools/scripts/bump_revision.pl,v retrieving revision 1.2 diff -u -u -r1.2 bump_revision.pl --- bump_revision.pl 6 Jun 2008 05:52:57 -0000 1.2 +++ bump_revision.pl 26 Jun 2008 20:24:12 -0000 @@ -10,15 +10,18 @@ use strict; use Cwd; use Data::Dumper; +use File::Basename; -use vars qw/$opt_i $opt_u/; +use vars qw/$opt_c $opt_n $opt_i $opt_u/; sub usage { print </] - -u - Your freebsd.org username. Defaults to \$ENV{USER}. - -i - Use this for INDEX name. Defaults to /usr/ports/INDEX. + -c - Just check + -n - No tmpdir, just use dirname(INDEX) + -u - Your freebsd.org username. Defaults to \$ENV{USER}. + -i - Use this for INDEX name. Defaults to /usr/ports/INDEX. Questions, suggestions etc -> edwin\@freebsd.org EOF @@ -30,16 +33,16 @@ { $opt_i = ""; $opt_u = ""; - getopts("i:u:"); + getopts("cni:u:"); $INDEX = $opt_i if ($opt_i); $USER = $opt_u if ($opt_u); - die "$INDEX doesn't seem to exist. Please check the value supplied with -i or use -i." if (! -f $INDEX); + die "$INDEX doesn't seem to exist. Please check the value supplied with -i or use -i." unless(-f $INDEX); } my $PORT = $ARGV[0]; -usage() if (!$PORT); +usage() unless($PORT); -my $CVSROOT = ":ext:$USER\@pcvs.freebsd.org:/home/pcvs"; +my $CVSROOT = $ENV{CVSROOT} // ':ext:$USER\@pcvs.freebsd.org:/home/pcvs'; # # Read the index, save some interesting keys @@ -47,10 +50,10 @@ my %index = (); { print "Reading $INDEX\n"; - open(FIN, "$INDEX") or die "Cannot open $INDEX for reading."; - my @lines = ; + open(my $fin, '<', "$INDEX") or die "Cannot open $INDEX for reading."; + my @lines = <$fin>; chomp(@lines); - close(FIN); + close($fin); foreach my $line (@lines) { my @a = split(/\|/, $line); @@ -80,9 +83,7 @@ # If specified as category/portname, that should be enough. # If specified as portname, check all indexes for existence or duplicates. # -if (defined $index{$PORT}) { - # all okay -} else { +unless (defined $index{$PORT}) { my $count = 0; my $n = ""; foreach my $p (keys(%index)) { @@ -126,13 +127,15 @@ # Create a temp directory and cvs checkout the ports # (don't do error checking, too complicated right now) # -my $TMPDIR = getcwd()."/.tmpdir.$$"; -{ - mkdir($TMPDIR, 0755); - chdir($TMPDIR); - `cvs -d $CVSROOT co -T $ports`; + +my $TMPDIR = File::Basename::dirname($INDEX); +unless ($opt_n) { + $TMPDIR = getcwd() . "/.tmpdir.$$"; + mkdir($TMPDIR, 0755); + chdir($TMPDIR); + system "cvs -d $CVSROOT co -T $ports"; + chdir($TMPDIR); } -chdir($TMPDIR); # # Bump portrevisions @@ -143,13 +146,15 @@ my $makefile = "ports/$p/Makefile"; print "- Updating Makefile of $p\n"; + next if $opt_c; - if (!open(FIN, $makefile)) { + my $fin; + unless(open($fin, $makefile)) { print "-- Cannot open Makefile of $p, ignored.\n"; next; } - my @lines = ; - close(FIN); + my @lines = <$fin>; + close($fin) or die "Can't close $makefile b/c $!"; chomp(@lines); my $revision = 1; @@ -160,28 +165,28 @@ } my $printedrev = 0; - open(FOUT, ">$makefile"); + open(my $fout, '>', "$makefile"); foreach my $line (@lines) { if (!$printedrev) { if ($line =~ /^CATEGORIES??=/ || $line =~ /^PORTEPOCH??=/) { - print FOUT "PORTREVISION= $revision\n"; + print $fout "PORTREVISION= $revision\n"; $printedrev = 1; # Fall through! } if ($line =~ /^PORTREVISION\?=/) { - print FOUT "PORTREVISION?= $revision\n"; + print $fout "PORTREVISION?= $revision\n"; $printedrev = 1; next; } if ($line =~ /^PORTREVISION=/) { - print FOUT "PORTREVISION= $revision\n"; + print $fout "PORTREVISION= $revision\n"; $printedrev = 1; next; } } - print FOUT "$line\n"; + print $fout "$line\n"; } - close(FOUT); + close($fout) or die "Can't close $makefile b/c $!"; } } --- .patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: