channels: Emit version 3 profiles.

Fixes <https://issues.guix.gnu.org/56441>.
Reported by zimoun <zimon.toutoune@gmail.com>.

Fixes a bug introduced in 4ff12d1de7 with
version 4 of the manifest format.  A new 'guix time-machine' would
create a v4 manifest; when targeting an old revision (v3),
'generate-package-cache' would fail to read that manifest and abort.
Furthermore, an old Guix living in a new profile with a v4 manifest
would be unable to describe itself via (guix describe).

* guix/channels.scm (package-cache-file): Add 'format-version' field to
PROFILE.
(channel-instances->derivation): Pass #:format-version to
'profile-derivation'.
This commit is contained in:
Ludovic Courtès 2022-07-08 12:31:25 +02:00
parent 89e2288751
commit c9fbd40785
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
@ -896,7 +896,12 @@ specified."
(define (package-cache-file manifest)
"Build a package cache file for the instance in MANIFEST. This is meant to
be used as a profile hook."
(let ((profile (profile (content manifest) (hooks '()))))
;; Note: Emit a profile in format version 3, which was introduced in 2017
;; and is readable by Guix since before version 1.0. This ensures that the
;; Guix in MANIFEST is able to read the manifest file created for its own
;; profile below. See <https://issues.guix.gnu.org/56441>.
(let ((profile (profile (content manifest) (hooks '())
(format-version 3))))
(define build
#~(begin
(use-modules (gnu packages))
@ -937,8 +942,12 @@ be used as a profile hook."
"Return the derivation of the profile containing INSTANCES, a list of
channel instances."
(mlet %store-monad ((manifest (channel-instances->manifest instances)))
;; Emit a profile in format version so that, if INSTANCES denotes an old
;; Guix, it can still read that profile, for instance for the purposes of
;; 'guix describe'.
(profile-derivation manifest
#:hooks %channel-profile-hooks)))
#:hooks %channel-profile-hooks
#:format-version 3)))
(define latest-channel-instances*
(store-lift latest-channel-instances))