From e6e31dd5406d59edaaf5a7eeebd2fb83fb86236f Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Wed, 14 Dec 2022 06:33:05 +0500 Subject: [PATCH] Add native-deb* targets to build native Debian packages In continuation of previous #13451, this commits adds native-deb* targets for make to build native debian packages. Github workflows are updated to build and test native Debian packages. Native packages only build with pre-configured paths (see the dh_auto_configure section in contrib/debian/rules.in). While building native packages, paths should not be configured. Initial config flags e.g. '--enable-debug' are replaced in contrib/debian/rules.in. Additional packages on top of existing zfs packages required to build native packages include debhelper-compat, dh-python, dkms, po-debconf, python3-all-dev, python3-sphinx. Reviewed-by: George Melikov Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Umer Saleem Closes #14265 --- .github/workflows/build-dependencies.txt | 6 ++++ .github/workflows/zfs-tests-functional.yml | 11 ++++--- .github/workflows/zfs-tests-sanity.yml | 11 ++++--- config/deb.am | 24 ++++++++++++--- config/zfs-build.m4 | 1 + configure.ac | 2 ++ contrib/debian/.gitignore | 1 + contrib/debian/control | 3 +- contrib/debian/openzfs-libpam-zfs.postinst | 4 ++- contrib/debian/openzfs-zfs-zed.postinst | 7 ----- contrib/debian/openzfs-zfs-zed.prerm | 16 ---------- contrib/debian/openzfs-zfsutils.install | 1 - contrib/debian/openzfs-zfsutils.postinst | 15 --------- contrib/debian/{rules => rules.in} | 4 +-- scripts/debian-packaging.sh | 36 ---------------------- 15 files changed, 50 insertions(+), 92 deletions(-) create mode 100644 contrib/debian/.gitignore delete mode 100644 contrib/debian/openzfs-zfs-zed.prerm rename contrib/debian/{rules => rules.in} (99%) delete mode 100755 scripts/debian-packaging.sh diff --git a/.github/workflows/build-dependencies.txt b/.github/workflows/build-dependencies.txt index 482d82fff1..73921865c4 100644 --- a/.github/workflows/build-dependencies.txt +++ b/.github/workflows/build-dependencies.txt @@ -6,6 +6,9 @@ bc build-essential curl dbench +debhelper-compat +dh-python +dkms fakeroot fio gdb @@ -33,12 +36,15 @@ mdadm nfs-kernel-server pamtester parted +po-debconf python3 +python3-all-dev python3-cffi python3-dev python3-packaging python3-pip python3-setuptools +python3-sphinx rng-tools-debian rsync samba diff --git a/.github/workflows/zfs-tests-functional.yml b/.github/workflows/zfs-tests-functional.yml index 69ca539b7b..b592a9c13e 100644 --- a/.github/workflows/zfs-tests-functional.yml +++ b/.github/workflows/zfs-tests-functional.yml @@ -32,15 +32,18 @@ jobs: ./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan - name: Make run: | - make -j$(nproc) --no-print-directory --silent pkg-utils pkg-kmod + make --no-print-directory --silent native-deb-utils native-deb-kmod + mv ../*.deb . + rm ./openzfs-zfs-dkms*.deb ./openzfs-zfs-dracut*.deb - name: Install run: | - sudo dpkg -i *.deb # Update order of directories to search for modules, otherwise # Ubuntu will load kernel-shipped ones. sudo sed -i.bak 's/updates/extra updates/' /etc/depmod.d/ubuntu.conf - sudo depmod - sudo modprobe zfs + sudo dpkg -i *.deb + # Native Debian packages enable and start the services + # Stop zfs-zed daemon, as it may interfere with some ZTS test cases + sudo systemctl stop zfs-zed # Workaround for cloud-init bug # see https://github.com/openzfs/zfs/issues/12644 FILE=/lib/udev/rules.d/10-cloud-init-hook-hotplug.rules diff --git a/.github/workflows/zfs-tests-sanity.yml b/.github/workflows/zfs-tests-sanity.yml index f3fc607cb4..7ec534f01d 100644 --- a/.github/workflows/zfs-tests-sanity.yml +++ b/.github/workflows/zfs-tests-sanity.yml @@ -28,15 +28,18 @@ jobs: ./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan - name: Make run: | - make -j$(nproc) --no-print-directory --silent pkg-utils pkg-kmod + make --no-print-directory --silent native-deb-utils native-deb-kmod + mv ../*.deb . + rm ./openzfs-zfs-dkms*.deb ./openzfs-zfs-dracut*.deb - name: Install run: | - sudo dpkg -i *.deb # Update order of directories to search for modules, otherwise # Ubuntu will load kernel-shipped ones. sudo sed -i.bak 's/updates/extra updates/' /etc/depmod.d/ubuntu.conf - sudo depmod - sudo modprobe zfs + sudo dpkg -i *.deb + # Native Debian packages enable and start the services + # Stop zfs-zed daemon, as it may interfere with some ZTS test cases + sudo systemctl stop zfs-zed # Workaround for cloud-init bug # see https://github.com/openzfs/zfs/issues/12644 FILE=/lib/udev/rules.d/10-cloud-init-hook-hotplug.rules diff --git a/config/deb.am b/config/deb.am index 0033dd7591..76e54acfa8 100644 --- a/config/deb.am +++ b/config/deb.am @@ -1,14 +1,17 @@ -PHONY += deb-kmod deb-dkms deb-utils deb deb-local +PHONY += deb-kmod deb-dkms deb-utils deb deb-local native-deb-local \ + native-deb-utils native-deb-kmod native-deb -deb-local: +native-deb-local: @(if test "${HAVE_DPKGBUILD}" = "no"; then \ echo -e "\n" \ "*** Required util ${DPKGBUILD} missing. Please install the\n" \ "*** package for your distribution which provides ${DPKGBUILD},\n" \ "*** re-run configure, and try again.\n"; \ exit 1; \ - fi; \ - if test "${HAVE_ALIEN}" = "no"; then \ + fi) + +deb-local: native-deb-local + @(if test "${HAVE_ALIEN}" = "no"; then \ echo -e "\n" \ "*** Required util ${ALIEN} missing. Please install the\n" \ "*** package for your distribution which provides ${ALIEN},\n" \ @@ -85,3 +88,16 @@ deb-utils: deb-local rpm-utils-initramfs $$pkg8 $$pkg9 $$pkg10 $$pkg11; deb: deb-kmod deb-dkms deb-utils + +debian: + cp -r contrib/debian debian; chmod +x debian/rules; + +native-deb-utils: native-deb-local debian + cp contrib/debian/control debian/control; \ + $(DPKGBUILD) -b -rfakeroot -us -uc; + +native-deb-kmod: native-deb-local debian + sh scripts/make_gitrev.sh; \ + fakeroot debian/rules override_dh_binary-modules; + +native-deb: native-deb-utils native-deb-kmod diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index bb3c81a647..2703e6c016 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -464,6 +464,7 @@ AC_DEFUN([ZFS_AC_DPKG], [ AC_SUBST(HAVE_DPKGBUILD) AC_SUBST(DPKGBUILD) AC_SUBST(DPKGBUILD_VERSION) + AC_SUBST([CFGOPTS], ["$CFGOPTS"]) ]) dnl # diff --git a/configure.ac b/configure.ac index 5cb25b32ae..4c75616e42 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_INIT(m4_esyscmd(awk '/^Name:/ {printf $2}' META), m4_esyscmd(awk '/^Version:/ {printf $2}' META)) +CFGOPTS="$*" AC_LANG(C) ZFS_AC_META AC_CONFIG_AUX_DIR([config]) @@ -65,6 +66,7 @@ ZFS_AC_DEBUG_KMEM_TRACKING ZFS_AC_DEBUG_INVARIANTS AC_CONFIG_FILES([ + contrib/debian/rules Makefile include/Makefile lib/libzfs/libzfs.pc diff --git a/contrib/debian/.gitignore b/contrib/debian/.gitignore new file mode 100644 index 0000000000..de7475d888 --- /dev/null +++ b/contrib/debian/.gitignore @@ -0,0 +1 @@ +rules diff --git a/contrib/debian/control b/contrib/debian/control index a0db4985ed..b9bb23b09b 100644 --- a/contrib/debian/control +++ b/contrib/debian/control @@ -2,8 +2,7 @@ Source: openzfs-linux Section: contrib/kernel Priority: optional Maintainer: ZFS on Linux specific mailing list -Build-Depends: abigail-tools, - debhelper-compat (= 12), +Build-Depends: debhelper-compat (= 12), dh-python, dkms (>> 2.1.1.2-5), libaio-dev, diff --git a/contrib/debian/openzfs-libpam-zfs.postinst b/contrib/debian/openzfs-libpam-zfs.postinst index 2db86744e4..03893454ee 100644 --- a/contrib/debian/openzfs-libpam-zfs.postinst +++ b/contrib/debian/openzfs-libpam-zfs.postinst @@ -1,6 +1,8 @@ #!/bin/sh set -e -pam-auth-update --package +if ! $(ldd "/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security/pam_zfs_key.so" | grep -q "libasan") ; then + pam-auth-update --package +fi #DEBHELPER# diff --git a/contrib/debian/openzfs-zfs-zed.postinst b/contrib/debian/openzfs-zfs-zed.postinst index a615eec957..ac14957a3f 100644 --- a/contrib/debian/openzfs-zfs-zed.postinst +++ b/contrib/debian/openzfs-zfs-zed.postinst @@ -4,13 +4,6 @@ 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 -sfT "${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 diff --git a/contrib/debian/openzfs-zfs-zed.prerm b/contrib/debian/openzfs-zfs-zed.prerm deleted file mode 100644 index b8340df534..0000000000 --- a/contrib/debian/openzfs-zfs-zed.prerm +++ /dev/null @@ -1,16 +0,0 @@ -#!/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}" - ( [ -L "${etcfile}" ] || [ -e "${etcfile}" ] ) && continue - ln -sT /dev/null "${etcfile}" - done < "${zedd}/DEFAULT-ENABLED" -fi - -#DEBHELPER# - diff --git a/contrib/debian/openzfs-zfsutils.install b/contrib/debian/openzfs-zfsutils.install index e10a50e012..9c7b05451b 100644 --- a/contrib/debian/openzfs-zfsutils.install +++ b/contrib/debian/openzfs-zfsutils.install @@ -131,5 +131,4 @@ usr/share/man/man8/zstreamdump.8 usr/share/man/man4/spl.4 usr/share/man/man4/zfs.4 usr/share/man/man7/zpool-features.7 -usr/share/man/man7/dracut.zfs.7 usr/share/man/man8/zpool_influxdb.8 diff --git a/contrib/debian/openzfs-zfsutils.postinst b/contrib/debian/openzfs-zfsutils.postinst index b13a78654c..7dc208d0dd 100644 --- a/contrib/debian/openzfs-zfsutils.postinst +++ b/contrib/debian/openzfs-zfsutils.postinst @@ -1,21 +1,6 @@ #!/bin/sh set -e -# The hostname and hostid of the last system to access a ZFS pool are stored in -# the ZFS pool itself. A pool is foreign if, during `zpool import`, the -# current hostname and hostid are different than the stored values thereof. -# -# The only way of having a stable hostid is to define it in /etc/hostid. -# This postinst helper will check if we already have the hostid stabilized by -# checking the existence of the file /etc/hostid to be 4 bytes at least. -# If this file don't already exists on our system or has less than 4 bytes, then -# a new (random) value is generated with zgenhostid (8) and stored in -# /etc/hostid - -if [ ! -f /etc/hostid ] || [ "$(stat -c %s /etc/hostid)" -lt 4 ] ; then - zgenhostid -fi - # When processed to here but zfs kernel module is not loaded, the subsequent # services would fail to start. In this case the installation process just # fails at the postinst stage. The user could do diff --git a/contrib/debian/rules b/contrib/debian/rules.in similarity index 99% rename from contrib/debian/rules rename to contrib/debian/rules.in index 5f4889445b..63892c6ca2 100755 --- a/contrib/debian/rules +++ b/contrib/debian/rules.in @@ -35,7 +35,7 @@ override_dh_autoreconf: override_dh_auto_configure: @# Build the userland, but don't build the kernel modules. - dh_auto_configure -- \ + dh_auto_configure -- @CFGOPTS@ \ --bindir=/usr/bin \ --sbindir=/sbin \ --libdir=/lib/"$(DEB_HOST_MULTIARCH)" \ @@ -195,7 +195,7 @@ override_dh_prep-deb-files: override_dh_configure_modules: override_dh_configure_modules_stamp override_dh_configure_modules_stamp: - ./configure \ + ./configure @CFGOPTS@ \ --with-config=kernel \ --with-linux=$(KSRC) \ --with-linux-obj=$(KOBJ) diff --git a/scripts/debian-packaging.sh b/scripts/debian-packaging.sh deleted file mode 100755 index 9cd042fa44..0000000000 --- a/scripts/debian-packaging.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# -# This script can be used to invoke OpenZFS build from native Debian -# packaging. -# - -print_help () -{ - echo "Usage: $(basename $0) [OPTIONS]" - echo - echo "Options:" - echo " -b, --build Build OpenZFS from Debian Packaging" - echo " -c, --clean Clean the workspace" -} - -if [ "$#" -ne 1 ]; then - print_help - exit 1 -fi - -case $1 in - -b|--build) - cp -r contrib/debian debian - debuild -i -us -uc -b && fakeroot debian/rules override_dh_binary-modules - ;; - -c|--clean) - fakeroot debian/rules override_dh_auto_clean - rm -rf debian - ;; - *) - print_help - ;; -esac - -exit 0