From 9c620e4afa03e63ddaff2979396144de8d9298a5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 13 Jul 2003 18:58:03 +0000 Subject: [PATCH] * Generate the scripts so that we can substitute the prefix etc. correctly. * Fixed nix-switch. --- scripts/Makefile.am | 10 ++++++++++ scripts/{nix-profile.sh => nix-profile.sh.in} | 10 +++++----- scripts/{nix-pull => nix-pull.in} | 7 ++----- scripts/{nix-push => nix-push.in} | 0 scripts/{nix-switch => nix-switch.in} | 17 ++++++----------- src/Makefile.am | 3 --- 6 files changed, 23 insertions(+), 24 deletions(-) rename scripts/{nix-profile.sh => nix-profile.sh.in} (70%) rename scripts/{nix-pull => nix-pull.in} (92%) rename scripts/{nix-push => nix-push.in} (100%) rename scripts/{nix-switch => nix-switch.in} (81%) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 2f4dbacc9..a8cbe8222 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,9 +1,19 @@ bin_SCRIPTS = nix-switch nix-collect-garbage \ nix-pull nix-push +noinst_SCRIPTS = nix-profile.sh + install-exec-local: $(INSTALL) -d $(sysconfdir)/profile.d $(INSTALL_PROGRAM) nix-profile.sh $(sysconfdir)/profile.d/nix.sh $(INSTALL) -d $(sysconfdir)/nix # !!! don't overwrite local modifications $(INSTALL_DATA) prebuilts.conf $(sysconfdir)/nix/prebuilts.conf + +%: %.in Makefile + sed \ + -e s^@prefix\@^$(prefix)^g \ + -e s^@sysconfdir\@^$(sysconfdir)^g \ + -e s^@localstatedir\@^$(localstatedir)^g \ + < $< > $@ || rm $@ + chmod +x $@ diff --git a/scripts/nix-profile.sh b/scripts/nix-profile.sh.in similarity index 70% rename from scripts/nix-profile.sh rename to scripts/nix-profile.sh.in index fb526a239..3a64caa04 100644 --- a/scripts/nix-profile.sh +++ b/scripts/nix-profile.sh.in @@ -1,10 +1,10 @@ -if test -z "$NIX_SET"; then +#if test -z "$NIX_SET"; then - export NIX_SET=1 +# export NIX_SET=1 - NIX_LINKS=/nix/var/nix/links/current + NIX_LINKS=@localstatedir@/nix/links/current - export PATH=$NIX_LINKS/bin:/nix/bin:$PATH + export PATH=$NIX_LINKS/bin:@prefix@/bin:$PATH export LD_LIBRARY_PATH=$NIX_LINKS/lib:$LD_LIBRARY_PATH @@ -17,4 +17,4 @@ if test -z "$NIX_SET"; then # export MANPATH=$NIX_LINKS/man:$MANPATH -fi +#fi diff --git a/scripts/nix-pull b/scripts/nix-pull.in similarity index 92% rename from scripts/nix-pull rename to scripts/nix-pull.in index 320322585..a75c1f258 100644 --- a/scripts/nix-pull +++ b/scripts/nix-pull.in @@ -1,10 +1,7 @@ #! /usr/bin/perl -w -my $prefix = $ENV{"NIX"} || "/tmp/nix"; # !!! use prefix -my $etcdir = "$prefix/etc/nix"; -my $tmpfile = "$prefix/var/nix/pull.tmp"; - -my $conffile = "$etcdir/prebuilts.conf"; +my $tmpfile = "@localstatedir@/nix/pull.tmp"; +my $conffile = "@sysconfdir@/nix/prebuilts.conf"; my @subs; my @sucs; diff --git a/scripts/nix-push b/scripts/nix-push.in similarity index 100% rename from scripts/nix-push rename to scripts/nix-push.in diff --git a/scripts/nix-switch b/scripts/nix-switch.in similarity index 81% rename from scripts/nix-switch rename to scripts/nix-switch.in index d58a5f249..55305418c 100755 --- a/scripts/nix-switch +++ b/scripts/nix-switch.in @@ -12,29 +12,24 @@ if (scalar @ARGV > 0 && $ARGV[0] eq "--keep") { my $hash = $ARGV[0]; $hash || die "no package hash specified"; -my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix -my $linkdir = "$prefix/var/nix/links"; +my $linkdir = "@localstatedir@/nix/links"; # Build the specified package, and all its dependencies. -my $pkgdir = `nix getpkg $hash`; -if ($?) { die "`nix getpkg' failed"; } +my $pkgdir = `nix -qph $hash`; +if ($?) { die "`nix -qph' failed"; } chomp $pkgdir; -my $id = `nix info $hash | cut -c 34-`; -if ($?) { die "`nix info' failed"; } -chomp $id; - # Figure out a generation number. my $nr = 0; -while (-e "$linkdir/$id-$nr") { $nr++; } -my $link = "$linkdir/$id-$nr"; +while (-e "$linkdir/$nr") { $nr++; } +my $link = "$linkdir/$nr"; # Create a symlink from $link to $pkgdir. symlink($pkgdir, $link) or die "cannot create $link: $!"; # Also store the hash of $pkgdir. This is useful for garbage # collection and the like. -my $hashfile = "$linkdir/$id-$nr.hash"; +my $hashfile = "$linkdir/$nr.hash"; open HASH, "> $hashfile" or die "cannot create $hashfile"; print HASH "$hash\n"; close HASH; diff --git a/src/Makefile.am b/src/Makefile.am index b22a56e3a..4b21f12b3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,9 +25,6 @@ libnix_a_SOURCES = util.cc hash.cc archive.cc md5.c \ install-data-local: $(INSTALL) -d $(localstatedir)/nix $(INSTALL) -d $(localstatedir)/nix/links -# $(INSTALL) -d $(localstatedir)/nix/prebuilts -# $(INSTALL) -d $(localstatedir)/nix/prebuilts/imports -# $(INSTALL) -d $(localstatedir)/nix/prebuilts/exports $(INSTALL) -d $(localstatedir)/log/nix $(INSTALL) -d $(prefix)/store $(bindir)/nix --init