xref: /minix/etc/mtree/mkcompattree.awk (revision 0a6a1f1d)
1BEGIN { split(COMPATDIRS, dirs); n = 1; last_prefix = "" }
2/^#/ { print; }
3{
4	if (NF > 0) {
5		pos = index($0, S);
6		if (pos == 0) {
7			print;
8			next;
9		}
10		prefix = substr($0, 1, pos)
11		if (prefix != last_prefix) {
12			for (d in dirs) {
13				for (f = 1; f < n; f++) {
14					x=files[f]; sub(S, S "/" dirs[d], x);
15					print x;
16				}
17			}
18			delete files;
19			n = 1;
20			last_prefix = prefix;
21		}
22		files[n++] = $0;
23	}
24	next
25}
26END {
27	for (d in dirs) {
28		for (f = 1; f < n; f++) {
29		    x=files[f]; sub(S, S "/" dirs[d], x); print x;
30		}
31	}
32}
33