mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 09:49:18 -04:00
Revert escaped un-approved commit.
This was not meant to be applied yet, as it is not yet completely developed. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192706
This commit is contained in:
parent
96833d568c
commit
1d10e55b18
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=413101
1 changed files with 74 additions and 136 deletions
|
@ -1,53 +1,33 @@
|
||||||
#!/usr/bin/env perl -wT
|
#!/usr/bin/env perl -w
|
||||||
|
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
|
|
||||||
#
|
|
||||||
# This Perl script helps with bumping the PORTREVISION of all ports
|
|
||||||
# that depend on a set of ports, for instance, when in the latter set
|
|
||||||
# one of the port bumped the .so library version.
|
|
||||||
#
|
|
||||||
# It is best executed with the working directory set to the base of a
|
|
||||||
# ports tree, usually /usr/ports.
|
|
||||||
#
|
|
||||||
# You must use either the -l (shaLlow, avoid grandparent dependencies,
|
|
||||||
# slower) or -g option (include grandparend dependencies) option.
|
|
||||||
#
|
#
|
||||||
# MAINTAINER= gerald@FreeBSD.org
|
# MAINTAINER= gerald@FreeBSD.org
|
||||||
#
|
#
|
||||||
|
|
||||||
use strict;
|
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use Carp 'verbose';
|
use strict;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
|
||||||
use vars qw/$opt_c $opt_n $opt_i $opt_u $opt_l $opt_g/;
|
use vars qw/$opt_c $opt_n $opt_i $opt_u/;
|
||||||
|
|
||||||
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
|
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
Usage: $0 [options] [<category>/]<portname>
|
Usage: $0 [options] [<category>/]<portname>
|
||||||
|
|
||||||
Mandatory flags:
|
-c - Just check
|
||||||
-l - shaLlow, only bump ports with direct dependencies.
|
-n - No tmpdir, just use dirname(INDEX)
|
||||||
-g - Grandchildren, also bump for indirect dependencies.
|
-u <username> - Your freebsd.org username. Defaults to \$ENV{USER}.
|
||||||
|
-i <filename> - Use this for INDEX name. Defaults to /usr/ports/INDEX.
|
||||||
Optional flags:
|
|
||||||
-c - Check only (dry-run), do not change Makefiles.
|
|
||||||
-n - No tmpdir, just use the directory where INDEX resides.
|
|
||||||
-i <filename> - Use this for INDEX name. Defaults to /usr/ports/INDEX-n,
|
|
||||||
where n is the major version of the OS, or /usr/ports/INDEX if missing.
|
|
||||||
|
|
||||||
Improvements, suggestions,questions -> gerald\@FreeBSD.org
|
Improvements, suggestions,questions -> gerald\@FreeBSD.org
|
||||||
EOF
|
EOF
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$| = 1;
|
|
||||||
|
|
||||||
sub bumpMakefile {
|
sub bumpMakefile {
|
||||||
|
|
||||||
my ($p) = @_;
|
my ($p) = @_;
|
||||||
|
@ -59,7 +39,6 @@ sub bumpMakefile {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
my @lines = <$fin>;
|
my @lines = <$fin>;
|
||||||
if ($!) { die "Error while reading $makefile: $!. Aborting"; }
|
|
||||||
close($fin) or die "Can't close $makefile b/c $!";
|
close($fin) or die "Can't close $makefile b/c $!";
|
||||||
chomp(@lines);
|
chomp(@lines);
|
||||||
|
|
||||||
|
@ -71,7 +50,7 @@ sub bumpMakefile {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $printedrev = 0;
|
my $printedrev = 0;
|
||||||
open(my $fout, '>', "$makefile.bumped");
|
open(my $fout, '>', "$makefile");
|
||||||
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
||||||
if (!$printedrev) {
|
if (!$printedrev) {
|
||||||
if ($line =~ /^CATEGORIES??=/ || $line =~ /^PORTEPOCH??=/) {
|
if ($line =~ /^CATEGORIES??=/ || $line =~ /^PORTEPOCH??=/) {
|
||||||
|
@ -93,40 +72,23 @@ sub bumpMakefile {
|
||||||
print $fout "$line\n";
|
print $fout "$line\n";
|
||||||
}
|
}
|
||||||
close($fout) or die "Can't close $makefile b/c $!";
|
close($fout) or die "Can't close $makefile b/c $!";
|
||||||
rename "$makefile.bumped", $makefile or die "Can't rename $makefile.bumped to $makefile: $!";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $osversion = `uname -r`;
|
my $INDEX = "/usr/ports/INDEX";
|
||||||
chomp $osversion;
|
my $USER = $ENV{USER};
|
||||||
$osversion =~ s/\..*//;
|
|
||||||
|
|
||||||
my $INDEX = "/usr/ports/INDEX-$osversion";
|
|
||||||
if (!-f $INDEX) { $INDEX = "/usr/ports/INDEX"; }
|
|
||||||
|
|
||||||
my $shallow = 0;
|
|
||||||
{
|
{
|
||||||
$opt_i = "";
|
$opt_i = "";
|
||||||
$opt_u = "";
|
$opt_u = "";
|
||||||
getopts("cgi:lnu:");
|
getopts("cni:u:");
|
||||||
$INDEX = $opt_i if ($opt_i);
|
$INDEX = $opt_i if ($opt_i);
|
||||||
$shallow = $opt_l if $opt_l;
|
$USER = $opt_u if ($opt_u);
|
||||||
if (not $opt_l and not $opt_g) {
|
|
||||||
die "Neither -g nor -l given. Aborting";
|
|
||||||
}
|
|
||||||
|
|
||||||
die "$INDEX doesn't seem to exist. Please check the value supplied with -i, or use -i /path/to/INDEX." unless(-f $INDEX);
|
die "$INDEX doesn't seem to exist. Please check the value supplied with -i or use -i." unless(-f $INDEX);
|
||||||
}
|
}
|
||||||
usage() unless(@ARGV);
|
my $PORT = $ARGV[0];
|
||||||
|
usage() unless($PORT);
|
||||||
|
|
||||||
my $TMPDIR = File::Basename::dirname($INDEX);
|
my $CVSROOT = $ENV{CVSROOT} // ':ext:$USER\@pcvs.freebsd.org:/home/pcvs';
|
||||||
|
|
||||||
#
|
|
||||||
# Sanity checking
|
|
||||||
#
|
|
||||||
if (-d "$TMPDIR/.svn" and not $opt_n and not $opt_c) {
|
|
||||||
print "$TMPDIR/.svn exists, do you want to use the -n option? Press Ctrl-C to abort.\n";
|
|
||||||
sleep 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read the index, save some interesting keys
|
# Read the index, save some interesting keys
|
||||||
|
@ -136,50 +98,53 @@ my %index = ();
|
||||||
print "Reading $INDEX\n";
|
print "Reading $INDEX\n";
|
||||||
open(my $fin, '<', "$INDEX") or die "Cannot open $INDEX for reading.";
|
open(my $fin, '<', "$INDEX") or die "Cannot open $INDEX for reading.";
|
||||||
my @lines = <$fin>;
|
my @lines = <$fin>;
|
||||||
if ($!) { die "Error while reading $INDEX: $! Aborting"; }
|
|
||||||
chomp(@lines);
|
chomp(@lines);
|
||||||
close($fin);
|
close($fin);
|
||||||
|
|
||||||
my @a;
|
foreach my $line (@lines) {
|
||||||
my @b;
|
my @a = split(/\|/, $line);
|
||||||
my $port;
|
my @b = split(/\//, $a[1]);
|
||||||
map {
|
|
||||||
@a = split(/\|/, $_);
|
|
||||||
@b = split(/\//, $a[1]);
|
|
||||||
|
|
||||||
$port = $b[-2]."/".$b[-1];
|
my $port = $b[-2]."/".$b[-1];
|
||||||
|
|
||||||
@{ $index{$port} }{'portname', 'portnameversion', 'portdir', 'comment', 'deps'}
|
$index{$port}{portname} = $b[-1];
|
||||||
= ($b[-1], $a[0], $a[1], $a[3], ());
|
$index{$port}{portnameversion} = $a[0];
|
||||||
|
$index{$port}{portdir} = $a[1];
|
||||||
|
$index{$port}{comment} = $a[3];
|
||||||
|
$index{$port}{deps} = ();
|
||||||
|
|
||||||
if ($a[8]) {
|
if ($a[8]) {
|
||||||
@b = split(" ", $a[8]);
|
@b = split(" ", $a[8]);
|
||||||
@{ $index{$port}{deps} }{@b} = (1) x @b;
|
foreach my $b (@b) {
|
||||||
|
$index{$port}{deps}{$b} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
my @k = keys(%index);
|
||||||
|
print "- Processed ", $#k+1, " entries.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} @lines;
|
|
||||||
print "- Processed ", scalar keys(%index), " entries.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
my %DEPPORTS = ();
|
|
||||||
|
|
||||||
foreach my $PORT (@ARGV) {
|
|
||||||
#
|
#
|
||||||
# See if the port does really exists.
|
# See if the port does really exists.
|
||||||
# If specified as category/portname, that should be enough.
|
# If specified as category/portname, that should be enough.
|
||||||
# If specified as portname, check all indexes for existence or duplicates.
|
# If specified as portname, check all indexes for existence or duplicates.
|
||||||
#
|
#
|
||||||
unless (defined $index{$PORT}) {
|
unless (defined $index{$PORT}) {
|
||||||
my @found = grep /\/$PORT$/, keys(%index);
|
my $count = 0;
|
||||||
my $count = @found;
|
my $n = "";
|
||||||
|
foreach my $p (keys(%index)) {
|
||||||
|
if ($p =~ /\/$PORT$/) {
|
||||||
|
$n .= " " if ($n);
|
||||||
|
$n .= $p;
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($count == 0) {
|
if ($count == 0) {
|
||||||
die "Cannot find ${PORT} in ${INDEX}.";
|
die "Cannot find ${PORT} in ${INDEX}.";
|
||||||
} elsif ($count == 1) {
|
} elsif ($count == 1) {
|
||||||
$PORT = $found[0];
|
$PORT = $n;
|
||||||
} else {
|
} else {
|
||||||
my $n = join(" ", @found);
|
die "Found ${PORT} more than once in ${INDEX}: $n. Try category/portname.";
|
||||||
die "Found ${PORT} more than once in ${INDEX}: $n. Try category/$PORT.\nAborting";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,60 +154,33 @@ foreach my $PORT (@ARGV) {
|
||||||
#
|
#
|
||||||
# Figure out all the ports depending on this one.
|
# Figure out all the ports depending on this one.
|
||||||
#
|
#
|
||||||
|
my %DEPPORTS = ();
|
||||||
|
my $ports = "";
|
||||||
{
|
{
|
||||||
print "Searching for ports depending on $PORT\n";
|
print "Searching for ports depending on $PORT\n";
|
||||||
|
|
||||||
foreach my $p (keys(%index)) {
|
foreach my $p (keys(%index)) {
|
||||||
if (defined $index{$p}{'deps'}{$PORTNAMEVERSION}) {
|
if (defined $index{$p}{deps}{$PORTNAMEVERSION}) {
|
||||||
$DEPPORTS{$p} = 1;
|
$DEPPORTS{$p} = 1;
|
||||||
|
$ports .= " " if ($ports);
|
||||||
|
$ports .= "ports/$p";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "- Found ", scalar keys(%DEPPORTS), " ports depending on $PORT.\n";
|
my @k = keys(%DEPPORTS);
|
||||||
|
print "- Found ", $#k+1, " ports depending on it.\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# In shallow mode, strip all those who don't have a direct dependency
|
|
||||||
#
|
|
||||||
sub direct_dependence($@) {
|
|
||||||
my ($port, @requisites) = @_;
|
|
||||||
open F, '-|', '/usr/bin/make', '-C', $port, qw/-V _RUN_DEPENDS -V _LIB_DEPENDS/ or die "cannot launch make: $!";
|
|
||||||
my @lines = <F>;
|
|
||||||
chomp @lines;
|
|
||||||
my $deps = join(" ", @lines);
|
|
||||||
my %deps = map { $_ =~ s[/usr/ports/][]; ($_ => 1) } split " ", $deps;
|
|
||||||
if ($!) { die "cannot read depends from make: $!"; }
|
|
||||||
close F or die "cannot read depends from make: $!";
|
|
||||||
my $required = grep { $_ } map { defined $deps{$_} } @requisites;
|
|
||||||
return $required;
|
|
||||||
}
|
|
||||||
if ($shallow) {
|
|
||||||
my $n = keys %DEPPORTS;
|
|
||||||
my $idx = 1;
|
|
||||||
foreach my $p (keys %DEPPORTS) {
|
|
||||||
print "- Checking requisites of port $idx/$n...\r";
|
|
||||||
++$idx;
|
|
||||||
unless (direct_dependence($p, @ARGV)) {
|
|
||||||
delete $DEPPORTS{$p};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print "- Found ", scalar keys(%DEPPORTS), " ports depending directly on either of @ARGV.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ports = join(" ", keys %DEPPORTS);
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create a temp directory and cvs checkout the ports
|
# Create a temp directory and cvs checkout the ports
|
||||||
# (don't do error checking, too complicated right now)
|
# (don't do error checking, too complicated right now)
|
||||||
#
|
#
|
||||||
unless ($opt_n or $opt_c) {
|
|
||||||
$TMPDIR = ".bump_rev_tmpdir.$$";
|
my $TMPDIR = File::Basename::dirname($INDEX);
|
||||||
print "svn checkout into $TMPDIR...\n";
|
unless ($opt_n) {
|
||||||
|
$TMPDIR = getcwd() . "/.tmpdir.$$";
|
||||||
mkdir($TMPDIR, 0755);
|
mkdir($TMPDIR, 0755);
|
||||||
chdir($TMPDIR);
|
chdir($TMPDIR);
|
||||||
system "svn checkout --depth=immediates svn+ssh://svn.freebsd.org/ports/head/ ports" and die "SVN checkout failed (wait value $?), aborting";
|
system "cvs -d $CVSROOT co -T $ports";
|
||||||
chdir('ports');
|
chdir($TMPDIR);
|
||||||
system "svn update --set-depth=infinity $ports" and die "SVN checkout failed (wait value $?), aborting";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -250,7 +188,7 @@ unless ($opt_n or $opt_c) {
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
print "Updating Makefiles\n";
|
print "Updating Makefiles\n";
|
||||||
foreach my $p (sort keys(%DEPPORTS)) {
|
foreach my $p (keys(%DEPPORTS)) {
|
||||||
print "- Updating Makefile of $p\n";
|
print "- Updating Makefile of $p\n";
|
||||||
next if $opt_c;
|
next if $opt_c;
|
||||||
bumpMakefile "$p";
|
bumpMakefile "$p";
|
||||||
|
|
Loading…
Add table
Reference in a new issue