container.scm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 David Thompson <davet@gnu.org>
  3. ;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix scripts container)
  20. #:use-module (ice-9 match)
  21. #:use-module (guix ui)
  22. #:use-module (guix scripts)
  23. #:export (guix-container))
  24. (define (show-help)
  25. (display (G_ "Usage: guix container ACTION ARGS...
  26. Build and manipulate Linux containers.\n"))
  27. (newline)
  28. (display (G_ "The valid values for ACTION are:\n"))
  29. (newline)
  30. (display (G_ "\
  31. exec execute a command inside of an existing container\n"))
  32. (newline)
  33. (display (G_ "
  34. -h, --help display this help and exit"))
  35. (display (G_ "
  36. -V, --version display version information and exit"))
  37. (newline)
  38. (show-bug-report-information))
  39. (define %actions '("exec"))
  40. (define (resolve-action name)
  41. (let ((module (resolve-interface
  42. `(guix scripts container ,(string->symbol name))))
  43. (proc (string->symbol (string-append "guix-container-" name))))
  44. (module-ref module proc)))
  45. (define-command (guix-container . args)
  46. (category development)
  47. (synopsis "run code in containers created by 'guix environment -C'")
  48. (with-error-handling
  49. (match args
  50. (()
  51. (format (current-error-port)
  52. (G_ "guix container: missing action~%")))
  53. ((or ("-h") ("--help"))
  54. (show-help)
  55. (exit 0))
  56. ((or ("-V") ("--version"))
  57. (show-version-and-exit "guix container"))
  58. ((action args ...)
  59. (if (member action %actions)
  60. (apply (resolve-action action) args)
  61. (format (current-error-port)
  62. (G_ "guix container: invalid action~%")))))))