@@ -12,7 +12,6 @@ stdenvNoCC.mkDerivation {
1212 outputs = [
1313 "out"
1414 "dev"
15- "bin"
1615 "static"
1716 ] ;
1817
@@ -35,31 +34,26 @@ stdenvNoCC.mkDerivation {
3534
3635 sourceRoot = "." ;
3736
38- unpackPhase = ''
39- runHook preUnpack
40- for src in $srcs; do
41- dpkg-deb --fsys-tarfile "$src" | tar xf -
42- done
43- runHook postUnpack
44- '' ;
45-
4637 installPhase = ''
4738 runHook preInstall
4839
40+ # dpkg unpack hook extracts each .deb into root/
41+ local s=root
42+
4943 # --- $out: shared libraries + CRT objects ---
5044 mkdir -p $out/lib
5145
5246 # Shared libraries from libc6 (./lib/x86_64-linux-gnu/)
53- cp -a lib/x86_64-linux-gnu/* $out/lib/
47+ cp -a $s/ lib/x86_64-linux-gnu/* $out/lib/
5448
5549 # CRT objects + linker scripts + static nonshared libs from libc6-dev
5650 # (./usr/lib/x86_64-linux-gnu/)
57- cp -a usr/lib/x86_64-linux-gnu/*.o $out/lib/
58- cp -a usr/lib/x86_64-linux-gnu/*_nonshared.a $out/lib/
51+ cp -a $s/ usr/lib/x86_64-linux-gnu/*.o $out/lib/
52+ cp -a $s/ usr/lib/x86_64-linux-gnu/*_nonshared.a $out/lib/
5953
6054 # Development .so files from libc6-dev: a mix of linker scripts and symlinks.
6155 # Both contain absolute Ubuntu paths that need rewriting.
62- for f in usr/lib/x86_64-linux-gnu/*.so; do
56+ for f in $s/ usr/lib/x86_64-linux-gnu/*.so; do
6357 name=$(basename "$f")
6458 # Skip if we already have this file (e.g. from the libc6 runtime package)
6559 [ -e "$out/lib/$name" ] && continue
@@ -70,10 +64,7 @@ stdenvNoCC.mkDerivation {
7064 ln -s "$target" "$out/lib/$name"
7165 elif [ -f "$f" ]; then
7266 # Linker script: rewrite absolute paths
73- # N.B. /usr/lib must be replaced before /lib to avoid partial matches
74- sed \
75- -e "s|/usr/lib/x86_64-linux-gnu/|$out/lib/|g" \
76- -e "s|/lib/x86_64-linux-gnu/|$out/lib/|g" \
67+ sed -E "s|(/usr)?/lib/x86_64-linux-gnu/|$out/lib/|g" \
7768 "$f" > "$out/lib/$name"
7869 fi
7970 done
@@ -82,24 +73,19 @@ stdenvNoCC.mkDerivation {
8273 mkdir -p $dev/include
8374
8475 # Main glibc headers from libc6-dev (./usr/include/)
85- cp -a usr/include/* $dev/include/
76+ cp -a $s/ usr/include/* $dev/include/
8677
8778 # Arch-specific headers go on top (./usr/include/x86_64-linux-gnu/)
8879 # These contain bits/, gnu/, sys/ subdirs that override/supplement the main ones
89- if [ -d usr/include/x86_64-linux-gnu ]; then
90- cp -a usr/include/x86_64-linux-gnu/* $dev/include/
91- rm -rf $dev/include/x86_64-linux-gnu
92- fi
80+ cp -a $s/usr/include/x86_64-linux-gnu/* $dev/include/
81+ rm -rf $dev/include/x86_64-linux-gnu
9382
9483 # Kernel headers from linux-libc-dev are already in usr/include/
9584 # (asm/, asm-generic/, linux/) - they were copied above
9685
97- # --- $bin: minimal (not needed for cross-compilation) ---
98- mkdir -p $bin/bin
99-
10086 # --- $static: static libraries ---
10187 mkdir -p $static/lib
102- cp -a usr/lib/x86_64-linux-gnu/*.a $static/lib/ 2>/dev/null || true
88+ cp -a $s/ usr/lib/x86_64-linux-gnu/*.a $static/lib/
10389 # Remove the nonshared libs we already put in $out
10490 rm -f $static/lib/*_nonshared.a
10591
0 commit comments