Subject: bug#37549: guix build bootstrap-tarballs installed but strip-install failed

From: Jan Nieuwenhuizen <[email-masked]>
Date: Sun, 29 Sep 2019 13:33:41 +0200

Jan Nieuwenhuizen writes:

> Bengt Richter writes:
>> I tried
>>     guix build bootstrap-tarballs
>
> Yes, sadly that's not supported on current master.  It should work on
> core-updates.  So I tried that and found it fails in similar ways.

The attached patches resurrect the creation of bootstrap tarballs.

Note that plain mes (./pre-inst-env guix build mes) still does not
build; that also needs #37550.

Greetings,
janneke

>From 74607653378ca1bcfed6a415a7432fd2a8af7105 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <[email-masked]>
Date: Sun, 29 Sep 2019 10:36:46 +0200
Subject: [PATCH 1/3] bootstrap: mescc-tools: Use mescc-tools-0.5.2,
 mescc-tools.

* gnu/packages/mes.scm (mescc-tools-0.5.2): New variable; rename from
mescc-tools.
(mescc-tools): Rename from mescc-tools-0.6.1.  Fix build.
* gnu/packages/make-bootstrap.scm (%mescc-tools-static): Inherit fixed
mescc-tools-0.5.2.
---
 gnu/packages/make-bootstrap.scm | 25 +------------------------
 gnu/packages/mes.scm            | 17 ++++++++++++-----
 2 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index 4594e2fe36..8db551b3a7 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -594,34 +594,11 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("gcc" ,%gcc-static)))))
 
-;; One package: build + remove store references
-;; (define %mescc-tools-static-stripped
-;;   ;; A statically linked Mescc Tools with store references removed, for
-;;   ;; bootstrap.
-;;   (package
-;;     (inherit mescc-tools)
-;;     (name "mescc-tools-static-stripped")
-;;     (arguments
-;;      `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
-;;                           "CC=gcc -static")
-;;        #:test-target "test"
-;;        #:phases (modify-phases %standard-phases
-;;                   (delete 'configure)
-;;                   (add-after 'install 'strip-store-references
-;;                     (lambda _
-;;                       (let* ((out (assoc-ref %outputs "out"))
-;;                              (bin (string-append out "/bin")))
-;;                         (for-each (lambda (file)
-;;                                  (let ((target (string-append bin "/" file)))
-;;                                    (format #t "strippingg `~a'...~%" target)
-;;                                    (remove-store-references target)))
-;;                                   '( "M1" "blood-elf" "hex2"))))))))))
-
 ;; Two packages: first build static, bare minimum content.
 (define %mescc-tools-static
   ;; A statically linked MesCC Tools.
   (package
-    (inherit mescc-tools)
+    (inherit mescc-tools-0.5.2)
     (name "mescc-tools-static")
     (arguments
      `(#:system "i686-linux"
diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index e1cb736b82..3f76eeb886 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -34,7 +34,8 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix licenses)
-  #:use-module (guix packages))
+  #:use-module (guix packages)
+  #:use-module (guix utils))
 
 (define-public nyacc-0.86
   (package
@@ -134,7 +135,8 @@ Guile.")
     (home-page "https://gnu.org/software/mes")
     (license gpl3+)))
 
-(define-public mescc-tools
+(define-public mescc-tools-0.5.2
+  ;; Mescc-tools used for bootstrap.
   (let ((commit "bb062b0da7bf2724ca40f9002b121579898d4ef7")
         (revision "0")
         (version "0.5.2"))
@@ -166,9 +168,9 @@ get_machine.")
     (home-page "https://savannah.nongnu.org/projects/mescc-tools")
     (license gpl3+))))
 
-(define-public mescc-tools-0.6.1
+(define-public mescc-tools
   (package
-    (inherit mescc-tools)
+    (inherit mescc-tools-0.5.2)
     (name "mescc-tools")
     (version "0.6.1")
     (source (origin
@@ -180,4 +182,9 @@ get_machine.")
               (file-name (string-append name "-" version ".tar.gz"))
               (sha256
                (base32
-                "06jpvq6xfjzn2al6b4rdwd3zv3h4cvilc4n9gqcnjr9cr6wjpw2n"))))))
+                "06jpvq6xfjzn2al6b4rdwd3zv3h4cvilc4n9gqcnjr9cr6wjpw2n"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments mescc-tools-0.5.2)
+       ((#:make-flags flags)
+        `(list (string-append "PREFIX=" (assoc-ref %outputs "out"))
+               "CC=gcc"))))))
-- 
2.23.0

>From 98382db4246a418b9e85a65f3e1a292fa5001e91 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <[email-masked]>
Date: Sun, 29 Sep 2019 10:39:40 +0200
Subject: [PATCH 2/3] bootstrap: mes: Add mes-0.19.

* gnu/packages/mes.scm (mes-0.19): New variable.
(mes): Inherit it.
* gnu/packages/make-bootstrap.scm (%mes-minimal): Likewise.
---
 gnu/packages/make-bootstrap.scm | 35 +--------------------------------
 gnu/packages/mes.scm            | 27 ++++++++++++++++++++-----
 2 files changed, 23 insertions(+), 39 deletions(-)

diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index 8db551b3a7..b1c4feb4f4 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -633,45 +633,12 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("mescc-tools" ,%mescc-tools-static)))))
 
-;; (define-public %mes-minimal-stripped
-;;   ;; A minimal Mes without documentation dependencies, for bootstrap.
-;;   (let ((triplet "i686-unknown-linux-gnu"))
-;;     (package
-;;       (inherit mes)
-;;       (name "mes-minimal-stripped")
-;;       (native-inputs
-;;        `(("guile" ,guile-2.2)))
-;;       (arguments
-;;        `(#:system "i686-linux"
-;;          #:strip-binaries? #f
-;;          #:configure-flags '("--mes")
-;;          #:phases
-;;          (modify-phases %standard-phases
-;;            (delete 'patch-shebangs)
-;;            (add-after 'install 'strip-install
-;;              (lambda _
-;;                (let* ((out (assoc-ref %outputs "out"))
-;;                       (share (string-append out "/share")))
-;;                  (delete-file-recursively (string-append out "/lib/guile"))
-;;                  (delete-file-recursively (string-append share "/guile"))
-;;                  (delete-file-recursively (string-append share "/mes/scaffold"))
-
-;;                  (for-each delete-file
-;;                            (find-files
-;;                             (string-append share "/mes/lib") "\\.(h|c)"))
-
-;;                  (for-each (lambda (dir)
-;;                              (for-each remove-store-references
-;;                                        (find-files (string-append out "/" dir)
-;;                                                    ".*")))
-;;                            '("bin" "share/mes")))))))))))
-
 ;; Two packages: first build static, bare minimum content.
 (define-public %mes-minimal
   ;; A minimal Mes without documentation.
   (let ((triplet "i686-unknown-linux-gnu"))
     (package
-      (inherit mes)
+      (inherit mes-0.19)
       (name "mes-minimal")
       (native-inputs
        `(("guile" ,guile-2.2)))
diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index 3f76eeb886..a01e98b855 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -38,6 +38,7 @@
   #:use-module (guix utils))
 
 (define-public nyacc-0.86
+  ;; Nyacc used for bootstrap.
   (package
     (name "nyacc")
     (version "0.86.0")
@@ -91,22 +92,23 @@ extensive examples, including parsers for the Javascript and C99 languages.")
     (inputs
      `(("guile" ,guile-2.2)))))
 
-(define-public mes
+(define-public mes-0.19
+  ;; Mes used for bootstrap.
   (package
     (name "mes")
-    (version "0.20")
+    (version "0.19")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://gnu/mes/"
                                   "mes-" version ".tar.gz"))
               (sha256
                (base32
-                "04pajp8v31na34ls4730ig5f6miiplhdvkmsb9ls1b8bbmw2vb4n"))))
+                "15h4yhaywdc0djpjlin2jz1kzahpqxfki0r0aav1qm9nxxmnp1l0"))))
     (build-system gnu-build-system)
     (supported-systems '("i686-linux" "x86_64-linux"))
     (propagated-inputs
-     `(("mescc-tools" ,mescc-tools)
-       ("nyacc" ,nyacc)))
+     `(("mescc-tools" ,mescc-tools-0.5.2)
+       ("nyacc" ,nyacc-0.86)))
     (native-inputs
      `(("guile" ,guile-2.2)
        ,@(let ((target-system (or (%current-target-system)
@@ -135,6 +137,21 @@ Guile.")
     (home-page "https://gnu.org/software/mes")
     (license gpl3+)))
 
+(define-public mes
+  (package
+    (inherit mes-0.19)
+    (version "0.20")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://gnu/mes/"
+                                  "mes-" version ".tar.gz"))
+              (sha256
+               (base32
+                "04pajp8v31na34ls4730ig5f6miiplhdvkmsb9ls1b8bbmw2vb4n"))))
+    (propagated-inputs
+     `(("mescc-tools" ,mescc-tools)
+       ("nyacc" ,nyacc)))))
+
 (define-public mescc-tools-0.5.2
   ;; Mescc-tools used for bootstrap.
   (let ((commit "bb062b0da7bf2724ca40f9002b121579898d4ef7")
-- 
2.23.0

>From a7bc0810e89013c4b908e29ed0d97ca8317c7ad7 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <[email-masked]>
Date: Sun, 29 Sep 2019 12:01:51 +0200
Subject: [PATCH 3/3] bootstrap: bash: Update for bash-5.0.

* gnu/packages/patches/bash-4.4-linux-pgrp-pipe.patch: Remove.
* gnu/packages/patches/bash-reproducible-linux-pgrp-pipe.patch: New file.
* gnu/packages/make-bootstrap.scm (static-bash-for-bootstrap): Update to use
it.
* gnu/local.mk (dist_patch_DATA): Likewise.
---
 gnu/local.mk                                  |  4 +--
 gnu/packages/make-bootstrap.scm               |  2 +-
 .../patches/bash-4.4-linux-pgrp-pipe.patch    | 30 ----------------
 .../bash-reproducible-linux-pgrp-pipe.patch   | 34 +++++++++++++++++++
 4 files changed, 37 insertions(+), 33 deletions(-)
 delete mode 100644 gnu/packages/patches/bash-4.4-linux-pgrp-pipe.patch
 create mode 100644 gnu/packages/patches/bash-reproducible-linux-pgrp-pipe.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9bd1e8882b..18a25e6bc7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -11,7 +11,7 @@
 # Copyright © 2016 Ben Woodcroft <[email-masked]>
 # Copyright © 2016, 2017, 2018, 2019 Alex Vong <[email-masked]>
 # Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <[email-masked]>
-# Copyright © 2016, 2017 Jan Nieuwenhuizen <[email-masked]>
+# Copyright © 2016, 2017, 2018, 2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
 # Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <[email-masked]>
 # Copyright © 2017, 2018 Clément Lassieur <[email-masked]>
 # Copyright © 2017 Mathieu Othacehe <[email-masked]>
@@ -706,7 +706,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/avidemux-install-to-lib.patch		\
   %D%/packages/patches/awesome-reproducible-png.patch		\
   %D%/packages/patches/azr3.patch				\
-  %D%/packages/patches/bash-4.4-linux-pgrp-pipe.patch		\
+  %D%/packages/patches/bash-reproducible-linux-pgrp-pipe.patch	\
   %D%/packages/patches/bash-completion-directories.patch	\
   %D%/packages/patches/bastet-change-source-of-unordered_set.patch	\
   %D%/packages/patches/bazaar-CVE-2017-14176.patch		\
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index b1c4feb4f4..3a664fd94f 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -164,7 +164,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (source (origin
               (inherit (package-source static-bash))
               (patches
-               (cons (search-patch "bash-4.4-linux-pgrp-pipe.patch")
+               (cons (search-patch "bash-reproducible-linux-pgrp-pipe.patch")
                      (origin-patches (package-source static-bash))))))))
 
 (define %static-inputs
diff --git a/gnu/packages/patches/bash-4.4-linux-pgrp-pipe.patch b/gnu/packages/patches/bash-4.4-linux-pgrp-pipe.patch
deleted file mode 100644
index 0d03d7ce37..0000000000
--- a/gnu/packages/patches/bash-4.4-linux-pgrp-pipe.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-Unconditionally enable PGRP_PIPE on Linux (the kernel), regardless of
-the kernel version in use on the build machine.
-
---- configure.ac.orig	1969-12-31 19:00:00.000000000 -0500
-+++ configure.ac	2019-08-11 22:28:26.038841961 -0400
-@@ -1092,9 +1092,7 @@
- solaris2*)	LOCAL_CFLAGS=-DSOLARIS ;;
- lynxos*)	LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
- linux*)		LOCAL_LDFLAGS=-rdynamic		 # allow dynamic loading
--		case "`uname -r`" in
--		2.[[456789]]*|[[34]]*)	AC_DEFINE(PGRP_PIPE) ;;
--		esac ;;
-+		AC_DEFINE(PGRP_PIPE) ;;
- *qnx6*)		LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
- *qnx*)		LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
- powerux*)	LOCAL_LIBS="-lgen" ;;
---- configure.orig	1969-12-31 19:00:00.000000000 -0500
-+++ configure	2019-08-11 22:28:10.166763255 -0400
-@@ -16064,10 +16064,7 @@
- solaris2*)	LOCAL_CFLAGS=-DSOLARIS ;;
- lynxos*)	LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
- linux*)		LOCAL_LDFLAGS=-rdynamic		 # allow dynamic loading
--		case "`uname -r`" in
--		2.[456789]*|[34]*)	$as_echo "#define PGRP_PIPE 1" >>confdefs.h
-- ;;
--		esac ;;
-+		$as_echo "#define PGRP_PIPE 1" >>confdefs.h ;;
- *qnx6*)		LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
- *qnx*)		LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
- powerux*)	LOCAL_LIBS="-lgen" ;;
diff --git a/gnu/packages/patches/bash-reproducible-linux-pgrp-pipe.patch b/gnu/packages/patches/bash-reproducible-linux-pgrp-pipe.patch
new file mode 100644
index 0000000000..8a03c4d982
--- /dev/null
+++ b/gnu/packages/patches/bash-reproducible-linux-pgrp-pipe.patch
@@ -0,0 +1,34 @@
+Unconditionally enable PGRP_PIPE on Linux (the kernel), regardless of
+the kernel version in use on the build machine.
+
+diff -purN bash-5.0-orig/configure bash-5.0/configure
+--- configure	1970-01-01 01:00:00.000000000 +0100
++++ configure	2019-09-29 11:51:42.664518665 +0200
+@@ -16312,11 +16312,7 @@ solaris2.10*)	LOCAL_CFLAGS=-DSOLARIS  ;;
+ solaris2*)	LOCAL_CFLAGS=-DSOLARIS ;;
+ lynxos*)	LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
+ linux*)		LOCAL_LDFLAGS=-rdynamic		 # allow dynamic loading
+-		case "`uname -r`" in
+-		1.*|2.[0123]*)	: ;;
+-		*)	$as_echo "#define PGRP_PIPE 1" >>confdefs.h
+- ;;
+-		esac ;;
++		$as_echo "#define PGRP_PIPE 1" >>confdefs.h ;;
+ netbsd*|openbsd*)	LOCAL_CFLAGS="-DDEV_FD_STAT_BROKEN" ;;
+ *qnx[67]*)	LOCAL_LIBS="-lncurses" ;;
+ *qnx*)		LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
+diff -purN bash-5.0-orig/configure.ac bash-5.0/configure.ac
+--- configure.ac	1970-01-01 01:00:00.000000000 +0100
++++ configure.ac	2019-09-29 11:51:10.692026225 +0200
+@@ -1108,10 +1108,7 @@ solaris2.10*)	LOCAL_CFLAGS=-DSOLARIS  ;;
+ solaris2*)	LOCAL_CFLAGS=-DSOLARIS ;;
+ lynxos*)	LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
+ linux*)		LOCAL_LDFLAGS=-rdynamic		 # allow dynamic loading
+-		case "`uname -r`" in
+-		1.*|2.[[0123]]*)	: ;;
+-		*)	AC_DEFINE(PGRP_PIPE) ;;
+-		esac ;;
++		AC_DEFINE(PGRP_PIPE) ;;
+ netbsd*|openbsd*)	LOCAL_CFLAGS="-DDEV_FD_STAT_BROKEN" ;;
+ *qnx[[67]]*)	LOCAL_LIBS="-lncurses" ;;
+ *qnx*)		LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
-- 
2.23.0

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com