diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2007-01-29 14:53:23 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2007-01-29 14:53:23 +0000 |
commit | 83a82a22e508d40f36f0d5345b8e4e497fa21c32 (patch) | |
tree | fcc51b1366040a2e8013018cdd8ac7dd7b41aa10 /pkgs/lib | |
parent | bffcfd2d780f71e210e79f948c5744997f6ce546 (diff) | |
download | nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.tar nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.tar.gz nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.tar.bz2 nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.tar.lz nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.tar.xz nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.tar.zst nixlib-83a82a22e508d40f36f0d5345b8e4e497fa21c32.zip |
* Filter out *~ files in cleanSource.
svn path=/nixpkgs/trunk/; revision=7803
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/default.nix | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index 32b20769647d..e0c96c2395bd 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -2,7 +2,8 @@ let - inherit (builtins) head tail isList; + inherit (builtins) + head tail isList stringLength substring lessThan sub; in @@ -81,13 +82,24 @@ rec { else if xs == [] || ys == [] then false else head xs == head ys && eqLists (tail xs) (tail ys); - - # Bring in a path as a source, filtering out all hidden Subversion - # directories. TODO: filter out backup files (*~) etc. + + # Determine whether a filename ends in the given suffix. + hasSuffix = ext: fileName: + let lenFileName = stringLength fileName; + lenExt = stringLength ext; + in !(lessThan lenFileName lenExt) && + substring (sub lenFileName lenExt) lenFileName fileName == ext; + + + # Bring in a path as a source, filtering out all Subversion and CVS + # directories, as well as backup files (*~). cleanSource = - let filter = name: type: - type != "directory" - || baseNameOf (toString name) != ".svn"; + let filter = name: type: let baseName = baseNameOf (toString name); in ! ( + # Filter out Subversion and CVS directories. + (type == "directory" && (name == ".svn" || name == "CVS")) || + # Filter out backup files. + (hasSuffix "~" name) + ); in src: builtins.filterSource filter src; |