summaryrefslogtreecommitdiff
path: root/distrib/sets/lists/Makefile
blob: 3fc023c2ba936a1e515cba8a439b88c749d84e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# $OpenBSD: Makefile,v 1.4 2008/04/08 21:53:47 todd Exp $

# Various list maintenance functions

#   sort: verify each md/mi file is sorted and contains uniq lines
# mdtomi: move common md file lines to mi, if present
#  dupes: detect (nothing more) duplicate entries in each arch's complete file
#         list
# sanity: sanity check sets for wrong filecounts across archs


all: sort


sort:
	@for f in */m*; do echo "===> sorting $$f"; \
		sed 's/[ ]*$$//' $$f | sort | uniq > $$f.tmp; \
		diff -u $$f $$f.tmp || true; \
		cat $$f.tmp > $$f && rm $$f.tmp; \
	done

basefiles!= cd xbase;echo md.*
archs  = ${basefiles:S/^md.//}

mdtomi:
	@echo "Checking for common md file lines for migration to mi files:"
	@for xdir in x*; do \
	[ "$$xdir" = "xfont" ] && continue; \
	dir=$$(mktemp -d /tmp/mdtomi.XXXXXXXXXX); \
	i1=first; \
	for a in ${archs}; do \
		sort $$xdir/md.$$a >> $$dir/$$a; \
		if [ "X$$i1" = "Xfirst" ]; then \
			i1=$$dir/$$a; \
		else \
			cat $$i1 $$dir/$$a | sort | uniq -d >> $$dir/mi.tmp; \
			echo "===> ($$(echo $$(cat $$dir/mi.tmp|wc -c)))\c"; \
			echo " $$i1 vs $$dir/$$a"; \
			mv $$dir/mi.tmp $$dir/mi; \
			i1=$$dir/mi; \
		fi; \
	done; \
	echo "If any common md files were found, migrating to mi files:"; \
	cat $$dir/mi | while read line; do \
		echo "==> $$line"; \
		for line2 in $$(grep "^$${line}$$" $$xdir/m*); do \
			f=$${line2%:*}; \
			grep -v "^$${line}$$" $$f > $$f.tmp && mv $$f.tmp $$f; \
			echo "===> -$$line2"; \
		done; \
		echo "===> +$$xdir/mi"; \
		echo $$line >> $$xdir/mi; \
	done; rm -rf $$dir; \
	done

dupes:
	@for d in x*; do \
	for arch in ${archs}; do \
		[ -f $$d/md.$$arch ] || continue; \
		echo "===> $$d/$$arch"; \
		cat $$d/md.$$arch $$d/mi | sort | uniq -d; \
	done; \
	done

sanity:
	@for d in x*; do \
		[ "$$d" = "xfont" ] && continue; \
		echo "==> $$d"; \
		(cd $$d; cat md* | sort | uniq -c | sort -n ); \
	done