mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-26 04:29:25 -05:00
shell: Fix '--emulate-fhs' sometimes not including 'glibc-for-fhs'.
Fixes <https://issues.guix.gnu.org/58861>. Previously the order of the options giving to 'guix shell' could mean that the 'glibc-for-fhs' package included with the '--emulate-fhs' option would not appear in the container. For example, using the development option with a package using the 'gnu-build-system', e.g. 'guix shell -CFD hello', would include the regular 'glibc' package. The option ordered mattered: 'guix shell -CD hello -F' would include the expected 'glibc-for-fhs'. We fix this by having 'glibc-for-fhs' added to the package list just before calling 'options-with-caching' so the option order given by the user does not matter. * guix/scripts/shell.scm (%options): Move the '--emulate-fhs' (expression . ...) component from here... (parse-args): ... to here. * tests/guix-environment-container.sh: Add a test to check that 'glibc-for-fhs' is in the container even when 'glibc' is included in the 'guix shell' package list. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
f1b0b2344c
commit
905443abb7
2 changed files with 23 additions and 12 deletions
|
@ -143,16 +143,7 @@ (define %options
|
||||||
|
|
||||||
(option '(#\F "emulate-fhs") #f #f
|
(option '(#\F "emulate-fhs") #f #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(let ((result
|
(alist-cons 'emulate-fhs? #t result))))
|
||||||
;; For an FHS-container, add the (hidden)
|
|
||||||
;; package glibc-for-fhs which uses the global
|
|
||||||
;; cache at /etc/ld.so.cache.
|
|
||||||
(alist-cons
|
|
||||||
'expression
|
|
||||||
'(ad-hoc-package
|
|
||||||
"(@@ (gnu packages base) glibc-for-fhs)")
|
|
||||||
result)))
|
|
||||||
(alist-cons 'emulate-fhs? #t result)))))
|
|
||||||
(filter-map (lambda (opt)
|
(filter-map (lambda (opt)
|
||||||
(and (not (any (lambda (name)
|
(and (not (any (lambda (name)
|
||||||
(member name to-remove))
|
(member name to-remove))
|
||||||
|
@ -173,8 +164,18 @@ (define (handle-argument arg result)
|
||||||
;; The '--' token is used to separate the command to run from the rest of
|
;; The '--' token is used to separate the command to run from the rest of
|
||||||
;; the operands.
|
;; the operands.
|
||||||
(let ((args command (break (cut string=? "--" <>) args)))
|
(let ((args command (break (cut string=? "--" <>) args)))
|
||||||
(let ((opts (parse-command-line args %options (list %default-options)
|
(let* ((args-parsed (parse-command-line args %options (list %default-options)
|
||||||
#:argument-handler handle-argument)))
|
#:argument-handler handle-argument))
|
||||||
|
;; For an FHS-container, add the (hidden) package glibc-for-fhs
|
||||||
|
;; which uses the global cache at /etc/ld.so.cache. We handle
|
||||||
|
;; adding this package here to ensure it will always appear in the
|
||||||
|
;; container as it is the first package in OPTS.
|
||||||
|
(opts (if (assoc-ref args-parsed 'emulate-fhs?)
|
||||||
|
(alist-cons 'expression
|
||||||
|
'(ad-hoc-package
|
||||||
|
"(@@ (gnu packages base) glibc-for-fhs)")
|
||||||
|
args-parsed)
|
||||||
|
args-parsed)))
|
||||||
(options-with-caching
|
(options-with-caching
|
||||||
(auto-detect-manifest
|
(auto-detect-manifest
|
||||||
(match command
|
(match command
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# GNU Guix --- Functional package management for GNU
|
# GNU Guix --- Functional package management for GNU
|
||||||
# Copyright © 2015 David Thompson <davet@gnu.org>
|
# Copyright © 2015 David Thompson <davet@gnu.org>
|
||||||
|
# Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Guix.
|
# This file is part of GNU Guix.
|
||||||
#
|
#
|
||||||
|
@ -231,3 +232,12 @@ guix shell -C --emulate-fhs --bootstrap guile-bootstrap \
|
||||||
# Test that the ld cache was generated and can be successfully read.
|
# Test that the ld cache was generated and can be successfully read.
|
||||||
guix shell -CF --bootstrap guile-bootstrap \
|
guix shell -CF --bootstrap guile-bootstrap \
|
||||||
-- guile -c '(execlp "ldconfig" "ldconfig" "-p")'
|
-- guile -c '(execlp "ldconfig" "ldconfig" "-p")'
|
||||||
|
|
||||||
|
# Test that the package glibc-for-fhs is in the container even if there is the
|
||||||
|
# regular glibc package from another source. See
|
||||||
|
# <https://issues.guix.gnu.org/58861>.
|
||||||
|
guix shell -CF --bootstrap guile-bootstrap glibc \
|
||||||
|
-- guile -c '(exit (if (string-contains (readlink "/lib/libc.so")
|
||||||
|
"glibc-for-fhs")
|
||||||
|
0
|
||||||
|
1))'
|
||||||
|
|
Loading…
Reference in a new issue