Re: [PATCHES] Add 'file' to %final-inputs; patch /usr/bin/file

2014-08-30 Thread Ludovic Courtès
m...@netris.org skribis:

> +(define* (patch-usr-bin-file #:key native-inputs inputs #:allow-other-keys)
> +  "Patch occurrences of /usr/bin/file in configure script, if present."
> +  (let ((file "configure")
> +(new (and=> (assoc-ref (or native-inputs inputs) "file")
> +(cut string-append <> "/bin/file"
> +(when (and new (file-exists? file))
> +  (let ((st (stat file)))
> +(substitute* file
> +  (("/usr/bin/file" old)
> +   (begin
> + (format (current-error-port)
> + "patch-usr-bin-file: ~a: changing `~a' to `~a'~%"
> + file old new)
> + new)))
> +(set-file-time file st)))
> +#t))

Having seen this commit:

  commit 6646747c020402fd077a719af99627d9cf3fe54d

  gnu: gawk: Patch /usr/bin/file in extension/configure on MIPS.

  * gnu/packages/gawk.scm (gawk): When building for MIPS, patch 
/usr/bin/file in
extension/configure.

I was thinking that perhaps the ‘patch-usr-bin-file’ phase should
operate on all the executable ‘configure’ files found in the source
tree, recursively.  WDYT?

Also, perhaps the procedure that does the actual patching could be moved
to (guix build utils), and then called from ‘patch-usr-bin-file’.

(This change can wait for the next core-updates if this one is going to
be merged real soon.)

Thanks,
Ludo’.



Re: [PATCHES] Add 'file' to %final-inputs; patch /usr/bin/file

2014-08-22 Thread Ludovic Courtès
m...@netris.org skribis:

> From 554d86b02c75922a1c05b5e65cfccd3cc8bd23db Mon Sep 17 00:00:00 2001
> From: Mark H Weaver 
> Date: Thu, 21 Aug 2014 11:26:40 -0400
> Subject: [PATCH 1/3] gnu: bootstrap: Add 'file' to %boot0-inputs and
>  %final-inputs.
>
> * gnu/packages/base.scm (file-boot0): New variable.
>   (%boot0-inputs): Add 'file-boot0'.
>   (%final-inputs): Add 'file' to list of packages to 'finalize'.

LGTM.

Please try to do the same check that
‘check-final-inputs-self-contained.scm’ does by hand, to make sure
nothing is breaking here.

> From 883f77d92f5b1e8af294f88abea0b09487fb901b Mon Sep 17 00:00:00 2001
> From: Mark H Weaver 
> Date: Thu, 21 Aug 2014 11:30:08 -0400
> Subject: [PATCH 2/3] gnu-build-system: Add 'patch-usr-bin-file' to
>  %standard-phases.
>
> * guix/build/gnu-build-system.scm (patch-usr-bin-file): New procedure.
>   (%standard-phases): Add it.

[...]

> +(define* (patch-usr-bin-file #:key native-inputs inputs #:allow-other-keys)
> +  "Patch occurrences of /usr/bin/file in configure, if present."

Please add a link to the Libtool bug report.

Also, for convenience, it might help to add a #:patch-/usr/bin/file?
keyword parameter.

> From 6818e2a6e53afa7b90379a4a99f014308c8cd2ee Mon Sep 17 00:00:00 2001
> From: Mark H Weaver 
> Date: Thu, 21 Aug 2014 22:39:18 -0400
> Subject: [PATCH 3/3] gnu: Rely on 'file' implicit input and
>  'patch-usr-bin-file'.
>
> * gnu/packages/admin.scm (sudo):
> * gnu/packages/gawk.scm (gawk): Remove workaround on MIPS.
>
> * gnu/packages/mcrypt.scm (mcrypt, libmhash):
> * gnu/packages/file.scm (file): Remove 'file' from native-inputs.
>
> * gnu/packages/mc.scm (mc):
> * gnu/packages/pretty-print.scm (a2ps, trueprint, source-highlight):
> * gnu/packages/image.scm (libtiff): Remove 'file' from native-inputs.
>   Remove 'patch-configure' phase.

OK.

Thanks for all this!

Ludo’.



Re: [PATCHES] Add 'file' to %final-inputs; patch /usr/bin/file

2014-08-22 Thread Ludovic Courtès
m...@netris.org skribis:

> I chose to add a 'file-boot0' to '%boot0-inputs' to make 'file'
> available as early as possible in the bootstrap, on the theory that any
> library could soon depend on 'file'.

That makes sense.

> I've successfully built 'hello' on i686 with these patches applied, but
> I've not yet tested them on MIPS.  If I test them on the Loongson 3A
> machine, then when hydra offloads the same builds, the build logs on
> hydra will be empty.  It would be good if hydra would copy over the
> saved build log in that case.

Yes, that’s annoying.  The crux of the problem is that the offload hook
just invokes ‘guix build’ on the remote machine, and ‘guix build’
produces no output when the thing is already built.

We could add a ‘--replay-log’ option to ‘guix build’ to handle that
case.

Thoughts?

Ludo’.



Re: [PATCHES] Add 'file' to %final-inputs; patch /usr/bin/file

2014-08-21 Thread mhw
Here are updated versions of these patches.  Please disregard the
earlier ones.

 Mark

>From 554d86b02c75922a1c05b5e65cfccd3cc8bd23db Mon Sep 17 00:00:00 2001
From: Mark H Weaver 
Date: Thu, 21 Aug 2014 11:26:40 -0400
Subject: [PATCH 1/3] gnu: bootstrap: Add 'file' to %boot0-inputs and
 %final-inputs.

* gnu/packages/base.scm (file-boot0): New variable.
  (%boot0-inputs): Add 'file-boot0'.
  (%final-inputs): Add 'file' to list of packages to 'finalize'.
---
 gnu/packages/base.scm | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 8060ab6..30176cf 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -29,6 +29,7 @@
   #:use-module (gnu packages compression)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages ed)
+  #:use-module (gnu packages file)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages multiprecision)
@@ -630,11 +631,20 @@ and daylight-saving rules.")
  (current-source-location)
  #:guile %bootstrap-guile)))
 
+(define file-boot0
+  (package-with-bootstrap-guile
+   (package-with-explicit-inputs file
+ `(("make" ,gnu-make-boot0)
+   ,@%bootstrap-inputs)
+ (current-source-location)
+ #:guile %bootstrap-guile)))
+
 
 (define %boot0-inputs
   `(("make" ,gnu-make-boot0)
 ("diffutils" ,diffutils-boot0)
 ("findutils" ,findutils-boot0)
+("file" ,file-boot0)
 ,@%bootstrap-inputs))
 
 (define* (nix-system->gnu-triplet
@@ -1187,6 +1197,7 @@ store.")
("gzip" ,gzip)
("bzip2" ,bzip2)
("xz" ,xz)
+   ("file" ,file)
("diffutils" ,diffutils)
("patch" ,patch)
("sed" ,sed)
-- 
1.8.4

>From 883f77d92f5b1e8af294f88abea0b09487fb901b Mon Sep 17 00:00:00 2001
From: Mark H Weaver 
Date: Thu, 21 Aug 2014 11:30:08 -0400
Subject: [PATCH 2/3] gnu-build-system: Add 'patch-usr-bin-file' to
 %standard-phases.

* guix/build/gnu-build-system.scm (patch-usr-bin-file): New procedure.
  (%standard-phases): Add it.
---
 guix/build/gnu-build-system.scm | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 8636931..a1fe26e 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -106,6 +106,31 @@ working directory."
   (and (zero? (system* "tar" "xvf" source))
(chdir (first-subdirectory ".")
 
+(define* (patch-usr-bin-file #:key native-inputs inputs #:allow-other-keys)
+  "Patch occurrences of /usr/bin/file in configure, if present."
+  (let ((file "configure")
+(file-command (or (and=> (assoc-ref (or native-inputs inputs) "file")
+ (cut string-append <> "/bin/file"))
+  (which "file"
+(cond ((not (file-exists? file))
+   (format (current-error-port)
+   "patch-usr-bin-file: warning: `~a' not found~%"
+   file))
+  ((not file-command)
+   (format (current-error-port)
+   "patch-usr-bin-file: warning: `file' not found in PATH~%"))
+  (else
+   (let ((st (stat file)))
+ (substitute* file
+   (("/usr/bin/file")
+(begin
+  (format (current-error-port)
+  "patch-usr-bin-file: ~a: changing `~a' to `~a'~%"
+  file "/usr/bin/file" file-command)
+  file-command)))
+ (set-file-time file st
+#t))
+
 (define* (patch-source-shebangs #:key source #:allow-other-keys)
   "Patch shebangs in all source files; this includes non-executable
 files such as `.in' templates.  Most scripts honor $SHELL and
@@ -353,6 +378,7 @@ makefiles."
   (let-syntax ((phases (syntax-rules ()
  ((_ p ...) `((p . ,p) ...)
 (phases set-paths unpack
+patch-usr-bin-file
 patch-source-shebangs configure patch-generated-file-shebangs
 build check install
 patch-shebangs strip)))
-- 
1.8.4

>From 6818e2a6e53afa7b90379a4a99f014308c8cd2ee Mon Sep 17 00:00:00 2001
From: Mark H Weaver 
Date: Thu, 21 Aug 2014 22:39:18 -0400
Subject: [PATCH 3/3] gnu: Rely on 'file' implicit input and
 'patch-usr-bin-file'.

* gnu/packages/admin.scm (sudo):
* gnu/packages/gawk.scm (gawk): Remove workaround on MIPS.

* gnu/packages/mcrypt.scm (mcrypt, libmhash):
* gnu/packages/file.scm (file): Remove 'file' from native-inputs.

* gnu/packages/mc.scm (mc):
* gnu/packages/pretty-print.scm (a2ps, trueprint, source-highlight):
* gnu/packages/image.scm (libtiff): Remove 'file' from native-inputs.
  Remove 'patch-configure' phase.
---
 gnu

[PATCHES] Add 'file' to %final-inputs; patch /usr/bin/file

2014-08-21 Thread mhw
l...@gnu.org (Ludovic Courtès) writes:

> m...@netris.org skribis:
>
>> Given that this problem is becoming increasingly common, I think we
>> should add 'file' as an implicit native-input for the gnu-build-system
>> in core-updates, and also add a new phase to %standard-phases that
>> substitutes /usr/bin/file in the usual places with a path that works in
>> the build environment.
>
> Yes, that makes sense.
>
> If you want, you (yes, you ;-)) can start it in a branch off
> core-updates, or directly in core-updates, if that’s fine this way.

Here are proposed patches for core-updates.

I chose to add a 'file-boot0' to '%boot0-inputs' to make 'file'
available as early as possible in the bootstrap, on the theory that any
library could soon depend on 'file'.

I've successfully built 'hello' on i686 with these patches applied, but
I've not yet tested them on MIPS.  If I test them on the Loongson 3A
machine, then when hydra offloads the same builds, the build logs on
hydra will be empty.  It would be good if hydra would copy over the
saved build log in that case.

Do these patches look right to you?  Do you expect that
cross-compilation would be handled correctly?

Thanks!
  Mark


>From cc6c36bb7ab93271c302b6e3c44a051ace1e729d Mon Sep 17 00:00:00 2001
From: Mark H Weaver 
Date: Thu, 21 Aug 2014 11:26:40 -0400
Subject: [PATCH 1/3] gnu: bootstrap: Add 'file' to %boot0-inputs and
 %final-inputs.

* gnu/packages/base.scm (file-boot0): New variable.
  (%boot0-inputs): Add 'file-boot0'.
  (%final-inputs): Add 'file' to list of packages to 'finalize'.
---
 gnu/packages/base.scm | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 8060ab6..30176cf 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -29,6 +29,7 @@
   #:use-module (gnu packages compression)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages ed)
+  #:use-module (gnu packages file)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages multiprecision)
@@ -630,11 +631,20 @@ and daylight-saving rules.")
  (current-source-location)
  #:guile %bootstrap-guile)))
 
+(define file-boot0
+  (package-with-bootstrap-guile
+   (package-with-explicit-inputs file
+ `(("make" ,gnu-make-boot0)
+   ,@%bootstrap-inputs)
+ (current-source-location)
+ #:guile %bootstrap-guile)))
+
 
 (define %boot0-inputs
   `(("make" ,gnu-make-boot0)
 ("diffutils" ,diffutils-boot0)
 ("findutils" ,findutils-boot0)
+("file" ,file-boot0)
 ,@%bootstrap-inputs))
 
 (define* (nix-system->gnu-triplet
@@ -1187,6 +1197,7 @@ store.")
("gzip" ,gzip)
("bzip2" ,bzip2)
("xz" ,xz)
+   ("file" ,file)
("diffutils" ,diffutils)
("patch" ,patch)
("sed" ,sed)
-- 
1.8.4

>From c41191e84b79af9021c7a17cdd1fd10564e96ad9 Mon Sep 17 00:00:00 2001
From: Mark H Weaver 
Date: Thu, 21 Aug 2014 11:30:08 -0400
Subject: [PATCH 2/3] build-system/gnu: Add 'patch-usr-bin-file' to
 %standard-phases.

* guix/build/gnu-build-system.scm (patch-usr-bin-file): New procedure.
  (%standard-phases): Add it.
---
 guix/build/gnu-build-system.scm | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 8636931..470e96e 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -106,6 +106,23 @@ working directory."
   (and (zero? (system* "tar" "xvf" source))
(chdir (first-subdirectory ".")
 
+(define* (patch-usr-bin-file #:key native-inputs inputs #:allow-other-keys)
+  "Patch occurrences of /usr/bin/file in configure script, if present."
+  (let ((file "configure")
+(new (and=> (assoc-ref (or native-inputs inputs) "file")
+(cut string-append <> "/bin/file"
+(when (and new (file-exists? file))
+  (let ((st (stat file)))
+(substitute* file
+  (("/usr/bin/file" old)
+   (begin
+ (format (current-error-port)
+ "patch-usr-bin-file: ~a: changing `~a' to `~a'~%"
+ file old new)
+ new)))
+(set-file-time file st)))
+#t))
+
 (define* (patch-source-shebangs #:key source #:allow-other-keys)
   "Patch shebangs in all source files; this includes non-executable
 files such as `.in' templates.  Most scripts honor $SHELL and
@@ -353,6 +370,7 @@ makefiles."
   (let-syntax ((phases (syntax-rules ()
  ((_ p ...) `((p . ,p) ...)
 (phases set-paths unpack
+patch-usr-bin-file
 patch-source-shebangs configure patch-generated-file-shebangs
 build check install