From patchwork Wed Aug 28 12:26:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 1154389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com 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 ozlabs.org (Postfix) with ESMTPS id 46JQ3c18yfz9sN1; Wed, 28 Aug 2019 22:27:08 +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 1i2x2V-0001PK-6t; Wed, 28 Aug 2019 12:27:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1i2x2P-0001KC-SV for kernel-team@lists.ubuntu.com; Wed, 28 Aug 2019 12:26:57 +0000 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1i2x2P-0000hn-EV for kernel-team@lists.ubuntu.com; Wed, 28 Aug 2019 12:26:57 +0000 Received: by mail-qt1-f200.google.com with SMTP id k47so2253217qtc.16 for ; Wed, 28 Aug 2019 05:26:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=C6HLsOD3yR8luMdYIm7qUai69+yP4/HmDwR9OQe8xoY=; b=LCN0MQMYLNfmJPOZLKXzZ734fDzo8A0EDYVLbmAtpKNOo3ivaljo2Q3D82ghcPm7DC S0eXqMQT4rj66dyv/X+Qf6BaNwmWPuBa7Yzk8G+a48UG3tRHom1NPFgcW8Q5kYG8C3nu 1BOykKCcR+FKYrMWiiaYMQJyLGmF1K72whsbvGBUg/cKO43m66eBisJUu0tquwEeeoCB Cj2jZ/kcj3LTDpRsyZg/rhu1m/GRqStizZWsMeNZwF9pfevIaUFlkHDLp6lMvvdDmHMa 2n4EWQCg2tA0AoZf70oXErISZ8wEoNDPFqoThELElLbeu74i2qglOCZ0cRgR1X5Jv64t e0cQ== X-Gm-Message-State: APjAAAWKkcJaqgnvC0PDMbhsa4nuf5CpaV/hFFB6b0N+hRk0+3Ur7b8G UQ2/rJUW7V8oV/VvROLtv5jxej9NfUCCSAmFgOnBB9jjbLJ9fjelqFfNiyF28ex2jMzjQXqjy8u VkIoaGb7Zp7ULQ8D3Nt1wMOubw48owjbB9ld9oFnPSg== X-Received: by 2002:a05:620a:1532:: with SMTP id n18mr1525497qkk.109.1566995216168; Wed, 28 Aug 2019 05:26:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyE+Qiy238oZ9V38MjFv0MFQqObXshUP58w9MnfEa1IPJ0elI83ezqZUItpNbEHiANzERLyYQ== X-Received: by 2002:a05:620a:1532:: with SMTP id n18mr1525473qkk.109.1566995215878; Wed, 28 Aug 2019 05:26:55 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:4e7:1017:a993:97d5:bc07:a234]) by smtp.gmail.com with ESMTPSA id u28sm1163909qtu.22.2019.08.28.05.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 05:26:55 -0700 (PDT) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [Unstable][PATCH 5/6] UBUNTU: [Debian]: dkms-build: new parameter for debug package directory Date: Wed, 28 Aug 2019 09:26:03 -0300 Message-Id: <20190828122604.6829-6-mfo@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190828122604.6829-1-mfo@canonical.com> References: <20190828122604.6829-1-mfo@canonical.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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1840704 Provide the 'dkms-build' script an argument that specifies the path for installing modules built with debug symbols, and update callers (currently just 'build_dkms' function) and post-processor scripts for consistency (nvidia, vbox). This is similar to the currently used package directory argument 'pkgdir/lib/modules/abi-release/kernel', where modules are installed anyway regardless of debug symbols. The proposal is that the 'dkms-build' script, if provided such argument, should handle the generation and stripping of debug symbols, and installing the non-stripped modules into the debug package directory and the stripped modules into the other package directory (which is used currently). The script double checks whether debug symbols are indeed present in the module file (via the '.debug_info' section) to avoid non-debug modules in the debug package directory, with an additional benefit of backwards compatibility and gracefully handling DKMS packages that do not yet support building debug symbols (or that failed to for some reason). The script should not handle the '.gnu_debuglink' section to reference the non-stripped modules in stripped modules (and re-signinig afterward), as this is now done in rules after the DKMS modules have been built and installed. This currently does nothing as no DKMS modules are built with debug symbols (so this keeps the new argument empty). This will allow for some of the DKMS-built modules to be shipped with debug symbols to aid with debug and support. Signed-off-by: Mauricio Faria de Oliveira --- debian/rules.d/2-binary-arch.mk | 10 +++--- debian/scripts/dkms-build | 34 +++++++++++++++++++-- debian/scripts/dkms-build--nvidia-N | 5 +-- debian/scripts/dkms-build--virtualbox-guest | 5 +-- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk index 9c991b49e868..90396689de2d 100644 --- a/debian/rules.d/2-binary-arch.mk +++ b/debian/rules.d/2-binary-arch.mk @@ -60,7 +60,7 @@ define build_dkms_sign = ) endef define build_dkms = - $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) + CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5) endef define install_control = @@ -390,15 +390,15 @@ endif install -d $(dkms_dir) $(dkms_dir)/headers $(dkms_dir)/build $(dkms_dir)/source cp -rp "$(hdrdir)" "$(indep_hdrdir)" "$(dkms_dir)/headers" - $(if $(filter true,$(enable_zfs)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, zfs, pool/universe/z/zfs-linux/zfs-dkms_$(dkms_zfs_linux_version)_all.deb)) + $(if $(filter true,$(enable_zfs)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, "", zfs, pool/universe/z/zfs-linux/zfs-dkms_$(dkms_zfs_linux_version)_all.deb)) ifeq ($(do_dkms_nvidia),true) - $(call build_dkms, $(bldinfo_pkg_name)-$*, $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/signatures, nvidia-390, pool/restricted/n/nvidia-graphics-drivers-390/nvidia-kernel-source-390_$(dkms_nvidia_390_version)_$(arch).deb pool/restricted/n/nvidia-graphics-drivers-390/nvidia-dkms-390_$(dkms_nvidia_390_version)_$(arch).deb) - $(call build_dkms, $(bldinfo_pkg_name)-$*, $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/signatures, nvidia-430, pool/restricted/n/nvidia-graphics-drivers-430/nvidia-kernel-source-430_$(dkms_nvidia_430_version)_$(arch).deb pool/restricted/n/nvidia-graphics-drivers-430/nvidia-dkms-430_$(dkms_nvidia_430_version)_$(arch).deb) + $(call build_dkms, $(bldinfo_pkg_name)-$*, $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/signatures, "", nvidia-390, pool/restricted/n/nvidia-graphics-drivers-390/nvidia-kernel-source-390_$(dkms_nvidia_390_version)_$(arch).deb pool/restricted/n/nvidia-graphics-drivers-390/nvidia-dkms-390_$(dkms_nvidia_390_version)_$(arch).deb) + $(call build_dkms, $(bldinfo_pkg_name)-$*, $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/signatures, "", nvidia-430, pool/restricted/n/nvidia-graphics-drivers-430/nvidia-kernel-source-430_$(dkms_nvidia_430_version)_$(arch).deb pool/restricted/n/nvidia-graphics-drivers-430/nvidia-dkms-430_$(dkms_nvidia_430_version)_$(arch).deb) endif ifeq ($(do_extras_package),true) - $(if $(filter true,$(do_dkms_vbox)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel, virtualbox-guest, http://archive.ubuntu.com/ubuntu/pool/multiverse/v/virtualbox/virtualbox-guest-dkms_$(dkms_vbox_guest_version)_all.deb)) + $(if $(filter true,$(do_dkms_vbox)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel, "", virtualbox-guest, http://archive.ubuntu.com/ubuntu/pool/multiverse/v/virtualbox/virtualbox-guest-dkms_$(dkms_vbox_guest_version)_all.deb)) endif ifneq ($(skipdbg),true) diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build index 7264852d3133..f77063f7b745 100755 --- a/debian/scripts/dkms-build +++ b/debian/scripts/dkms-build @@ -6,8 +6,9 @@ abi_flavour="$2" sign="$3" pkgname="$4" pkgdir="$5" -package="$6" -shift 6 +dbgpkgdir="$6" +package="$7" +shift 7 srcdir=$(pwd) cd "$dkms_dir" || exit 1 @@ -134,6 +135,34 @@ sed -e "s@$dkms_dir@<>@g" <"$log" # If this build failed then exit here. [ "$rc" != 0 ] && exit "$rc" +# Install the modules with debug symbols we possibly built, +# and strip the original modules for the next install step. +if [ -n "$dbgpkgdir" ]; then + dbgpkgdir="$dbgpkgdir/$package" + echo "II: dkms-build installing $package into $dbgpkgdir (debug symbols)" + install -d "$dbgpkgdir" + find "$dkms_dir/build/$dkms_package/$dkms_version/$abi_version" -name \*.ko | + while read module; do + vmodule=$( basename "$module" ) + + # Check for '.debug_info' section in order to copy module. + # Useful if debug symbols are requested but not built for + # any reason (including not yet supported by DKMS package). + # Strip module just in case even if section isn't present. + if ${CROSS_COMPILE}objdump -h -j '.debug_info' "$module" >/dev/null 2>&1 + then + echo "copying $vmodule" + cp "$module" "$dbgpkgdir" + else + echo "ignoring $vmodule (missing debug symbols)" + fi + + # Just 'strip -g' as '/usr/sbin/dkms' does. + echo "stripping $vmodule" + strip -g "$module" + done +fi + # Install and optionally sign the modules we have built. pkgdir="$pkgdir/$package" echo "II: dkms-build installing $package into $pkgdir" @@ -180,6 +209,7 @@ do "$sign" \ "$pkgname" \ "$pkgdir" \ + "$dbgpkgdir" \ "$package" \ "$@" || exit 1 break diff --git a/debian/scripts/dkms-build--nvidia-N b/debian/scripts/dkms-build--nvidia-N index 72673e0ba7d8..bdec78233b43 100755 --- a/debian/scripts/dkms-build--nvidia-N +++ b/debian/scripts/dkms-build--nvidia-N @@ -10,8 +10,9 @@ abi_flavour="$2" sign="$3" pkgname="$4" pkgdir="$5" -package="$6" -shift 6 +dbgpkgdir="$6" +package="$7" +shift 7 build="$( dirname "$objects" )/build" diff --git a/debian/scripts/dkms-build--virtualbox-guest b/debian/scripts/dkms-build--virtualbox-guest index 29b5a1686bd1..dd981b83e77e 100644 --- a/debian/scripts/dkms-build--virtualbox-guest +++ b/debian/scripts/dkms-build--virtualbox-guest @@ -10,8 +10,9 @@ abi_flavour="$2" sign="$3" pkgname="$4" pkgdir="$5" -package="$6" -shift 6 +dbgpkgdir="$6" +package="$7" +shift 7 # We want to ship the vboxvideo.ko from the upstream staging tree, so # remove the one built via dkms.