From fbad1b3a56c4885702739d89b9b80397c5f6d512 Mon Sep 17 00:00:00 2001 From: LluĂ­s Batlle i Rossell Date: Sun, 1 Aug 2010 21:06:45 +0000 Subject: Trying to make busybox more configurable svn path=/nixpkgs/branches/stdenv-updates/; revision=22846 --- pkgs/misc/busybox/default.nix | 57 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 11 deletions(-) (limited to 'pkgs/misc/busybox/default.nix') 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 ""); }; } -- cgit 1.4.1