diff options
author | gerald <gerald@FreeBSD.org> | 2009-01-08 05:33:17 +0800 |
---|---|---|
committer | gerald <gerald@FreeBSD.org> | 2009-01-08 05:33:17 +0800 |
commit | 785be011fb410c0ab3bda564b50a63b10331a2f1 (patch) | |
tree | d25a530512bc9207aaf4d7305191c506ec493253 | |
parent | 789048bac99010ed35d664f591e78b590d540155 (diff) | |
download | freebsd-ports-gnome-785be011fb410c0ab3bda564b50a63b10331a2f1.tar.gz freebsd-ports-gnome-785be011fb410c0ab3bda564b50a63b10331a2f1.tar.zst freebsd-ports-gnome-785be011fb410c0ab3bda564b50a63b10331a2f1.zip |
Factor out the code that performs the PORTREVISION bump for one port.
Approved by: edwin
-rwxr-xr-x | Tools/scripts/bump_revision.pl | 89 |
1 files changed, 47 insertions, 42 deletions
diff --git a/Tools/scripts/bump_revision.pl b/Tools/scripts/bump_revision.pl index 7fe997c20aa8..239fe070dd10 100755 --- a/Tools/scripts/bump_revision.pl +++ b/Tools/scripts/bump_revision.pl @@ -28,6 +28,52 @@ EOF exit 1; } +sub bumpMakefile { + + my ($p) = @_; + + my $makefile = "$p/Makefile"; + my $fin; + unless(open($fin, $makefile)) { + print "-- Cannot open Makefile of $p, ignored.\n"; + next; + } + my @lines = <$fin>; + close($fin) or die "Can't close $makefile b/c $!"; + chomp(@lines); + + my $revision = 1; + + foreach my $line (@lines) { + last if ($line =~ /^MAINTAINER/); + $revision += $1 if ($line =~ /PORTREVISION??=[ \t]*(\d+)$/); + } + + my $printedrev = 0; + open(my $fout, '>', "$makefile"); + foreach my $line (@lines) { + if (!$printedrev) { + if ($line =~ /^CATEGORIES??=/ || $line =~ /^PORTEPOCH??=/) { + print $fout "PORTREVISION= $revision\n"; + $printedrev = 1; + # Fall through! + } + if ($line =~ /^PORTREVISION\?=/) { + print $fout "PORTREVISION?= $revision\n"; + $printedrev = 1; + next; + } + if ($line =~ /^PORTREVISION=/) { + print $fout "PORTREVISION= $revision\n"; + $printedrev = 1; + next; + } + } + print $fout "$line\n"; + } + close($fout) or die "Can't close $makefile b/c $!"; +} + my $INDEX = "/usr/ports/INDEX"; my $USER = $ENV{USER}; { @@ -143,50 +189,9 @@ unless ($opt_n) { { print "Updating Makefiles\n"; foreach my $p (keys(%DEPPORTS)) { - my $makefile = "ports/$p/Makefile"; - print "- Updating Makefile of $p\n"; next if $opt_c; - - my $fin; - unless(open($fin, $makefile)) { - print "-- Cannot open Makefile of $p, ignored.\n"; - next; - } - my @lines = <$fin>; - close($fin) or die "Can't close $makefile b/c $!"; - chomp(@lines); - - my $revision = 1; - - foreach my $line (@lines) { - last if ($line =~ /^MAINTAINER/); - $revision += $1 if ($line =~ /PORTREVISION??=[ \t]*(\d+)$/); - } - - my $printedrev = 0; - open(my $fout, '>', "$makefile"); - foreach my $line (@lines) { - if (!$printedrev) { - if ($line =~ /^CATEGORIES??=/ || $line =~ /^PORTEPOCH??=/) { - print $fout "PORTREVISION= $revision\n"; - $printedrev = 1; - # Fall through! - } - if ($line =~ /^PORTREVISION\?=/) { - print $fout "PORTREVISION?= $revision\n"; - $printedrev = 1; - next; - } - if ($line =~ /^PORTREVISION=/) { - print $fout "PORTREVISION= $revision\n"; - $printedrev = 1; - next; - } - } - print $fout "$line\n"; - } - close($fout) or die "Can't close $makefile b/c $!"; + bumpMakefile "ports/$p"; } } |