From f9c0400392843540a87985a67ffb9fb6e4dbc2fa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 18 Sep 2019 14:55:44 +0200 Subject: guix package: "guix package -f FILE" ensures FILE returns a package. * guix/scripts/package.scm (options->installable): Add clause for 'install option with a non-package object. * tests/guix-package.sh: Add test. --- guix/scripts/package.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guix/scripts') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index a43c96516f..21737f43da 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -607,7 +607,11 @@ (define to-install (let-values (((package output) (specification->package+output spec))) (package->manifest-entry* package output)))) - (_ #f)) + (('install . obj) + (leave (G_ "cannot install non-package object: ~s~%") + obj)) + (_ + #f)) opts)) (fold manifest-transaction-install-entry -- cgit v1.2.3 From ee25048e51dd45ad91a1ad4b0f25f4013843c52b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 18 Sep 2019 22:59:13 +0200 Subject: pull: Work around Ubuntu's 'sudo'. Partly fixes . Reported by Julien Lepiller . * guix/scripts/pull.scm (ensure-default-profile): Do not call 'migrate-generations' when "SUDO_USER" is set. --- guix/scripts/pull.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 54bbaddf30..4b03cea2e3 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -293,8 +293,15 @@ (define (ensure-default-profile) ;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move ;; them to %PROFILE-DIRECTORY. - (unless (string=? %profile-directory - (dirname (canonicalize-profile %user-profile-directory))) + ;; + ;; XXX: Ubuntu's 'sudo' preserves $HOME by default, and thus the second + ;; condition below is always false when one runs "sudo guix pull". As a + ;; workaround, skip this code when $SUDO_USER is set. See + ;; . + (unless (or (getenv "SUDO_USER") + (string=? %profile-directory + (dirname + (canonicalize-profile %user-profile-directory)))) (migrate-generations %user-profile-directory %profile-directory)) ;; Make sure ~/.config/guix/current points to /var/guix/profiles/…. -- cgit v1.2.3 From da551107129d22dfb2a4278a55b702a7340e7f51 Mon Sep 17 00:00:00 2001 From: Konrad Hinsen Date: Wed, 18 Sep 2019 09:52:18 +0200 Subject: scripts: pull: Add options for generation management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/pull.scm (%options) Add --roll-back, --switch-generation, --delete-generations (process-generation-change): New function (guix-pull): Execute generation management operations * doc/guix.texi: Document the generation management operations Signed-off-by: Ludovic Courtès --- doc/guix.texi | 47 +++++++++++++++++++++++++++++++++++++++++++++-- guix/scripts/pull.scm | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) (limited to 'guix/scripts') diff --git a/doc/guix.texi b/doc/guix.texi index da62194a16..0ed59072c9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3673,11 +3673,20 @@ Generation 3 Jun 13 2018 23:31:07 (current) @xref{Invoking guix describe, @command{guix describe}}, for other ways to describe the current status of Guix. -This @code{~/.config/guix/current} profile works like any other profile -created by @command{guix package} (@pxref{Invoking guix package}). That +This @code{~/.config/guix/current} profile works exactly like the profiles +created by @command{guix package} (@pxref{Invoking guix package}). That is, you can list generations, roll back to the previous generation---i.e., the previous Guix---and so on: +@example +$ guix pull --roll-back +switched from generation 3 to 2 +$ guix pull --delete-generations=1 +deleting /var/guix/profiles/per-user/charlie/current-guix-1-link +@end example + +You can also use @command{guix package} (@pxref{Invoking guix package}) +to manage the profile by naming it explicitly: @example $ guix package -p ~/.config/guix/current --roll-back switched from generation 3 to 2 @@ -3724,6 +3733,40 @@ is provided, the subset of generations that match @var{pattern}. The syntax of @var{pattern} is the same as with @code{guix package --list-generations} (@pxref{Invoking guix package}). +@item --roll-back +@cindex rolling back +@cindex undoing transactions +@cindex transactions, undoing +Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e., +undo the last transaction. + +@item --switch-generation=@var{pattern} +@itemx -S @var{pattern} +@cindex generations +Switch to a particular generation defined by @var{pattern}. + +@var{pattern} may be either a generation number or a number prefixed +with ``+'' or ``-''. The latter means: move forward/backward by a +specified number of generations. For example, if you want to return to +the latest generation after @code{--roll-back}, use +@code{--switch-generation=+1}. + +@item --delete-generations[=@var{pattern}] +@itemx -d [@var{pattern}] +When @var{pattern} is omitted, delete all generations except the current +one. + +This command accepts the same patterns as @option{--list-generations}. +When @var{pattern} is specified, delete the matching generations. When +@var{pattern} specifies a duration, generations @emph{older} than the +specified duration match. For instance, @code{--delete-generations=1m} +deletes generations that are more than one month old. + +If the current generation matches, it is @emph{not} deleted. + +Note that deleting generations prevents rolling back to them. +Consequently, this command must be used with care. + @xref{Invoking guix describe}, for a way to display information about the current generation only. diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 4b03cea2e3..c9835cef34 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -38,7 +38,8 @@ (define-module (guix scripts pull) #:use-module (guix git) #:use-module (git) #:use-module (gnu packages) - #:use-module ((guix scripts package) #:select (build-and-use-profile)) + #:use-module ((guix scripts package) #:select (build-and-use-profile + delete-matching-generations)) #:use-module ((gnu packages base) #:select (canonical-package)) #:use-module (gnu packages guile) #:use-module ((gnu packages bootstrap) @@ -91,6 +92,14 @@ (define (show-help) (display (G_ " -l, --list-generations[=PATTERN] list generations matching PATTERN")) + (display (G_ " + --roll-back roll back to the previous generation")) + (display (G_ " + -d, --delete-generations[=PATTERN] + delete generations matching PATTERN")) + (display (G_ " + -S, --switch-generation=PATTERN + switch to a generation matching PATTERN")) (display (G_ " -p, --profile=PROFILE use PROFILE instead of ~/.config/guix/current")) (display (G_ " @@ -120,6 +129,18 @@ (define %options (lambda (opt name arg result) (cons `(query list-generations ,arg) result))) + (option '("roll-back") #f #f + (lambda (opt name arg result) + (cons '(generation roll-back) + result))) + (option '(#\S "switch-generation") #t #f + (lambda (opt name arg result) + (cons `(generation switch ,arg) + result))) + (option '(#\d "delete-generations") #f #t + (lambda (opt name arg result) + (cons `(generation delete ,arg) + result))) (option '(#\N "news") #f #f (lambda (opt name arg result) (cons '(query display-news) result))) @@ -505,6 +526,22 @@ (define (list-generations profile numbers) (display-profile-news profile #:current-is-newer? #t)))) +(define (process-generation-change opts profile) + "Process a request to change the current generation (roll-back, switch, delete)." + (unless (assoc-ref opts 'dry-run?) + (match (assoc-ref opts 'generation) + (('roll-back) + (with-store store + (roll-back* store profile))) + (('switch pattern) + (let ((number (relative-generation-spec->number profile pattern))) + (if number + (switch-to-generation* profile number) + (leave (G_ "cannot switch to generation '~a'~%") pattern)))) + (('delete pattern) + (with-store store + (delete-matching-generations store profile pattern)))))) + (define (channel-list opts) "Return the list of channels to use. If OPTS specify a channel file, channels are read from there; otherwise, if ~/.config/guix/channels.scm @@ -572,6 +609,8 @@ (define (guix-pull . args) (profile (or (assoc-ref opts 'profile) %current-profile))) (cond ((assoc-ref opts 'query) (process-query opts profile)) + ((assoc-ref opts 'generation) + (process-generation-change opts profile)) (else (with-store store (ensure-default-profile) -- cgit v1.2.3 From aeb51370da7c854e8167066df9b138e15d7363e6 Mon Sep 17 00:00:00 2001 From: zimoun Date: Thu, 19 Sep 2019 19:24:42 +0200 Subject: guix package: Add 'guix show' alias. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/show.scm: New file. * Makefile.am (MODULES): Add it. * po/guix/POTFILES.in: Add it. * tests/guix-package-aliases.sh: Add test. * doc/guix.texi (Invoking guix package): Document it and use it in a example. Signed-off-by: Ludovic Courtès --- Makefile.am | 1 + doc/guix.texi | 8 ++++-- guix/scripts/show.scm | 67 +++++++++++++++++++++++++++++++++++++++++++ po/guix/POTFILES.in | 1 + tests/guix-package-aliases.sh | 4 +++ 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 guix/scripts/show.scm (limited to 'guix/scripts') diff --git a/Makefile.am b/Makefile.am index 93d18d7df6..f71ea77671 100644 --- a/Makefile.am +++ b/Makefile.am @@ -241,6 +241,7 @@ MODULES = \ guix/scripts/remove.scm \ guix/scripts/upgrade.scm \ guix/scripts/search.scm \ + guix/scripts/show.scm \ guix/scripts/gc.scm \ guix/scripts/hash.scm \ guix/scripts/pack.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 0ed59072c9..af1903f6ff 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2657,7 +2657,9 @@ For your convenience, we also provide the following aliases: @item @command{guix remove} is an alias for @command{guix package -r}, @item -and @command{guix upgrade} is an alias for @command{guix package -u}. +@command{guix upgrade} is an alias for @command{guix package -u}, +@item +and @command{guix show} is an alias for @command{guix package --show=}. @end itemize These aliases are less expressive than @command{guix package} and provide @@ -3020,9 +3022,9 @@ version: 3.3.5 @end example You may also specify the full name of a package to only get details about a -specific version of it: +specific version of it (this time using the @command{guix show} alias): @example -$ guix package --show=python@@3.4 | recsel -p name,version +$ guix show python@@3.4 | recsel -p name,version name: python version: 3.4.3 @end example diff --git a/guix/scripts/show.scm b/guix/scripts/show.scm new file mode 100644 index 0000000000..94f0559358 --- /dev/null +++ b/guix/scripts/show.scm @@ -0,0 +1,67 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Simon Tournier +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix scripts show) + #:use-module (guix ui) + #:use-module (guix scripts package) + #:use-module (guix scripts) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-37) + #:export (guix-show)) + +(define (show-help) + (display (G_ "Usage: guix show [OPTION] PACKAGE... +Show details about PACKAGE.")) + (display (G_" +This is an alias for 'guix package --show='.\n")) + (newline) + (display (G_ " + -h, --help display this help and exit")) + (display (G_ " + -V, --version display version information and exit")) + (newline) + (show-bug-report-information)) + +(define %options + ;; Specification of the command-line options. + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix show"))))) + +(define (guix-show . args) + (define (handle-argument arg result) + ;; Treat all non-option arguments as regexps. + (cons `(query show ,arg) + result)) + + (define opts + (args-fold* args %options + (lambda (opt name arg . rest) + (leave (G_ "~A: unrecognized option~%") name)) + handle-argument + '())) + + (unless (assoc-ref opts 'query) + (leave (G_ "missing arguments: no package to show~%"))) + + (guix-package* opts)) diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index 8b556ac0ec..f629034d61 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -47,6 +47,7 @@ guix/scripts/install.scm guix/scripts/remove.scm guix/scripts/upgrade.scm guix/scripts/search.scm +guix/scripts/show.scm guix/scripts/gc.scm guix/scripts/hash.scm guix/scripts/import.scm diff --git a/tests/guix-package-aliases.sh b/tests/guix-package-aliases.sh index 5c68664093..9c038b99a5 100644 --- a/tests/guix-package-aliases.sh +++ b/tests/guix-package-aliases.sh @@ -58,3 +58,7 @@ if guix remove -i guile-bootstrap -p "$profile" --bootstrap then false; else true; fi guix search '\' game | grep '^name: gnubg' + +guix show --version +guix show guile +guix show python@3 | grep "^name: python" -- cgit v1.2.3 From 660dbe65641851aa99b810e4ae065a5f72dc37d0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 20 Sep 2019 23:02:30 +0200 Subject: guix package: '--show' ignores deprecated packages. * guix/scripts/package.scm (process-query) <'show>: Remove superseded packages. * tests/guix-package-aliases.sh: Add test. --- guix/scripts/package.scm | 3 ++- tests/guix-package-aliases.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'guix/scripts') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 21737f43da..f03741aa9e 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -764,7 +764,8 @@ (define (diff-profiles profile numbers) (('show requested-name) (let-values (((name version) (package-name->name+version requested-name))) - (match (find-packages-by-name name version) + (match (remove package-superseded + (find-packages-by-name name version)) (() (leave (G_ "~a~@[@~a~]: package not found~%") name version)) (packages diff --git a/tests/guix-package-aliases.sh b/tests/guix-package-aliases.sh index 9c038b99a5..4beed2e5b7 100644 --- a/tests/guix-package-aliases.sh +++ b/tests/guix-package-aliases.sh @@ -62,3 +62,6 @@ guix search '\' game | grep '^name: gnubg' guix show --version guix show guile guix show python@3 | grep "^name: python" + +# "python@2" exists but is deprecated; make sure it doesn't show up. +if guix show python@2; then false; else true; fi -- cgit v1.2.3 From 961b95c985991ed4421c2419c22026eb0153c1ba Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 14 Sep 2019 14:59:58 +0200 Subject: pull: '--news' shows the list of channels added or removed. * guix/scripts/pull.scm (display-channel, channel=?) (display-channel-news, display-news): New procedures. (process-query): Call 'display-news' instead of 'display-profile-news'. --- guix/scripts/pull.scm | 61 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index c9835cef34..472947bb3a 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -213,6 +213,62 @@ (define* (display-profile-news profile #:key concise? (G_ "New in this revision:\n"))))) (_ #t))) +(define (display-channel channel) + "Display information about CHANNEL." + (format (current-error-port) + ;; TRANSLATORS: This describes a "channel"; the first placeholder is + ;; the channel name (e.g., "guix") and the second placeholder is its + ;; URL. + (G_ " ~a at ~a~%") + (channel-name channel) + (channel-url channel))) + +(define (channel=? channel1 channel2) + "Return true if CHANNEL1 and CHANNEL2 are the same for all practical +purposes." + ;; Assume that the URL matters less than the name. + (eq? (channel-name channel1) (channel-name channel2))) + +(define (display-channel-news profile) + "Display news about the channels of PROFILE " + (define previous + (and=> (relative-generation profile -1) + (cut generation-file-name profile <>))) + + (when previous + (let ((old-channels (profile-channels previous)) + (new-channels (profile-channels profile))) + (and (pair? old-channels) (pair? new-channels) + (begin + (match (lset-difference channel=? new-channels old-channels) + (() + #t) + (new + (let ((count (length new))) + (format (current-error-port) + (N_ " ~*One new channel:~%" + " ~a new channels:~%" count) + count) + (for-each display-channel new)))) + (match (lset-difference channel=? old-channels new-channels) + (() + #t) + (removed + (let ((count (length removed))) + (format (current-error-port) + (N_ " ~*One channel removed:~%" + " ~a channels removed:~%" count) + count) + (for-each display-channel removed))))))))) + +(define (display-news profile) + ;; Display profile news, with the understanding that this process represents + ;; the newest generation. + (display-profile-news profile + #:current-is-newer? #t) + + (display-channel-news profile)) + (define* (build-and-install instances profile #:key use-substitutes? verbose? dry-run?) "Build the tool from SOURCE, and install it in PROFILE. When DRY-RUN? is @@ -521,10 +577,7 @@ (define (list-generations profile numbers) ((numbers ...) (list-generations profile numbers))))))) (('display-news) - ;; Display profile news, with the understanding that this process - ;; represents the newest generation. - (display-profile-news profile - #:current-is-newer? #t)))) + (display-news profile)))) (define (process-generation-change opts profile) "Process a request to change the current generation (roll-back, switch, delete)." -- cgit v1.2.3 From 7faffdc2d53b982d8443c376d6ed2f41a13b3f36 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 15 Sep 2019 17:57:10 +0200 Subject: pull: Display channel news. * guix/scripts/pull.scm (display-news-entry) (display-channel-specific-news): New procedures. (display-channel-news): Call it. (display-new/upgraded-packages): Adjust hint message. * doc/guix.texi (Invoking guix pull): Mention it. --- doc/guix.texi | 11 ++++++---- guix/scripts/pull.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 7 deletions(-) (limited to 'guix/scripts') diff --git a/doc/guix.texi b/doc/guix.texi index 33bf08e9dd..4830f39cdb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3720,13 +3720,16 @@ Read the list of channels from @var{file} instead of evaluates to a list of channel objects. @xref{Channels}, for more information. +@cindex channel news @item --news @itemx -N -Display the list of packages added or upgraded since the previous generation. +Display the list of packages added or upgraded since the previous +generation, as well as, occasionally, news written by channel authors +for their users (@pxref{Channels, Writing Channel News}). -This is the same information as displayed upon @command{guix pull} completion, -but without ellipses; it is also similar to the output of @command{guix pull --l} for the last generation (see below). +The package information is the same as displayed upon @command{guix +pull} completion, but without ellipses; it is also similar to the output +of @command{guix pull -l} for the last generation (see below). @item --list-generations[=@var{pattern}] @itemx -l [@var{pattern}] diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 472947bb3a..d734df5e24 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -19,6 +19,7 @@ (define-module (guix scripts pull) #:use-module (guix ui) + #:use-module (guix colors) #:use-module (guix utils) #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module (guix scripts) @@ -229,6 +230,48 @@ (define (channel=? channel1 channel2) ;; Assume that the URL matters less than the name. (eq? (channel-name channel1) (channel-name channel2))) +(define (display-news-entry entry language port) + "Display ENTRY, a , in LANGUAGE, a language code, to +PORT." + (let ((title (channel-news-entry-title entry)) + (body (channel-news-entry-body entry))) + (format port " ~a~%" + (highlight + (string-trim-right + (texi->plain-text (or (assoc-ref title language) + (assoc-ref title (%default-message-language)) + ""))))) + (format port (G_ " commit ~a~%") + (channel-news-entry-commit entry)) + (newline port) + (format port " ~a~%" + (indented-string + (parameterize ((%text-width (- (%text-width) 4))) + (string-trim-right + (texi->plain-text (or (assoc-ref body language) + (assoc-ref body (%default-message-language)) + "")))) + 4)))) + +(define* (display-channel-specific-news new old + #:key (port (current-output-port))) + "Display channel news applicable the commits between OLD and NEW, where OLD +and NEW are records with a proper 'commit' field." + (let ((channel new) + (old (channel-commit old)) + (new (channel-commit new))) + (when (and old new) + (let ((language (current-message-language))) + (match (channel-news-for-commit channel new old) + (() ;no news is good news + #t) + ((entries ...) + (newline port) + (format port (G_ "News for channel '~a'~%") + (channel-name channel)) + (for-each (cut display-news-entry <> language port) entries) + (newline port))))))) + (define (display-channel-news profile) "Display news about the channels of PROFILE " (define previous @@ -259,7 +302,20 @@ (define previous (N_ " ~*One channel removed:~%" " ~a channels removed:~%" count) count) - (for-each display-channel removed))))))))) + (for-each display-channel removed)))) + + ;; Display channel-specific news for those channels that were + ;; here before and are still around afterwards. + (for-each (match-lambda + ((new old) + (display-channel-specific-news new old))) + (filter-map (lambda (new) + (define old + (find (cut channel=? new <>) + old-channels)) + + (and old (list new old))) + new-channels))))))) (define (display-news profile) ;; Display profile news, with the understanding that this process represents @@ -534,8 +590,7 @@ (define upgraded-count (length upgraded)) (when (and concise? (or (> new-count concise/max-item-count) (> upgraded-count concise/max-item-count))) - (display-hint (G_ "Run @command{guix pull --news} to view the complete -list of package changes."))))) + (display-hint (G_ "Run @command{guix pull --news} to read all the news."))))) (define (display-profile-content-diff profile gen1 gen2) "Display the changes in PROFILE GEN2 compared to generation GEN1." -- cgit v1.2.3 From 192ee02aeb3d2f6d14ea93cfc43b30dd93df80e8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 15 Sep 2019 23:55:19 +0200 Subject: pull: '-l' displays channel news. * guix/scripts/pull.scm (display-channel-news): Make 'previous' a parameter. (process-query)[list-generations]: Call 'display-channel-news'. --- guix/scripts/pull.scm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index d734df5e24..4a4756dc6e 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -272,12 +272,12 @@ (define* (display-channel-specific-news new old (for-each (cut display-news-entry <> language port) entries) (newline port))))))) -(define (display-channel-news profile) - "Display news about the channels of PROFILE " - (define previous - (and=> (relative-generation profile -1) - (cut generation-file-name profile <>))) - +(define* (display-channel-news profile + #:optional + (previous + (and=> (relative-generation profile -1) + (cut generation-file-name profile <>)))) + "Display news about the channels of PROFILE compared to PREVIOUS." (when previous (let ((old-channels (profile-channels previous)) (new-channels (profile-channels profile))) @@ -614,6 +614,8 @@ (define (list-generations profile numbers) ((first second rest ...) (display-profile-content-diff profile first second) + (display-channel-news (generation-file-name profile second) + (generation-file-name profile first)) (loop (cons second rest))) ((_) #t) (() #t)))))) -- cgit v1.2.3 From dabdd7d4650da685a9bfe470abbc2ec066ff00b9 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 21 Sep 2019 23:00:07 +0200 Subject: pull: Display news titles directly upon 'pull'. * guix/scripts/pull.scm (display-profile-news): Return true when there's more to display. (display-news-entry-title): New procedure. (display-news-entry): Use it. (display-channel-specific-news): Return true when there's more to display. (display-channel-news-headlines): New procedure. (build-and-install): Call it. When 'display-channel-news-headlines' or 'display-profile-news' returns #t, print a hint to run "pull --news". (display-new/upgraded-packages): Return true when there's more to display. --- guix/scripts/pull.scm | 112 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 81 insertions(+), 31 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 4a4756dc6e..a7fd36fffc 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -189,7 +189,7 @@ (define* (display-profile-news profile #:key concise? current-is-newer?) "Display what's up in PROFILE--new packages, and all that. If CURRENT-IS-NEWER? is true, assume that the current process represents the -newest generation of PROFILE." +newest generation of PROFILE. Return true when there's more info to display." (match (memv (generation-number profile) (reverse (profile-generations profile))) ((current previous _ ...) @@ -212,7 +212,7 @@ (define* (display-profile-news profile #:key concise? #:concise? concise? #:heading (G_ "New in this revision:\n"))))) - (_ #t))) + (_ #f))) (define (display-channel channel) "Display information about CHANNEL." @@ -230,33 +230,44 @@ (define (channel=? channel1 channel2) ;; Assume that the URL matters less than the name. (eq? (channel-name channel1) (channel-name channel2))) +(define (display-news-entry-title entry language port) + "Display the title of ENTRY, a news entry, to PORT." + (define title + (channel-news-entry-title entry)) + + (format port " ~a~%" + (highlight + (string-trim-right + (texi->plain-text (or (assoc-ref title language) + (assoc-ref title (%default-message-language)) + "")))))) + (define (display-news-entry entry language port) "Display ENTRY, a , in LANGUAGE, a language code, to PORT." - (let ((title (channel-news-entry-title entry)) - (body (channel-news-entry-body entry))) - (format port " ~a~%" - (highlight + (define body + (channel-news-entry-body entry)) + + (display-news-entry-title entry language port) + (format port (G_ " commit ~a~%") + (channel-news-entry-commit entry)) + (newline port) + (format port " ~a~%" + (indented-string + (parameterize ((%text-width (- (%text-width) 4))) (string-trim-right - (texi->plain-text (or (assoc-ref title language) - (assoc-ref title (%default-message-language)) - ""))))) - (format port (G_ " commit ~a~%") - (channel-news-entry-commit entry)) - (newline port) - (format port " ~a~%" - (indented-string - (parameterize ((%text-width (- (%text-width) 4))) - (string-trim-right - (texi->plain-text (or (assoc-ref body language) - (assoc-ref body (%default-message-language)) - "")))) - 4)))) + (texi->plain-text (or (assoc-ref body language) + (assoc-ref body (%default-message-language)) + "")))) + 4))) (define* (display-channel-specific-news new old - #:key (port (current-output-port))) + #:key (port (current-output-port)) + concise?) "Display channel news applicable the commits between OLD and NEW, where OLD -and NEW are records with a proper 'commit' field." +and NEW are records with a proper 'commit' field. When CONCISE? is +true, display nothing but the news titles. Return true if there are more news +to display." (let ((channel new) (old (channel-commit old)) (new (channel-commit new))) @@ -264,13 +275,17 @@ (define* (display-channel-specific-news new old (let ((language (current-message-language))) (match (channel-news-for-commit channel new old) (() ;no news is good news - #t) + #f) ((entries ...) (newline port) (format port (G_ "News for channel '~a'~%") (channel-name channel)) - (for-each (cut display-news-entry <> language port) entries) - (newline port))))))) + (for-each (if concise? + (cut display-news-entry-title <> language port) + (cut display-news-entry <> language port)) + entries) + (newline port) + #t)))))) (define* (display-channel-news profile #:optional @@ -317,6 +332,35 @@ (define old (and old (list new old))) new-channels))))))) +(define* (display-channel-news-headlines profile) + "Display the titles of news about the channels of PROFILE compared to its +previous generation. Return true if there are news to display." + (define previous + (and=> (relative-generation profile -1) + (cut generation-file-name profile <>))) + + (when previous + (let ((old-channels (profile-channels previous)) + (new-channels (profile-channels profile))) + ;; Find the channels present in both PROFILE and PREVIOUS, and print + ;; their news. + (and (pair? old-channels) (pair? new-channels) + (let ((channels (filter-map (lambda (new) + (define old + (find (cut channel=? new <>) + old-channels)) + + (and old (list new old))) + new-channels))) + (define more? + (map (match-lambda + ((new old) + (display-channel-specific-news new old + #:concise? #t))) + channels)) + + (any ->bool more?)))))) + (define (display-news profile) ;; Display profile news, with the understanding that this process represents ;; the newest generation. @@ -344,7 +388,12 @@ (define guix-command #:dry-run? dry-run?) (munless dry-run? (return (newline)) - (return (display-profile-news profile #:concise? #t)) + (return + (let ((more? (list (display-profile-news profile #:concise? #t) + (display-channel-news-headlines profile)))) + (when (any ->bool more?) + (display-hint + (G_ "Run @command{guix pull --news} to read all the news."))))) (if guix-command (let ((new (map (cut string-append <> "/bin/guix") (list (user-friendly-profile profile) @@ -544,7 +593,9 @@ (define* (display-new/upgraded-packages alist1 alist2 "Given the two package name/version alists ALIST1 and ALIST2, display the list of new and upgraded packages going from ALIST1 to ALIST2. When ALIST1 and ALIST2 differ, display HEADING upfront. When CONCISE? is true, do not -display long package lists that would fill the user's screen." +display long package lists that would fill the user's screen. + +Return true when there is more package info to display." (define (pretty str column) (indented-string (fill-paragraph str (- (%text-width) 4) column) @@ -587,10 +638,9 @@ (define upgraded-count (length upgraded)) (pretty (list->enumeration (sort upgraded string new-count concise/max-item-count) - (> upgraded-count concise/max-item-count))) - (display-hint (G_ "Run @command{guix pull --news} to read all the news."))))) + (and concise? + (or (> new-count concise/max-item-count) + (> upgraded-count concise/max-item-count))))) (define (display-profile-content-diff profile gen1 gen2) "Display the changes in PROFILE GEN2 compared to generation GEN1." -- cgit v1.2.3 From b69ce8a8721ad82a528acc21bed68e611e5c6114 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 23 Sep 2019 11:57:39 +0200 Subject: deploy: Add '--verbosity' and properly interpret build log. This is a followup to 91300526b7d9d775bd98a700ed3758420ef9eac6. * guix/scripts/deploy.scm (show-help, %options): Add '--verbosity'. (guix-deploy): Wrap 'with-store' in 'with-status-verbosity'. --- guix/scripts/deploy.scm | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm index cf571756fd..f311587ec3 100644 --- a/guix/scripts/deploy.scm +++ b/guix/scripts/deploy.scm @@ -26,6 +26,7 @@ (define-module (guix scripts deploy) #:use-module (guix ui) #:use-module (guix utils) #:use-module (guix grafts) + #:use-module (guix status) #:use-module (ice-9 format) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) @@ -52,6 +53,8 @@ (define (show-help) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -v, --verbosity=LEVEL use the given verbosity LEVEL")) (show-bug-report-information)) (define %options @@ -63,6 +66,12 @@ (define %options (lambda (opt name arg result) (alist-cons 'system arg (alist-delete 'system result eq?)))) + (option '(#\v "verbosity") #t #f + (lambda (opt name arg result) + (let ((level (string->number* arg))) + (alist-cons 'verbosity level + (alist-delete 'verbosity result))))) + %standard-build-options)) (define %default-options @@ -87,25 +96,27 @@ (module (make-user-module (append '((gnu) (gnu machine)) (define (guix-deploy . args) (define (handle-argument arg result) (alist-cons 'file arg result)) + (let* ((opts (parse-command-line args %options (list %default-options) #:argument-handler handle-argument)) (file (assq-ref opts 'file)) (machines (or (and file (load-source-file file)) '()))) - (with-store store - (set-build-options-from-command-line store opts) - (for-each (lambda (machine) - (info (G_ "deploying to ~a...~%") - (machine-display-name machine)) - (parameterize ((%graft? (assq-ref opts 'graft?))) - (guard (c ((message-condition? c) - (report-error (G_ "failed to deploy ~a: ~a~%") - (machine-display-name machine) - (condition-message c))) - ((deploy-error? c) - (when (deploy-error-should-roll-back c) - (info (G_ "rolling back ~a...~%") - (machine-display-name machine)) - (run-with-store store (roll-back-machine machine))) - (apply throw (deploy-error-captured-args c)))) - (run-with-store store (deploy-machine machine))))) - machines)))) + (with-status-verbosity (assoc-ref opts 'verbosity) + (with-store store + (set-build-options-from-command-line store opts) + (for-each (lambda (machine) + (info (G_ "deploying to ~a...~%") + (machine-display-name machine)) + (parameterize ((%graft? (assq-ref opts 'graft?))) + (guard (c ((message-condition? c) + (report-error (G_ "failed to deploy ~a: ~a~%") + (machine-display-name machine) + (condition-message c))) + ((deploy-error? c) + (when (deploy-error-should-roll-back c) + (info (G_ "rolling back ~a...~%") + (machine-display-name machine)) + (run-with-store store (roll-back-machine machine))) + (apply throw (deploy-error-captured-args c)))) + (run-with-store store (deploy-machine machine))))) + machines))))) -- cgit v1.2.3 From 77c2eafbbb9036c0e5ccc60e39c08439731791d8 Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Mon, 23 Sep 2019 11:55:33 -0700 Subject: scripts: container: Fix typo. * guix/scripts/container/exec (show-help): Fix spelling of COMMAND. --- guix/scripts/container/exec.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix/scripts') diff --git a/guix/scripts/container/exec.scm b/guix/scripts/container/exec.scm index d598f5cac4..51b616b384 100644 --- a/guix/scripts/container/exec.scm +++ b/guix/scripts/container/exec.scm @@ -38,7 +38,7 @@ (define %options (define (show-help) (display (G_ "Usage: guix container exec PID COMMAND [ARGS...] -Execute COMMMAND within the container process PID.\n")) +Execute COMMAND within the container process PID.\n")) (newline) (display (G_ " -h, --help display this help and exit")) -- cgit v1.2.3 From 4f8c29a75c3647b104c43ebf615d4a63a5e056b3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 23 Sep 2019 21:22:28 +0200 Subject: show, search: Add '--load-path'. * guix/scripts/search.scm (show-help, %options): Add -L/--load-path. * guix/scripts/show.scm (show-help, %options): Add -L/--load-path. --- guix/scripts/search.scm | 11 ++++++++++- guix/scripts/show.scm | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/search.scm b/guix/scripts/search.scm index 8fceb83668..827b2eb7a9 100644 --- a/guix/scripts/search.scm +++ b/guix/scripts/search.scm @@ -19,6 +19,8 @@ (define-module (guix scripts search) #:use-module (guix ui) #:use-module (guix scripts package) + #:use-module ((guix scripts build) + #:select (%standard-build-options)) #:use-module (guix scripts) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -36,6 +38,9 @@ (define (show-help) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -L, --load-path=DIR prepend DIR to the package module search path")) + (newline) (show-bug-report-information)) (define %options @@ -46,7 +51,11 @@ (define %options (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix search"))))) + (show-version-and-exit "guix search"))) + + (find (lambda (option) + (member "load-path" (option-names option))) + %standard-build-options))) (define (guix-search . args) (define (handle-argument arg result) diff --git a/guix/scripts/show.scm b/guix/scripts/show.scm index 94f0559358..ef64b5755b 100644 --- a/guix/scripts/show.scm +++ b/guix/scripts/show.scm @@ -19,6 +19,8 @@ (define-module (guix scripts show) #:use-module (guix ui) #:use-module (guix scripts package) + #:use-module ((guix scripts build) + #:select (%standard-build-options)) #:use-module (guix scripts) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -36,6 +38,9 @@ (define (show-help) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -L, --load-path=DIR prepend DIR to the package module search path")) + (newline) (show-bug-report-information)) (define %options @@ -46,7 +51,11 @@ (define %options (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix show"))))) + (show-version-and-exit "guix show"))) + + (find (lambda (option) + (member "load-path" (option-names option))) + %standard-build-options))) (define (guix-show . args) (define (handle-argument arg result) -- cgit v1.2.3 From 7b3f56f5d7f4d2bb936e1579ed442e7f5b080abd Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 23 Sep 2019 23:38:59 +0200 Subject: pull: Use ~/.cache/guix/checkouts instead of ~/.cache/guix/pull. Previously 'channel-news-for-commit' would use the former while 'guix pull' would use the latter. Consequently, the first 'guix pull -N' would clone the repository anew. * guix/scripts/pull.scm (guix-pull): Remove 'cache', and leave %REPOSITORY-CACHE-DIRECTORY to its default value. --- guix/scripts/pull.scm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index a7fd36fffc..2b7b991b50 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -764,7 +764,6 @@ (define (guix-pull . args) (with-git-error-handling (let* ((opts (parse-command-line args %options (list %default-options))) - (cache (string-append (cache-directory) "/pull")) (channels (channel-list opts)) (profile (or (assoc-ref opts 'profile) %current-profile))) (cond ((assoc-ref opts 'query) @@ -776,8 +775,7 @@ (define (guix-pull . args) (ensure-default-profile) (with-status-verbosity (assoc-ref opts 'verbosity) (parameterize ((%current-system (assoc-ref opts 'system)) - (%graft? (assoc-ref opts 'graft?)) - (%repository-cache-directory cache)) + (%graft? (assoc-ref opts 'graft?))) (set-build-options-from-command-line store opts) (honor-x509-certificates store) -- cgit v1.2.3