ports/62302: SIZE in distinfos causes failure with FETCH_CMD=wget
Gerard O'Donnell
gerard at serizon.com
Sat Feb 7 07:50:20 UTC 2004
The following reply was made to PR ports/62302; it has been noted by GNATS.
From: "Gerard O'Donnell" <gerard at serizon.com>
To: <vd at datamax.bg>, <freebsd-gnats-submit at FreeBSD.org>
Cc:
Subject: RE: Re: ports/62302: SIZE in distinfos causes failure with FETCH_CMD=wget
Date: Sat, 7 Feb 2004 17:14:32 +1030
This is a multi-part message in MIME format.
------=_NextPart_000_0000_01C3ED9D.DDFB7B00
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Further to email previously, attached is a perl script if anyone wants
to use to traverse the ports tree to strip SIZE information from the
distinfo files so that wget works.
Usage is stripSIZE.pl <wherever the ports tree is located>
e.g:
stripSIZE.pl /usr/ports
------=_NextPart_000_0000_01C3ED9D.DDFB7B00
Content-Type: application/octet-stream;
name="stripSIZE.pl"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="stripSIZE.pl"
#!/usr/bin/perl -w
use integer;
use strict;
use Cwd;
use Digest::MD5;
# -------------------------------------------------------------------
my($hashRef) =3D {};
my $increment =3D "0000";
my($dirName) =3D join(' ', @ARGV) || die("Usage: $0 <dirName>\n");
$hashRef =3D &process($hashRef, $dirName);
print "All done!\n";
# -------------------------------------------------------------------
sub process {
my($hashRef, $dirName) =3D @_;
$dirName =3D~ tr|\\|/|;
my($cwd) =3D cwd();
chdir($dirName) || die("Can't chdir($dirName): $!");
opendir(INX, '.') || die("Can't open($dirName): $!");
my(@fileName) =3D readdir(INX);
closedir(INX);
my($fileName);
=20
=20
for $fileName (@fileName) {
#print "Got $fileName.\n";
if ($fileName =3D~ /distinfo/i && $fileName !~ /^distinfo.*bak$/i) {
print "Got $dirName/$fileName.\n";
open(INX, $fileName) || croak("Can't open($fileName): $!");
my(@line) =3D <INX>;
my $linee;
my $hasSize =3D 0;
foreach $linee( @line) {
if ($linee =3D~ /^SIZE.*=3D.*[0-9]+/) {
$hasSize =3D 1;
print "HAS SIZE.\n";
}
#print "$linee";
}
close(INX);
=20
if ($hasSize) {
my $old =3D $fileName;
my $new =3D "$fileName.tmp";
my $bak =3D "$fileName.bak";
open(OLD, "< $old") or die "can't open $old: $!";
open(NEW, "> $new") or die "can't open $new: $!";
# Correct typos, preserving case
while (<OLD>) {
chomp if /^SIZE.*=3D.*[0-9]+/;
s/^SIZE.*=3D.*[0-9]+//g;
(print NEW $_) or die "can't write to $new: $!";
}
close(OLD) or die "can't close $old: $!";
close(NEW) or die "can't close $new: $!";
rename($old, $bak) or die "can't rename $old to $bak: $!";
rename($new, $old) or die "can't rename $new to $old: $!";
$hasSize =3D 0;
}
}
# Skip ., ..
next if ($fileName =3D~ /(^\.\.?)$/i);
# Recurse on directories.
($hashRef =3D &process($hashRef, "$dirName/$fileName") ), next if =
(-d $fileName);
$increment++;
if (! defined($$hashRef{$dirName}) ) {
$$hashRef{$dirName} =3D {};
$$hashRef{$dirName}{$fileName} =3D {};
}
}
chdir($cwd) || die("Can't chdir($cwd): $!");
$hashRef;
} # End of process.
#--------------------------------------------------------------------
# Read a file. Pass in $chomp =3D=3D 0 to stop chomping.
sub readFile
{
my($fileName, $chomp) =3D @_;
$chomp =3D 1 if ($#_ =3D=3D 0);
open(INX, $fileName) || croak("Can't open($fileName): $!");
my(@line) =3D <INX>;
close(INX);
chomp(@line) if ($chomp !=3D 0);
\@line;
} # End of readFile.
#--------------------------------------------------------------------
------=_NextPart_000_0000_01C3ED9D.DDFB7B00--
More information about the freebsd-ports-bugs
mailing list