From: Miroslav Ondra Date: Wed, 13 Oct 2021 09:08:48 +0000 (+0200) Subject: Change from static to debian control files generator X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=278b08a48a454cb61bffa776740dbfcb6908ab29;p=graphit%2Funipi-kernel.git Change from static to debian control files generator --- diff --git a/debian/control b/debian/control index d16ff6d..3557002 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Vcs-Git: https://git.unipi.technology/UniPi/unipi-kernel.git Package: unipi-kernel-modules-dkms Architecture: all -Pre-Depends: raspberrypi-kernel-headers | axon-kernel-headers | linux-headers(>=4.0) | zulu-kernel-headers, unipi-common +Pre-Depends: raspberrypi-kernel-headers | axon-kernel-headers | linux-headers(>=4.0), unipi-common Depends: ${misc:Depends}, dkms, unipi-firmware (>=5.50) Replaces: neuron-kernel, unipi-kernel-modules Conflicts: neuron-kernel, unipi-kernel-modules diff --git a/debian/control-generator.sh b/debian/control-generator.sh new file mode 100755 index 0000000..60043a6 --- /dev/null +++ b/debian/control-generator.sh @@ -0,0 +1,162 @@ +#!/bin/bash + + +. /ci-scripts/include.sh + +arch=`dpkg-architecture -q DEB_BUILD_ARCH` + +# ${PRODUCT} set by gitlab-ci +# ${DEBIAN_VERSION} from bob-the-builder image +# ${arch} from building arch + +PROJECT_VERSION=$(dpkg-parsechangelog -S Version) + +if [ -z "${PRODUCT}" ]; then + ################## dkms #################333 + cat >debian/rules.in <debian/${BINARY_PKG_NAME}.changelog < $(date -R) + +EOF +cat debian/changelog >>debian/${BINARY_PKG_NAME}.changelog + +##################################################################### +### Append binary packages definition to control file + +if [ ${BINARY_PKG_NAME} == "unipi-kernel-modules" ]; then + breaks="neuron-kernel" + provides="" +elif [ ${BINARY_PKG_NAME} == "neuron-kernel" ]; then + breaks="" + provides="unipi-kernel-modules(=${PROJECT_VERSION})" +else + breaks="unipi-kernel-modules, neuron-kernel" + provides="unipi-kernel-modules(=${PROJECT_VERSION})" +fi + +cat >>debian/control <=5.50) +Provides: ${provides} +Replaces: ${breaks} +Breaks: ${breaks} +Description: UniPi kernel modules + Binary kernel modules for UniPi Neuron/Axon/Patron/Iris controller. + Compiled for ${PKG_KERNEL_IMAGE} version ${PKG_KERNEL_VER}. + +EOF + +##################################################################### +### Create rules.in + +cat >debian/rules.in <=5.50) -Replaces: neuron-kernel -Breaks: neuron-kernel -Description: UniPi Neuron/Axon kernel modules - Binary kernel modules for UniPi Neuron/Axon controller. Compiled for axon-kernel-image - version. - diff --git a/debian/control.dkms b/debian/control.dkms deleted file mode 100644 index 0f6b366..0000000 --- a/debian/control.dkms +++ /dev/null @@ -1,12 +0,0 @@ -Package: unipi-kernel-modules-dkms -Architecture: all -Pre-Depends: raspberrypi-kernel-headers | axon-kernel-headers | linux-headers(>=4.0), unipi-common -Depends: ${misc:Depends}, dkms, unipi-firmware (>=5.50) -Replaces: neuron-kernel, unipi-kernel-modules -Conflicts: neuron-kernel, unipi-kernel-modules -Description: UniPi Neuron/Axon kernel modules - DKMS source - This package contains source code of kernel module for spi protocol - used by internal boards in the UniPi Neuron/Axon controllers. - Can be used with DKMS so that local kernel images are automatically - built and installed every time relevant kernel packages are upgraded. - diff --git a/debian/control.g1 b/debian/control.g1 deleted file mode 100644 index c164566..0000000 --- a/debian/control.g1 +++ /dev/null @@ -1,11 +0,0 @@ -Package: g1-unipi-kernel-modules -Architecture: arm64 -Pre-Depends: unipi-common -Depends: ${misc:Depends}, g1-kernel-image(=${PKG-KERNEL-VER}), unipi-firmware (>=5.50) -Provides: unipi-kernel-modules(=${PROJECT-VERSION}) -Replaces: unipi-kernel-modules -Breaks: unipi-kernel-modules -Description: UniPi G1 kernel modules - Binary kernel modules for UniPi G1 gateway. Compiled for g1-kernel-image - version. - diff --git a/debian/control.in b/debian/control.in deleted file mode 100644 index 4899dec..0000000 --- a/debian/control.in +++ /dev/null @@ -1,9 +0,0 @@ -Source: unipi-kernel-modules -Section: kernel -Priority: optional -Maintainer: Miroslav Ondra -Build-Depends: debhelper (>= 9) -Standards-Version: 3.9.8 -Homepage: https://www.unipi.technology/ -Vcs-Git: https://git.unipi.technology/UniPi/unipi-kernel.git - diff --git a/debian/control.neuron b/debian/control.neuron deleted file mode 100644 index 8bcdc3f..0000000 --- a/debian/control.neuron +++ /dev/null @@ -1,8 +0,0 @@ -Package: neuron-kernel -Architecture: armhf -Pre-Depends: unipi-common -Depends: ${misc:Depends}, raspberrypi-kernel(=${PKG-KERNEL-VER}), unipi-firmware (>=5.50) -Description: UniPi Neuron kernel modules - Binary kernel modules for UniPi Neuron controller. Compiled with - raspberrypi-kernel from Raspbian distribution. - diff --git a/debian/control.neuron64 b/debian/control.neuron64 deleted file mode 100644 index a590bc0..0000000 --- a/debian/control.neuron64 +++ /dev/null @@ -1,8 +0,0 @@ -Package: neuron-kernel -Architecture: arm64 -Pre-Depends: unipi-common -Depends: ${misc:Depends}, raspberrypi-kernel(=${PKG-KERNEL-VER}), unipi-firmware (>=5.50) -Description: UniPi Neuron kernel modules - Binary kernel modules for UniPi Neuron controller. Compiled with - raspberrypi-kernel from Raspbian distribution. - diff --git a/debian/control.zulu b/debian/control.zulu deleted file mode 100644 index e86b13f..0000000 --- a/debian/control.zulu +++ /dev/null @@ -1,11 +0,0 @@ -Package: zulu-unipi-kernel-modules -Architecture: arm64 -Pre-Depends: unipi-common -Depends: ${misc:Depends}, zulu-kernel-image(=${PKG-KERNEL-VER}), unipi-firmware (>=5.50) -Provides: unipi-kernel-modules(=${PROJECT-VERSION}) -Replaces: unipi-kernel-modules -Breaks: unipi-kernel-modules -Description: UniPi Zulu kernel modules - Binary kernel modules for UniPi Patron (Zulu based) PLC. Compiled for g1-kernel-image - version. - diff --git a/debian/pkg-common b/debian/pkg-common deleted file mode 100644 index 4613c41..0000000 --- a/debian/pkg-common +++ /dev/null @@ -1 +0,0 @@ -unipi-kernel-modules-dkms diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..c0b1aed --- /dev/null +++ b/debian/rules @@ -0,0 +1,25 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed +export DEB_LDFLAGS_SET = -zrelro + +clean: + dh clean --with dkms + [ -x debian/control-generator.sh ] && debian/control-generator.sh + + +override_dh_installmodules: + DH_AUTOSCRIPTDIR=debian/autoscripts dh_installmodules + +-include debian/rules.in diff --git a/debian/rules.amd64 b/debian/rules.amd64 deleted file mode 100755 index 143916c..0000000 --- a/debian/rules.amd64 +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/make -f -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 - - -# see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -export DEB_LDFLAGS_SET = -zrelro - -MOD_VERSION=$(shell dpkg-parsechangelog |grep ^Version:|cut -d ' ' -f 2) - -clean: - #cat debian/control.in debian/control.dkms >debian/control - dh clean --with dkms - -%: - dh $@ --with dkms - - -override_dh_installmodules: - DH_AUTOSCRIPTDIR=debian/autoscripts dh_installmodules - -override_dh_dkms: - dh_dkms -V $(MOD_VERSION) - make dkms DESTDIR=$(PWD)/debian/unipi-kernel-modules-dkms/usr/src/unipi-$(MOD_VERSION) - -override_dh_auto_build: - @echo "skip build" - -override_dh_auto_install: - @echo skip install - diff --git a/debian/rules.arm64 b/debian/rules.arm64 deleted file mode 100755 index 67d1050..0000000 --- a/debian/rules.arm64 +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/make -f -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 - - -# see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -export DEB_LDFLAGS_SET = -zrelro - -DEBIAN_VERSION=$(shell . /ci-scripts/include.sh; echo $${DEBIAN_VERSION}) -PLATFORM=$(shell echo $${PLATFORM:-axon}) - -CONTROL_INC=$(PLATFORM) - -ifeq ($(PLATFORM),axon) - BINARY_PKG_NAME=unipi-kernel-modules -else - BINARY_PKG_NAME=$(PLATFORM)-unipi-kernel-modules -endif - - -PKG_KERNEL_VER = $(shell dpkg-query -f='$${Version}' -W $(PLATFORM)-kernel-headers) -LINUX_DIR_PATH = $(shell dpkg -L $(PLATFORM)-kernel-headers | sed -n '/^\/lib\/modules\/.*\/build$$/p') -KERNEL_VERSION = $(subst /lib/modules/,,$(subst /build,,$(LINUX_DIR_PATH))) - -PROJECT_VERSION=$(shell dpkg-parsechangelog -S Version) - -clean: - cat debian/control.in debian/control.$(CONTROL_INC) >debian/control - dh clean - -%: - dh $@ - - -override_dh_installmodules: - DH_AUTOSCRIPTDIR=debian/autoscripts dh_installmodules - -override_dh_prep: - @dh_prep --exclude=unipi-kernel-modules.substvars - @echo PKG-KERNEL-VER=${PKG_KERNEL_VER} > debian/unipi-kernel-modules.substvars - @echo PKG-KERNEL-VER=${PKG_KERNEL_VER} > debian/$(PLATFORM)-unipi-kernel-modules.substvars - @echo PROJECT-VERSION=${PROJECT_VERSION} >> debian/unipi-kernel-modules.substvars - @echo PROJECT-VERSION=${PROJECT_VERSION} >> debian/$(PLATFORM)-unipi-kernel-modules.substvars - ( sed 's/)/.${PKG_KERNEL_VER})/;q' debian/changelog; \ - printf "\n * Compiled for $(PLATFORM)-kernel-image\n";\ - printf "\n -- auto-generator %s\n\n" "`date -R`"; \ - cat debian/changelog;\ - ) >debian/unipi-kernel-modules.changelog - @cat debian/unipi-kernel-modules.changelog > debian/$(PLATFORM)-unipi-kernel-modules.changelog - - -override_dh_auto_build: - dh_auto_build -- CCPREFIX=${DEB_TARGET_GNU_TYPE}- LINUX_DIR_PATH=$(LINUX_DIR_PATH) ARCH=${DEB_TARGET_ARCH_CPU} - -override_dh_auto_install: - dh_auto_install --destdir=debian/$(BINARY_PKG_NAME) -- CCPREFIX=${DEB_TARGET_GNU_TYPE}- \ - LINUX_DIR_PATH=$(LINUX_DIR_PATH) ARCH=${DEB_TARGET_ARCH_CPU} diff --git a/debian/rules.armhf b/debian/rules.armhf deleted file mode 100755 index 538ca9c..0000000 --- a/debian/rules.armhf +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/make -f -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 - - -# see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -export DEB_LDFLAGS_SET = -zrelro - -DEBIAN_VERSION=$(shell . /ci-scripts/include.sh; echo $${DEBIAN_VERSION}) -PLATFORM=$(shell echo $${PLATFORM:-neuron}) - -ifeq ($(DEBIAN_VERSION),stretch) - BINARY_PKG_NAME=neuron-kernel - CONTROL_INC=neuron -else - BINARY_PKG_NAME=unipi-kernel-modules - CONTROL_INC=axon -endif - -## Check possible cross compile -## LINUX_DIR_PATH can contain more directories !! -ifeq ($(shell dpkg-architecture -q DEB_BUILD_ARCH),armhf) -RPI_FIRMWARE_VER = $(shell dpkg-query -f='$${Version}' -W raspberrypi-kernel-headers) -# after rpi kernel 1.20210303-1 the version is prefixed with "1:", e.g. 1:1.20210430-2 -# this breaks the combined version since it is no longer a number (1.66.1:1.20210430-2) -# we will strip the first ":" part -# but in dependencies, we need to keep it !!! -RPI_FIRMWARE_VER_STRIPPED = $(shell echo $(RPI_FIRMWARE_VER) | cut -d":" -f 2-) -LINUX_DIR_PATH = $(shell dpkg -L raspberrypi-kernel-headers | sed -n '/^\/lib\/modules\/.*-v7.*\/build$$/p') -KERNEL_VERSION = $(subst /lib/modules/,,$(subst /build,,$(LINUX_DIR_PATH))) -else -.raspbian-versions: - misc/check-raspbian -include ./.raspbian-versions -LINUX_DIR_PATH = ${PWD}/tmp/linux-raspberrypi-kernel_${RPI_FIRMWARE_VER} - -ifneq ($(shell dpkg-architecture -q DEB_BUILD_ARCH),armhf) -override_dh_auto_configure: - misc/check-raspbian - misc/current -endif - -endif - -clean: - cat debian/control.in debian/control.$(CONTROL_INC) >debian/control - dh clean --with dkms - -%: - dh $@ - -override_dh_installmodules: - DH_AUTOSCRIPTDIR=debian/autoscripts dh_installmodules - -override_dh_prep: - @dh_prep --exclude=$(BINARY_PKG_NAME).substvars - @echo PKG-KERNEL-VER=${RPI_FIRMWARE_VER} >> debian/$(BINARY_PKG_NAME).substvars - ( sed 's/)/.$(RPI_FIRMWARE_VER_STRIPPED))/;q' debian/changelog; \ - printf "\n * Compiled for raspberrypi-kernel\n";\ - printf "\n -- auto-generator %s\n\n" "`date -R`"; \ - cat debian/changelog;\ - ) >debian/$(BINARY_PKG_NAME).changelog - - -## LINUX_DIR_PATH can contain more directories !! -override_dh_auto_build: - for LDP in $(LINUX_DIR_PATH); do \ - make clean || exit 1;\ - dh_auto_build -- CCPREFIX=${DEB_TARGET_GNU_TYPE}- LINUX_DIR_PATH=$${LDP} ARCH=${DEB_TARGET_ARCH_CPU} || exit 1;\ - dh_auto_install --destdir=debian/tempdest -- CCPREFIX=${DEB_TARGET_GNU_TYPE}- \ - LINUX_DIR_PATH=$${LDP} ARCH=${DEB_TARGET_ARCH_CPU} || exit 1;\ - done - -override_dh_auto_install: - mkdir -p debian/$(BINARY_PKG_NAME) - mv debian/tempdest/* debian/$(BINARY_PKG_NAME) || exit 1;