blob: 412da379d6bc0a5d7080456abd0e81c6f7de300c (
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
|
#!/bin/bash
mirror_dir='/srv/http/arch-mirror'
find "${mirror_dir}" -type f -printf '%h\n' \
| uniq \
| sort -u \
| while read -r repo_dir; do
paccache -v -r -k 2 -c "${repo_dir}"
if [ -z "${repo_dir##*/os/*}" ]; then
repo="${repo_dir%%/os/*}"
repo="${repo##*/}"
else
repo="${repo_dir##*/}"
fi
curl \
--resolve 'arch-mirror.home.eckner.net:80:127.0.0.1' \
-Ss 'http://arch-mirror.home.eckner.net/'"${repo_dir#${mirror_dir}/}/${repo}"'.db' \
| tar -Oxz \
| sed -n '
/^%\(FILENAME\|CSIZE\|SHA256SUM\)%$/,/^$/p
' \
| grep -v '^%.*%$' \
| grep -vxF '' \
| sed '
N;N
s@\n@ @g
' \
| while read -r file size sum; do
[ -f "${repo_dir}/${file}" ] || continue
if stat -c'%s' "${repo_dir}/${file}" \
| grep -qxF "${size}" \
&& printf '%s %s/%s\n' "${sum}" "${repo_dir}" "${file}" \
| sha256sum -c --quiet; then
continue
fi
rm "${repo_dir}/${file}"
done
done
|