[Top][All Lists]

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

Re: How to add /bin/sh to the build environment

From: Foo Chuan Wei
Subject: Re: How to add /bin/sh to the build environment
Date: Mon, 8 Nov 2021 20:19:27 +0000

On 2021-11-08 17:54 +0100, Xinglu Chen wrote:
> I would use ‘substitute*’ from (guix build utils) to patch the
> references to /bin/sh
>   (lambda* (#:key inputs #:allow-other-keys)
>     (let ((sh (assoc-ref inputs "bash")))
>       (substitute* "some-file"
>        (("\"/bin/sh\"") (string-append "\"" sh "/bin/sh\"")))))
> Hope that helps!

Thank you for the suggestion, but this will not work for packaging
SML/NJ. The build process depends on the existence of /bin/sh in a
fundamental way:

* Part of the build process relies on programs written in Standard ML.
* The part written in Standard ML uses a function from the SML Basis
  Library: `OS.Process.system`.
* `OS.Process.system` will always use /bin/sh. This is hardcoded. I
 cannot change it. If I change it, the behavior of `OS.Process.system`
 would probably be wrong in the final product (the sml compiler).

I'm not even sure if I can use `substitute*`, since the build process
relies on binary "bootfiles" where /bin/sh is hardcoded.

Note that I've managed to work around the problem.
Before building:
* Create a symlink /tmp/sh that points to `(which "sh")`.
* Edit the binary bootfiles so that they use /tmp/sh instead of /bin/sh.

After building:
* Edit the resulting binaries so that they use /bin/sh instead of /tmp/sh.

Is there really no way to create /bin/sh in the build environment, so
that binary patching can be avoided?

reply via email to

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