summaryrefslogtreecommitdiff
path: root/http/bin/prune_out
blob: f8bbcab2d714323cb9fd4993695e210c5299a8bd (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
#!/bin/sh -e

for out in $(find out -type f)
do
	out_basename="$(basename "$out")"
	out_ext="${out_basename##*\.}"
	rel_path="$(echo "${out}" | cut -c5-)"

	if [ -f "public/${rel_path}" ]; then
		continue
	fi

	base_rel_path="${rel_path%%.${out_ext}}"
	src_path="src/${base_rel_path}.upp${out_ext}"
	if [ -f "$src_path" ]; then
		continue
	fi

	for layout in $(find share/layouts -name "*.layout.upp${out_ext}"); do
		layout="$(basename "$layout")"
		layout="$(echo ${layout} | cut -c1-$(( ${#layout} - 15 )) )"
		rel_path="$(echo "${out}" | cut -c5-)"
		base_rel_path="${rel_path%%.${out_ext}}"
		src_path="src/${base_rel_path}.${layout}.upp${out_ext}"
		if [ -f "$src_path" ]; then
			continue 2
		fi
	done

  echo "No source file found to match ${out}: removing it"
	rm "$out"
done