#!/bin/bash home="$(dirname "${0}")" target="${home}/repo" lock='/tmp/mirrorsync.lck' tmp="$(mktemp -d)" [[ -f "${lock}" ]] && exit 1 touch "${lock}" trap "rm -rf '${lock}' '${tmp}'" EXIT INT TERM 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