I’m trying to compile a library that needs to be compiled inside an FHS environment.
the problem is if I put my compiling/linking steps inside extraBuildCommands
, targetPkgs
are not yet installed. and if I use runScript
I can’t move the compiled code back to the FHS environment (because it is read-only system).
any help ?
the build directory is still writable… I would try to patch the assumptions it makes to something more reasonable, like TMPDIR.
It would help if you expanded on what aspects of a FHS are required.
I’m trying to build ‘kaldi’.
it has some steps like configure, make, sed something like that.
it depends so hard on /bin/bash inside its makefiles . it even generate makfiles that needs /bin/bash.
so I decided to build it inside fhs environment, and I succeded but I can’t put the built directory back to the environment itself.
I’m trying to build a Singularity (Apptainer) image with the --fakeroot
option, but have encountered an issue about the (seemingly hard-coded) PATH variable.
Considering that the product is an image to be used on an HPC grid, and that I don’t want to hack the singularity
derivation just for building it. It would be great if there’s an option to build things in an FHS environment.
Atemu
February 4, 2022, 9:53am
5
In that case it is better to use patchShebangs
on the generated makefiles after configuring and/or patch the configure scripts.
Atemu
February 4, 2022, 9:55am
6
If the PATH is hard-coded, try to patch it. Things like these are usually simple string substitutions (substituteInPlace
).
The Apptainer --fakeroot
issue is more complex than a line of hard-coded PATH. Ideally, it should be solved upstream.
opened 02:01PM - 03 Feb 22 UTC
Moved here from https://github.com/apptainer/singularity/issues/6363
### Vers… ion of Apptainer:
What version of Apptainer are you using? Run:
```
$ singularity --version
singularity version 3.8.4
```
### Expected behavior
1. `newuidmap` and `newgidmap` are found in directories prefixed in the `PATH` environment variable.
2. `singularity build --fakeroot` works.
### Actual behavior
After running `singularity build --fakeroot` (in a Nix expression with `shadow` provided)
```
> PATH is /nix/store/k1a6qkjw9m6b3r100i0w2qknl0g6ll31-singularity-3.8.4/bin:/nix/store/k21halap3i7hgglxpdnpx29538g3irin-coreutils-9.0/bin:/nix/store/ki4j2cwwm8p2www0071ss8mja20dkzbb-squashfs-4.5/bin:/nix/store/2aq9imyh2m0wglfbp00m35rgfyqaqww3-shadow-4.8.1/bin:/nix/store/xfb60lr4bh1dgn93cswif4j3gadfpjyp-xAna_monoZ_preselect-0.0.1/bin:/nix/store/y5dkkfin05252783r42vc38s83297ypv-patchelf-0.13/bin:/nix/store/k21halap3i7hgglxpdnpx29538g3irin-coreutils-9.0/bin:/nix/store/bfbsy0kyb3r2azfh9dimgqa1qxplkwgl-findutils-4.8.0/bin:/nix/store/9dpl3qwz7ziwx9cssj36zlca4q4wya4h-diffutils-3.8/bin:/nix/store/lwgh498dp39g9pnnaa8im4c4kkb1b4m0-gnused-4.8/bin:/nix/store/1m0rkfgnj9rlbp2jd3iz5h2lpv60ngxh-gnugrep-3.7/bin:/nix/store/xa8vlasjm4g7bqdijmwzbh077cbs6k2h-gawk-5.1.1/bin:/nix/store/gxzcls54jx8f7a8vcglwzsgkkizzrwnp-gnutar-1.34/bin:/nix/store/z3kr7132d3rncaaj2pch6fiw5bz8bpmd-gzip-1.11/bin:/nix/store/cdxwlsm848djwc86f4dqj47sd4byq0rk-bzip2-1.0.6.0.2-bin/bin:/nix/store/40qfhd1jlk4nrlilyh7s9mf3f3k65bw1-gnumake-4.3/bin:/nix/store/vfai0jim0db67nk9rd7ziq29jxb5n79n-bash-5.1-p8/bin:/nix/store/bdvz1ilv1x2qh45xa0qkfgb9vdrv5xa2-patch-2.7.6/bin:/nix/store/l5pns19l44hk17yr89l3i09bzx2nsgnr-xz-5.2.5-bin/bin
> Executable newuidmap is /nix/store/2aq9imyh2m0wglfbp00m35rgfyqaqww3-shadow-4.8.1/bin/newuidmap
> Executable newgidmap is /nix/store/2aq9imyh2m0wglfbp00m35rgfyqaqww3-shadow-4.8.1/bin/newgidmap
> FATAL: newuidmap was not found in PATH (/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin), required with fakeroot and unprivileged installation
```
### Steps to reproduce this behavior
`stub.def`
```Singularity
Bootstrap: scratch
```
```console
[shamrock@nixos-202104:/dev/shm]$ nix-shell -p singularity shadow
[nix-shell:/dev/shm]$ singularity build --fakeroot stub.sif stub.def
FATAL: newuidmap was not found in PATH (/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin), required with fakeroot and unprivileged installation
[nix-shell:/dev/shm]$ type -p newuidmap
/nix/store/jki00pcw0npk9hfmxc5ln41003225b1h-shadow-4.8.1/bin/newuidmap
[nix-shell:/dev/shm]$ echo $PATH
/nix/store/6kxhv6s36p5l3jylxzwvqn4qm3fjkb63-bash-interactive-4.4-p23/bin:/nix/store/m40wl6v6ayalys7l5x5iqif6qwjj1dsx-patchelf-0.12/bin:/nix/store/ryy81g8zv6c8fh0j10m6fdynrgrn239k-gcc-wrapper-9.3.0/bin:/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/bin:/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/h8ibzi1f489avmhcz754chnrgr3dysjr-binutils-wrapper-2.31.1/bin:/nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin:/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/d7zl264bdvkiqls47b4bj7v21wxi7p2n-singularity-3.6.4/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/d9j1hbbz8d2g620dsvga9n0l1qcdniz9-squashfs-4.4/bin:/nix/store/jki00pcw0npk9hfmxc5ln41003225b1h-shadow-4.8.1/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/ax8vv1ds6l81jx8cmflx3fvcl9jdxd2w-findutils-4.7.0/bin:/nix/store/m87blzdbjqhj1dghl5l2dqqnl9dhvarz-diffutils-3.7/bin:/nix/store/gdr4s4xx41n8krk9carr8amvncy8x3p3-gnused-4.8/bin:/nix/store/rxkghln0km9axapv94iz3pcsln6ricms-gnugrep-3.4/bin:/nix/store/b9j6qhmxpwfvga2bfxn1khjrv3v3qxg7-gawk-5.1.0/bin:/nix/store/k6ssslsxmvndgm056k7x4s75390sjfkz-gnutar-1.32/bin:/nix/store/2hh9fld5r11zhp3697pzjwmqag76yc54-gzip-1.10/bin:/nix/store/6v59a9iszrs0kxk1b79v7fasn9bwi79q-bzip2-1.0.6.0.1-bin/bin:/nix/store/7fqqkrz6m11793cw7by8wbn2q87za8ny-gnumake-4.3/bin:/nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin:/nix/store/5vpsaqjazidyfrpjx2z137jmqwn3f2ai-patch-2.7.6/bin:/nix/store/n5xz5y5wazbhrwa9s9cyv52dabx9qxsq-xz-5.2.5-bin/bin:/run/wrappers/bin:/home/shamrock/.nix-profile/bin:/etc/profiles/per-user/shamrock/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
```
### What OS/distro are you running
```
$ cat /etc/os-release
NAME=NixOS
ID=nixos
VERSION="21.05.20211019.8fe3b97 (Okapi)"
VERSION_CODENAME=okapi
VERSION_ID="21.05.20211019.8fe3b97"
PRETTY_NAME="NixOS 21.05 (Okapi)"
LOGO="nix-snowflake"
HOME_URL="https://nixos.org/"
DOCUMENTATION_URL="https://nixos.org/learn.html"
SUPPORT_URL="https://nixos.org/community.html"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
```
### How did you install Apptainer
Through Nix.
`flake.nix`
```Nix
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
# ...
}
```
`flake.lock`
```json
{
# ...
"nixpkgs": {
"locked": {
"lastModified": 1643247693,
"narHash": "sha256-rmShxIuNjYBz4l83J0J++sug+MURUY1koPCzX4F8hfo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6c4b9f1a2fd761e2d384ef86cff0d208ca27fdca",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
}
# ..
}
```
I acknowledge that packages for Nixpkgs should not be built in such a manner. However, when trying to build, say, an image to be run on FHS-compliant platforms, such kind of setup would make development and testing faster.
IMO, if the program is to be merged into NixOS/nixpkgs, it should be patched and the result should be independent from /bin
and /usr/bin
. Otherwise, the same problems will occur when being run by users.
If it heavily relies on /bin/bash
, it would be better to send a patch upstream.
Nevertheless, an FHS builder would still be a cheaper / more convenient alternative to vmTools.runInLinuxVM
for local run / tests.