From patchwork Thu May 5 21:52:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1627290 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvS9v13rlz9sCq for ; Fri, 6 May 2022 07:53:07 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nmjP9-0004O8-CK; Thu, 05 May 2022 21:52:59 +0000 Received: from mail-pl1-f177.google.com ([209.85.214.177]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nmjP4-0004Ay-5l for kernel-team@lists.ubuntu.com; Thu, 05 May 2022 21:52:54 +0000 Received: by mail-pl1-f177.google.com with SMTP id k1so5621389pll.4 for ; Thu, 05 May 2022 14:52:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CVJGaCect9+NslvNP1zaObybXsDkD7ug08511YPqB+s=; b=LxVtp+UMptdg/ixsEWNBFy2NLRQZM7tUisCPpEFzb9ctl/SuwowJR21TDiQ8T5jNW6 hjihubd9Te89L1OW0tCiXhXeJ6DDaR6kFHWOFRPKNPJxg6XEjYcjk3alaOT7KSOykofw RLd/7xyI1qoDwmqKqKGu5ouiRmh/jdCK4luefKurtJropbi3FFnPm7AqPOkE7721mG+C BuIN47uZS1JSR2d11rJcVQ+mjcIMDqMOyHhcN2IdubziFTmb36Bf3o0byOQSjb/+qe/P ANSVo+RsJdZ43bVIIYjmcNWfMYaFE64ULbu75CAPmH+jJhQdHE4Blc61BI54nOmlsblf Gdcg== X-Gm-Message-State: AOAM5328hUwOUjSLDd8fYAsk2FwxvQQOJu4yGJQgH/EPMlKk3EMgZnp2 W/CwLR3SBx/oCxKYTDQX3uC3Ch+3RMI= X-Google-Smtp-Source: ABdhPJzZz30tHIo6b+7PTRQPGbqbAvYLBxXhVTquNiQiahSER11kL7joLJ0tXaWhChC/EUtqw1zrpw== X-Received: by 2002:a17:90b:30c4:b0:1d8:3395:a158 with SMTP id hi4-20020a17090b30c400b001d83395a158mr397893pjb.184.1651787571658; Thu, 05 May 2022 14:52:51 -0700 (PDT) Received: from yewun.. (114-40-220-49.dynamic-ip.hinet.net. [114.40.220.49]) by smtp.gmail.com with ESMTPSA id v22-20020a636116000000b003c14af505fdsm1835572pgb.21.2022.05.05.14.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 14:52:51 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH v3 1/2][SRU][linux-meta][OEM-5.14] UBUNTU: [Packaging] support standalone dkms module builds Date: Fri, 6 May 2022 05:52:43 +0800 Message-Id: <20220505215247.3466816-3-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220505215247.3466816-1-vicamo.yang@canonical.com> References: <20220505215247.3466816-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.177; envelope-from=vicamo@gmail.com; helo=mail-pl1-f177.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "You-Sheng Yang (vicamo)" BugLink: https://bugs.launchpad.net/bugs/1969434 Signed-off-by: You-Sheng Yang (vicamo) --- debian/control.d/oem | 2 +- debian/control.dkms | 10 +++++++ debian/rules | 69 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 debian/control.dkms diff --git a/debian/control.d/oem b/debian/control.d/oem index 1c4e2de4..7260a6c3 100644 --- a/debian/control.d/oem +++ b/debian/control.d/oem @@ -10,7 +10,7 @@ Description: OEM Linux kernel headers Package: linux-image-oem${variant:suffix} Architecture: amd64 Section: kernel -Provides: ${variant:provides-image} ${dkms:zfs-modules} ${dkms:wireguard-linux-compat-modules} +Provides: ${variant:provides-image} ${dkms:v4l2loopback-modules} ${dkms:zfs-modules} ${dkms:wireguard-linux-compat-modules} Depends: ${misc:Depends}, linux-image-${kernel-abi-version}-oem, linux-firmware, intel-microcode [amd64], amd64-microcode [amd64] Recommends: thermald [amd64] Description: OEM Linux kernel image diff --git a/debian/control.dkms b/debian/control.dkms new file mode 100644 index 00000000..fe409562 --- /dev/null +++ b/debian/control.dkms @@ -0,0 +1,10 @@ + +Package: linux-modules-MODULE-FLAVOUR${variant:suffix} +Architecture: ARCH +Section: kernel +Provides: ${dkms:MODULE-modules} +Depends: + ${misc:Depends}, + linux-modules-MODULE-${kernel-abi-version}-FLAVOUR (= ${binary:Version}), +Description: Extra drivers for MODULE for the FLAVOUR flavour + Install extra signed MODULE modules compatible with the FLAVOUR flavour. diff --git a/debian/rules b/debian/rules index 9b67b955..635182bd 100755 --- a/debian/rules +++ b/debian/rules @@ -7,6 +7,11 @@ # Copyright (c) 2004 Jens Schmalzing # +include /usr/share/dpkg/architecture.mk + +# Used when you need to 'escape' a comma. +comma = , + SERIES=$(shell dpkg-parsechangelog -SDistribution | sed -e 's/-\(security\|updates\|proposed\)$$//') SOURCE=$(shell dpkg-parsechangelog -SSource) KERNEL_SOURCE=$(shell echo "$(SOURCE)" | sed -e 's/-meta//') @@ -26,10 +31,11 @@ endif control_files := debian/control.common # control files only wanted for the primary variant primary_control_files := $(shell LC_ALL=C ls -d debian/control.d/primary debian/control.d/transitionals-* 2>/dev/null) +dkms_control_files := ifneq ($(filter --,$(variants)),) control_files += $(primary_control_files) endif -control_files += $(filter-out $(primary_control_files),$(shell LC_ALL=C ls -d debian/control.d/*)) +control_files += $(filter-out $(primary_control_files) $(wildcard debian/control.d/dkms-*),$(shell LC_ALL=C ls -d debian/control.d/*)) SHELL := sh -e @@ -38,13 +44,57 @@ clean: debian/control dh_testroot dh_clean -# Versions of dkms packages. -dkms_zfs_linux_version=$(shell gawk '/^zfs-linux/ { print $$2; }' debian/dkms-versions) +# DKMS +all_dkms_modules = +$(foreach _line,$(shell gawk '{ OFS = "!"; $$1 = $$1; print }' debian/dkms-versions), \ + $(eval _params = $(subst !, ,$(_line))) \ + $(eval _deb_pkgname = $(firstword $(_params))) \ + $(eval _deb_version = $(word 2,$(_params))) \ + $(if $(filter modulename=%,$(_params)), \ + $(eval _m = $(word 2,$(subst =, ,$(filter modulename=%,$(_params))))) \ + , \ + $(info modulename for $(_deb_pkgname) not specified in dkms-versions. Assume $(_deb_pkgname).) \ + $(eval _m = $(_deb_pkgname)) \ + ) \ + $(eval all_dkms_modules += $(_m)) \ + $(eval dkms_$(_m)_version = $(_deb_version)) \ + $(if $(filter arch=%,$(_params)), \ + $(eval dkms_$(_m)_archs = $(patsubst arch=%,%,$(filter arch=%,$(_params)))) \ + , \ + $(eval dkms_$(_m)_archs = any) \ + ) \ + $(eval dkms_$(_m)_rprovides = $(patsubst rprovides=%,%,$(filter rprovides=%,$(_params)))) \ + $(eval dkms_$(_m)_type = $(word 1,$(patsubst type=%,%,$(filter type=%,$(_params))) built-in)) \ + $(eval all_$(dkms_$(_m)_type)_dkms_modules += $(_m)) \ + $(if $(filter standalone,$(dkms_$(_m)_type)), \ + $(eval dkms_$(_m)_rprovides += $(_m)-prebuilt-kernel) \ + $(eval dkms_control_files += debian/control.d/dkms-$(_m)) \ + ) \ +) dkms_virtualbox_version=$(KERNEL_ABI_VERSION) dkms_wireguard_version=$(shell /sbin/modinfo -F version /lib/modules/$(KERNEL_ABI_VERSION)-oem/kernel/drivers/net/wireguard/wireguard.ko) +debian/control.d/dkms-%: module = $(patsubst debian/control.d/dkms-%,%,$@) +debian/control.d/dkms-%: module_archs = $(dkms_$(patsubst debian/control.d/dkms-%,%,$@)_archs) +debian/control.d/dkms-%: debian/control.dkms + for cf in $(filter-out debian/control.common $(primary_control_files),$(control_files)); do \ + flavour=$$(basename $$cf); \ + flavour_archs=$$(gawk "/^Package: linux-image-$${flavour}\\\$$/ { getline; \$$1=\"\"; print; }" $$cf); \ + available_archs=$${flavour_archs}; \ + if ! test "$(module_archs)" = "any"; then \ + available_archs=$$(echo "$${flavour_archs} $(module_archs)" | tr " " "\n" | sort | uniq -d); \ + test -n "$${available_archs}" || continue; \ + fi; \ + cat debian/control.dkms | sed \ + -e "s/MODULE/$(module)/g" \ + -e "s/ARCH/$${available_archs}/g" \ + -e "s/FLAVOUR/$${flavour}/g"; \ + done >$@.tmp + rm -f $@ + mv $@.tmp $@ + debian/control: tp_key=test:provides\(-full\|-image\|-headers\|-modules-extra\) -debian/control: $(control_files) +debian/control: $(control_files) $(dkms_control_files) for i in $^; do \ if grep -q "{variant:" $$i; then \ variant_first='yes'; \ @@ -75,7 +125,16 @@ debian/control: $(control_files) gencontrol_flags = -Vkernel-version=$(KERNEL_VERSION) gencontrol_flags += -Vkernel-abi-version=$(KERNEL_ABI_VERSION) -gencontrol_flags += -Vdkms:zfs-modules="zfs-modules (= $(dkms_zfs_linux_version))," +gencontrol_flags += \ + $(foreach _m,$(all_dkms_modules), \ + $(if $(filter $(DEB_HOST_ARCH),$(subst any,$(DEB_HOST_ARCH),$(dkms_$(_m)_archs))), \ + $(if $(filter standalone,$(dkms_$(_m)_type)), \ + -Vdkms:$(_m)-modules="$(foreach _p,$(dkms_$(_m)_rprovides),$(_p) (= $(dkms_$(_m)_version))$(comma) )" \ + , \ + -Vdkms:$(_m)-modules="$(foreach _p,$(filter %-modules,$(dkms_$(_m)_rprovides)),$(_p) (= $(dkms_$(_m)_version))$(comma) )" \ + ) \ + ) \ + ) gencontrol_flags += -Vdkms:virtualbox-guest-modules="virtualbox-guest-modules (= $(dkms_virtualbox_version))," gencontrol_flags += -Vdkms:wireguard-linux-compat-modules="wireguard-modules (= $(dkms_wireguard_version)),"