guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with handicapped 'bash' from glibc package


From: Ludovic Courtès
Subject: Re: Problems with handicapped 'bash' from glibc package
Date: Thu, 27 Mar 2014 00:29:51 +0100
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

address@hidden (Ludovic Courtès) skribis:

> Mark H Weaver <address@hidden> 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’.

commit 3e8578b7899454645072594fdc392c872e8947c0 (HEAD, 
refs/heads/wip-glibc-bash)
Author: Ludovic Courtès <address@hidden>
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 
\"address@hidden"~%"
                               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 <address@hidden>
+;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <address@hidden>
 ;;; Copyright © 2014 Mark H Weaver <address@hidden>
 ;;;
 ;;; 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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]