Merge pull request #503 from Gottox/xdelta

Generates binary diffs for repository indexes.
This commit is contained in:
Juan RP 2014-08-13 21:57:46 +02:00
commit 8ff17f52f3
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# This hook generates vcdiffs
hook() {
set -x
type -P xdelta3 > /dev/null || return 0;
find $XBPS_REPOSITORY -name '*.genVcdiff' | xargs -r sha256sum | \
while read chk oldfile; do
newfile=${oldfile/.genVcdiff/}
if ! cmp -s "${newfile}" "${oldfile}"; then
newdiff="${newfile}.${chk}.vcdiff"
xdelta3 -f -e -s "${oldfile}" "${newfile}" "${newdiff}"
for diff in ${newfile}.*.vcdiff; do
[ "${diff}" = "${newdiff}" ] && continue;
cp -- "${diff}" "${diff}.tmp"
xdelta3 -f merge -m "${diff}.tmp" "${newdiff}" "${diff}"
rm -- "${diff}.tmp"
done
fi
# generate an empty diff to the new file
newchk=`sha256sum ${newfile} | awk '{ print $1 }'`
xdelta3 -f -e -s "${newfile}" "${newfile}" \
"${newfile}.${newchk}.vcdiff"
rm -- "${oldfile}"
done
}

View File

@ -0,0 +1,11 @@
# this hook marks files which are about to change for generating vcdiffs
hook() {
type -P xdelta3 > /dev/null || return 0;
# create links to preserve old versions of repodata
find $XBPS_REPOSITORY -name '*-repodata' | \
while read; do
ln "${REPLY}" "${REPLY}.genVcdiff"
done
}