mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
nix-push: Add ‘--link’ flag
If ‘--link’ is given, nix-push will create hard links to the NAR files in the store, rather than copying them. This is faster and requires less disk space. However, it doesn't work if the store is on a different file system.
This commit is contained in:
parent
167e36a5c3
commit
c8daeba303
1 changed files with 8 additions and 1 deletions
|
@ -23,6 +23,7 @@ my $force = 0;
|
||||||
my $destDir;
|
my $destDir;
|
||||||
my $writeManifest = 0;
|
my $writeManifest = 0;
|
||||||
my $archivesURL;
|
my $archivesURL;
|
||||||
|
my $link = 0;
|
||||||
my @roots;
|
my @roots;
|
||||||
|
|
||||||
for (my $n = 0; $n < scalar @ARGV; $n++) {
|
for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
|
@ -45,6 +46,8 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
$n++;
|
$n++;
|
||||||
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
|
||||||
$archivesURL = $ARGV[$n];
|
$archivesURL = $ARGV[$n];
|
||||||
|
} elsif ($arg eq "--link") {
|
||||||
|
$link = 1;
|
||||||
} elsif (substr($arg, 0, 1) eq "-") {
|
} elsif (substr($arg, 0, 1) eq "-") {
|
||||||
die "$0: unknown flag `$arg'\n";
|
die "$0: unknown flag `$arg'\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -209,7 +212,11 @@ for (my $n = 0; $n < scalar @storePaths2; $n++) {
|
||||||
my $dst = "$destDir/$narName";
|
my $dst = "$destDir/$narName";
|
||||||
if (! -f $dst) {
|
if (! -f $dst) {
|
||||||
my $tmp = "$destDir/.tmp.$$.$narName";
|
my $tmp = "$destDir/.tmp.$$.$narName";
|
||||||
|
if ($link) {
|
||||||
|
link($narFile, $tmp) or die "cannot link $tmp to $narFile: $!\n";
|
||||||
|
} else {
|
||||||
copy($narFile, $tmp) or die "cannot copy $narFile to $tmp: $!\n";
|
copy($narFile, $tmp) or die "cannot copy $narFile to $tmp: $!\n";
|
||||||
|
}
|
||||||
rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n";
|
rename($tmp, $dst) or die "cannot rename $tmp to $dst: $!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue