diff options
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/archive.scm | 2 | ||||
-rw-r--r-- | guix/scripts/authenticate.scm | 2 | ||||
-rw-r--r-- | guix/scripts/describe.scm | 159 | ||||
-rw-r--r-- | guix/scripts/download.scm | 2 | ||||
-rw-r--r-- | guix/scripts/hash.scm | 6 | ||||
-rw-r--r-- | guix/scripts/pack.scm | 60 | ||||
-rw-r--r-- | guix/scripts/package.scm | 57 | ||||
-rw-r--r-- | guix/scripts/publish.scm | 4 | ||||
-rw-r--r-- | guix/scripts/pull.scm | 22 | ||||
-rw-r--r-- | guix/scripts/refresh.scm | 2 | ||||
-rwxr-xr-x | guix/scripts/substitute.scm | 4 |
11 files changed, 252 insertions, 68 deletions
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm index a359f405fe..fb2f61ce30 100644 --- a/guix/scripts/archive.scm +++ b/guix/scripts/archive.scm @@ -29,7 +29,7 @@ #:use-module (guix monads) #:use-module (guix ui) #:use-module (guix pki) - #:use-module (guix pk-crypto) + #:use-module (gcrypt pk-crypto) #:use-module (guix scripts) #:use-module (guix scripts build) #:use-module (gnu packages) diff --git a/guix/scripts/authenticate.scm b/guix/scripts/authenticate.scm index 8b19dc871b..f1fd8ee895 100644 --- a/guix/scripts/authenticate.scm +++ b/guix/scripts/authenticate.scm @@ -19,7 +19,7 @@ (define-module (guix scripts authenticate) #:use-module (guix config) #:use-module (guix base16) - #:use-module (guix pk-crypto) + #:use-module (gcrypt pk-crypto) #:use-module (guix pki) #:use-module (guix ui) #:use-module (ice-9 binary-ports) diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm new file mode 100644 index 0000000000..fdff07d0e3 --- /dev/null +++ b/guix/scripts/describe.scm @@ -0,0 +1,159 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org> +;;; +;;; 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 <http://www.gnu.org/licenses/>. + +(define-module (guix scripts describe) + #:use-module ((guix ui) #:hide (display-profile-content)) + #:use-module (guix scripts) + #:use-module (guix describe) + #:use-module (guix profiles) + #:use-module ((guix scripts pull) #:select (display-profile-content)) + #:use-module (git) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-37) + #:use-module (ice-9 match) + #:autoload (ice-9 pretty-print) (pretty-print) + #:export (guix-describe)) + + +;;; +;;; Command-line options. +;;; + +(define %options + ;; Specifications of the command-line options. + (list (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg '("human" "channels")) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format 'channels result))) + (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix describe"))))) + +(define %default-options + ;; Alist of default option values. + '((format . human))) + +(define (show-help) + (display (G_ "Usage: guix describe [OPTION]... +Display information about the channels currently in use.\n")) + (display (G_ " + -f, --format=FORMAT display information in the given FORMAT")) + (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 (display-package-search-path fmt) + "Display GUIX_PACKAGE_PATH, if it is set, according to FMT." + (match (getenv "GUIX_PACKAGE_PATH") + (#f #t) + (string + (match fmt + ('human + (format #t "~%GUIX_PACKAGE_PATH=\"~a\"~%" string)) + ('channels + (format #t (G_ "~%;; warning: GUIX_PACKAGE_PATH=\"~a\"~%") + string)))))) + +(define (display-checkout-info fmt) + "Display information about the current checkout according to FMT, a symbol +denoting the requested format. Exit if the current directory does not lie +within a Git checkout." + (let* ((program (car (command-line))) + (directory (catch 'git-error + (lambda () + (repository-discover (dirname program))) + (lambda (key err) + (leave (G_ "failed to determine origin~%"))))) + (repository (repository-open directory)) + (head (repository-head repository)) + (commit (oid->string (reference-target head)))) + (match fmt + ('human + (format #t (G_ "Git checkout:~%")) + (format #t (G_ " repository: ~a~%") (dirname directory)) + (format #t (G_ " branch: ~a~%") (reference-shorthand head)) + (format #t (G_ " commit: ~a~%") commit)) + ('channels + (pretty-print `(list (channel + (name 'guix) + (url ,(dirname directory)) + (commit ,commit)))))) + (display-package-search-path fmt))) + +(define (display-profile-info profile fmt) + "Display information about PROFILE, a profile as created by (guix channels), +in the format specified by FMT." + (define number + (generation-number profile)) + + (match fmt + ('human + (display-profile-content profile number)) + ('channels + (pretty-print + `(list ,@(map (lambda (entry) + (match (assq 'source (manifest-entry-properties entry)) + (('source ('repository ('version 0) + ('url url) + ('branch branch) + ('commit commit) + _ ...)) + `(channel (name ',(string->symbol + (manifest-entry-name entry))) + (url ,url) + (commit ,commit))) + + ;; Pre-0.15.0 Guix does not provide that information, + ;; so there's not much we can do in that case. + (_ '???))) + + ;; Show most recently installed packages last. + (reverse + (manifest-entries + (profile-manifest (generation-file-name profile + number))))))))) + (display-package-search-path fmt)) + + +;;; +;;; Entry point. +;;; + +(define (guix-describe . args) + (let* ((opts (args-fold* args %options + (lambda (opt name arg result) + (leave (G_ "~A: unrecognized option~%") + name)) + cons + %default-options)) + (format (assq-ref opts 'format))) + (with-error-handling + (match (current-profile) + (#f + (display-checkout-info format)) + (profile + (display-profile-info profile format)))))) diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm index 1b99bc62cf..b9162d3449 100644 --- a/guix/scripts/download.scm +++ b/guix/scripts/download.scm @@ -20,7 +20,7 @@ #:use-module (guix ui) #:use-module (guix scripts) #:use-module (guix store) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix base16) #:use-module (guix base32) #:use-module ((guix download) #:hide (url-fetch)) diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm index cae5d6bcdf..2bd2ac4a06 100644 --- a/guix/scripts/hash.scm +++ b/guix/scripts/hash.scm @@ -20,7 +20,7 @@ (define-module (guix scripts hash) #:use-module (guix base32) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix serialization) #:use-module (guix ui) #:use-module (guix scripts) @@ -44,7 +44,7 @@ `((format . ,bytevector->nix-base32-string))) (define (show-help) - (display (G_ "Usage: guix hash [OPTION] FILE + (display (G_ "Usage: gcrypt hash [OPTION] FILE Return the cryptographic hash of FILE. Supported formats: 'nix-base32' (default), 'base32', and 'base16' ('hex' @@ -93,7 +93,7 @@ and 'hexadecimal' can be used as well).\n")) (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix hash"))))) + (show-version-and-exit "gcrypt hash"))))) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index fb0677de28..1916f3b9d7 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -41,7 +41,7 @@ #:use-module (gnu packages guile) #:use-module (gnu packages base) #:autoload (gnu packages package-management) (guix) - #:autoload (gnu packages gnupg) (libgcrypt) + #:autoload (gnu packages gnupg) (guile-gcrypt) #:autoload (gnu packages guile) (guile2.0-json guile-json) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -95,10 +95,12 @@ found." (('gnu _ ...) #t) (_ #f))) -(define guile-sqlite3&co - ;; Guile-SQLite3 and its propagated inputs. - (cons guile-sqlite3 - (package-transitive-propagated-inputs guile-sqlite3))) +(define gcrypt-sqlite3&co + ;; Guile-Gcrypt, Guile-SQLite3, and their propagated inputs. + (append-map (lambda (package) + (cons package + (package-transitive-propagated-inputs package))) + (list guile-gcrypt guile-sqlite3))) (define* (self-contained-tarball name profile #:key target @@ -124,16 +126,14 @@ added to the pack." "guix/store/schema.sql")))) (define build - (with-imported-modules `(((guix config) - => ,(make-config.scm - #:libgcrypt libgcrypt)) + (with-imported-modules `(((guix config) => ,(make-config.scm)) ,@(source-module-closure `((guix build utils) (guix build union) (guix build store-copy) (gnu build install)) #:select? not-config?)) - (with-extensions guile-sqlite3&co + (with-extensions gcrypt-sqlite3&co #~(begin (use-modules (guix build utils) ((guix build union) #:select (relative-file-name)) @@ -251,22 +251,14 @@ points for virtual file systems (like procfs), and optional symlinks. SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be added to the pack." - (define libgcrypt - ;; XXX: Not strictly needed, but pulled by (guix store database). - (module-ref (resolve-interface '(gnu packages gnupg)) - 'libgcrypt)) - - (define build - (with-imported-modules `(((guix config) - => ,(make-config.scm - #:libgcrypt libgcrypt)) + (with-imported-modules `(((guix config) => ,(make-config.scm)) ,@(source-module-closure '((guix build utils) (guix build store-copy) (gnu build install)) #:select? not-config?)) - (with-extensions guile-sqlite3&co + (with-extensions gcrypt-sqlite3&co #~(begin (use-modules (guix build utils) (gnu build install) @@ -349,32 +341,12 @@ must a be a GNU triplet and it is used to derive the architecture metadata in the image." (define defmod 'define-module) ;trick Geiser - (define config - ;; (guix config) module for consumption by (guix gcrypt). - (scheme-file "gcrypt-config.scm" - #~(begin - (#$defmod (guix config) - #:export (%libgcrypt)) - - ;; XXX: Work around <http://bugs.gnu.org/15602>. - (eval-when (expand load eval) - (define %libgcrypt - #+(file-append libgcrypt "/lib/libgcrypt")))))) - - (define json - ;; Pick the guile-json package that corresponds to the Guile used to build - ;; derivations. - (if (string-prefix? "2.0" (package-version (default-guile))) - guile2.0-json - guile-json)) - (define build - ;; Guile-JSON is required by (guix docker). - (with-extensions (list json) - (with-imported-modules `(,@(source-module-closure '((guix docker) - (guix build store-copy)) - #:select? not-config?) - ((guix config) => ,config)) + ;; Guile-JSON and Guile-Gcrypt are required by (guix docker). + (with-extensions (list guile-json guile-gcrypt) + (with-imported-modules (source-module-closure '((guix docker) + (guix build store-copy)) + #:select? not-config?) #~(begin (use-modules (guix docker) (srfi srfi-19) (guix build store-copy)) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index b38a55d01c..97bcc699d9 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -35,6 +35,7 @@ #:use-module (guix config) #:use-module (guix scripts) #:use-module (guix scripts build) + #:autoload (guix describe) (current-profile-entries) #:use-module ((guix build utils) #:select (directory-exists? mkdir-p)) #:use-module (ice-9 format) @@ -238,7 +239,7 @@ of relevance scores." (info (G_ "package '~a' has been superseded by '~a'~%") (manifest-entry-name old) (package-name new)) (manifest-transaction-install-entry - (package->manifest-entry new (manifest-entry-output old)) + (package->manifest-entry* new (manifest-entry-output old)) (manifest-transaction-remove-pattern (manifest-pattern (name (manifest-entry-name old)) @@ -261,7 +262,7 @@ of relevance scores." (case (version-compare candidate-version version) ((>) (manifest-transaction-install-entry - (package->manifest-entry pkg output) + (package->manifest-entry* pkg output) transaction)) ((<) transaction) @@ -274,7 +275,7 @@ of relevance scores." (null? (package-propagated-inputs pkg))) transaction (manifest-transaction-install-entry - (package->manifest-entry pkg output) + (package->manifest-entry* pkg output) transaction)))))))) (#f (warning (G_ "package '~a' no longer exists~%") name) @@ -570,6 +571,52 @@ upgrading, #f otherwise." (output "out") ;XXX: wild guess (item item)))) +(define (package-provenance package) + "Return the provenance of PACKAGE as an sexp for use as the 'provenance' +property of manifest entries, or #f if it could not be determined." + (define (entry-source entry) + (match (assq 'source + (manifest-entry-properties entry)) + (('source value) value) + (_ #f))) + + (match (and=> (package-location package) location-file) + (#f #f) + (file + (let ((file (if (string-prefix? "/" file) + file + (search-path %load-path file)))) + (and file + (string-prefix? (%store-prefix) file) + + ;; Always store information about the 'guix' channel and + ;; optionally about the specific channel FILE comes from. + (or (let ((main (and=> (find (lambda (entry) + (string=? "guix" + (manifest-entry-name entry))) + (current-profile-entries)) + entry-source)) + (extra (any (lambda (entry) + (let ((item (manifest-entry-item entry))) + (and (string-prefix? item file) + (entry-source entry)))) + (current-profile-entries)))) + (and main + `(,main + ,@(if extra (list extra) '())))))))))) + +(define (package->manifest-entry* package output) + "Like 'package->manifest-entry', but attach PACKAGE provenance meta-data to +the resulting manifest entry." + (define (provenance-properties package) + (match (package-provenance package) + (#f '()) + (sexp `((provenance ,@sexp))))) + + (package->manifest-entry package output + #:properties (provenance-properties package))) + + (define (options->installable opts manifest transaction) "Given MANIFEST, the current manifest, and OPTS, the result of 'args-fold', return an variant of TRANSACTION that accounts for the specified installations @@ -590,13 +637,13 @@ and upgrades." (('install . (? package? p)) ;; When given a package via `-e', install the first of its ;; outputs (XXX). - (package->manifest-entry p "out")) + (package->manifest-entry* p "out")) (('install . (? string? spec)) (if (store-path? spec) (store-item->manifest-entry spec) (let-values (((package output) (specification->package+output spec))) - (package->manifest-entry package output)))) + (package->manifest-entry* package output)))) (_ #f)) opts)) diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index b5dfdab32f..c5326b33da 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -44,9 +44,9 @@ #:use-module (guix base64) #:use-module (guix config) #:use-module (guix derivations) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix pki) - #:use-module (guix pk-crypto) + #:use-module (gcrypt pk-crypto) #:use-module (guix workers) #:use-module (guix store) #:use-module ((guix serialization) #:select (write-file)) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 18c04f05dd..976e054a84 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -48,7 +48,8 @@ #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (ice-9 vlist) - #:export (guix-pull)) + #:export (display-profile-content + guix-pull)) ;;; @@ -80,6 +81,8 @@ Download and deploy the latest version of Guix.\n")) -l, --list-generations[=PATTERN] list generations matching PATTERN")) (display (G_ " + -p, --profile=PROFILE use PROFILE instead of ~/.config/guix/current")) + (display (G_ " --bootstrap use the bootstrap Guile to build the new Guix")) (newline) (show-build-options-help) @@ -113,6 +116,10 @@ Download and deploy the latest version of Guix.\n")) (lambda (opt name arg result) (alist-cons 'ref `(branch . ,(string-append "origin/" arg)) result))) + (option '(#\p "profile") #t #f + (lambda (opt name arg result) + (alist-cons 'profile (canonicalize-profile arg) + result))) (option '(#\n "dry-run") #f #f (lambda (opt name arg result) (alist-cons 'dry-run? #t (alist-cons 'graft? #f result)))) @@ -152,15 +159,12 @@ Download and deploy the latest version of Guix.\n")) #:heading (G_ "New in this revision:\n")))) (_ #t))) -(define* (build-and-install instances config-dir +(define* (build-and-install instances profile #:key verbose?) - "Build the tool from SOURCE, and install it in CONFIG-DIR." + "Build the tool from SOURCE, and install it in PROFILE." (define update-profile (store-lift build-and-use-profile)) - (define profile - (string-append config-dir "/current")) - (mlet %store-monad ((manifest (channel-instances->manifest instances))) (mbegin %store-monad (update-profile profile manifest) @@ -414,7 +418,9 @@ Use '~/.config/guix/channels.scm' instead.")) (let* ((opts (parse-command-line args %options (list %default-options))) (cache (string-append (cache-directory) "/pull")) - (channels (channel-list opts))) + (channels (channel-list opts)) + (profile (or (assoc-ref opts 'profile) + (string-append (config-directory) "/current")))) (cond ((assoc-ref opts 'query) (process-query opts)) @@ -456,7 +462,7 @@ Use '~/.config/guix/channels.scm' instead.")) %bootstrap-guile (canonical-package guile-2.2))))) (run-with-store store - (build-and-install instances (config-directory) + (build-and-install instances profile #:verbose? (assoc-ref opts 'verbose?))))))))))))) diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index a8fe993e33..bcc23bd39c 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -23,7 +23,7 @@ (define-module (guix scripts refresh) #:use-module (guix ui) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix scripts) #:use-module (guix store) #:use-module (guix utils) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 7634bb37f6..cd300195d8 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -26,11 +26,11 @@ #:use-module (guix config) #:use-module (guix records) #:use-module ((guix serialization) #:select (restore-file)) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix base32) #:use-module (guix base64) #:use-module (guix cache) - #:use-module (guix pk-crypto) + #:use-module (gcrypt pk-crypto) #:use-module (guix pki) #:use-module ((guix build utils) #:select (mkdir-p dump-port)) #:use-module ((guix build download) |