forked from lix-project/lix
* When doing a nix-pull, remove old manifests downloaded from the same
URL. This prevents lots of old cruft accumulating in /nix/var/nix/manifests.
This commit is contained in:
parent
c4c84d1edb
commit
7ca9972636
|
@ -88,11 +88,6 @@ sub update {
|
||||||
# source.
|
# source.
|
||||||
if (-W "$stateDir/manifests") {
|
if (-W "$stateDir/manifests") {
|
||||||
|
|
||||||
# Remove all the old manifests.
|
|
||||||
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
|
|
||||||
unlink $manifest or die "cannot remove `$manifest': $!";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Pull cache manifests.
|
# Pull cache manifests.
|
||||||
foreach my $url (@channels) {
|
foreach my $url (@channels) {
|
||||||
#print "pulling cache manifest from `$url'\n";
|
#print "pulling cache manifest from `$url'\n";
|
||||||
|
|
|
@ -51,7 +51,7 @@ sub processURL {
|
||||||
|
|
||||||
# First see if a bzipped manifest is available.
|
# First see if a bzipped manifest is available.
|
||||||
if (system("@curl@ --fail --silent --head '$url'.bz2 > /dev/null") == 0) {
|
if (system("@curl@ --fail --silent --head '$url'.bz2 > /dev/null") == 0) {
|
||||||
print "obtaining list of Nix archives at `$url.bz2'...\n";
|
print "fetching list of Nix archives at `$url.bz2'...\n";
|
||||||
my $bzipped = downloadFile "$url.bz2";
|
my $bzipped = downloadFile "$url.bz2";
|
||||||
|
|
||||||
$manifest = "$tmpDir/MANIFEST";
|
$manifest = "$tmpDir/MANIFEST";
|
||||||
|
@ -93,10 +93,30 @@ sub processURL {
|
||||||
or die "cannot hash `$manifest'";
|
or die "cannot hash `$manifest'";
|
||||||
chomp $hash;
|
chomp $hash;
|
||||||
|
|
||||||
|
my $urlFile = "$manifestDir/$baseName-$hash.url";
|
||||||
|
open URL, ">$urlFile" or die "cannot create `$urlFile'";
|
||||||
|
print URL "$url";
|
||||||
|
close URL;
|
||||||
|
|
||||||
my $finalPath = "$manifestDir/$baseName-$hash.nixmanifest";
|
my $finalPath = "$manifestDir/$baseName-$hash.nixmanifest";
|
||||||
|
|
||||||
system("@coreutils@/ln", "-sfn", "$manifest", "$finalPath") == 0
|
unlink $finalPath if -e $finalPath;
|
||||||
|
|
||||||
|
symlink("$manifest", "$finalPath")
|
||||||
or die "cannot link `$finalPath to `$manifest'";
|
or die "cannot link `$finalPath to `$manifest'";
|
||||||
|
|
||||||
|
# Delete all old manifests downloaded from this URL.
|
||||||
|
for my $urlFile2 (glob "$manifestDir/*.url") {
|
||||||
|
next if $urlFile eq $urlFile2;
|
||||||
|
open URL, "<$urlFile2" or die;
|
||||||
|
my $url2 = <URL>;
|
||||||
|
chomp $url2;
|
||||||
|
close URL;
|
||||||
|
next unless $url eq $url2;
|
||||||
|
my $base = $urlFile2; $base =~ s/.url$//;
|
||||||
|
unlink "${base}.url";
|
||||||
|
unlink "${base}.nixmanifest";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (@ARGV) {
|
while (@ARGV) {
|
||||||
|
|
Loading…
Reference in a new issue