From d2952326ae18f50f6b3abefe0b12547556f9a1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 2 Apr 2014 15:44:42 +0200 Subject: guix package: Register non-default profiles as GC roots. * guix/scripts/package.scm (maybe-register-gc-root): New procedure. * tests/guix-package.sh (profile): Grep the output of "guix gc --list-live" in a couple of places. --- guix/scripts/package.scm | 6 ++++++ tests/guix-package.sh | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 6069b203de..36d47348f1 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -723,6 +723,11 @@ removed from MANIFEST." (_ #f)) options)) +(define (maybe-register-gc-root store profile) + "Register PROFILE as a GC root, unless it doesn't need it." + (unless (string=? profile %current-profile) + (add-indirect-root store (canonicalize-path profile)))) + ;;; ;;; Entry point. @@ -915,6 +920,7 @@ more information.~%")) (let ((count (length entries))) (switch-symlinks name prof) (switch-symlinks profile name) + (maybe-register-gc-root (%store) profile) (format #t (N_ "~a package in profile~%" "~a packages in profile~%" count) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 253a9317a6..3fd65a2e1a 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -41,6 +41,9 @@ guix package --bootstrap -p "$profile" -i guile-bootstrap test -L "$profile" && test -L "$profile-1-link" test -f "$profile/bin/guile" +# Make sure the profile is a GC root. +guix gc --list-live | grep "`readlink "$profile-1-link"`" + # Installing the same package a second time does nothing. guix package --bootstrap -p "$profile" -i guile-bootstrap test -L "$profile" && test -L "$profile-1-link" @@ -209,6 +212,10 @@ fi default_profile="`readlink "$HOME/.guix-profile"`" for i in `seq 1 3` do + # Make sure the current generation is a GC root. + profile_link="`readlink "$default_profile"`" + guix gc --list-live | grep "`readlink "$profile_link"`" + guix package --bootstrap --roll-back ! test -f "$HOME/.guix-profile/bin" ! test -f "$HOME/.guix-profile/lib" -- cgit v1.2.3