#!/usr/bin/make -f # -*- makefile -*- include /usr/share/dpkg/default.mk include debian/rules.d/env.mk include debian/rules.d/${DEB_BUILD_ARCH}.mk BUILD_DIR ?= ${CURDIR} CHANGELOG_DATE:=$(shell dpkg-parsechangelog -SDate) PVE_KERNEL_PKG=pve-kernel-${KVNAME} PVE_HEADER_PKG=pve-headers-${KVNAME} PVE_USR_HEADER_PKG=pve-kernel-libc-dev LINUX_TOOLS_PKG=linux-tools-${KERNEL_MAJMIN} # If no custom compiler is specified, use the default PVE_BUILD_CC ?= ${CC} %: dh $@ --with quilt debian/control: $(wildcard debian/*.in) sed -e 's/@@KVNAME@@/${KVNAME}/g' < debian/templates/pve-kernel.prerm.in > debian/${PVE_KERNEL_PKG}.prerm sed -e 's/@@KVNAME@@/${KVNAME}/g' < debian/templates/pve-kernel.postrm.in > debian/${PVE_KERNEL_PKG}.postrm sed -e 's/@@KVNAME@@/${KVNAME}/g' < debian/templates/pve-kernel.postinst.in > debian/${PVE_KERNEL_PKG}.postinst sed -e 's/@@KVNAME@@/${KVNAME}/g' < debian/templates/pve-headers.postinst.in > debian/${PVE_HEADER_PKG}.postinst chmod +x debian/${PVE_KERNEL_PKG}.prerm chmod +x debian/${PVE_KERNEL_PKG}.postrm chmod +x debian/${PVE_KERNEL_PKG}.postinst chmod +x debian/${PVE_HEADER_PKG}.postinst sed -e 's/@KVNAME@/${KVNAME}/g' -e 's/@KVMAJMIN@/${KERNEL_MAJMIN}/g' < debian/templates/control.in > debian/control debian/SOURCE: echo "git clone git@github.com:fabianishere/pve-kernel-edge.git\\ngit checkout $(shell git rev-parse HEAD)" > $@ override_dh_quilt_patch: cd linux; \ QUILT_PATCHES=../debian/patches \ QUILT_SERIES=series.linux \ quilt --quiltrc /dev/null --color=always push -a || test $$? = 2 cd zfs; \ QUILT_PATCHES=../debian/patches \ QUILT_SERIES=series.zfs \ quilt --quiltrc /dev/null --color=always push -a || test $$? = 2 override_dh_quilt_unpatch: cd linux; \ QUILT_PATCHES=../debian/patches \ QUILT_SERIES=series.linux \ quilt --quiltrc /dev/null pop -a || test $$? = 2 cd zfs; \ QUILT_PATCHES=../debian/patches \ QUILT_SERIES=series.zfs \ quilt --quiltrc /dev/null pop -a || test $$? = 2 rm -rf linux/.pc zfs/.pc override_dh_auto_build: .compile_mark .tools_compile_mark .modules_compile_mark override_dh_auto_install: debian/SOURCE .install_mark .tools_install_mark .headers_install_mark .usr_headers_install_mark dh_installdocs -A debian/copyright debian/SOURCE dh_installchangelogs dh_installman dh_strip_nondeterminism dh_compress dh_fixperms ${KERNEL_SRC}/.config: ${KERNEL_SRC}/scripts/kconfig/merge_config.sh -m \ -O ${KERNEL_SRC} \ ${KERNEL_SRC}/debian.master/config/config.common.ubuntu \ ${KERNEL_SRC}/debian.master/config/${DEB_BUILD_ARCH}/config.common.${DEB_BUILD_ARCH} \ ${KERNEL_SRC}/debian.master/config/${DEB_BUILD_ARCH}/config.flavour.generic \ debian/config/config.pve ${MAKE} -C ${KERNEL_SRC} CC=${PVE_BUILD_CC} oldconfig .config_mark: ${KERNEL_SRC}/.config touch $@ .compile_mark: .config_mark ${MAKE} -C ${KERNEL_SRC} CC=${PVE_BUILD_CC} KCFLAGS="${PVE_BUILD_CFLAGS}" KBUILD_BUILD_VERSION_TIMESTAMP="${KVNAME} ${PVE_BUILD_TYPE} (${CHANGELOG_DATE})" touch $@ .install_mark: .compile_mark .modules_compile_mark rm -rf debian/${PVE_KERNEL_PKG} mkdir -p debian/${PVE_KERNEL_PKG}/lib/modules/${KVNAME} mkdir debian/${PVE_KERNEL_PKG}/boot install -m 644 ${KERNEL_SRC}/.config debian/${PVE_KERNEL_PKG}/boot/config-${KVNAME} install -m 644 ${KERNEL_SRC}/System.map debian/${PVE_KERNEL_PKG}/boot/System.map-${KVNAME} install -m 644 ${KERNEL_SRC}/${KERNEL_IMAGE_PATH} debian/${PVE_KERNEL_PKG}/boot/${KERNEL_INSTALL_FILE}-${KVNAME} ${MAKE} -C ${KERNEL_SRC} INSTALL_MOD_PATH=${BUILD_DIR}/debian/${PVE_KERNEL_PKG}/ modules_install # install zfs drivers install -d -m 0755 debian/${PVE_KERNEL_PKG}/lib/modules/${KVNAME}/zfs install -m 644 $(addprefix modules/,zfs.ko zavl.ko znvpair.ko zunicode.ko zcommon.ko icp.ko zlua.ko spl.ko zzstd.ko) debian/${PVE_KERNEL_PKG}/lib/modules/${KVNAME}/zfs # remove firmware rm -rf debian/${PVE_KERNEL_PKG}/lib/firmware # strip debug info find debian/${PVE_KERNEL_PKG}/lib/modules -name \*.ko -print | while read f ; do strip --strip-debug "$$f"; done # finalize /sbin/depmod -b debian/${PVE_KERNEL_PKG}/ ${KVNAME} # Autogenerate blacklist for watchdog devices (see README) install -m 0755 -d debian/${PVE_KERNEL_PKG}/lib/modprobe.d ls debian/${PVE_KERNEL_PKG}/lib/modules/${KVNAME}/kernel/drivers/watchdog/ > watchdog-blacklist.tmp echo ipmi_watchdog.ko >> watchdog-blacklist.tmp cat watchdog-blacklist.tmp|sed -e 's/^/blacklist /' -e 's/.ko$$//'|sort -u > debian/${PVE_KERNEL_PKG}/lib/modprobe.d/blacklist_${PVE_KERNEL_PKG}.conf rm -f debian/${PVE_KERNEL_PKG}/lib/modules/${KVNAME}/source rm -f debian/${PVE_KERNEL_PKG}/lib/modules/${KVNAME}/build touch $@ .tools_compile_mark: .compile_mark ${MAKE} -C ${KERNEL_SRC}/tools/perf prefix=/usr HAVE_NO_LIBBFD=1 HAVE_CPLUS_DEMANGLE_SUPPORT=1 NO_LIBPYTHON=1 NO_LIBPERL=1 NO_LIBCRYPTO=1 PYTHON=python2.7 echo "checking GPL-2 only perf binary for library linkage with incompatible licenses.." ! ldd ${KERNEL_SRC}/tools/perf/perf | grep -q -E '\blibbfd' ! ldd ${KERNEL_SRC}/tools/perf/perf | grep -q -E '\blibcrypto' ${MAKE} -C ${KERNEL_SRC}/tools/perf man touch $@ .tools_install_mark: .tools_compile_mark rm -rf debian/${LINUX_TOOLS_PKG} mkdir -p debian/${LINUX_TOOLS_PKG}/usr/bin mkdir -p debian/${LINUX_TOOLS_PKG}/usr/share/man/man1 install -m 755 ${BUILD_DIR}/${KERNEL_SRC}/tools/perf/perf debian/${LINUX_TOOLS_PKG}/usr/bin/perf_$(KERNEL_MAJMIN) for i in ${BUILD_DIR}/${KERNEL_SRC}/tools/perf/Documentation/*.1; do \ fname="$${i##*/}"; manname="$${fname%.1}"; \ install -m644 "$$i" "debian/${LINUX_TOOLS_PKG}/usr/share/man/man1/$${manname}_$(KERNEL_MAJMIN).1"; \ done touch $@ .headers_prepare_mark: .config_mark rm -rf debian/${PVE_HEADER_PKG} mkdir -p debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME} install -m 0644 ${KERNEL_SRC}/.config debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME} touch $@ .headers_install_mark: .compile_mark .modules_compile_mark .headers_prepare_mark ( \ cd ${KERNEL_SRC}; \ find . arch/${KERNEL_BUILD_ARCH} -maxdepth 1 -name Makefile\*; \ find include scripts -type f -o -type l; \ find arch/${KERNEL_BUILD_ARCH} -name module.lds -o -name Kbuild.platforms -o -name Platform; \ find $$(find arch/${KERNEL_BUILD_ARCH} -name include -o -name scripts -type d) -type f; \ find arch/${KERNEL_BUILD_ARCH}/include Module.symvers include scripts -type f \ ) | rsync -av --files-from=- ${KERNEL_SRC} debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME} mkdir -p debian/${PVE_HEADER_PKG}/lib/modules/${KVNAME} ln -sf /usr/src/linux-headers-${KVNAME} debian/${PVE_HEADER_PKG}/lib/modules/${KVNAME}/build touch $@ .usr_headers_install_mark: PKG_DIR = debian/${PVE_USR_HEADER_PKG} .usr_headers_install_mark: OUT_DIR = ${PKG_DIR}/usr .usr_headers_install_mark: .config_mark rm -rf '${PKG_DIR}' mkdir -p '${PKG_DIR}' $(MAKE) -C ${KERNEL_SRC} headers_check ARCH=$(KERNEL_HEADER_ARCH) $(MAKE) -C ${KERNEL_SRC} headers_install ARCH=$(KERNEL_HEADER_ARCH) INSTALL_HDR_PATH='$(CURDIR)'/$(OUT_DIR) rm -rf $(OUT_DIR)/include/drm $(OUT_DIR)/include/scsi find $(OUT_DIR)/include \( -name .install -o -name ..install.cmd \) -execdir rm {} + # Move include/asm to arch-specific directory mkdir -p $(OUT_DIR)/include/$(DEB_HOST_MULTIARCH) mv $(OUT_DIR)/include/asm $(OUT_DIR)/include/$(DEB_HOST_MULTIARCH)/ test ! -d $(OUT_DIR)/include/arch || \ mv $(OUT_DIR)/include/arch $(OUT_DIR)/include/$(DEB_HOST_MULTIARCH)/ touch $@ .modules_compile_mark: ${MODULES}/zfs.ko touch $@ modules/zfs.ko: .compile_mark dh_autoreconf -D zfs dh_auto_configure -D zfs -- --with-config=kernel --with-linux=$(realpath linux) --with-linux-obj=$(realpath linux) dh_auto_build -D zfs mkdir -p modules cp zfs/module/avl/zavl.ko modules/ cp zfs/module/nvpair/znvpair.ko modules/ cp zfs/module/unicode/zunicode.ko modules/ cp zfs/module/zcommon/zcommon.ko modules/ cp zfs/module/icp/icp.ko modules/ cp zfs/module/zfs/zfs.ko modules/ cp zfs/module/lua/zlua.ko modules/ cp zfs/module/spl/spl.ko modules/ cp zfs/module/zstd/zzstd.ko modules/