aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/hooks/post-pkg/01-xdelta_repolist.sh29
-rw-r--r--common/hooks/pre-pkg/01-xdelta_repolist.sh11
2 files changed, 40 insertions, 0 deletions
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 00000000000..24c961a470f
--- /dev/null
+++ b/common/hooks/post-pkg/01-xdelta_repolist.sh
@@ -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
+}
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 00000000000..4a3941885e2
--- /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() {
+ 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
+}