From a919ef0a9b1b79d2373d3e47cf4fdf1a8a01be9b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 Apr 2009 13:58:06 +0000 Subject: [PATCH] git-svn-id: https://nixos.org/repos/nix/release/trunk/channels@15277 70bd8c7a-acb8-0310-9f0d-9cc1c95dcdbb --- mirror-channel.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mirror-channel.pl b/mirror-channel.pl index 83a6bcb..0560c0e 100644 --- a/mirror-channel.pl +++ b/mirror-channel.pl @@ -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 \n"; +if (scalar @ARGV != 3 && scalar @ARGV != 4) { + print STDERR "Syntax: perl mirror-channel.pl []\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";