summary refs log tree commit diff
path: root/pkgs/os-specific/linux/klibc/shrunk.nix
blob: 8b79940ed78cd69d591b65607e0e305c2602e201 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{stdenv, klibc}:

stdenv.mkDerivation {
  # !!! For now, the name has to be exactly as long as the original
  # name due to the sed hackery below.  Once patchelf 0.4 is in the
  # tree, we can do this properly.
  #name = "${klibc.name}-shrunk";
  name = klibc.name;
  buildCommand = ''
    mkdir -p $out/lib
    cp -prd ${klibc.out}/lib/klibc/bin $out/
    cp -p ${klibc.out}/lib/*.so $out/lib/
    chmod +w $out/*
    old=$(echo ${klibc.out}/lib/klibc-*.so)
    new=$(echo $out/lib/klibc-*.so)
    for i in $out/bin/*; do
      echo $i
      sed "s^$old^$new^" -i $i
      # !!! use patchelf
      #patchelf --set-interpreter $new $i
    done
  ''; # */
  allowedReferences = ["out"];

  inherit (klibc) meta;
}