From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: guix-devel@gnu.org
Subject: Re: Problems with handicapped 'bash' from glibc package
Date: Thu, 27 Mar 2014 00:29:51 +0100 [thread overview]
Message-ID: <87ppl8y1w0.fsf@gnu.org> (raw)
In-Reply-To: <874n2oubuq.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 23 Mar 2014 17:19:09 +0100")
[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]
ludo@gnu.org (Ludovic Courtès) skribis:
> Mark H Weaver <mhw@netris.org> skribis:
>
>> The 'bash' in the glibc package is handicapped in at least two ways:
>>
>> * It can't set the locale, because it looks for locales in
>> /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-intermediate-2.18-locales
>>
>> * It can't look up anything from NSS, such as passwd data, because it
>> tries to load the modules from
>> /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-intermediate-2.18
>>
>> There are two problems that need to be addressed, I think:
>>
>> * Users could easily end up with this handicapped 'bash' as their
>> primary bash, if they installed (or upgraded?) 'glibc' since the last
>> time I installed 'bash'. This happened to me, for example.
>
> I realized that this particular problem is easily solved by moving
> glibc’s bash away from $bindir, for instance to $libexecdir.
I gave up on this one for this time, because it started taking too much
time, and because new hacks were needed to make sure we wouldn’t keep
references to the bootstrap sh.
For reference, below is the unfinished patch.
Ludo’.
[-- Attachment #2: Type: text/x-patch, Size: 6217 bytes --]
commit 3e8578b7899454645072594fdc392c872e8947c0 (HEAD, refs/heads/wip-glibc-bash)
Author: Ludovic Courtès <ludo@gnu.org>
Date: Mon Mar 24 00:53:16 2014 +0100
gnu: glibc: Move stand-alone Bash to $libexecdir.
* gnu/packages/base.scm (glibc)[arguments] <pre-configure phase>:
Install 'static-bash' to $out/libexec/glibc-2.19 instead of $out/bin.
Adjust system.c and iopopen.c substitutions accordingly.
(gcc-final)[arguments] <phases>: Add 'libc-bash-first' phase.
* gnu/packages/ncurses.scm (ncurses) <configure phase>: Search the
'bash' executable under $libc/libexec. Set $PATH.
Modified gnu/packages/base.scm
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index bf1ebfa..888c20a 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -431,8 +431,9 @@ library for working with executable and object formats is also included.")
#:phases (alist-cons-before
'configure 'pre-configure
(lambda* (#:key inputs outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (bin (string-append out "/bin")))
+ (let* ((out (assoc-ref outputs "out"))
+ (libexec (string-append out "/libexec/" ,name
+ "-" ,version)))
;; Use `pwd', not `/bin/pwd'.
(substitute* "configure"
(("/bin/pwd") "pwd"))
@@ -454,27 +455,29 @@ library for working with executable and object formats is also included.")
;; Copy a statically-linked Bash in the output, with
;; no references to other store paths.
- (mkdir-p bin)
+ (mkdir-p libexec)
(copy-file (string-append (assoc-ref inputs "static-bash")
"/bin/bash")
- (string-append bin "/bash"))
- (remove-store-references (string-append bin "/bash"))
- (chmod (string-append bin "/bash") #o555)
-
- ;; Keep a symlink, for `patch-shebang' resolution.
- (with-directory-excursion bin
+ (string-append libexec "/bash"))
+ (remove-store-references (string-append libexec "/bash"))
+ (chmod (string-append libexec "/bash") #o555)
+
+ ;; Keep a symlink and augment $PATH, for `patch-shebang'
+ ;; resolution for $bin/sotruss, etc.
+ (setenv "PATH" (string-append libexec ":" (getenv "PATH")))
+ (with-directory-excursion libexec
(symlink "bash" "sh"))
;; Have `system' use that Bash.
(substitute* "sysdeps/posix/system.c"
(("#define[[:blank:]]+SHELL_PATH.*$")
- (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
- out)))
+ (format #f "#define SHELL_PATH \"~a/bash\"\n"
+ libexec)))
;; Same for `popen'.
(substitute* "libio/iopopen.c"
(("/bin/sh")
- (string-append out "/bin/bash")))
+ (string-append libexec "/bash")))
;; Make sure we don't retain a reference to the
;; bootstrap Perl.
@@ -1000,7 +1003,21 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
flag))
,flags)))
((#:phases phases)
- `(alist-delete 'symlink-libgcc_eh ,phases)))))
+ `(alist-delete
+ 'symlink-libgcc_eh
+ (alist-cons-before
+ 'configure 'libc-bash-first
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Arrange so that the shebangs of 'mkheaders', 'fixinc.sh',
+ ;; etc. refer to libc's bash rather than to the bootstrap
+ ;; bash.
+ (let* ((libc (assoc-ref inputs "libc"))
+ (bash (car (find-files (string-append libc "/libexec")
+ "^bash$"))))
+ (setenv "PATH"
+ (string-append (dirname bash) ":"
+ (getenv "PATH")))))
+ ,phases))))))
(inputs `(("gmp-source" ,(package-source gmp))
("mpfr-source" ,(package-source mpfr))
Modified gnu/packages/ncurses.scm
diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index b8f6bc8..8e75cdb 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
@@ -35,8 +35,15 @@
;; it to point to libc's embedded Bash, to avoid retaining a
;; reference to the bootstrap Bash.
(let* ((libc (assoc-ref inputs "libc"))
- (bash (string-append libc "/bin/bash"))
+ (bash (car (find-files (string-append libc "/libexec")
+ "^bash$")))
(out (assoc-ref outputs "out")))
+ ;; The post-installation 'patch-shebangs' phase patches
+ ;; according to what's in $PATH, so make sure libc's bash comes
+ ;; first.
+ (setenv "PATH"
+ (string-append (dirname bash) ":" (getenv "PATH")))
+
(format #t "configure flags: ~s~%" configure-flags)
(zero? (apply system* bash "./configure"
(string-append "SHELL=" bash)
prev parent reply other threads:[~2014-03-26 23:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 7:12 Problems with handicapped 'bash' from glibc package Mark H Weaver
2014-02-12 13:14 ` Ludovic Courtès
2014-02-12 17:39 ` Mark H Weaver
2014-02-12 19:31 ` Andreas Enge
2014-02-12 20:33 ` Ludovic Courtès
2014-02-12 21:33 ` Mark H Weaver
2014-02-13 9:14 ` Andreas Enge
2014-03-23 16:19 ` Ludovic Courtès
2014-03-23 20:19 ` Mark H Weaver
2014-03-23 20:27 ` Ludovic Courtès
2014-03-24 3:31 ` Mark H Weaver
2014-03-28 13:48 ` Ludovic Courtès
2014-03-24 3:55 ` Optimizing union.scm Mark H Weaver
2014-03-24 13:45 ` Ludovic Courtès
2014-03-25 7:04 ` Mark H Weaver
2014-03-25 17:18 ` Ludovic Courtès
2014-03-25 22:30 ` Mark H Weaver
2014-03-25 22:58 ` Ludovic Courtès
2014-03-27 7:09 ` Mark H Weaver
2014-03-27 9:57 ` Ludovic Courtès
2014-04-02 14:14 ` Optimizing ‘guix package’ Ludovic Courtès
2014-04-02 16:58 ` Mark H Weaver
2014-03-26 23:29 ` Ludovic Courtès [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppl8y1w0.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=mhw@netris.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).