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