guix: pack: Add '--entry-point-argument' option.
* guix/scripts/pack.scm: (entry-point-argument-spec-option-parser): New procedure. (docker-image, %default-options, %docker-format-options, show-docker-format-options/detailed, %options, show-docker-format-options, guix-pack): Handle '--entry-point-argument' option. * doc/guix.texi: (Invoking guix pack): Document this Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com> Change-Id: I1124feff6af39dcc63c85fd6cc7ad50f398489dcmaster
parent
7a7c8920ae
commit
7d5168a2af
|
@ -122,6 +122,7 @@ Copyright @copyright{} 2023 Felix Lechner@*
|
||||||
Copyright @copyright{} 2023 Foundation Devices, Inc.@*
|
Copyright @copyright{} 2023 Foundation Devices, Inc.@*
|
||||||
Copyright @copyright{} 2023 Thomas Ieong@*
|
Copyright @copyright{} 2023 Thomas Ieong@*
|
||||||
Copyright @copyright{} 2023 Saku Laesvuori@*
|
Copyright @copyright{} 2023 Saku Laesvuori@*
|
||||||
|
Copyright @copyright{} 2023 Graham James Addis@*
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
@ -7406,7 +7407,7 @@ execution engines listed above by setting the
|
||||||
@env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
|
@env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
|
||||||
@end quotation
|
@end quotation
|
||||||
|
|
||||||
@cindex entry point, for Docker images
|
@cindex entry point, for Docker and Singularity images
|
||||||
@item --entry-point=@var{command}
|
@item --entry-point=@var{command}
|
||||||
Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
|
Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
|
||||||
format supports it---currently @code{docker} and @code{squashfs} (Singularity)
|
format supports it---currently @code{docker} and @code{squashfs} (Singularity)
|
||||||
|
@ -7429,6 +7430,17 @@ docker load -i pack.tar.gz
|
||||||
docker run @var{image-id}
|
docker run @var{image-id}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
@cindex entry point arguments, for docker images
|
||||||
|
@item --entry-point-argument=@var{command}
|
||||||
|
@itemx -A @var{command}
|
||||||
|
Use @var{command} as an argument to @dfn{entry point} of the resulting pack.
|
||||||
|
This option is only valid in conjunction with @code{--entry-point} and can
|
||||||
|
appear multiple times on the command line.
|
||||||
|
|
||||||
|
@example
|
||||||
|
guix pack -f docker --entry-point=bin/guile --entry-point-argument="--help" guile
|
||||||
|
@end example
|
||||||
|
|
||||||
@item --expression=@var{expr}
|
@item --expression=@var{expr}
|
||||||
@itemx -e @var{expr}
|
@itemx -e @var{expr}
|
||||||
Consider the package @var{expr} evaluates to.
|
Consider the package @var{expr} evaluates to.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
;;; Copyright © 2020 Eric Bavier <bavier@posteo.net>
|
;;; Copyright © 2020 Eric Bavier <bavier@posteo.net>
|
||||||
;;; Copyright © 2022 Alex Griffin <a@ajgrf.com>
|
;;; Copyright © 2022 Alex Griffin <a@ajgrf.com>
|
||||||
|
;;; Copyright © 2023 Graham James Addis <graham@addis.org.uk>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -202,6 +203,16 @@ target the profile's @file{bin/env} file:
|
||||||
(leave (G_ "~a: invalid symlink specification~%")
|
(leave (G_ "~a: invalid symlink specification~%")
|
||||||
arg))))
|
arg))))
|
||||||
|
|
||||||
|
(define (entry-point-argument-spec-option-parser opt name arg result)
|
||||||
|
"A SRFI-37 opion parser for the --entry-point-argument option. The spec
|
||||||
|
takes multiple occurances. The entries are used in the exec form for the
|
||||||
|
docker entry-point. The values are used as parameters in conjunction with
|
||||||
|
the --entry-point option which is used as the first value in the exec form."
|
||||||
|
(let ((entry-point-argument (assoc-ref result 'entry-point-argument)))
|
||||||
|
(alist-cons 'entry-point-argument
|
||||||
|
(append entry-point-argument (list arg))
|
||||||
|
(alist-delete 'entry-point-argument result eq?))))
|
||||||
|
|
||||||
(define (set-utf8-locale profile)
|
(define (set-utf8-locale profile)
|
||||||
"Configure the environment to use the \"en_US.utf8\" locale provided by the
|
"Configure the environment to use the \"en_US.utf8\" locale provided by the
|
||||||
GLIBC-UT8-LOCALES package."
|
GLIBC-UT8-LOCALES package."
|
||||||
|
@ -562,10 +573,22 @@ the image. EXTRA-OPTIONS may contain the IMAGE-TAG keyword argument."
|
||||||
`((directory "/tmp" ,(getuid) ,(getgid) #o1777)
|
`((directory "/tmp" ,(getuid) ,(getgid) #o1777)
|
||||||
,@(append-map symlink->directives '#$symlinks)))
|
,@(append-map symlink->directives '#$symlinks)))
|
||||||
|
|
||||||
|
(define (form-entry-point prefix entry-point entry-point-argument)
|
||||||
|
;; Construct entry-point parameter for build-docker-image. The
|
||||||
|
;; first entry is constructed by prefixing the entry-point with
|
||||||
|
;; the supplied index subsequent entries are taken from the
|
||||||
|
;; --entry-point-argument options.
|
||||||
|
(and=> entry-point
|
||||||
|
(lambda (entry-point)
|
||||||
|
(cons* (string-append prefix "/" entry-point)
|
||||||
|
entry-point-argument))))
|
||||||
|
|
||||||
(setenv "PATH" #+(file-append archiver "/bin"))
|
(setenv "PATH" #+(file-append archiver "/bin"))
|
||||||
|
|
||||||
(let-keywords '#$extra-options #f
|
(let-keywords '#$extra-options #f
|
||||||
((image-tag #f))
|
((image-tag #f)
|
||||||
|
(entry-point-argument #f))
|
||||||
|
|
||||||
(build-docker-image #$output
|
(build-docker-image #$output
|
||||||
(map store-info-item
|
(map store-info-item
|
||||||
(call-with-input-file "profile"
|
(call-with-input-file "profile"
|
||||||
|
@ -578,11 +601,10 @@ the image. EXTRA-OPTIONS may contain the IMAGE-TAG keyword argument."
|
||||||
#:database #+database
|
#:database #+database
|
||||||
#:system (or #$target %host-type)
|
#:system (or #$target %host-type)
|
||||||
#:environment environment
|
#:environment environment
|
||||||
#:entry-point
|
#:entry-point (form-entry-point
|
||||||
#$(and entry-point
|
#$profile
|
||||||
#~(list
|
#$entry-point
|
||||||
(string-append #$profile "/"
|
entry-point-argument)
|
||||||
#$entry-point)))
|
|
||||||
#:extra-files directives
|
#:extra-files directives
|
||||||
#:compressor
|
#:compressor
|
||||||
#+(compressor-command compressor)
|
#+(compressor-command compressor)
|
||||||
|
@ -1264,6 +1286,7 @@ last resort for relocation."
|
||||||
(debug . 0)
|
(debug . 0)
|
||||||
(verbosity . 1)
|
(verbosity . 1)
|
||||||
(symlinks . ())
|
(symlinks . ())
|
||||||
|
(entry-point-argument . ())
|
||||||
(compressor . ,(first %compressors))))
|
(compressor . ,(first %compressors))))
|
||||||
|
|
||||||
(define %formats
|
(define %formats
|
||||||
|
@ -1299,7 +1322,9 @@ last resort for relocation."
|
||||||
rest))))
|
rest))))
|
||||||
|
|
||||||
(define %docker-format-options
|
(define %docker-format-options
|
||||||
(list (required-option 'image-tag)))
|
(list (required-option 'image-tag)
|
||||||
|
(option '(#\A "entry-point-argument") #t #f
|
||||||
|
entry-point-argument-spec-option-parser)))
|
||||||
|
|
||||||
(define (show-docker-format-options)
|
(define (show-docker-format-options)
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
|
@ -1308,7 +1333,12 @@ last resort for relocation."
|
||||||
(define (show-docker-format-options/detailed)
|
(define (show-docker-format-options/detailed)
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
--image-tag=NAME
|
--image-tag=NAME
|
||||||
Use the given NAME for the Docker image repository"))
|
Use the given NAME for the Docker image repository
|
||||||
|
|
||||||
|
-A, --entry-point-argument=COMMAND/PARAMETER
|
||||||
|
Value(s) to use for the Docker EntryPoint arguments.
|
||||||
|
Multiple instances are accepted. This is only valid
|
||||||
|
in conjunction with the --entry-point option"))
|
||||||
(newline)
|
(newline)
|
||||||
(exit 0))
|
(exit 0))
|
||||||
|
|
||||||
|
@ -1619,7 +1649,9 @@ Create a bundle of PACKAGE.\n"))
|
||||||
(extra-options (match pack-format
|
(extra-options (match pack-format
|
||||||
('docker
|
('docker
|
||||||
(list #:image-tag
|
(list #:image-tag
|
||||||
(assoc-ref opts 'image-tag)))
|
(assoc-ref opts 'image-tag)
|
||||||
|
#:entry-point-argument
|
||||||
|
(assoc-ref opts 'entry-point-argument)))
|
||||||
('deb
|
('deb
|
||||||
(list #:control-file
|
(list #:control-file
|
||||||
(process-file-arg opts 'control-file)
|
(process-file-arg opts 'control-file)
|
||||||
|
|
Reference in New Issue