* Allow a name to be given to a system configuration through `--name
NAME'. E.g., on the losser Subversion server, I do `nix-switch --name svn $(fix ...)' to atomically upgrade the server (the SVN server uses the Apache and Subversion installations in /nix/var/nix/links/svn).
This commit is contained in:
parent
9ad39df282
commit
f8035d06f2
|
@ -4,11 +4,15 @@ use strict;
|
||||||
|
|
||||||
my $keep = 0;
|
my $keep = 0;
|
||||||
my $sourceroot = 0;
|
my $sourceroot = 0;
|
||||||
|
my $name = "current";
|
||||||
my $srcid;
|
my $srcid;
|
||||||
|
|
||||||
foreach my $arg (@ARGV) {
|
my $argnr = 0;
|
||||||
|
while ($argnr < scalar @ARGV) {
|
||||||
|
my $arg = $ARGV[$argnr++];
|
||||||
if ($arg eq "--keep") { $keep = 1; }
|
if ($arg eq "--keep") { $keep = 1; }
|
||||||
elsif ($arg eq "--source-root") { $sourceroot = 1; }
|
elsif ($arg eq "--source-root") { $sourceroot = 1; }
|
||||||
|
elsif ($arg eq "--name") { $name = $ARGV[$argnr++]; }
|
||||||
elsif ($arg =~ /^([0-9a-z]{32})$/) { $srcid = $arg; }
|
elsif ($arg =~ /^([0-9a-z]{32})$/) { $srcid = $arg; }
|
||||||
else { die "unknown argument `$arg'" };
|
else { die "unknown argument `$arg'" };
|
||||||
}
|
}
|
||||||
|
@ -54,7 +58,7 @@ if ($sourceroot) {
|
||||||
close ID;
|
close ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $current = "$linkdir/current";
|
my $current = "$linkdir/$name";
|
||||||
|
|
||||||
# Read the current generation so that we can delete it (if --keep
|
# Read the current generation so that we can delete it (if --keep
|
||||||
# wasn't specified).
|
# wasn't specified).
|
||||||
|
@ -70,7 +74,7 @@ my $oldlink = readlink($current);
|
||||||
|
|
||||||
print "switching $current to $link\n";
|
print "switching $current to $link\n";
|
||||||
|
|
||||||
my $tmplink = "$linkdir/new_current";
|
my $tmplink = "$linkdir/.new_$name";
|
||||||
symlink($link, $tmplink) or die "cannot create $tmplink";
|
symlink($link, $tmplink) or die "cannot create $tmplink";
|
||||||
rename($tmplink, $current) or die "cannot rename $tmplink";
|
rename($tmplink, $current) or die "cannot rename $tmplink";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue