2004-03-15 16:23:53 +01:00
|
|
|
#! @perl@ -w
|
2003-11-24 12:11:40 +01:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use POSIX qw(tmpnam);
|
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
my $pkgFile = $ARGV[0];
|
|
|
|
die unless defined $pkgFile;
|
2003-11-24 12:11:40 +01:00
|
|
|
|
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
# Re-execute in a terminal, if necessary, so that if we're executed
|
|
|
|
# from a web browser, the user gets to see us.
|
|
|
|
if (!defined $ENV{"NIX_HAVE_TERMINAL"}) {
|
|
|
|
$ENV{"NIX_HAVE_TERMINAL"} = "1";
|
|
|
|
exec("xterm", "-e", "@bindir@/nix-install-package", "$pkgFile");
|
|
|
|
die "cannot execute `xterm'";
|
|
|
|
}
|
2003-11-24 12:11:40 +01:00
|
|
|
|
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
# Read and parse the package file.
|
|
|
|
open PKGFILE, "<$pkgFile" or die "cannot open `$pkgFile': $!";
|
|
|
|
my $contents = <PKGFILE>;
|
|
|
|
close PKGFILE;
|
2003-11-24 12:11:40 +01:00
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
$contents =~ /^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ or die "invalid package contents";
|
|
|
|
my $version = $1;
|
|
|
|
my $manifestURL = $2;
|
|
|
|
my $drvName = $3;
|
|
|
|
my $system = $4;
|
|
|
|
my $drvPath = $5;
|
|
|
|
my $outPath = $6;
|
|
|
|
|
|
|
|
die "invalid package version `$version'" unless $version eq "NIXPKG1";
|
|
|
|
|
|
|
|
|
|
|
|
# Ask confirmation.
|
|
|
|
print "Do you want to install `$drvName' (Y/N)? ";
|
2003-11-24 12:11:40 +01:00
|
|
|
my $reply = <STDIN>;
|
|
|
|
chomp $reply;
|
2005-02-25 16:42:52 +01:00
|
|
|
exit if $reply ne "y" && $reply ne "Y";
|
2003-11-24 12:11:40 +01:00
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
print "\nPulling manifests...\n";
|
|
|
|
system "@bindir@/nix-pull '$manifestURL'";
|
|
|
|
die if $? != 0;
|
2003-11-24 12:11:40 +01:00
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
print "\nInstalling package...\n";
|
|
|
|
system "@bindir@/nix-env -i '$drvPath'";
|
|
|
|
die if $? != 0;
|
2003-11-24 12:11:40 +01:00
|
|
|
|
2005-02-25 16:42:52 +01:00
|
|
|
print "\nInstallation succeeded! Press Enter to continue.\n";
|
2003-11-24 12:11:40 +01:00
|
|
|
<STDIN>;
|