# GNU Guix --- Functional package management for GNU
-# Copyright © 2012, 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012, 2013, 2014, 2015, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+# Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
#
# This file is part of GNU Guix.
#
profile_alt="t-profile-alt-$$"
rm -f "$profile"
-trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* ; rm -rf t-home-'"$$" EXIT
+trap 'rm -f "$profile" "$profile_alt" "$profile-"[0-9]* "$profile_alt-"[0-9]* ; rm -rf t-home-'"$$" EXIT
guix package --bootstrap -p "$profile" -i guile-bootstrap
! test -f "$profile-2-link"
test -f "$profile/bin/guile"
-boot_make="(@@ (gnu packages commencement) gnu-make-boot0)"
+boot_make="(@ (guix tests) gnu-make-for-tests)"
boot_make_drv="`guix build -e "$boot_make" | grep -v -e -debug`"
guix package --bootstrap -p "$profile" -i "$boot_make_drv"
test -L "$profile-2-link"
test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
+guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
+installed="`guix package -p "$profile" -p "$profile_alt" -I | cut -f1 | xargs echo | sort`"
+case "x$installed" in
+ "gcc-bootstrap guile-bootstrap make-boot0")
+ true;;
+ "*")
+ false;;
+esac
+test "`guix package -p "$profile_alt" -p "$profile" -I | wc -l`" = "3"
+rm "$profile_alt"
+
# List generations.
test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
= " guile-bootstrap"
guix package -p "$profile" -p "$profile_alt" --search-paths \
| grep "LIBRARY_PATH.*$profile/lib.$profile_alt/lib"
+# Simulate an upgrade and make sure the package order is preserved.
+module_dir="t-guix-package-net-$$"
+trap 'rm -rf "$module_dir"' EXIT
+
+mkdir "$module_dir"
+cat > "$module_dir/new.scm" <<EOF
+(define-module (new)
+ #:use-module (guix)
+ #:use-module (gnu packages bootstrap))
+
+(define-public new-guile
+ (package (inherit %bootstrap-guile)
+ (version (string-append "42." (getenv "V_MINOR")))))
+(define-public new-gcc
+ (package (inherit %bootstrap-gcc)
+ (version (string-append "77." (getenv "V_MINOR")))))
+EOF
+
+guix package --bootstrap -p "$profile" -i gcc-bootstrap
+installed="`guix package -p "$profile" -I | cut -f1`"
+
+for i in 1 2
+do
+ V_MINOR="$i"
+ export V_MINOR
+
+ guix package -p "$profile" --bootstrap -L "$module_dir" -u .
+ post_upgrade="`guix package -p "$profile" -I | cut -f1`"
+ test "$post_upgrade" = "$installed"
+done
+
#
# Try with the default profile.
#