common/hooks: add support for vcdiff creation

This commit is contained in:
Enno Boland 2014-08-11 18:05:13 +02:00
parent 19332495b8
commit f4544b82a6
3 changed files with 37 additions and 1 deletions

View file

@ -0,0 +1,24 @@
# This hook generates vcdiffs
hook() {
set -x
[ -z "$XBPS_GENERATE_VCDIFF" ] && 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 -D -R -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
rm -- "${oldfile}"
done
}

View file

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

View file

@ -469,7 +469,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \
XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_PKG_OPTIONS \
XBPS_CONFIG_FILE XBPS_KEEP_ALL XBPS_HOSTDIR XBPS_MASTERDIR \
XBPS_SRC_VERSION XBPS_DESTDIR FAKEROOT_CMD CHROOT_CMD XBPS_MACHINE
XBPS_SRC_VERSION XBPS_DESTDIR FAKEROOT_CMD CHROOT_CMD XBPS_MACHINE \
XBPS_GENERATE_VCDIFF
for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
eval val="\$XBPS_$i"