Corrected a flaw that made automated package silently accept any extra arguments

svn path=/nixpkgs/trunk/; revision=9101
This commit is contained in:
Michael Raskin 2007-08-11 11:14:36 +00:00
parent efbabdb598
commit 118e9d6ebf
3 changed files with 25 additions and 22 deletions

View File

@ -2,7 +2,6 @@ args:
let
defList = [];
#stdenv and fetchurl are added automatically
notForBuildInputs = [];
getVal = (args.lib.getValue args defList);
check = args.lib.checkFlag args;
reqsList = [
@ -11,14 +10,13 @@ let
["x11Support" "libX11"]
["hugeFeatures"]
["true" "ncurses"]
["false" "libSM"]
];
buildInputsNames = args.lib.filter (x: (null!=getVal x)&&
(! args.lib.isInList (notForBuildInputs ++
["stdenv" "fetchurl" "lib"] ++
(map builtins.head reqsList)) x))
/*["libX11" "glib" "gtk" "pkgconfig" "libXpm" "libXext"
"libXau" "libXt" "libXaw" "ncurses"];*/
(builtins.attrNames args);
buildInputsNames = args.lib.filter (x: (null!=getVal x))
(args.lib.uniqList {inputList =
(args.lib.concatLists (map
(x:(if (x==[]) then [] else builtins.tail x))
reqsList));});
in
assert args.lib.checkReqs args defList reqsList;
args.stdenv.mkDerivation {
@ -36,10 +34,8 @@ args.stdenv.mkDerivation {
inherit (args) ncurses;
debug = builtins.attrNames args;
buildInputs = args.lib.filter (x: x!=null) (map getVal buildInputsNames);
preConfigure = "echo \$debug";
buildInputs = args.lib.filter (x: (x!=null)) (map getVal buildInputsNames);
postInstall = "ln -s $out/bin/vim $out/bin/vi";
preBuild="touch src/auto/link.sed";
configureFlags=" --enable-gui=auto --disable-xim "+

View File

@ -127,6 +127,7 @@ rec {
# Return true only if there is an attribute and it is true.
checkFlag = attrSet: name:
if (name == "true") then true else
if (name == "false") then false else
getAttr [name] false attrSet ;
logicalOR = x: y: x || y;
@ -160,4 +161,13 @@ rec {
if (list == []) then false else
if (x == (head list)) then true else
isInList (tail list) x;
uniqList = {inputList, outputList ? []}:
if (inputList == []) then outputList else
let x=head inputList;
newOutputList = outputList ++
(if (isInList outputList x) then [] else [x]);
in uniqList {outputList=newOutputList;
inputList = (tail inputList);};
}

View File

@ -4,21 +4,18 @@ let
(assert false) - correct it; List element is of form ["name" default]
];
#stdenv and fetchurl are added automatically
notForBuildInputs = [
(assert false) - correct it; List of names of non-buildInput arguments
];
getVal = (args.lib.getValue args defList);
check = args.lib.checkFlag args;
reqsList = [
(assert false) - correct it; List element is of form ["name" "requirement-name" ... ]
["true"]
["false"]
];
buildInputsNames = args.lib.filter (x: (null!=getVal x)&&
(! args.lib.isInList (notForBuildInputs ++
["stdenv" "fetchurl" "lib"] ++
(map builtins.head reqsList)) x))
/*["libX11" "glib" "gtk" "pkgconfig" "libXpm" "libXext"
"libXau" "libXt" "libXaw" "ncurses"];*/
(builtins.attrNames args);
buildInputsNames = args.lib.filter (x: (null!=getVal x))
(args.lib.uniqList {inputList =
(args.lib.concatLists (map
(x:(if (x==[]) then [] else builtins.tail x))
reqsList));});
in
assert args.lib.checkReqs args defList reqsList;
with args;