refactor
This commit is contained in:
parent
342c87b256
commit
f02efa3fe3
1 changed files with 24 additions and 22 deletions
|
@ -12,30 +12,32 @@ let
|
|||
msg;
|
||||
l =
|
||||
mapAttrsToList
|
||||
(filename: attrs:
|
||||
(filename: {
|
||||
type ? "f"
|
||||
, mode ? null
|
||||
, target ? null
|
||||
, contents ? null
|
||||
, file ? null
|
||||
, major ? null
|
||||
, minor ? null
|
||||
, subtype ? null
|
||||
}:
|
||||
let
|
||||
attrs' = {type = "f"; } // attrs;
|
||||
mode = if attrs ? mode then attrs.mode else
|
||||
(if attrs'.type == "d" then "0755" else "0644");
|
||||
line = "${prefix}/${filename} ${attrs'.type} ${mode} 0 0";
|
||||
mode' = if mode != null then mode else
|
||||
(if type == "d" then "0755" else "0644");
|
||||
pathname = "${prefix}/${filename}";
|
||||
line = "${pathname} ${type} ${mode'} 0 0";
|
||||
in
|
||||
if attrs'.type == "f" then
|
||||
"${line} echo -n \"${qprint attrs'.file}\" |qprint -d"
|
||||
else if attrs'.type == "d" then
|
||||
(visit "${prefix}/${filename}" attrs.contents) +
|
||||
"\n" + line
|
||||
else if attrs'.type == "c" then
|
||||
with attrs'; "${line} ${major} ${minor}"
|
||||
else if attrs'.type == "b" then
|
||||
with attrs'; "${line} ${major} ${minor}"
|
||||
else if attrs'.type == "s" then
|
||||
"${line} ${attrs'.target}"
|
||||
else if attrs'.type == "l" then
|
||||
"${prefix}/${filename} l ${attrs'.target}"
|
||||
else if attrs'.type == "i" then
|
||||
"${line} ${attrs.subtype}"
|
||||
else
|
||||
line)
|
||||
if type == "f" then
|
||||
"${line} echo -n \"${qprint file}\" |qprint -d"
|
||||
else if type == "d" then
|
||||
(visit pathname contents) + "\n" + line
|
||||
else if type == "c" then "${line} ${major} ${minor}"
|
||||
else if type == "b" then "${line} ${major} ${minor}"
|
||||
else if type == "s" then "${line} ${target}"
|
||||
else if type == "l" then "${pathname} l ${target}"
|
||||
else if type == "i" then "${line} ${subtype}"
|
||||
else line)
|
||||
attrset;
|
||||
in builtins.concatStringsSep "\n" l;
|
||||
in {
|
||||
|
|
Loading…
Reference in a new issue