From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Problems with handicapped 'bash' from glibc package Date: Thu, 27 Mar 2014 00:29:51 +0100 Message-ID: <87ppl8y1w0.fsf@gnu.org> References: <871tz8oldk.fsf@netris.org> <874n2oubuq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSxGg-00068w-It for guix-devel@gnu.org; Wed, 26 Mar 2014 19:30:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSxGb-0002CR-QW for guix-devel@gnu.org; Wed, 26 Mar 2014 19:29:58 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:49015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSxGb-0002CL-FA for guix-devel@gnu.org; Wed, 26 Mar 2014 19:29:53 -0400 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") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Mark H Weaver Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > Mark H Weaver 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-lo= cales >> >> * 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=E2=80=99s 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=E2=80=99t ke= ep references to the bootstrap sh. For reference, below is the unfinished patch. Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable commit 3e8578b7899454645072594fdc392c872e8947c0 (HEAD, refs/heads/wip-glibc= -bash) Author: Ludovic Court=C3=A8s Date: Mon Mar 24 00:53:16 2014 +0100 gnu: glibc: Move stand-alone Bash to $libexecdir. =20=20=20=20 * gnu/packages/base.scm (glibc)[arguments] : Install 'static-bash' to $out/libexec/glibc-2.19 instead of $out/bin. Adjust system.c and iopopen.c substitutions accordingly. (gcc-final)[arguments] : Add 'libc-bash-first' phase. * gnu/packages/ncurses.scm (ncurses) : 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 format= s is also included.") =20 ;; 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-ba= sh") "/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-sheban= g' + ;; resolution for $bin/sotruss, etc. + (setenv "PATH" (string-append libexec ":" (getenv "PAT= H"))) + (with-directory-excursion libexec (symlink "bash" "sh")) =20 ;; 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))) =20 ;; Same for `popen'. (substitute* "libio/iopopen.c" (("/bin/sh") - (string-append out "/bin/bash"))) + (string-append libexec "/bash"))) =20 ;; 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.s= h', + ;; 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 "/libex= ec") + "^bash$")))) + (setenv "PATH" + (string-append (dirname bash) ":" + (getenv "PATH"))))) + ,phases)))))) =20 (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 =C2=A9 2012, 2013 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2012, 2013, 2014 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014 Mark H Weaver ;;; ;;; 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 co= mes + ;; first. + (setenv "PATH" + (string-append (dirname bash) ":" (getenv "PATH"))) + (format #t "configure flags: ~s~%" configure-flags) (zero? (apply system* bash "./configure" (string-append "SHELL=3D" bash) --=-=-=--