From: Antonio Russo <antonio.e.ru...@gmail.com> Of the zedlet scripts shipped by upstream, a subset are enabled by default, by creating symlinks in /etc/zfs/zed.d. These symlinks are shipped in the zfs-zed package. dpkg, however, does not support conffile handling of symlinks, and therefore any changes (removals) to the symlinks are not preserved on package upgrade.
To address this policy violation, we: 1. During package build, create a list of enabled-by-default zedlets, instead of creating symlinks. 2. On package removal, identify all enabled-by-default zedlets whose symlinks do not exist (i.e., were removed by the user). This is done by creating "whiteout" links to /dev/null in their place). 3. On package installation, create links to enabled-by-default zedlets UNLESS there is already a file there (i.e., abort if there is a whiteout link). 4. We also clean up broken symlinks to removed zedlets at package postinst. (cherry picked and adapted from 5cee380324d74e640d5dd7a360faba3994c8007f [0]) [0] https://salsa.debian.org/zfsonlinux-team/zfs.git Signed-off-by: Stoiko Ivanov <s.iva...@proxmox.com> --- .../0006-dont-symlink-zed-scripts.patch | 12 +++++++++++ debian/patches/series | 1 + debian/zfs-zed.postinst | 20 +++++++++++++++++++ debian/zfs-zed.prerm | 16 +++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 debian/patches/0006-dont-symlink-zed-scripts.patch create mode 100644 debian/zfs-zed.postinst create mode 100644 debian/zfs-zed.prerm diff --git a/debian/patches/0006-dont-symlink-zed-scripts.patch b/debian/patches/0006-dont-symlink-zed-scripts.patch new file mode 100644 index 00000000..de995793 --- /dev/null +++ b/debian/patches/0006-dont-symlink-zed-scripts.patch @@ -0,0 +1,12 @@ +Description: track default symlinks, instead of symlinking +Forwarded: no need +--- a/cmd/zed/zed.d/Makefile.am ++++ b/cmd/zed/zed.d/Makefile.am +@@ -52,6 +52,6 @@ + for f in $(zedconfdefaults); do \ + test -f "$(DESTDIR)$(zedconfdir)/$${f}" -o \ + -L "$(DESTDIR)$(zedconfdir)/$${f}" || \ +- ln -s "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \ ++ echo "$${f}" >> "$(DESTDIR)$(zedexecdir)/DEFAULT-ENABLED" ; \ + done + chmod 0600 "$(DESTDIR)$(zedconfdir)/zed.rc" diff --git a/debian/patches/series b/debian/patches/series index 988c5a3b..8fe3840a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,4 @@ 0003-Fix-the-path-to-the-zed-binary-on-the-systemd-unit.patch 0004-import-with-d-dev-disk-by-id-in-scan-service.patch 0005-Enable-zed-emails.patch +0006-dont-symlink-zed-scripts.patch diff --git a/debian/zfs-zed.postinst b/debian/zfs-zed.postinst new file mode 100644 index 00000000..93325438 --- /dev/null +++ b/debian/zfs-zed.postinst @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +zedd="/usr/lib/zfs-linux/zed.d" +etcd="/etc/zfs/zed.d" + +# enable all default zedlets that are not overridden +while read -r file ; do + etcfile="${etcd}/${file}" + [ -e "${etcfile}" ] && continue + ln -s "${zedd}/${file}" "${etcfile}" +done < "${zedd}/DEFAULT-ENABLED" + +# remove the overrides created in prerm +find "${etcd}" -maxdepth 1 -lname '/dev/null' -delete +# remove any dangling symlinks to old zedlets +find "${etcd}" -maxdepth 1 -lname "${zedd}/*" -xtype l -delete + +#DEBHELPER# + diff --git a/debian/zfs-zed.prerm b/debian/zfs-zed.prerm new file mode 100644 index 00000000..fca0f4a7 --- /dev/null +++ b/debian/zfs-zed.prerm @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +zedd="/usr/lib/zfs-linux/zed.d" +etcd="/etc/zfs/zed.d" + +if [ "$1" != "failed-upgrade" ] && [ -d "${etcd}" ] && [ -d "${zedd}" ] ; then + while read -r file ; do + etcfile="${etcd}/${file}" + [ -e "${etcfile}" ] && continue + ln -s /dev/null "${etcfile}" + done < "${zedd}/DEFAULT-ENABLED" +fi + +#DEBHELPER# + -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel