From 06baf4d6ba187e4f56f15692b6013cf1c89df7f1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 19 Mar 2024 15:53:02 +0100 Subject: profiles: ‘read-manifest’ raises to ‘&profile-error’ upon version mismatch. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/profiles.scm (sexp->manifest): In the catch-all clause, raise to ‘&profile-error’ in addition to ‘&message’. Change-Id: Ieb08187b388531c2157bfe67fb1b7319dbbb4ff3 --- guix/profiles.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/profiles.scm b/guix/profiles.scm index ce2f8337bf..2d695a52f8 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013-2023 Ludovic Courtès +;;; Copyright © 2013-2024 Ludovic Courtès ;;; Copyright © 2013 Nikita Karetnikov ;;; Copyright © 2014, 2016 Alex Kost ;;; Copyright © 2015 Mark H Weaver @@ -652,6 +652,8 @@ (define* (sexp->manifest-entry sexp #:optional (parent (delay #f))) vlist-null))) (_ (raise (condition + (&profile-error + (profile (and=> (source-property sexp 'filename) dirname))) (&message (message "unsupported manifest format"))))))) (define (read-manifest port) -- cgit v1.2.3 From c90a4e8dcd6ac650392ffcc039273baf145aa3cc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 19 Mar 2024 12:56:49 +0100 Subject: describe: Try harder to find the ‘guix pull’ profile. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . The strategy used by ‘current-profile’ so far would fail to find the right profile (the one created by ‘guix pull’ or ‘guix time-machine’) in cases where said profile is itself included in another profile. This happens, for instance, when running ‘guix shell -CW -- guix describe’, which, as a result, would display nothing but the ‘guix’ channel. This patch fixes that by having ‘current-profile’ not just check for the presence of a ‘manifest’ file but also parse it to determine whether it’s a ‘guix pull’ kind of manifest. * guix/describe.scm (find-profile): New procedure. (current-profile): Adjust to use it. Change-Id: I9194f54ce1496a6591e247c76203f497f28c330b --- guix/describe.scm | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'guix') diff --git a/guix/describe.scm b/guix/describe.scm index 65cd79094b..a4ca2462f4 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2018-2021, 2024 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -27,6 +27,7 @@ (define-module (guix describe) sexp->channel manifest-entry-channel) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-34) #:use-module (ice-9 match) #:export (current-profile current-profile-date @@ -55,20 +56,49 @@ (define initial-program-arguments ;; later on. (program-arguments)) +(define (find-profile program) + "Return the profile created by 'guix pull' or 'guix time-machine' that +PROGRAM lives in; PROGRAM is expected to end in \"/bin/guix\". Return #f if +such a profile could not be found." + (and (string-suffix? "/bin/guix" program) + ;; Note: We want to do _lexical dot-dot resolution_. Using ".." for + ;; real would instead take us into the /gnu/store directory that + ;; ~/.config/guix/current/bin points to, whereas we want to obtain + ;; ~/.config/guix/current. + (let ((candidate (dirname (dirname program)))) + (and (file-exists? (string-append candidate "/manifest")) + (let ((manifest (guard (c ((profile-error? c) #f)) + (profile-manifest candidate)))) + (define (fallback) + (or (and=> (false-if-exception (readlink program)) + find-profile) + (and=> (false-if-exception (readlink (dirname program))) + (lambda (target) + (find-profile (in-vicinity target "guix")))))) + + ;; Is CANDIDATE the "right" profile--the one created by 'guix + ;; pull'? It might be that CANDIDATE itself contains a + ;; symlink to the "right" profile; this happens for instance + ;; when using 'guix shell -CW'. Thus, if CANDIDATE doesn't + ;; fit the bill, dereference PROGRAM or its parent directory + ;; and try again. + (match (and manifest + (manifest-lookup manifest + (manifest-pattern (name "guix")))) + (#f + (fallback)) + (entry + (if (assq 'source (manifest-entry-properties entry)) + candidate + (fallback))))))))) + (define current-profile (mlambda () "Return the profile (created by 'guix pull') the calling process lives in, or #f if this is not applicable." (match initial-program-arguments ((program . _) - (and (string-suffix? "/bin/guix" program) - ;; Note: We want to do _lexical dot-dot resolution_. Using ".." - ;; for real would instead take us into the /gnu/store directory - ;; that ~/.config/guix/current/bin points to, whereas we want to - ;; obtain ~/.config/guix/current. - (let ((candidate (dirname (dirname program)))) - (and (file-exists? (string-append candidate "/manifest")) - candidate))))))) + (find-profile program))))) (define (current-profile-date) "Return the creation date of the current profile (produced by 'guix pull'), -- cgit v1.2.3 From b7931e6f5d606a7032d5408885ee43fa9e88454b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 19 Mar 2024 16:49:02 +0100 Subject: git authenticate: Document ‘--end’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/git/authenticate.scm (show-help): Document ‘--end’. * doc/guix.texi (Invoking guix git authenticate): Likewise. Reported-by: Tomas Volf <~@wolfsden.cz> Change-Id: Ia646203ce2f721487de547c76b9488754c70db66 --- doc/guix.texi | 3 +++ guix/scripts/git/authenticate.scm | 2 ++ 2 files changed, 5 insertions(+) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index af246562a8..20f007b1c0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7632,6 +7632,9 @@ contain OpenPGP public keys in @file{.key} files, either in binary form or ``ASCII-armored''. By default the keyring is loaded from the branch named @code{keyring}. +@item --end=@var{commit} +Authenticate revisions up to @var{commit}. + @item --stats Display commit signing statistics upon completion. diff --git a/guix/scripts/git/authenticate.scm b/guix/scripts/git/authenticate.scm index 6ff5cee682..def4879e96 100644 --- a/guix/scripts/git/authenticate.scm +++ b/guix/scripts/git/authenticate.scm @@ -100,6 +100,8 @@ (define (show-help) (display (G_ " -k, --keyring=REFERENCE load keyring from REFERENCE, a Git branch")) + (display (G_ " + --end=COMMIT authenticate revisions up to COMMIT")) (display (G_ " --stats display commit signing statistics upon completion")) (display (G_ " -- cgit v1.2.3