2014-08-14 08:56:48 +02:00
|
|
|
# This hook generates vcdiffs for repository data.
|
2014-08-11 18:05:13 +02:00
|
|
|
|
|
|
|
hook() {
|
2014-08-14 12:28:27 +02:00
|
|
|
[ -z "$XBPS_REPO_DELTAS" ] && return 0
|
2014-08-13 21:59:20 +02:00
|
|
|
type -P xdelta3 > /dev/null || return 0
|
2014-08-11 18:05:13 +02:00
|
|
|
|
2014-08-13 22:30:51 +02:00
|
|
|
find $XBPS_REPOSITORY -name "${XBPS_TARGET_MACHINE}-repodata.genVcdiff" | xargs -r sha256sum | \
|
2014-08-11 18:05:13 +02:00
|
|
|
while read chk oldfile; do
|
|
|
|
newfile=${oldfile/.genVcdiff/}
|
|
|
|
|
|
|
|
if ! cmp -s "${newfile}" "${oldfile}"; then
|
|
|
|
newdiff="${newfile}.${chk}.vcdiff"
|
2014-08-14 08:56:48 +02:00
|
|
|
xdelta3 -q -f -e -s "${oldfile}" "${newfile}" "${newdiff}"
|
2014-08-11 18:05:13 +02:00
|
|
|
for diff in ${newfile}.*.vcdiff; do
|
|
|
|
[ "${diff}" = "${newdiff}" ] && continue;
|
|
|
|
cp -- "${diff}" "${diff}.tmp"
|
2014-08-14 08:56:48 +02:00
|
|
|
xdelta3 -q -f merge -m "${diff}.tmp" "${newdiff}" "${diff}"
|
2014-08-11 18:05:13 +02:00
|
|
|
rm -- "${diff}.tmp"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2014-08-11 19:55:14 +02:00
|
|
|
# generate an empty diff to the new file
|
|
|
|
newchk=`sha256sum ${newfile} | awk '{ print $1 }'`
|
2014-08-14 08:56:48 +02:00
|
|
|
xdelta3 -q -f -e -s "${newfile}" "${newfile}" "${newfile}.${newchk}.vcdiff"
|
2014-08-11 18:05:13 +02:00
|
|
|
rm -- "${oldfile}"
|
|
|
|
done
|
|
|
|
}
|