diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-01-17 22:20:42 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-01-17 22:42:39 +0100 |
commit | 24e262f086980a13d9d0a27615ed7eaec4aacbff (patch) | |
tree | 4c519de6a66020766572e3d419cda80290c81634 /tests/guix-package.sh | |
parent | 8ca6cc4b451cab4b686d28f8aedef2c39fab6a17 (diff) | |
download | guix-24e262f086980a13d9d0a27615ed7eaec4aacbff.tar.gz |
guix-package: Add `--roll-back'.
Based on a patch by Nikita Karetnikov <nikita@karetnikov.org>. * guix-package.in (profile-regexp): New procedure. (latest-profile-number): Remove `%profile-rx', and use `profile-regexp' instead. (profile-number, roll-back): New procedure. (show-help): Add `--roll-back'. (%options): Likewise. (guix-package)[process-actions]: First check whether `roll-back?' is among OPTS, and call `roll-back' if it is, followed by a recursive call to `process-actions'. Emit the "nothing to be done" message only when INSTALL or REMOVE is non-empty. * tests/guix-package.sh (readlink_base): New function. Add tests for `--roll-back'. * doc/guix.texi (Invoking guix-package): Document `--roll-back'.
Diffstat (limited to 'tests/guix-package.sh')
-rw-r--r-- | tests/guix-package.sh | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/tests/guix-package.sh b/tests/guix-package.sh index e5b8db7088..fd778f4f4f 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -22,6 +22,11 @@ guix-package --version +readlink_base () +{ + basename `readlink "$1"` +} + profile="t-profile-$$" rm -f "$profile" @@ -34,8 +39,7 @@ test -L "$profile" && test -L "$profile-1-link" test -f "$profile/bin/guile" # Installing the same package a second time does nothing. -guix-package --bootstrap -p "$profile" \ - -i `guix-build -e '(@@ (distro packages base) %bootstrap-guile)'` +guix-package --bootstrap -p "$profile" -i "$boot_guile" test -L "$profile" && test -L "$profile-1-link" ! test -f "$profile-2-link" test -f "$profile/bin/guile" @@ -43,8 +47,8 @@ test -f "$profile/bin/guile" # Check whether we have network access. if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null then - guix-package --bootstrap -p "$profile" \ - -i `guix-build -e '(@@ (distro packages base) gnu-make-boot0)'` + boot_make="`guix-build -e '(@@ (distro packages base) gnu-make-boot0)'`" + guix-package --bootstrap -p "$profile" -i "$boot_make" test -L "$profile-2-link" test -f "$profile/bin/make" && test -f "$profile/bin/guile" @@ -68,6 +72,29 @@ then guix-package --bootstrap -p "$profile" -r "guile-bootstrap" test -L "$profile-3-link" test -f "$profile/bin/make" && ! test -f "$profile/bin/guile" + + # Roll back. + guix-package --roll-back -p "$profile" + test "`readlink_base "$profile"`" = "$profile-2-link" + test -x "$profile/bin/guile" && test -x "$profile/bin/make" + guix-package --roll-back -p "$profile" + test "`readlink_base "$profile"`" = "$profile-1-link" + test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" + + # Failed attempt to roll back because there's no previous generation. + if guix-package --roll-back -p "$profile"; + then false; else true; fi + + # Reinstall after roll-back to generation 1. + guix-package --bootstrap -p "$profile" -i "$boot_make" + test "`readlink_base "$profile"`" = "$profile-4-link" + test -x "$profile/bin/guile" && test -x "$profile/bin/make" + + # Roll-back to generation 3[*], and install---all at once. + # [*] FIXME: Eventually, this should roll-back to generation 1. + guix-package --bootstrap -p "$profile" --roll-back -i "$boot_guile" + test "`readlink_base "$profile"`" = "$profile-5-link" + test -x "$profile/bin/guile" && test -x "$profile/bin/make" fi # Make sure the `:' syntax works. @@ -88,3 +115,7 @@ mkdir -p "$HOME" guix-package --bootstrap -i "$boot_guile" test -L "$HOME/.guix-profile" test -f "$HOME/.guix-profile/bin/guile" + +# Failed attempt to roll back. +if guix-package --bootstrap --roll-back; +then false; else true; fi |