upgrade.scm 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
  4. ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (guix scripts upgrade)
  21. #:use-module (guix ui)
  22. #:use-module (guix scripts package)
  23. #:use-module (guix scripts build)
  24. #:use-module (guix transformations)
  25. #:use-module (guix scripts)
  26. #:use-module (srfi srfi-1)
  27. #:use-module (srfi srfi-26)
  28. #:use-module (srfi srfi-37)
  29. #:use-module (ice-9 match)
  30. #:export (guix-upgrade))
  31. (define (show-help)
  32. (display (G_ "Usage: guix upgrade [OPTION] [REGEXP]
  33. Upgrade packages that match REGEXP.
  34. This is an alias for 'guix package -u'.\n"))
  35. (display (G_ "
  36. -p, --profile=PROFILE use PROFILE instead of the user's default profile"))
  37. (display (G_ "
  38. -v, --verbosity=LEVEL use the given verbosity LEVEL"))
  39. (display (G_ "
  40. --do-not-upgrade[=REGEXP] do not upgrade any packages matching REGEXP"))
  41. (newline)
  42. (show-build-options-help)
  43. (newline)
  44. (show-transformation-options-help)
  45. (newline)
  46. (display (G_ "
  47. -h, --help display this help and exit"))
  48. (display (G_ "
  49. -V, --version display version information and exit"))
  50. (newline)
  51. (show-bug-report-information))
  52. (define %options
  53. ;; Specification of the command-line options.
  54. (cons* (option '(#\h "help") #f #f
  55. (lambda args
  56. (show-help)
  57. (exit 0)))
  58. (option '(#\V "version") #f #f
  59. (lambda args
  60. (show-version-and-exit "guix upgrade")))
  61. ;; Preserve some of the 'guix package' options.
  62. (append (filter (lambda (option)
  63. (any (cut member <> (option-names option))
  64. '("profile" "dry-run" "verbosity" "do-not-upgrade")))
  65. %package-options)
  66. %transformation-options
  67. %standard-build-options)))
  68. (define-command (guix-upgrade . args)
  69. (synopsis "upgrade packages to their latest version")
  70. (define (handle-argument arg result arg-handler)
  71. ;; Treat non-option arguments as upgrade regexps.
  72. (values (alist-cons 'upgrade arg
  73. (delete '(upgrade . #f) result))
  74. arg-handler))
  75. (define opts
  76. (parse-command-line args %options
  77. (list `((upgrade . #f)
  78. ,@%package-default-options)
  79. #f)
  80. #:argument-handler handle-argument))
  81. (guix-package* opts))