git-svn-id: https://nixos.org/repos/nix/release/trunk/channels@15277 70bd8c7a-acb8-0310-9f0d-9cc1c95dcdbb

This commit is contained in:
Eelco Dolstra 2009-04-23 13:58:06 +00:00
parent cfdd333199
commit a919ef0a9b

View file

@ -4,19 +4,20 @@ use File::Basename;
use File::stat;
use File::Temp qw/tempfile/;
if (scalar @ARGV != 3) {
print STDERR "Syntax: perl mirror-channel.pl <src-channel-url> <dst-channel-url> <dst-channel-dir>\n";
if (scalar @ARGV != 3 && scalar @ARGV != 4) {
print STDERR "Syntax: perl mirror-channel.pl <src-channel-url> <dst-channel-url> <dst-channel-dir> [<nix-exprs-url>]\n";
exit 1;
}
my $srcChannelURL = $ARGV[0];
my $dstChannelURL = $ARGV[1];
my $dstChannelPath = $ARGV[2];
my $nixexprsURL = $ARGV[3] || "$srcChannelURL/nixexprs.tar.bz2";
die "$dstChannelPath doesn't exist\n" unless -d $dstChannelPath;
my ($fh, $tmpManifest) = tempfile(UNLINK => 1);
system("curl --fail '$srcChannelURL/MANIFEST' > $tmpManifest") == 0 or die;
system("curl --location --fail '$srcChannelURL/MANIFEST' > $tmpManifest") == 0 or die;
# Read the manifest.
my %narFiles;
@ -46,7 +47,7 @@ while (my ($storePath, $files) = each %narFiles) {
if (! -e $dstFile) {
print "downloading $srcURL\n";
my $dstFileTmp = "$dstChannelPath/.tmp.$$.nar.$dstName";
system("curl --fail '$srcURL' > $dstFileTmp") == 0 or die;
system("curl --location --fail '$srcURL' > $dstFileTmp") == 0 or die;
rename($dstFileTmp, $dstFile) or die "cannot rename $dstFileTmp";
}
@ -74,5 +75,5 @@ writeManifest("$dstChannelPath/MANIFEST", \%narFiles, \%patches);
# Mirror nixexprs.tar.bz2.
my $tmpFile = "$dstChannelPath/.tmp.$$.nixexprs.tar.bz2";
system("curl --fail '$srcChannelURL/nixexprs.tar.bz2' > $tmpFile") == 0 or die;
system("curl --location --fail '$nixexprsURL' > $tmpFile") == 0 or die;
rename($tmpFile, "$dstChannelPath/nixexprs.tar.bz2") or die "cannot rename $tmpFile";