2018-01-24 10:54:19 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
# -*- makefile -*-
|
|
|
|
|
2018-02-28 08:31:06 +00:00
|
|
|
# TODO: check for headers not being installed
|
2018-03-09 10:25:58 +00:00
|
|
|
BUILD_DIR=$(shell pwd)
|
2018-01-24 10:54:19 +00:00
|
|
|
|
2018-02-28 08:31:06 +00:00
|
|
|
include /usr/share/dpkg/default.mk
|
2018-03-09 10:25:58 +00:00
|
|
|
include debian/rules.d/env.mk
|
2018-02-28 08:31:06 +00:00
|
|
|
include debian/rules.d/${DEB_BUILD_ARCH}.mk
|
|
|
|
|
|
|
|
CHANGELOG_DATE:=$(shell dpkg-parsechangelog -SDate)
|
|
|
|
|
2021-04-18 09:30:19 +00:00
|
|
|
PVE_KERNEL_PKG=pve-kernel-${KVNAME}
|
|
|
|
PVE_HEADER_PKG=pve-headers-${KVNAME}
|
2020-05-27 15:12:08 +00:00
|
|
|
PVE_USR_HEADER_PKG=pve-kernel-libc-dev
|
2018-05-28 09:04:46 +00:00
|
|
|
LINUX_TOOLS_PKG=linux-tools-${KERNEL_MAJMIN}
|
2018-05-09 10:15:20 +00:00
|
|
|
KERNEL_SRC_COPY=${KERNEL_SRC}_tmp
|
2018-02-28 08:31:06 +00:00
|
|
|
|
2020-04-28 13:13:50 +00:00
|
|
|
# If no custom compiler is specified, use the default
|
|
|
|
PVE_BUILD_CC ?= ${CC}
|
|
|
|
|
2021-03-28 19:34:25 +00:00
|
|
|
%:
|
2021-03-28 19:51:08 +00:00
|
|
|
dh $@ --with quilt
|
2021-03-28 19:34:25 +00:00
|
|
|
|
2018-02-28 08:31:06 +00:00
|
|
|
debian/control: $(wildcard debian/*.in)
|
2021-03-28 19:07:30 +00:00
|
|
|
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
|
2018-02-28 08:31:06 +00:00
|
|
|
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
|
2021-03-28 19:07:30 +00:00
|
|
|
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)" > $@
|
2018-02-28 08:31:06 +00:00
|
|
|
|
2021-03-28 19:51:08 +00:00
|
|
|
override_dh_quilt_patch:
|
|
|
|
cd linux; \
|
|
|
|
QUILT_PATCHES=../debian/patches \
|
|
|
|
QUILT_SERIES=series.linux \
|
|
|
|
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
|
|
|
|
rm -rf linux/.pc
|
|
|
|
|
2021-03-28 19:34:25 +00:00
|
|
|
override_dh_auto_build: .compile_mark .tools_compile_mark .modules_compile_mark
|
2018-02-28 08:31:06 +00:00
|
|
|
|
2021-03-28 19:34:25 +00:00
|
|
|
override_dh_auto_install: debian/SOURCE .install_mark .tools_install_mark .headers_install_mark .usr_headers_install_mark
|
2018-02-28 08:31:06 +00:00
|
|
|
dh_installdocs -A debian/copyright debian/SOURCE
|
|
|
|
dh_installchangelogs
|
|
|
|
dh_installman
|
|
|
|
dh_strip_nondeterminism
|
|
|
|
dh_compress
|
|
|
|
dh_fixperms
|
|
|
|
|
2021-03-28 13:01:15 +00:00
|
|
|
${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
|
2020-04-28 13:13:50 +00:00
|
|
|
${MAKE} -C ${KERNEL_SRC} CC=${PVE_BUILD_CC} oldconfig
|
2021-03-28 13:01:15 +00:00
|
|
|
|
|
|
|
.config_mark: ${KERNEL_SRC}/.config
|
2018-05-09 10:15:20 +00:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
.compile_mark: .config_mark
|
2020-08-08 12:17:53 +00:00
|
|
|
${MAKE} -C ${KERNEL_SRC} CC=${PVE_BUILD_CC} KCFLAGS="${PVE_BUILD_CFLAGS}" KBUILD_BUILD_VERSION_TIMESTAMP="${KVNAME} ${PVE_BUILD_TYPE} (${CHANGELOG_DATE})"
|
2018-02-28 08:31:06 +00:00
|
|
|
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
|
2020-12-02 19:18:00 +00:00
|
|
|
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
|
2018-02-28 08:31:06 +00:00
|
|
|
# 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
|
2018-04-25 10:17:19 +00:00
|
|
|
${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'
|
2018-02-28 08:31:06 +00:00
|
|
|
${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
|
2018-04-24 11:57:29 +00:00
|
|
|
mkdir -p debian/${LINUX_TOOLS_PKG}/usr/share/man/man1
|
2018-05-28 09:04:46 +00:00
|
|
|
install -m 755 ${BUILD_DIR}/${KERNEL_SRC}/tools/perf/perf debian/${LINUX_TOOLS_PKG}/usr/bin/perf_$(KERNEL_MAJMIN)
|
2018-05-28 09:04:48 +00:00
|
|
|
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
|
2018-02-28 08:31:06 +00:00
|
|
|
touch $@
|
|
|
|
|
2018-05-09 10:15:20 +00:00
|
|
|
.headers_prepare_mark: .config_mark
|
2018-02-28 08:31:06 +00:00
|
|
|
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}
|
2018-05-09 10:15:20 +00:00
|
|
|
# copy to allow building in parallel to kernel/module compilation without interference
|
|
|
|
rm -rf ${KERNEL_SRC_COPY}
|
2020-11-12 18:23:40 +00:00
|
|
|
-cp -ar ${KERNEL_SRC} ${KERNEL_SRC_COPY}
|
2018-05-09 10:15:20 +00:00
|
|
|
make -C ${KERNEL_SRC_COPY} mrproper
|
|
|
|
cd ${KERNEL_SRC_COPY}; find . -path './debian/*' -prune \
|
2018-04-24 11:57:27 +00:00
|
|
|
-o -path './include/*' -prune \
|
|
|
|
-o -path './Documentation' -prune \
|
|
|
|
-o -path './scripts' -prune \
|
|
|
|
-o -type f \
|
|
|
|
\( \
|
|
|
|
-name 'Makefile*' \
|
|
|
|
-o -name 'Kconfig*' \
|
|
|
|
-o -name 'Kbuild*' \
|
|
|
|
-o -name '*.sh' \
|
|
|
|
-o -name '*.pl' \
|
|
|
|
\) \
|
|
|
|
-print | cpio -pd --preserve-modification-time ${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}
|
2018-05-09 10:15:20 +00:00
|
|
|
cd ${KERNEL_SRC_COPY}; cp -a include scripts ${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}
|
|
|
|
cd ${KERNEL_SRC_COPY}; \
|
2018-04-24 11:57:27 +00:00
|
|
|
( \
|
|
|
|
find arch/${KERNEL_HEADER_ARCH} -name include -type d -print | \
|
|
|
|
xargs -n1 -i: find : -type f \
|
|
|
|
) | \
|
|
|
|
cpio -pd --preserve-modification-time ${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}
|
2021-02-17 14:46:34 +00:00
|
|
|
# Workaround for #48
|
|
|
|
mv ${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/scripts/module.lds.S \
|
|
|
|
${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/scripts/module.lds
|
|
|
|
sed -i '$$ d' ${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/scripts/module.lds
|
2018-05-09 10:15:20 +00:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
.headers_compile_mark: .headers_prepare_mark
|
|
|
|
# set output to subdir of source to reduce number of hardcoded paths in output files
|
|
|
|
rm -rf ${BUILD_DIR}/${KERNEL_SRC_COPY}/${PVE_HEADER_PKG}
|
|
|
|
mkdir -p ${BUILD_DIR}/${KERNEL_SRC_COPY}/${PVE_HEADER_PKG}
|
|
|
|
cp ${KERNEL_SRC}/.config ${BUILD_DIR}/${KERNEL_SRC_COPY}/${PVE_HEADER_PKG}/.config
|
2019-03-12 08:54:42 +00:00
|
|
|
${MAKE} -C ${KERNEL_SRC_COPY} O=${BUILD_DIR}/${KERNEL_SRC_COPY}/${PVE_HEADER_PKG} -j1 syncconfig prepare scripts
|
2018-05-09 10:15:20 +00:00
|
|
|
find ${BUILD_DIR}/${KERNEL_SRC_COPY}/${PVE_HEADER_PKG} -name \*.o.ur-\* | xargs rm -f
|
|
|
|
rsync --ignore-existing -r -v -a $(addprefix ${BUILD_DIR}/${KERNEL_SRC_COPY}/${PVE_HEADER_PKG}/,arch include kernel scripts tools) ${BUILD_DIR}/debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/
|
|
|
|
rm -rf ${BUILD_DIR}/${KERNEL_SRC_COPY}
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
.headers_install_mark: .compile_mark .modules_compile_mark .headers_compile_mark
|
|
|
|
cp ${KERNEL_SRC}/include/generated/compile.h debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/include/generated/compile.h
|
|
|
|
install -m 0644 ${KERNEL_SRC}/Module.symvers debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}
|
2018-02-28 08:31:06 +00:00
|
|
|
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 $@
|
|
|
|
|
2020-05-27 15:12:08 +00:00
|
|
|
.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 $@
|
|
|
|
|
2019-05-24 12:40:35 +00:00
|
|
|
.modules_compile_mark: ${MODULES}/zfs.ko
|
2018-02-28 08:31:06 +00:00
|
|
|
touch $@
|
|
|
|
|
2019-05-24 12:40:35 +00:00
|
|
|
${MODULES}/zfs.ko: .compile_mark
|
2018-02-28 08:31:06 +00:00
|
|
|
cd ${MODULES}/${ZFSDIR}; ./autogen.sh
|
2019-05-24 12:40:35 +00:00
|
|
|
cd ${MODULES}/${ZFSDIR}; ./configure --with-config=kernel --with-linux=${BUILD_DIR}/${KERNEL_SRC} --with-linux-obj=${BUILD_DIR}/${KERNEL_SRC}
|
2018-02-28 08:31:06 +00:00
|
|
|
${MAKE} -C ${MODULES}/${ZFSDIR}
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/avl/zavl.ko ${MODULES}/
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/nvpair/znvpair.ko ${MODULES}/
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/unicode/zunicode.ko ${MODULES}/
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/zcommon/zcommon.ko ${MODULES}/
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/icp/icp.ko ${MODULES}/
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/zfs/zfs.ko ${MODULES}/
|
2019-05-24 12:40:35 +00:00
|
|
|
cp ${MODULES}/${ZFSDIR}/module/lua/zlua.ko ${MODULES}/
|
|
|
|
cp ${MODULES}/${ZFSDIR}/module/spl/spl.ko ${MODULES}/
|
2020-12-02 19:18:00 +00:00
|
|
|
cp ${MODULES}/${ZFSDIR}/module/zstd/zzstd.ko ${MODULES}/
|