From f4544b82a6d53a413bd093ec0bb490e21c04801a Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Mon, 11 Aug 2014 18:05:13 +0200 Subject: [PATCH] common/hooks: add support for vcdiff creation --- common/hooks/post-pkg/01-xdelta_repolist.sh | 24 +++++++++++++++++++++ common/hooks/pre-pkg/01-xdelta_repolist.sh | 11 ++++++++++ xbps-src | 3 ++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 common/hooks/post-pkg/01-xdelta_repolist.sh create mode 100644 common/hooks/pre-pkg/01-xdelta_repolist.sh diff --git a/common/hooks/post-pkg/01-xdelta_repolist.sh b/common/hooks/post-pkg/01-xdelta_repolist.sh new file mode 100644 index 0000000000..a18f6ae307 --- /dev/null +++ b/common/hooks/post-pkg/01-xdelta_repolist.sh @@ -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 +} diff --git a/common/hooks/pre-pkg/01-xdelta_repolist.sh b/common/hooks/pre-pkg/01-xdelta_repolist.sh new file mode 100644 index 0000000000..6d6b21d739 --- /dev/null +++ b/common/hooks/pre-pkg/01-xdelta_repolist.sh @@ -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 +} diff --git a/xbps-src b/xbps-src index dc3535ee67..684e19aa14 100755 --- a/xbps-src +++ b/xbps-src @@ -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"