From 5a08cc71a068545032e2a1c1bb189a73cd8559f6 Mon Sep 17 00:00:00 2001 From: Roland Clobus Date: Wed, 19 Jan 2022 22:30:18 +0100 Subject: [PATCH] Add hook for libxmlb2 (used by appstream) Caused by appstreamcli refresh-cache in package appstream (the apt-conf/50appstream file) Fixed upstream in libxmlb in https://github.com/hughsie/libxmlb/commit/0652ec042cc0611b9b98e080e64e1025db9b4183 --- ...eproducible-libxmlb2-appstream.hook.chroot | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 examples/hooks/reproducible/1005-reproducible-libxmlb2-appstream.hook.chroot diff --git a/examples/hooks/reproducible/1005-reproducible-libxmlb2-appstream.hook.chroot b/examples/hooks/reproducible/1005-reproducible-libxmlb2-appstream.hook.chroot new file mode 100755 index 000000000..9d786de60 --- /dev/null +++ b/examples/hooks/reproducible/1005-reproducible-libxmlb2-appstream.hook.chroot @@ -0,0 +1,53 @@ +#!/bin/sh +set -e + +# libxmlb2 creates random GUIDs +# See https://github.com/hughsie/libxmlb/issues/110 +# Fixed upstream: https://github.com/hughsie/libxmlb/commit/0652ec042cc0611b9b98e080e64e1025db9b4183 +# Not released in Debian yet +# +# Until a sufficiently new version is installed, apply the work-around + +# Don't run if libxmlb2 is not installed +if [ ! -e /usr/share/doc/libxmlb2 ]; +then + exit 0 +fi + +# Don't run if AppStream is not installed +if [ ! -e /usr/bin/appstreamcli ]; +then + exit 0 +fi + +# Don't run if the version of libxmlb2 is sufficiently new +if [ $(dpkg --compare-versions $(dpkg-query --show --showformat '${Version}\n' libxmlb2 | head -1) le 0.3.6-2) ]; +then + exit 0 +fi + +# Refresh the compressed XML files +appstreamcli refresh --force > /dev/null + +# Set the GUID field for each compressed XML file to zero +for f in $(ls /var/cache/app-info/cache/*.xb); +do + dd if=$f of=tmp.xb count=8 iflag=count_bytes status=none + dd if=/dev/zero of=tmp.xb count=16 iflag=count_bytes status=none oflag=append conv=notrunc + dd if=$f of=tmp.xb skip=24 iflag=skip_bytes status=none oflag=append conv=notrunc + rm $f + mv tmp.xb $f +done + +# When apt update is invoked, 50appstream calls 'appstreamcli refresh' +# so add another hook to reset the guid again +# +# Before the chroot is finalised, 'apt update' is invoked again, so the reset guid step needs to be re-applied +cat << EOF > /etc/apt/apt.conf.d/51appstream_reset_guid +# Reset the GUID of the AppStream cache files when APT's cache is updated (i.e. apt update) +APT::Update::Post-Invoke-Success { + "if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then for f in \$(ls /var/cache/app-info/cache/*.xb); do dd if=\$f of=tmp.xb count=8 iflag=count_bytes status=none; dd if=/dev/zero of=tmp.xb count=16 iflag=count_bytes status=none oflag=append conv=notrunc; dd if=\$f of=tmp.xb skip=24 iflag=skip_bytes status=none oflag=append conv=notrunc; rm \$f; mv tmp.xb \$f; done; fi"; +}; +EOF + +echo "P: $(basename $0) Reproducible hook has been applied"