summary refs log tree commit diff
path: root/pkgs/misc/busybox/default.nix
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2010-08-01 21:06:45 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2010-08-01 21:06:45 +0000
commitfbad1b3a56c4885702739d89b9b80397c5f6d512 (patch)
tree25def67a2c1452af1dc8e5e57cfa51647964df03 /pkgs/misc/busybox/default.nix
parent212161482ff18471ecb51823060505ffa9291605 (diff)
downloadnixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.tar
nixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.tar.gz
nixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.tar.bz2
nixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.tar.lz
nixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.tar.xz
nixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.tar.zst
nixpkgs-fbad1b3a56c4885702739d89b9b80397c5f6d512.zip
Trying to make busybox more configurable
svn path=/nixpkgs/branches/stdenv-updates/; revision=22846
Diffstat (limited to 'pkgs/misc/busybox/default.nix')
-rw-r--r--pkgs/misc/busybox/default.nix57
1 files changed, 46 insertions, 11 deletions
diff --git a/pkgs/misc/busybox/default.nix b/pkgs/misc/busybox/default.nix
index 1d190cf661d..c3afdb4b71f 100644
--- a/pkgs/misc/busybox/default.nix
+++ b/pkgs/misc/busybox/default.nix
@@ -1,12 +1,37 @@
-{stdenv, fetchurl, enableStatic ? false}:
+{stdenv, fetchurl, enableStatic ? false, extraConfig ? ""}:
 
 let
-  basicConfigure = ''
-    make defconfig
-    sed -i 's,.*CONFIG_PREFIX.*,CONFIG_PREFIX="'$out'",' .config
-    sed -i 's,.*CONFIG_INSTALL_NO_USR.*,CONFIG_INSTALL_NO_USR=y,' .config
-  '' +
-    (if enableStatic then ''
+  configParser = ''
+    function parseconfig {
+        set -x
+        while read LINE; do
+            NAME=`cut -d \  -f 1 $LINE`
+            OPTION=`cut -d \  -f 2 $LINE`
+
+            if test -z "$NAME"; then
+                continue
+            fi
+
+            if test "$NAME" == "CLEAR"; then
+                echo > .config
+            fi
+
+            sed -i /^$NAME=/d .config
+
+            if test "$OPTION" != n; then
+                echo "$NAME=$OPTION" >> .config
+            fi
+        done
+        set +x
+    }
+  '';
+
+  nixConfig = ''
+    CONFIG_PREFIX "$out"
+    CONFIG_INSTALL_NO_USR n
+  '';
+
+  staticConfig = (if enableStatic then ''
       sed -i 's,.*CONFIG_STATIC.*,CONFIG_STATIC=y,' .config
     '' else "");
 
@@ -20,14 +45,24 @@ stdenv.mkDerivation {
     sha256 = "1n738zk01yi2sjrx2y36hpzxbslas8b91vzykcifr0p1j7ym0lim";
   };
 
-  configurePhase = basicConfigure;
+  configurePhase = ''
+    set -x
+    make defconfig
+    ${configParser}
+    cat << EOF | parseconfig
+    ${extraConfig}
+    ${nixConfig}
+    $extraCrossConfig
+    EOF
+    set +x
+  '';
 
   crossAttrs = {
-    configurePhase = basicConfigure + ''
-      sed -i 's,.*CONFIG_CROSS_COMPILER_PREFIX.*,CONFIG_CROSS_COMPILER_PREFIX="'$crossConfig-'",' .config
+    extraCrossConfig = ''
+      CONFIG_CROSS_COMPILER_PREFIX "$crossConfig-"
     '' +
       (if (stdenv.cross.platform.kernelMajor == "2.4") then ''
-        sed -i 's,.*CONFIG_IONICE.*,CONFIG_IONICE=n,' .config
+        CONFIG_IONICE n
       '' else "");
   };
 }