awk -v 'ROOT='$ROOT ' BEGIN{ collect = ispkg = isdep = 0; } /^$/{ next; } /^#/{ next; } collect && /^[^ \t]/{ collect = ispkg = isdep = 0; } collect && $0 ~ /[^ \t]+/{ if(ispkg) { curpkg = $1; pkg[npkg++] = $1; } if(isdep) dep[curpkg " " $1]++; } $0 ~ /^[^ \t]/{ if($1 == "pkg"){ collect = 1; ispkg = 1; } if($1 == "dep"){ collect = 1; isdep = 1; } next; } END{ # TODO: implement the dependencies! for(i = 0; i < npkg; i++) x = x ROOT "/src/pkg/" pkg[i] "\n" printf x }' $* | sed 's/ //'