diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-04-27 18:04:00 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-04-29 10:13:44 +0200 |
| commit | d824cfbabeb0780c9ea7a6dab02c47b6a4d029c6 (patch) | |
| tree | 6ebf175470992c311a20278cf3b3162da6c9c82b | |
| parent | 4c89dc354ea19234b05b7948a55ec435df9753f0 (diff) | |
guix package: Add 'install', 'remove', and 'upgrade' aliases.
* guix/scripts/install.scm, guix/scripts/remove.scm,
guix/scripts/upgrade.scm, tests/guix-package-aliases.sh: New files.
* Makefile.am (MODULES, SH_TESTS): Add them.
* po/guix/POTFILES.in: Add them.
* guix/scripts/package.scm (guix-package): Split with...
(guix-package*): ... this. New procedure.
* doc/guix.texi (Invoking guix package): Document them.
(Binary Installation, Application Setup, Package Management)
(Packages with Multiple Outputs, Package Modules)
(X.509 Certificates, Installing Debugging Files): Use 'guix install' in
simple examples.
* etc/completion/bash/guix (_guix_complete): Handle "install", "remove",
and "upgrade".
| -rw-r--r-- | Makefile.am | 4 | ||||
| -rw-r--r-- | doc/guix.texi | 39 | ||||
| -rw-r--r-- | etc/completion/bash/guix | 11 | ||||
| -rw-r--r-- | guix/scripts/install.scm | 80 | ||||
| -rw-r--r-- | guix/scripts/package.scm | 11 | ||||
| -rw-r--r-- | guix/scripts/remove.scm | 77 | ||||
| -rw-r--r-- | guix/scripts/upgrade.scm | 88 | ||||
| -rw-r--r-- | po/guix/POTFILES.in | 3 | ||||
| -rw-r--r-- | tests/guix-package-aliases.sh | 58 |
9 files changed, 358 insertions, 13 deletions
diff --git a/Makefile.am b/Makefile.am index 05940719cd1..076f1c7a714 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -224,6 +224,9 @@ MODULES = \ | |||
| 224 | guix/scripts/archive.scm \ | 224 | guix/scripts/archive.scm \ |
| 225 | guix/scripts/import.scm \ | 225 | guix/scripts/import.scm \ |
| 226 | guix/scripts/package.scm \ | 226 | guix/scripts/package.scm \ |
| 227 | guix/scripts/install.scm \ | ||
| 228 | guix/scripts/remove.scm \ | ||
| 229 | guix/scripts/upgrade.scm \ | ||
| 227 | guix/scripts/gc.scm \ | 230 | guix/scripts/gc.scm \ |
| 228 | guix/scripts/hash.scm \ | 231 | guix/scripts/hash.scm \ |
| 229 | guix/scripts/pack.scm \ | 232 | guix/scripts/pack.scm \ |
| @@ -425,6 +428,7 @@ SH_TESTS = \ | |||
| 425 | tests/guix-pack-localstatedir.sh \ | 428 | tests/guix-pack-localstatedir.sh \ |
| 426 | tests/guix-pack-relocatable.sh \ | 429 | tests/guix-pack-relocatable.sh \ |
| 427 | tests/guix-package.sh \ | 430 | tests/guix-package.sh \ |
| 431 | tests/guix-package-aliases.sh \ | ||
| 428 | tests/guix-package-net.sh \ | 432 | tests/guix-package-net.sh \ |
| 429 | tests/guix-system.sh \ | 433 | tests/guix-system.sh \ |
| 430 | tests/guix-archive.sh \ | 434 | tests/guix-archive.sh \ |
diff --git a/doc/guix.texi b/doc/guix.texi index c28ded1cf11..6c3dc7d2081 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -689,7 +689,7 @@ You can confirm that Guix is working by installing a sample package into | |||
| 689 | the root profile: | 689 | the root profile: |
| 690 | 690 | ||
| 691 | @example | 691 | @example |
| 692 | # guix package -i hello | 692 | # guix install hello |
| 693 | @end example | 693 | @end example |
| 694 | 694 | ||
| 695 | The binary installation tarball can be (re)produced and verified simply | 695 | The binary installation tarball can be (re)produced and verified simply |
| @@ -1577,7 +1577,7 @@ available with Guix and then define the @code{GUIX_LOCPATH} environment | |||
| 1577 | variable: | 1577 | variable: |
| 1578 | 1578 | ||
| 1579 | @example | 1579 | @example |
| 1580 | $ guix package -i glibc-locales | 1580 | $ guix install glibc-locales |
| 1581 | $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale | 1581 | $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale |
| 1582 | @end example | 1582 | @end example |
| 1583 | 1583 | ||
| @@ -1677,7 +1677,7 @@ Multiple Outputs}). For instance, the following command installs fonts | |||
| 1677 | for Chinese languages: | 1677 | for Chinese languages: |
| 1678 | 1678 | ||
| 1679 | @example | 1679 | @example |
| 1680 | guix package -i font-adobe-source-han-sans:cn | 1680 | guix install font-adobe-source-han-sans:cn |
| 1681 | @end example | 1681 | @end example |
| 1682 | 1682 | ||
| 1683 | @cindex @code{xterm} | 1683 | @cindex @code{xterm} |
| @@ -2492,7 +2492,7 @@ emacs-guix, The Emacs-Guix Reference Manual}), after installing | |||
| 2492 | with it): | 2492 | with it): |
| 2493 | 2493 | ||
| 2494 | @example | 2494 | @example |
| 2495 | guix package -i emacs-guix | 2495 | guix install emacs-guix |
| 2496 | @end example | 2496 | @end example |
| 2497 | 2497 | ||
| 2498 | @menu | 2498 | @menu |
| @@ -2610,6 +2610,7 @@ is: | |||
| 2610 | @example | 2610 | @example |
| 2611 | guix package @var{options} | 2611 | guix package @var{options} |
| 2612 | @end example | 2612 | @end example |
| 2613 | |||
| 2613 | @cindex transactions | 2614 | @cindex transactions |
| 2614 | Primarily, @var{options} specifies the operations to be performed during | 2615 | Primarily, @var{options} specifies the operations to be performed during |
| 2615 | the transaction. Upon completion, a new profile is created, but | 2616 | the transaction. Upon completion, a new profile is created, but |
| @@ -2623,6 +2624,22 @@ For example, to remove @code{lua} and install @code{guile} and | |||
| 2623 | guix package -r lua -i guile guile-cairo | 2624 | guix package -r lua -i guile guile-cairo |
| 2624 | @end example | 2625 | @end example |
| 2625 | 2626 | ||
| 2627 | @cindex aliases, for @command{guix package} | ||
| 2628 | For your convenience, we also provide the following aliases: | ||
| 2629 | |||
| 2630 | @itemize | ||
| 2631 | @item | ||
| 2632 | @command{guix install} is an alias for @command{guix package -i}, | ||
| 2633 | @item | ||
| 2634 | @command{guix remove} is an alias for @command{guix package -r}, | ||
| 2635 | @item | ||
| 2636 | and @command{guix upgrade} is an alias for @command{guix package -u}. | ||
| 2637 | @end itemize | ||
| 2638 | |||
| 2639 | These aliases are less expressive than @command{guix package} and provide | ||
| 2640 | fewer options, so in some cases you'll probably want to use @command{guix | ||
| 2641 | package} directly. | ||
| 2642 | |||
| 2626 | @command{guix package} also supports a @dfn{declarative approach} | 2643 | @command{guix package} also supports a @dfn{declarative approach} |
| 2627 | whereby the user specifies the exact set of packages to be available and | 2644 | whereby the user specifies the exact set of packages to be available and |
| 2628 | passes it @i{via} the @option{--manifest} option | 2645 | passes it @i{via} the @option{--manifest} option |
| @@ -3312,7 +3329,7 @@ like to discuss this project, join us on @email{guix-devel@@gnu.org}. | |||
| 3312 | 3329 | ||
| 3313 | Often, packages defined in Guix have a single @dfn{output}---i.e., the | 3330 | Often, packages defined in Guix have a single @dfn{output}---i.e., the |
| 3314 | source package leads to exactly one directory in the store. When running | 3331 | source package leads to exactly one directory in the store. When running |
| 3315 | @command{guix package -i glibc}, one installs the default output of the | 3332 | @command{guix install glibc}, one installs the default output of the |
| 3316 | GNU libc package; the default output is called @code{out}, but its name | 3333 | GNU libc package; the default output is called @code{out}, but its name |
| 3317 | can be omitted as shown in this command. In this particular case, the | 3334 | can be omitted as shown in this command. In this particular case, the |
| 3318 | default output of @code{glibc} contains all the C header files, shared | 3335 | default output of @code{glibc} contains all the C header files, shared |
| @@ -3328,14 +3345,14 @@ separate output, called @code{doc}. To install the main GLib output, | |||
| 3328 | which contains everything but the documentation, one would run: | 3345 | which contains everything but the documentation, one would run: |
| 3329 | 3346 | ||
| 3330 | @example | 3347 | @example |
| 3331 | guix package -i glib | 3348 | guix install glib |
| 3332 | @end example | 3349 | @end example |
| 3333 | 3350 | ||
| 3334 | @cindex documentation | 3351 | @cindex documentation |
| 3335 | The command to install its documentation is: | 3352 | The command to install its documentation is: |
| 3336 | 3353 | ||
| 3337 | @example | 3354 | @example |
| 3338 | guix package -i glib:doc | 3355 | guix install glib:doc |
| 3339 | @end example | 3356 | @end example |
| 3340 | 3357 | ||
| 3341 | Some packages install programs with different ``dependency footprints''. | 3358 | Some packages install programs with different ``dependency footprints''. |
| @@ -4986,7 +5003,7 @@ module exports a variable named @code{emacs}, which is bound to a | |||
| 4986 | 5003 | ||
| 4987 | The @code{(gnu packages @dots{})} module name space is | 5004 | The @code{(gnu packages @dots{})} module name space is |
| 4988 | automatically scanned for packages by the command-line tools. For | 5005 | automatically scanned for packages by the command-line tools. For |
| 4989 | instance, when running @code{guix package -i emacs}, all the @code{(gnu | 5006 | instance, when running @code{guix install emacs}, all the @code{(gnu |
| 4990 | packages @dots{})} modules are scanned until one that exports a package | 5007 | packages @dots{})} modules are scanned until one that exports a package |
| 4991 | object whose name is @code{emacs} is found. This package search | 5008 | object whose name is @code{emacs} is found. This package search |
| 4992 | facility is implemented in the @code{(gnu packages)} module. | 5009 | facility is implemented in the @code{(gnu packages)} module. |
| @@ -23634,7 +23651,7 @@ pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you | |||
| 23634 | would typically run something like: | 23651 | would typically run something like: |
| 23635 | 23652 | ||
| 23636 | @example | 23653 | @example |
| 23637 | $ guix package -i nss-certs | 23654 | $ guix install nss-certs |
| 23638 | $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs" | 23655 | $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs" |
| 23639 | $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" | 23656 | $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" |
| 23640 | $ export GIT_SSL_CAINFO="$SSL_CERT_FILE" | 23657 | $ export GIT_SSL_CAINFO="$SSL_CERT_FILE" |
| @@ -23645,7 +23662,7 @@ variable to point to a certificate bundle, so you would have to run | |||
| 23645 | something like this: | 23662 | something like this: |
| 23646 | 23663 | ||
| 23647 | @example | 23664 | @example |
| 23648 | $ guix package -i nss-certs | 23665 | $ guix install nss-certs |
| 23649 | $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" | 23666 | $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" |
| 23650 | @end example | 23667 | @end example |
| 23651 | 23668 | ||
| @@ -25427,7 +25444,7 @@ installs the debugging information for the GNU C Library and for GNU | |||
| 25427 | Guile: | 25444 | Guile: |
| 25428 | 25445 | ||
| 25429 | @example | 25446 | @example |
| 25430 | guix package -i glibc:debug guile:debug | 25447 | guix install glibc:debug guile:debug |
| 25431 | @end example | 25448 | @end example |
| 25432 | 25449 | ||
| 25433 | GDB must then be told to look for debug files in the user's profile, by | 25450 | GDB must then be told to look for debug files in the user's profile, by |
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix index 3d2b3ddda7a..edfb627e876 100644 --- a/etc/completion/bash/guix +++ b/etc/completion/bash/guix | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # GNU Guix --- Functional package management for GNU | 1 | # GNU Guix --- Functional package management for GNU |
| 2 | # Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> | 2 | # Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> |
| 3 | # | 3 | # |
| 4 | # This file is part of GNU Guix. | 4 | # This file is part of GNU Guix. |
| 5 | # | 5 | # |
| @@ -167,6 +167,15 @@ _guix_complete () | |||
| 167 | else | 167 | else |
| 168 | _guix_complete_available_package "$word_at_point" | 168 | _guix_complete_available_package "$word_at_point" |
| 169 | fi | 169 | fi |
| 170 | elif _guix_is_command "install" | ||
| 171 | then | ||
| 172 | _guix_complete_available_package "$word_at_point" | ||
| 173 | elif _guix_is_command "remove" | ||
| 174 | then | ||
| 175 | _guix_complete_installed_package "$word_at_point" | ||
| 176 | elif _guix_is_command "upgrade" | ||
| 177 | then | ||
| 178 | _guix_complete_installed_package "$word_at_point" | ||
| 170 | elif _guix_is_command "build" | 179 | elif _guix_is_command "build" |
| 171 | then | 180 | then |
| 172 | if _guix_is_dash_L | 181 | if _guix_is_dash_L |
diff --git a/guix/scripts/install.scm b/guix/scripts/install.scm new file mode 100644 index 00000000000..d88e86e77ad --- /dev/null +++ b/guix/scripts/install.scm | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (guix scripts install) | ||
| 20 | #:use-module (guix ui) | ||
| 21 | #:use-module (guix scripts package) | ||
| 22 | #:use-module (guix scripts build) | ||
| 23 | #:use-module (guix scripts) | ||
| 24 | #:use-module (srfi srfi-1) | ||
| 25 | #:use-module (srfi srfi-26) | ||
| 26 | #:use-module (srfi srfi-37) | ||
| 27 | #:export (guix-install)) | ||
| 28 | |||
| 29 | (define (show-help) | ||
| 30 | (display (G_ "Usage: guix install [OPTION] PACKAGES... | ||
| 31 | Install the given PACKAGES. | ||
| 32 | This is an alias for 'guix package -i'.\n")) | ||
| 33 | (display (G_ " | ||
| 34 | -p, --profile=PROFILE use PROFILE instead of the user's default profile")) | ||
| 35 | ;; '--bootstrap' not shown here. | ||
| 36 | (display (G_ " | ||
| 37 | -v, --verbosity=LEVEL use the given verbosity LEVEL")) | ||
| 38 | (newline) | ||
| 39 | (show-build-options-help) | ||
| 40 | (newline) | ||
| 41 | (show-transformation-options-help) | ||
| 42 | (newline) | ||
| 43 | (display (G_ " | ||
| 44 | -h, --help display this help and exit")) | ||
| 45 | (display (G_ " | ||
| 46 | -V, --version display version information and exit")) | ||
| 47 | (newline) | ||
| 48 | (show-bug-report-information)) | ||
| 49 | |||
| 50 | (define %options | ||
| 51 | ;; Specification of the command-line options. | ||
| 52 | (cons* (option '(#\h "help") #f #f | ||
| 53 | (lambda args | ||
| 54 | (show-help) | ||
| 55 | (exit 0))) | ||
| 56 | (option '(#\V "version") #f #f | ||
| 57 | (lambda args | ||
| 58 | (show-version-and-exit "guix install"))) | ||
| 59 | |||
| 60 | ;; Preserve some of the 'guix package' options. | ||
| 61 | (append (filter (lambda (option) | ||
| 62 | (any (cut member <> (option-names option)) | ||
| 63 | '("profile" "dry-run" "verbosity" "bootstrap"))) | ||
| 64 | %package-options) | ||
| 65 | |||
| 66 | %transformation-options | ||
| 67 | %standard-build-options))) | ||
| 68 | |||
| 69 | (define (guix-install . args) | ||
| 70 | (define (handle-argument arg result arg-handler) | ||
| 71 | ;; Treat all non-option arguments as package specs. | ||
| 72 | (values (alist-cons 'install arg result) | ||
| 73 | arg-handler)) | ||
| 74 | |||
| 75 | (define opts | ||
| 76 | (parse-command-line args %options | ||
| 77 | (list %package-default-options #f) | ||
| 78 | #:argument-handler handle-argument)) | ||
| 79 | |||
| 80 | (guix-package* opts)) | ||
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 564236988ec..aa27984ea2a 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm | |||
| @@ -58,7 +58,11 @@ | |||
| 58 | delete-generations | 58 | delete-generations |
| 59 | delete-matching-generations | 59 | delete-matching-generations |
| 60 | display-search-paths | 60 | display-search-paths |
| 61 | guix-package)) | 61 | guix-package |
| 62 | |||
| 63 | (%options . %package-options) | ||
| 64 | (%default-options . %package-default-options) | ||
| 65 | guix-package*)) | ||
| 62 | 66 | ||
| 63 | (define %store | 67 | (define %store |
| 64 | (make-parameter #f)) | 68 | (make-parameter #f)) |
| @@ -899,6 +903,11 @@ processed, #f otherwise." | |||
| 899 | (parse-command-line args %options (list %default-options #f) | 903 | (parse-command-line args %options (list %default-options #f) |
| 900 | #:argument-handler handle-argument)) | 904 | #:argument-handler handle-argument)) |
| 901 | 905 | ||
| 906 | (guix-package* opts)) | ||
| 907 | |||
| 908 | (define (guix-package* opts) | ||
| 909 | "Run the 'guix package' command on OPTS, an alist resulting for command-line | ||
| 910 | option processing with 'parse-command-line'." | ||
| 902 | (with-error-handling | 911 | (with-error-handling |
| 903 | (or (process-query opts) | 912 | (or (process-query opts) |
| 904 | (parameterize ((%store (open-connection)) | 913 | (parameterize ((%store (open-connection)) |
diff --git a/guix/scripts/remove.scm b/guix/scripts/remove.scm new file mode 100644 index 00000000000..2f06ea4f377 --- /dev/null +++ b/guix/scripts/remove.scm | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (guix scripts remove) | ||
| 20 | #:use-module (guix ui) | ||
| 21 | #:use-module (guix scripts package) | ||
| 22 | #:use-module (guix scripts build) | ||
| 23 | #:use-module (guix scripts) | ||
| 24 | #:use-module (srfi srfi-1) | ||
| 25 | #:use-module (srfi srfi-26) | ||
| 26 | #:use-module (srfi srfi-37) | ||
| 27 | #:export (guix-remove)) | ||
| 28 | |||
| 29 | (define (show-help) | ||
| 30 | (display (G_ "Usage: guix remove [OPTION] PACKAGES... | ||
| 31 | Remove the given PACKAGES. | ||
| 32 | This is an alias for 'guix package -r'.\n")) | ||
| 33 | (display (G_ " | ||
| 34 | -p, --profile=PROFILE use PROFILE instead of the user's default profile")) | ||
| 35 | ;; '--bootstrap' not shown here. | ||
| 36 | (display (G_ " | ||
| 37 | -v, --verbosity=LEVEL use the given verbosity LEVEL")) | ||
| 38 | (newline) | ||
| 39 | (show-build-options-help) | ||
| 40 | (newline) | ||
| 41 | (display (G_ " | ||
| 42 | -h, --help display this help and exit")) | ||
| 43 | (display (G_ " | ||
| 44 | -V, --version display version information and exit")) | ||
| 45 | (newline) | ||
| 46 | (show-bug-report-information)) | ||
| 47 | |||
| 48 | (define %options | ||
| 49 | ;; Specification of the command-line options. | ||
| 50 | (cons* (option '(#\h "help") #f #f | ||
| 51 | (lambda args | ||
| 52 | (show-help) | ||
| 53 | (exit 0))) | ||
| 54 | (option '(#\V "version") #f #f | ||
| 55 | (lambda args | ||
| 56 | (show-version-and-exit "guix remove"))) | ||
| 57 | |||
| 58 | ;; Preserve some of the 'guix package' options. | ||
| 59 | (append (filter (lambda (option) | ||
| 60 | (any (cut member <> (option-names option)) | ||
| 61 | '("profile" "dry-run" "verbosity" "bootstrap"))) | ||
| 62 | %package-options) | ||
| 63 | |||
| 64 | %standard-build-options))) | ||
| 65 | |||
| 66 | (define (guix-remove . args) | ||
| 67 | (define (handle-argument arg result arg-handler) | ||
| 68 | ;; Treat all non-option arguments as package specs. | ||
| 69 | (values (alist-cons 'remove arg result) | ||
| 70 | arg-handler)) | ||
| 71 | |||
| 72 | (define opts | ||
| 73 | (parse-command-line args %options | ||
| 74 | (list %package-default-options #f) | ||
| 75 | #:argument-handler handle-argument)) | ||
| 76 | |||
| 77 | (guix-package* opts)) | ||
diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm new file mode 100644 index 00000000000..7f14a2fdbed --- /dev/null +++ b/guix/scripts/upgrade.scm | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (guix scripts upgrade) | ||
| 20 | #:use-module (guix ui) | ||
| 21 | #:use-module (guix scripts package) | ||
| 22 | #:use-module (guix scripts build) | ||
| 23 | #:use-module (guix scripts) | ||
| 24 | #:use-module (srfi srfi-1) | ||
| 25 | #:use-module (srfi srfi-26) | ||
| 26 | #:use-module (srfi srfi-37) | ||
| 27 | #:use-module (ice-9 match) | ||
| 28 | #:export (guix-upgrade)) | ||
| 29 | |||
| 30 | (define (show-help) | ||
| 31 | (display (G_ "Usage: guix upgrade [OPTION] [REGEXP] | ||
| 32 | Upgrade packages that match REGEXP. | ||
| 33 | This is an alias for 'guix package -u'.\n")) | ||
| 34 | (display (G_ " | ||
| 35 | -p, --profile=PROFILE use PROFILE instead of the user's default profile")) | ||
| 36 | (display (G_ " | ||
| 37 | -v, --verbosity=LEVEL use the given verbosity LEVEL")) | ||
| 38 | (newline) | ||
| 39 | (show-build-options-help) | ||
| 40 | (newline) | ||
| 41 | (show-transformation-options-help) | ||
| 42 | (newline) | ||
| 43 | (display (G_ " | ||
| 44 | -h, --help display this help and exit")) | ||
| 45 | (display (G_ " | ||
| 46 | -V, --version display version information and exit")) | ||
| 47 | (newline) | ||
| 48 | (show-bug-report-information)) | ||
| 49 | |||
| 50 | (define %options | ||
| 51 | ;; Specification of the command-line options. | ||
| 52 | (cons* (option '(#\h "help") #f #f | ||
| 53 | (lambda args | ||
| 54 | (show-help) | ||
| 55 | (exit 0))) | ||
| 56 | (option '(#\V "version") #f #f | ||
| 57 | (lambda args | ||
| 58 | (show-version-and-exit "guix upgrade"))) | ||
| 59 | |||
| 60 | ;; Preserve some of the 'guix package' options. | ||
| 61 | (append (filter (lambda (option) | ||
| 62 | (any (cut member <> (option-names option)) | ||
| 63 | '("profile" "dry-run" "verbosity"))) | ||
| 64 | %package-options) | ||
| 65 | |||
| 66 | %transformation-options | ||
| 67 | %standard-build-options))) | ||
| 68 | |||
| 69 | (define (guix-upgrade . args) | ||
| 70 | (define (handle-argument arg result arg-handler) | ||
| 71 | ;; Accept at most one non-option argument, and treat it as an upgrade | ||
| 72 | ;; regexp. | ||
| 73 | (match (assq-ref result 'upgrade) | ||
| 74 | (#f | ||
| 75 | (values (alist-cons 'upgrade arg | ||
| 76 | (alist-delete 'upgrade result)) | ||
| 77 | arg-handler)) | ||
| 78 | (_ | ||
| 79 | (leave (G_ "~A: extraneous argument~%") arg)))) | ||
| 80 | |||
| 81 | (define opts | ||
| 82 | (parse-command-line args %options | ||
| 83 | (list `((upgrade . #f) | ||
| 84 | ,@%package-default-options) | ||
| 85 | #f) | ||
| 86 | #:argument-handler handle-argument)) | ||
| 87 | |||
| 88 | (guix-package* opts)) | ||
diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index a2c89db981d..91de60efc7f 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in | |||
| @@ -41,6 +41,9 @@ guix/scripts/build.scm | |||
| 41 | guix/discovery.scm | 41 | guix/discovery.scm |
| 42 | guix/scripts/download.scm | 42 | guix/scripts/download.scm |
| 43 | guix/scripts/package.scm | 43 | guix/scripts/package.scm |
| 44 | guix/scripts/install.scm | ||
| 45 | guix/scripts/remove.scm | ||
| 46 | guix/scripts/upgrade.scm | ||
| 44 | guix/scripts/gc.scm | 47 | guix/scripts/gc.scm |
| 45 | guix/scripts/hash.scm | 48 | guix/scripts/hash.scm |
| 46 | guix/scripts/import.scm | 49 | guix/scripts/import.scm |
diff --git a/tests/guix-package-aliases.sh b/tests/guix-package-aliases.sh new file mode 100644 index 00000000000..64ed2fbb675 --- /dev/null +++ b/tests/guix-package-aliases.sh | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | # GNU Guix --- Functional package management for GNU | ||
| 2 | # Copyright © 2019 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | # | ||
| 4 | # This file is part of GNU Guix. | ||
| 5 | # | ||
| 6 | # GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | # under the terms of the GNU General Public License as published by | ||
| 8 | # the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | # your option) any later version. | ||
| 10 | # | ||
| 11 | # GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | # GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License | ||
| 17 | # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | # | ||
| 20 | # Test the `guix package' aliases. | ||
| 21 | # | ||
| 22 | |||
| 23 | guix install --version | ||
| 24 | |||
| 25 | readlink_base () | ||
| 26 | { | ||
| 27 | basename `readlink "$1"` | ||
| 28 | } | ||
| 29 | |||
| 30 | profile="t-profile-$$" | ||
| 31 | rm -f "$profile" | ||
| 32 | |||
| 33 | trap 'rm -f "$profile" "$profile-"[0-9]*' EXIT | ||
| 34 | |||
| 35 | guix install --bootstrap guile-bootstrap -p "$profile" | ||
| 36 | test -x "$profile/bin/guile" | ||
| 37 | |||
| 38 | # Make sure '-r' isn't passed as-is to 'guix package'. | ||
| 39 | if guix install -r guile-bootstrap -p "$profile" --bootstrap | ||
| 40 | then false; else true; fi | ||
| 41 | test -x "$profile/bin/guile" | ||
| 42 | |||
| 43 | guix upgrade --version | ||
| 44 | guix upgrade -n | ||
| 45 | guix upgrade gui.e -n | ||
| 46 | if guix upgrade foo bar -n; | ||
| 47 | then false; else true; fi | ||
| 48 | |||
| 49 | guix remove --version | ||
| 50 | guix remove --bootstrap guile-bootstrap -p "$profile" | ||
| 51 | ! test -x "$profile/bin/guile" | ||
| 52 | test `guix package -p "$profile" -I | wc -l` -eq 0 | ||
| 53 | |||
| 54 | if guix remove -p "$profile" this-is-not-installed --bootstrap | ||
| 55 | then false; else true; fi | ||
| 56 | |||
| 57 | if guix remove -i guile-bootstrap -p "$profile" --bootstrap | ||
| 58 | then false; else true; fi | ||
