···
# mounting `/`, like `/` on a loopback).
fileSystems = filter utils.fsNeededForBoot config.system.build.fileSystems;
33
+
# A utility for enumerating the shared-library dependencies of a program
34
+
findLibs = pkgs.writeShellScriptBin "find-libs" ''
40
+
patchelf="${pkgs.buildPackages.patchelf}/bin/patchelf"
42
+
function add_needed {
43
+
rpath="$($patchelf --print-rpath $1)"
45
+
for lib in $($patchelf --print-needed $1); do
46
+
left+=("$lib" "$rpath" "$dir")
52
+
while [ ''${#left[@]} -ne 0 ]; do
56
+
left=("''${left[@]:3}")
57
+
if [ -z ''${seen[$next]+x} ]; then
59
+
IFS=: read -ra paths <<< $rpath
61
+
for path in "''${paths[@]}"; do
62
+
path=$(eval "echo $path")
63
+
if [ -f "$path/$next" ]; then
70
+
if [ -z "$res" ]; then
71
+
echo "Couldn't satisfy dependency $next" >&2
# Some additional utilities needed in stage 1, like mount, lvm, fsck
# etc. We don't want to bring in all of those packages, so we just
···
# Copy all of the needed libraries
find $out/bin $out/lib -type f | while read BIN; do
echo "Copying libs for executable $BIN"
106
-
LDD="$(ldd $BIN)" || continue
107
-
LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')"
108
-
for LIB in $LIBS; do
150
+
for LIB in $(${findLibs}/bin/find-libs $BIN); do
TGT="$out/lib/$(basename $LIB)"
SRC="$(readlink -e $LIB)"