me
/
guix
Archived
1
0
Fork 0

scripts: Add --list-systems and --list-targets options.

Also factorize the --system and --target build options. Check that the passed
system and target arguments are known platforms.

* doc/guix.texi (Additional Build Options): Document the new --list-systems
and --list-targets options.
* guix/scripts/build.scm (show-cross-build-options-help,
show-emulated-build-options-help, list-systems, list-targets): New procedures.
(%standard-cross-build-options, %standard-emulated-build-options): New
variables.
(show-help): Remove --system and --target entries and use
show-cross-build-options-help and show-emulated-build-options-help procedures instead.
(%options): Remove --system and --target entries and use
%standard-cross-build-options and %standard-emulated-build-options variables instead.
* guix/scripts/archive.scm (show-help, %options): Adapt them.
* guix/scripts/environment.scm: Ditto.
* guix/scripts/graph.scm: Ditto.
* guix/scripts/pack.scm: Ditto.
* guix/scripts/pull.scm: Ditto.
* guix/scripts/size.scm: Ditto.
* guix/scripts/weather.scm: Ditto.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
master
Mathieu Othacehe 2022-05-02 12:59:14 +02:00
parent dd970122dd
commit ec42d287b4
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
9 changed files with 120 additions and 74 deletions

View File

@ -12397,6 +12397,14 @@ Cross-build for @var{triplet}, which must be a valid GNU triplet, such
as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
configuration triplets,, autoconf, Autoconf}). configuration triplets,, autoconf, Autoconf}).
@item --list-systems
List all the supported systems, that can be passed as an argument to
@option{--system}.
@item --list-targets
List all the supported targets, that can be passed as an argument to
@option{--target}.
@anchor{build-check} @anchor{build-check}
@item --check @item --check
@cindex determinism, checking @cindex determinism, checking

View File

@ -93,14 +93,14 @@ Export/import one or more packages from/to the store.\n"))
(display (G_ " (display (G_ "
-S, --source build the packages' source derivations")) -S, --source build the packages' source derivations"))
(display (G_ " (display (G_ "
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
(display (G_ "
--target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
(display (G_ "
-v, --verbosity=LEVEL use the given verbosity LEVEL")) -v, --verbosity=LEVEL use the given verbosity LEVEL"))
(newline) (newline)
(show-build-options-help) (show-build-options-help)
(newline)
(show-cross-build-options-help)
(newline)
(show-native-build-options-help)
(newline) (newline)
(display (G_ " (display (G_ "
@ -166,14 +166,6 @@ Export/import one or more packages from/to the store.\n"))
(option '(#\S "source") #f #f (option '(#\S "source") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'source? #t result))) (alist-cons 'source? #t result)))
(option '(#\s "system") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg
(alist-delete 'system result eq?))))
(option '("target") #t #f
(lambda (opt name arg result)
(alist-cons 'target arg
(alist-delete 'target result eq?))))
(option '(#\e "expression") #t #f (option '(#\e "expression") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'expression arg result))) (alist-cons 'expression arg result)))
@ -186,7 +178,9 @@ Export/import one or more packages from/to the store.\n"))
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'dry-run? #t result))) (alist-cons 'dry-run? #t result)))
%standard-build-options)) (append %standard-build-options
%standard-cross-build-options
%standard-native-build-options)))
(define (derivation-from-expression store str package-derivation (define (derivation-from-expression store str package-derivation
system source?) system source?)

View File

@ -47,6 +47,7 @@
#:use-module (srfi srfi-35) #:use-module (srfi srfi-35)
#:use-module (srfi srfi-37) #:use-module (srfi srfi-37)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu platform)
#:use-module ((guix status) #:select (with-status-verbosity)) #:use-module ((guix status) #:select (with-status-verbosity))
#:use-module ((guix progress) #:select (current-terminal-columns)) #:use-module ((guix progress) #:select (current-terminal-columns))
#:use-module ((guix build syscalls) #:select (terminal-columns)) #:use-module ((guix build syscalls) #:select (terminal-columns))
@ -54,9 +55,15 @@
#:export (log-url #:export (log-url
%standard-build-options %standard-build-options
%standard-cross-build-options
%standard-native-build-options
set-build-options-from-command-line set-build-options-from-command-line
set-build-options-from-command-line* set-build-options-from-command-line*
show-build-options-help show-build-options-help
show-cross-build-options-help
show-native-build-options-help
guix-build guix-build
register-root register-root
@ -184,6 +191,18 @@ options handled by 'set-build-options-from-command-line', and listed in
(display (G_ " (display (G_ "
--debug=LEVEL produce debugging output at LEVEL"))) --debug=LEVEL produce debugging output at LEVEL")))
(define (show-cross-build-options-help)
(display (G_ "
--list-targets list available targets"))
(display (G_ "
--target=TRIPLET cross-build for TRIPLET--e.g., \"aarch64-linux-gnu\"")))
(define (show-native-build-options-help)
(display (G_ "
--list-systems list available systems"))
(display (G_ "
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\"")))
(define (set-build-options-from-command-line store opts) (define (set-build-options-from-command-line store opts)
"Given OPTS, an alist as returned by 'args-fold' given "Given OPTS, an alist as returned by 'args-fold' given
'%standard-build-options', set the corresponding build options on STORE." '%standard-build-options', set the corresponding build options on STORE."
@ -319,6 +338,52 @@ use '--no-offload' instead~%")))
(leave (G_ "not a number: '~a' option argument: ~a~%") (leave (G_ "not a number: '~a' option argument: ~a~%")
name arg))))))) name arg)))))))
(define (list-systems)
"Print the available systems."
(display (G_ "The available systems are:\n"))
(newline)
(format #t "~{ - ~a ~%~}"
(sort (systems) string<?)))
(define (list-targets)
"Print the available targets."
(display (G_ "The available targets are:\n"))
(newline)
(format #t "~{ - ~a ~%~}"
(sort (targets) string<?)))
(define %standard-cross-build-options
;; Build options related to cross builds.
(list
(option '("list-targets") #f #f
(lambda (opt name arg result)
(list-targets)
(exit 0)))
(option '("target") #t #f
(lambda (opt name arg result . rest)
(let ((t (false-if-exception
(first (member arg (targets))))))
(if t
(apply values (alist-cons 'target t result) rest)
(leave (G_ "'~a' is not a supported target~%")
arg)))))))
(define %standard-native-build-options
;; Build options related to native builds.
(list
(option '("list-systems") #f #f
(lambda (opt name arg result)
(list-systems)
(exit 0)))
(option '(#\s "system") #t #f
(lambda (opt name arg result . rest)
(let ((s (false-if-exception
(first (member arg (systems))))))
(if s
(apply values (alist-cons 'system s result) rest)
(leave (G_ "'~a' is not a supported system~%")
arg)))))))
;;; ;;;
;;; Command-line options. ;;; Command-line options.
@ -353,10 +418,6 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
--sources[=TYPE] build source derivations; TYPE may optionally be one --sources[=TYPE] build source derivations; TYPE may optionally be one
of \"package\", \"all\" (default), or \"transitive\"")) of \"package\", \"all\" (default), or \"transitive\""))
(display (G_ " (display (G_ "
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
(display (G_ "
--target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
(display (G_ "
-d, --derivations return the derivation paths of the given packages")) -d, --derivations return the derivation paths of the given packages"))
(display (G_ " (display (G_ "
--check rebuild items to check for non-determinism issues")) --check rebuild items to check for non-determinism issues"))
@ -374,6 +435,10 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
(newline) (newline)
(show-build-options-help) (show-build-options-help)
(newline) (newline)
(show-cross-build-options-help)
(newline)
(show-native-build-options-help)
(newline)
(show-transformation-options-help) (show-transformation-options-help)
(newline) (newline)
(display (G_ " (display (G_ "
@ -420,13 +485,6 @@ must be one of 'package', 'all', or 'transitive'~%")
(alist-cons 'build-mode (build-mode repair) (alist-cons 'build-mode (build-mode repair)
result) result)
rest))) rest)))
(option '(#\s "system") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg result)))
(option '("target") #t #f
(lambda (opt name arg result)
(alist-cons 'target arg
(alist-delete 'target result eq?))))
(option '(#\d "derivations") #f #f (option '(#\d "derivations") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'derivations-only? #t result))) (alist-cons 'derivations-only? #t result)))
@ -459,7 +517,9 @@ must be one of 'package', 'all', or 'transitive'~%")
(alist-cons 'log-file? #t result))) (alist-cons 'log-file? #t result)))
(append %transformation-options (append %transformation-options
%standard-build-options))) %standard-build-options
%standard-cross-build-options
%standard-native-build-options)))
(define (options->things-to-build opts) (define (options->things-to-build opts)
"Read the arguments from OPTS and return a list of high-level objects to "Read the arguments from OPTS and return a list of high-level objects to

View File

@ -96,8 +96,6 @@ shell'."
(display (G_ " (display (G_ "
--search-paths display needed environment variable definitions")) --search-paths display needed environment variable definitions"))
(display (G_ " (display (G_ "
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
(display (G_ "
-r, --root=FILE make FILE a symlink to the result, and register it -r, --root=FILE make FILE a symlink to the result, and register it
as a garbage collector root")) as a garbage collector root"))
(display (G_ " (display (G_ "
@ -145,6 +143,8 @@ COMMAND or an interactive shell in that environment.\n"))
(newline) (newline)
(show-build-options-help) (show-build-options-help)
(newline) (newline)
(show-native-build-options-help)
(newline)
(show-transformation-options-help) (show-transformation-options-help)
(newline) (newline)
(display (G_ " (display (G_ "
@ -226,10 +226,6 @@ use '--preserve' instead~%"))
(option '(#\n "dry-run") #f #f (option '(#\n "dry-run") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'dry-run? #t result))) (alist-cons 'dry-run? #t result)))
(option '(#\s "system") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg
(alist-delete 'system result eq?))))
(option '(#\C "container") #f #f (option '(#\C "container") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'container? #t result))) (alist-cons 'container? #t result)))
@ -273,7 +269,8 @@ use '--preserve' instead~%"))
(alist-cons 'bootstrap? #t result))) (alist-cons 'bootstrap? #t result)))
(append %transformation-options (append %transformation-options
%standard-build-options))) %standard-build-options
%standard-native-build-options)))
(define (pick-all alist key) (define (pick-all alist key)
"Return a list of values in ALIST associated with KEY." "Return a list of values in ALIST associated with KEY."

View File

@ -39,7 +39,9 @@
options->transformation options->transformation
%transformation-options)) %transformation-options))
#:use-module ((guix scripts build) #:use-module ((guix scripts build)
#:select (%standard-build-options)) #:select (%standard-build-options
%standard-native-build-options
show-native-build-options-help))
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:use-module (srfi srfi-34) #:use-module (srfi srfi-34)
@ -504,10 +506,6 @@ package modules, while attempting to retain user package modules."
(option '(#\e "expression") #t #f (option '(#\e "expression") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'expression arg result))) (alist-cons 'expression arg result)))
(option '(#\s "system") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg
(alist-delete 'system result eq?))))
(find (lambda (option) (find (lambda (option)
(member "load-path" (option-names option))) (member "load-path" (option-names option)))
%standard-build-options) %standard-build-options)
@ -519,7 +517,8 @@ package modules, while attempting to retain user package modules."
(lambda args (lambda args
(show-version-and-exit "guix graph"))) (show-version-and-exit "guix graph")))
%transformation-options)) (append %transformation-options
%standard-native-build-options)))
(define (show-help) (define (show-help)
;; TRANSLATORS: Here 'dot' is the name of a program; it must not be ;; TRANSLATORS: Here 'dot' is the name of a program; it must not be
@ -540,8 +539,6 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
--path display the shortest path between the given nodes")) --path display the shortest path between the given nodes"))
(display (G_ " (display (G_ "
-e, --expression=EXPR consider the package EXPR evaluates to")) -e, --expression=EXPR consider the package EXPR evaluates to"))
(display (G_ "
-s, --system=SYSTEM consider the graph for SYSTEM--e.g., \"i686-linux\""))
(newline) (newline)
(display (G_ " (display (G_ "
-L, --load-path=DIR prepend DIR to the package module search path")) -L, --load-path=DIR prepend DIR to the package module search path"))
@ -553,6 +550,8 @@ Emit a representation of the dependency graph of PACKAGE...\n"))
(display (G_ " (display (G_ "
-V, --version display version information and exit")) -V, --version display version information and exit"))
(newline) (newline)
(show-native-build-options-help)
(newline)
(show-bug-report-information)) (show-bug-report-information))
(define %default-options (define %default-options

View File

@ -1244,17 +1244,9 @@ last resort for relocation."
(option '(#\m "manifest") #t #f (option '(#\m "manifest") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'manifest arg result))) (alist-cons 'manifest arg result)))
(option '(#\s "system") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg
(alist-delete 'system result eq?))))
(option '("entry-point") #t #f (option '("entry-point") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'entry-point arg result))) (alist-cons 'entry-point arg result)))
(option '("target") #t #f
(lambda (opt name arg result)
(alist-cons 'target arg
(alist-delete 'target result eq?))))
(option '(#\C "compression") #t #f (option '(#\C "compression") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'compressor (lookup-compressor arg) (alist-cons 'compressor (lookup-compressor arg)
@ -1305,13 +1297,19 @@ last resort for relocation."
(append %deb-format-options (append %deb-format-options
%transformation-options %transformation-options
%standard-build-options))) %standard-build-options
%standard-cross-build-options
%standard-native-build-options)))
(define (show-help) (define (show-help)
(display (G_ "Usage: guix pack [OPTION]... PACKAGE... (display (G_ "Usage: guix pack [OPTION]... PACKAGE...
Create a bundle of PACKAGE.\n")) Create a bundle of PACKAGE.\n"))
(show-build-options-help) (show-build-options-help)
(newline) (newline)
(show-cross-build-options-help)
(newline)
(show-native-build-options-help)
(newline)
(show-transformation-options-help) (show-transformation-options-help)
(newline) (newline)
(show-deb-format-options) (show-deb-format-options)
@ -1325,10 +1323,6 @@ Create a bundle of PACKAGE.\n"))
(display (G_ " (display (G_ "
-e, --expression=EXPR consider the package EXPR evaluates to")) -e, --expression=EXPR consider the package EXPR evaluates to"))
(display (G_ " (display (G_ "
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
(display (G_ "
--target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
(display (G_ "
-C, --compression=TOOL compress using TOOL--e.g., \"lzip\"")) -C, --compression=TOOL compress using TOOL--e.g., \"lzip\""))
(display (G_ " (display (G_ "
-S, --symlink=SPEC create symlinks to the profile according to SPEC")) -S, --symlink=SPEC create symlinks to the profile according to SPEC"))

View File

@ -116,12 +116,13 @@ Download and deploy the latest version of Guix.\n"))
-p, --profile=PROFILE use PROFILE instead of ~/.config/guix/current")) -p, --profile=PROFILE use PROFILE instead of ~/.config/guix/current"))
(display (G_ " (display (G_ "
-v, --verbosity=LEVEL use the given verbosity LEVEL")) -v, --verbosity=LEVEL use the given verbosity LEVEL"))
(display (G_ "
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
(display (G_ " (display (G_ "
--bootstrap use the bootstrap Guile to build the new Guix")) --bootstrap use the bootstrap Guile to build the new Guix"))
(newline) (newline)
(show-build-options-help) (show-build-options-help)
(newline)
(show-native-build-options-help)
(newline)
(display (G_ " (display (G_ "
-h, --help display this help and exit")) -h, --help display this help and exit"))
(display (G_ " (display (G_ "
@ -182,10 +183,6 @@ Download and deploy the latest version of Guix.\n"))
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'profile (canonicalize-profile arg) (alist-cons 'profile (canonicalize-profile arg)
result))) result)))
(option '(#\s "system") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg
(alist-delete 'system result eq?))))
(option '(#\n "dry-run") #f #f (option '(#\n "dry-run") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'dry-run? #t result))) (alist-cons 'dry-run? #t result)))
@ -206,7 +203,8 @@ Download and deploy the latest version of Guix.\n"))
(lambda args (lambda args
(show-version-and-exit "guix pull"))) (show-version-and-exit "guix pull")))
%standard-build-options)) (append %standard-build-options
%standard-native-build-options)))
(define (warn-about-backward-updates channel start commit relation) (define (warn-about-backward-updates channel start commit relation)
"Warn about non-forward updates of CHANNEL from START to COMMIT, without "Warn about non-forward updates of CHANNEL from START to COMMIT, without

View File

@ -235,8 +235,6 @@ Report the size of the PACKAGE or STORE-ITEM, with its dependencies.\n"))
(display (G_ " (display (G_ "
--substitute-urls=URLS --substitute-urls=URLS
fetch substitute from URLS if they are authorized")) fetch substitute from URLS if they are authorized"))
(display (G_ "
-s, --system=SYSTEM consider packages for SYSTEM--e.g., \"i686-linux\""))
;; TRANSLATORS: "closure" and "self" must not be translated. ;; TRANSLATORS: "closure" and "self" must not be translated.
(display (G_ " (display (G_ "
--sort=KEY sort according to KEY--\"closure\" or \"self\"")) --sort=KEY sort according to KEY--\"closure\" or \"self\""))
@ -251,15 +249,13 @@ Report the size of the PACKAGE or STORE-ITEM, with its dependencies.\n"))
(display (G_ " (display (G_ "
-V, --version display version information and exit")) -V, --version display version information and exit"))
(newline) (newline)
(show-native-build-options-help)
(newline)
(show-bug-report-information)) (show-bug-report-information))
(define %options (define %options
;; Specifications of the command-line options. ;; Specifications of the command-line options.
(list (option '(#\s "system") #t #f (cons* (option '("substitute-urls") #t #f
(lambda (opt name arg result)
(alist-cons 'system arg
(alist-delete 'system result eq?))))
(option '("substitute-urls") #t #f
(lambda (opt name arg result . rest) (lambda (opt name arg result . rest)
(apply values (apply values
(alist-cons 'substitute-urls (alist-cons 'substitute-urls
@ -287,7 +283,8 @@ Report the size of the PACKAGE or STORE-ITEM, with its dependencies.\n"))
(exit 0))) (exit 0)))
(option '(#\V "version") #f #f (option '(#\V "version") #f #f
(lambda args (lambda args
(show-version-and-exit "guix size"))))) (show-version-and-exit "guix size")))
%standard-native-build-options))
(define %default-options (define %default-options
`((system . ,(%current-system)) `((system . ,(%current-system))

View File

@ -40,6 +40,7 @@
#:use-module (guix ci) #:use-module (guix ci)
#:use-module (guix sets) #:use-module (guix sets)
#:use-module (guix graph) #:use-module (guix graph)
#:use-module (guix scripts build)
#:autoload (guix scripts graph) (%bag-node-type) #:autoload (guix scripts graph) (%bag-node-type)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (web uri) #:use-module (web uri)
@ -339,18 +340,18 @@ Report the availability of substitutes.\n"))
COUNT dependents")) COUNT dependents"))
(display (G_ " (display (G_ "
--display-missing display the list of missing substitutes")) --display-missing display the list of missing substitutes"))
(display (G_ "
-s, --system=SYSTEM consider substitutes for SYSTEM--e.g., \"i686-linux\""))
(newline) (newline)
(display (G_ " (display (G_ "
-h, --help display this help and exit")) -h, --help display this help and exit"))
(display (G_ " (display (G_ "
-V, --version display version information and exit")) -V, --version display version information and exit"))
(newline) (newline)
(show-native-build-options-help)
(newline)
(show-bug-report-information)) (show-bug-report-information))
(define %options (define %options
(list (option '(#\h "help") #f #f (cons* (option '(#\h "help") #f #f
(lambda args (lambda args
(show-help) (show-help)
(exit 0))) (exit 0)))
@ -380,9 +381,7 @@ Report the availability of substitutes.\n"))
(option '("display-missing") #f #f (option '("display-missing") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'display-missing? #t result))) (alist-cons 'display-missing? #t result)))
(option '(#\s "system") #t #f %standard-native-build-options))
(lambda (opt name arg result)
(alist-cons 'system arg result)))))
(define %default-options (define %default-options
`((substitute-urls . ,%default-substitute-urls))) `((substitute-urls . ,%default-substitute-urls)))