summaryrefslogtreecommitdiffstats
path: root/checkrepo
blob: ddce82a7a1895dbf24b798b0606b95718e31d1b8 (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
#!/bin/bash

home="$(dirname "${0}")"
target="${home}/repo"
lock='/tmp/mirrorsync.lck'
tmp="$(mktemp -d)"

[[ -f "${lock}" ]] && exit 1
touch "${lock}"

echo '
	BEGIN {
		arg_filename = ARGV[1]
	}

	arg_filename != FILENAME {
		arg_filename = FILENAME
		printf "%s  %s%s\n", md5sum, path, filename
	}

	$0 == "%MD5SUM%" {
		getline md5sum
	}

	$0 == "%FILENAME%" {
		getline filename
	}

	END {
		arg_filename = FILENAME
		printf "%s  %s%s\n", md5sum, path, filename
	}
	' > ${tmp}/dbinfo.awk

echo 'Checking repository...'
for repo in {core,extra,community,testing,community-testing,staging}; do
	for arch in {i686,x86_64}; do
		mkdir -p ${tmp}/${repo}/${arch}
		if [ -r ${target}/${repo}/os/${arch}/${repo}.db ]; then
			bsdtar xf ${target}/${repo}/os/${arch}/${repo}.db -C ${tmp}/${repo}/${arch}
			if [ -z "$(find ${tmp}/${repo}/${arch} -type d -empty)" ]; then
				find ${tmp}/${repo}/${arch} -name desc -print0 \
					| xargs -0 awk -f ${tmp}/dbinfo.awk -vpath=${target}/${repo}/os/${arch}/ \
					>> ${tmp}/md5sums-${arch}.txt
			fi
		fi
	done
done

cat ${tmp}/md5sums-{i686,x86_64}.txt > ${tmp}/md5sums.txt
md5sum -c --quiet ${tmp}/md5sums.txt

rm -rf ${tmp}
rm -f "${lock}"