Move common definitions in separate file

This commit is contained in:
Fabian Mastenbroek 2021-04-18 19:30:23 +02:00
parent 65aa877bb0
commit 7d07970695
No known key found for this signature in database
GPG key ID: 405FC6F81F0A7B85
4 changed files with 69 additions and 45 deletions

View file

@ -28,15 +28,6 @@ HDRPACKAGE=pve-headers-${KVNAME}
ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH) ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
# amd64/x86_64/x86 share the arch subdirectory in the kernel, 'x86' so we need
# a mapping
KERNEL_ARCH=x86
ifneq (${ARCH}, amd64)
KERNEL_ARCH=${ARCH}
endif
GITVERSION:=$(shell git rev-parse HEAD)
BUILD_DIR=build BUILD_DIR=build
KERNEL_SRC=linux KERNEL_SRC=linux
@ -82,27 +73,20 @@ debian.prepared: debian
rm -rf ${BUILD_DIR}/debian rm -rf ${BUILD_DIR}/debian
mkdir -p ${BUILD_DIR} mkdir -p ${BUILD_DIR}
cp -a debian ${BUILD_DIR}/debian cp -a debian ${BUILD_DIR}/debian
echo "git clone git@github.com:fabianishere/pve-kernel-edge.git\\ngit checkout ${GITVERSION}" > ${BUILD_DIR}/debian/SOURCE
@$(foreach dir, ${DIRS},echo "${dir}=${${dir}}" >> ${BUILD_DIR}/debian/rules.d/env.mk;)
echo "KVNAME=${KVNAME}" >> ${BUILD_DIR}/debian/rules.d/env.mk
echo "KERNEL_MAJMIN=${KERNEL_MAJMIN}" >> ${BUILD_DIR}/debian/rules.d/env.mk
cd ${BUILD_DIR}; debian/rules debian/control cd ${BUILD_DIR}; debian/rules debian/control
ifneq (${PVE_BUILD_TYPE},generic) ifneq (${PVE_BUILD_TYPE},generic)
cd ${BUILD_DIR}; debchange -l +${PVE_BUILD_TYPE} -D edge --force-distribution -U -M "Specialization for ${PVE_BUILD_TYPE}" cd ${BUILD_DIR}; debchange -l +${PVE_BUILD_TYPE} -D edge --force-distribution -U -M "Specialization for ${PVE_BUILD_TYPE}"
endif endif
touch $@ touch $@
PVE_PATCHES=$(wildcard patches/pve/*.patch)
${KERNEL_SRC}.prepared: ${KERNEL_SRC_SUBMODULE} ${KERNEL_SRC}.prepared: ${KERNEL_SRC_SUBMODULE}
git -C ${KERNEL_SRC} fetch ../crack.bundle $$(git -C ${KERNEL_SRC} ls-remote ../crack.bundle | cut -f1) git -C ${KERNEL_SRC} fetch ../crack.bundle $$(git -C ${KERNEL_SRC} ls-remote ../crack.bundle | cut -f1)
git -C ${KERNEL_SRC} checkout -f FETCH_HEAD git -C ${KERNEL_SRC} checkout -f FETCH_HEAD
rm -rf ${BUILD_DIR}/${KERNEL_SRC} $@ rm -rf ${BUILD_DIR}/${KERNEL_SRC} $@
mkdir -p ${BUILD_DIR} mkdir -p ${BUILD_DIR}
cp -a ${KERNEL_SRC_SUBMODULE} ${BUILD_DIR}/${KERNEL_SRC} cp -a ${KERNEL_SRC_SUBMODULE} ${BUILD_DIR}/${KERNEL_SRC}
sed -i ${BUILD_DIR}/${KERNEL_SRC}/Makefile -e 's/^EXTRAVERSION.*$$/EXTRAVERSION=${EXTRAVERSION}/'
rm -rf ${BUILD_DIR}/${KERNEL_SRC}/debian rm -rf ${BUILD_DIR}/${KERNEL_SRC}/debian
cp -r zfs ${BUILD_DIR}/zfs cp -r zfs scripts ${BUILD_DIR}/
touch $@ touch $@
${MODULES}.prepared: $(addsuffix .prepared,${MODULE_DIRS}) ${MODULES}.prepared: $(addsuffix .prepared,${MODULE_DIRS})
@ -112,4 +96,4 @@ ${MODULES}.prepared: $(addsuffix .prepared,${MODULE_DIRS})
clean: clean:
rm -rf *~ build *.prepared ${KERNEL_CFG_ORG} rm -rf *~ build *.prepared ${KERNEL_CFG_ORG}
rm -f *.deb *.ddeb *.changes *.buildinfo release.txt artifacts.txt rm -f *.deb *.ddeb *.changes *.buildinfo release.txt artifacts.txt
rm -f debian/control debian/pve-edge-*.postinst debian/pve-edge-*.prerm debian/pve-edge-*.postrm debian/rules.d/env.mk rm -f debian/control debian/pve-edge-*.postinst debian/pve-edge-*.prerm debian/pve-edge-*.postrm

55
debian/rules vendored
View file

@ -1,19 +1,16 @@
#!/usr/bin/make -f #!/usr/bin/make -f
# -*- makefile -*- # -*- makefile -*-
include /usr/share/dpkg/default.mk include /usr/share/dpkg/default.mk
include debian/rules.d/env.mk
include debian/rules.d/${DEB_BUILD_ARCH}.mk # Common variables for all architectures
include debian/rules.d/common.mk
# Pull in some arch specific stuff
include debian/rules.d/arch/${DEB_BUILD_ARCH}.mk
BUILD_DIR ?= ${CURDIR} BUILD_DIR ?= ${CURDIR}
CHANGELOG_DATE:=$(shell dpkg-parsechangelog -SDate) KERNEL_SRC := linux
ZFS_SRC := zfs
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 dh $@ --with quilt
@ -30,7 +27,9 @@ debian/control: $(wildcard debian/*.in)
sed -e 's/@KVNAME@/${KVNAME}/g' -e 's/@KVMAJMIN@/${KERNEL_MAJMIN}/g' < debian/templates/control.in > debian/control sed -e 's/@KVNAME@/${KVNAME}/g' -e 's/@KVMAJMIN@/${KERNEL_MAJMIN}/g' < debian/templates/control.in > debian/control
debian/SOURCE: debian/SOURCE:
echo "git clone git@github.com:fabianishere/pve-kernel-edge.git\\ngit checkout $(shell git rev-parse HEAD)" > $@ echo "git clone git@github.com:fabianishere/pve-edge-kernel.git \
git checkout ${PKG_GIT_VERSION} \
git submodule update --init --depth=1" > $@
override_dh_quilt_patch: override_dh_quilt_patch:
cd linux; \ cd linux; \
@ -76,7 +75,11 @@ ${KERNEL_SRC}/.config:
touch $@ touch $@
.compile_mark: .config_mark .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})" ${MAKE} -C ${KERNEL_SRC} \
CC=${PVE_BUILD_CC} \
KCFLAGS="${PVE_BUILD_CFLAGS}" \
EXTRAVERSION="${EXTRAVERSION}" \
KBUILD_BUILD_VERSION_TIMESTAMP="${KVNAME} ${PVE_BUILD_PROFILE} (${PKG_DATE})"
touch $@ touch $@
.install_mark: .compile_mark .modules_compile_mark .install_mark: .compile_mark .modules_compile_mark
@ -160,20 +163,20 @@ ${KERNEL_SRC}/.config:
mv $(OUT_DIR)/include/arch $(OUT_DIR)/include/$(DEB_HOST_MULTIARCH)/ mv $(OUT_DIR)/include/arch $(OUT_DIR)/include/$(DEB_HOST_MULTIARCH)/
touch $@ touch $@
.modules_compile_mark: ${MODULES}/zfs.ko .modules_compile_mark: modules/zfs.ko
touch $@ touch $@
modules/zfs.ko: .compile_mark modules/zfs.ko: .compile_mark
dh_autoreconf -D zfs dh_autoreconf -D ${ZFS_SRC}
dh_auto_configure -D zfs -- --with-config=kernel --with-linux=$(realpath linux) --with-linux-obj=$(realpath linux) dh_auto_configure -D ${ZFS_SRC} -- --with-config=kernel --with-linux=$(realpath ${KERNEL_SRC}) --with-linux-obj=$(realpath ${KERNEL_SRC})
dh_auto_build -D zfs dh_auto_build -D ${ZFS_SRC}
mkdir -p modules mkdir -p modules
cp zfs/module/avl/zavl.ko modules/ cp ${ZFS_SRC}/module/avl/zavl.ko modules/
cp zfs/module/nvpair/znvpair.ko modules/ cp ${ZFS_SRC}/module/nvpair/znvpair.ko modules/
cp zfs/module/unicode/zunicode.ko modules/ cp ${ZFS_SRC}/module/unicode/zunicode.ko modules/
cp zfs/module/zcommon/zcommon.ko modules/ cp ${ZFS_SRC}/module/zcommon/zcommon.ko modules/
cp zfs/module/icp/icp.ko modules/ cp ${ZFS_SRC}/module/icp/icp.ko modules/
cp zfs/module/zfs/zfs.ko modules/ cp ${ZFS_SRC}/module/zfs/zfs.ko modules/
cp zfs/module/lua/zlua.ko modules/ cp ${ZFS_SRC}/module/lua/zlua.ko modules/
cp zfs/module/spl/spl.ko modules/ cp ${ZFS_SRC}/module/spl/spl.ko modules/
cp zfs/module/zstd/zzstd.ko modules/ cp ${ZFS_SRC}/module/zstd/zzstd.ko modules/

37
debian/rules.d/common.mk vendored Normal file
View file

@ -0,0 +1,37 @@
## Kernel information
KERNEL_MAJMIN=$(shell ./scripts/version.sh -n)
KERNEL_VER=$(shell ./scripts/version.sh -L)
# Increment KERNEL_RELEASE if the ABI changes (abicheck target in debian/rules)
KERNEL_RELEASE=1
## Debian package information
PKG_RELEASE=$(shell ./scripts/version.sh -r)
PKG_DATE:=$(shell dpkg-parsechangelog -SDate)
PKG_GIT_VERSION:=$(shell git rev-parse HEAD)
## Build flavor
# Default to PVE flavor
PKG_BUILD_FLAVOR ?= edge
ifneq (${PKG_BUILD_FLAVOR},edge)
_ := $(info Using custom build flavor: ${PKG_BUILD_FLAVOR})
endif
## Build profile
# Default to generic march optimizations
PKG_BUILD_PROFILE ?= generic
ifneq (${PKG_BUILD_PROFILE},generic)
_ := $(info Using custom build profile: ${PKG_BUILD_PROFILE})
endif
# Build settings
PVE_BUILD_CC ?= ${CC}
### Debian package names
EXTRAVERSION=-${KERNEL_RELEASE}-${PKG_BUILD_FLAVOR}
KVNAME=${KERNEL_VER}${EXTRAVERSION}
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}