From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Mar 7 19:50:05 2004 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F279616A4CE for ; Sun, 7 Mar 2004 19:50:04 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E437A43D2F for ; Sun, 7 Mar 2004 19:50:04 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i283o4bv036994 for ; Sun, 7 Mar 2004 19:50:04 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i283o4bO036993; Sun, 7 Mar 2004 19:50:04 -0800 (PST) (envelope-from gnats) Resent-Date: Sun, 7 Mar 2004 19:50:04 -0800 (PST) Resent-Message-Id: <200403080350.i283o4bO036993@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, Edwin Groothuis Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 768A416A4CE for ; Sun, 7 Mar 2004 19:42:41 -0800 (PST) Received: from mailout2.barnet.com.au (mailout2.barnet.com.au [218.185.88.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6457D43D1D for ; Sun, 7 Mar 2004 19:42:40 -0800 (PST) (envelope-from edwin@mavetju.org) Received: by mailout2.barnet.com.au (Postfix, from userid 27) id 5A678AA6247; Mon, 8 Mar 2004 14:42:39 +1100 (EST) Received: from mail2-auth.barnet.com.au (localhost [127.0.0.1]) by mail2.barnet.com.au (Postfix) with ESMTP id E99E2B29F9F for ; Mon, 8 Mar 2004 14:42:37 +1100 (EST) Received: from k7.mavetju (edwin.adsl.barnet.com.au [203.111.122.2]) by mail2-auth.barnet.com.au (Postfix) with ESMTP id 0B4861930E for ; Mon, 8 Mar 2004 14:42:36 +1100 (EST) Received: by k7.mavetju (Postfix, from userid 1001) id B2C6A6184; Mon, 8 Mar 2004 14:43:30 +1100 (EST) Message-Id: <20040308034330.B2C6A6184@k7.mavetju> Date: Mon, 8 Mar 2004 14:43:30 +1100 (EST) From: Edwin Groothuis To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/63915: [new tool] bump_revision script X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Edwin Groothuis List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2004 03:50:05 -0000 >Number: 63915 >Category: ports >Synopsis: [new tool] bump_revision script >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: Sun Mar 07 19:50:04 PST 2004 >Closed-Date: >Last-Modified: >Originator: Edwin Groothuis >Release: FreeBSD 5.2.1-RELEASE i386 >Organization: - >Environment: System: FreeBSD k7.mavetju 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #3: Fri Feb 27 13:54:29 EST 2004 edwin@k7.mavetju:/usr/src/sys/i386/compile/k7 i386 >Description: Small script to bump the PORTREVISION variable of ports which are depending on a port with a changed shared lib version. History: I'm about to commit ports/57475, which included a version bump for libsdl.so from 5 to 6. That means for 199 ports I need to udpate the PORTREVISION. I don't want to do this manually :-) >How-To-Repeat: >Fix: Suggested directory: Tools/scripts. #!/usr/bin/perl -w # $FreeBSD$ # # Author: Edwin Groothuis # use Getopt::Std; use strict; use Cwd; use Data::Dumper; use vars qw/$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. Questions, suggestions etc -> edwin\@freebsd.org EOF exit 1; } my $INDEX="/usr/ports/INDEX"; my $USER=$ENV{USER}; { $opt_i=""; $opt_u=""; getopts("i: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); } my $PORT=$ARGV[0]; usage() if (!$PORT); my $CVSROOT=":ext:$USER\@pcvs.freebsd.org:/home/pcvs"; # # Read the index, save some interesting keys # my %index=(); { print "Reading $INDEX\n"; open(FIN,"$INDEX") or die "Cannot open $INDEX for reading."; my @lines=; chomp(@lines); close(FIN); foreach my $line (@lines) { my @a=split(/\|/,$line); my @b=split(/\//,$a[1]); my $port=$b[-2]."/".$b[-1]; $index{$port}{portname}=$b[-1]; $index{$port}{portnameversion}=$a[0]; $index{$port}{portdir}=$a[1]; $index{$port}{comment}=$a[3]; $index{$port}{deps}=(); if ($a[8]) { @b=split(" ",$a[8]); foreach my $b (@b) { $index{$port}{deps}{$b}=1; } } } my @k=keys(%index); print "- Processed ",$#k+1," entries.\n"; } # # See if the port does really exists. # 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 { my $count=0; my $n=""; foreach my $p (keys(%index)) { if ($p=~/\/$PORT$/) { $n.=" " if ($n); $n.=$p; $count++; } } if ($count==0) { die "Cannot find ${PORT} in ${INDEX}."; } elsif ($count==1) { $PORT=$n; } else { die "Found ${PORT} more than once in ${INDEX}: $n. Try category/portname."; } } my $PORTNAMEVERSION=$index{$PORT}{portnameversion}; print "Found $PORT as $PORTNAMEVERSION\n"; # # Figure out all the ports depending on this one. # my %DEPPORTS=(); my $ports=""; { print "Searching for ports depending on $PORT\n"; foreach my $p (keys(%index)) { if (defined $index{$p}{deps}{$PORTNAMEVERSION}) { $DEPPORTS{$p}=1; $ports.=" " if ($ports); $ports.="ports/$p"; } } my @k=keys(%DEPPORTS); print "- Found ",$#k+1," ports depending on it.\n"; } # # 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`; } chdir($TMPDIR); # # Bump portrevisions # { print "Updating Makefiles\n"; foreach my $p (keys(%DEPPORTS)) { my $makefile="ports/$p/Makefile"; print "- Updating Makefile of $p\n"; if (!open(FIN,$makefile)) { print "-- Cannot open Makefile of $p, ignored.\n"; next; } my @lines=; close(FIN); chomp(@lines); my $revision=1; foreach my $line (@lines) { last if ($line=~/^MAINTAINER/); $revision+=$1 if ($line=~/PORTREVISION=[ \t](\d+)$/); } my $printedrev=0; open(FOUT,">$makefile"); foreach my $line (@lines) { if (!$printedrev) { if ($line=~/^CATEGORIES=/ || $line=~/^PORTREVISION=/) { print FOUT "PORTREVISION= $revision\n"; $printedrev=1; } } next if ($line=~/^PORTREVISION=/); print FOUT "$line\n"; } close(FOUT); } } # # Commit the changes. Not automated. # print <Release-Note: >Audit-Trail: >Unformatted: