Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp199202lqk; Sat, 9 Mar 2024 06:25:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXlqG1019DDatvOgACu5KNQR5d1/dlYhySrTQfNTsXnV9zv9w0ZbfyhwCIqANR6sigOhgLdNV+HQ+vSovhNY/C18NCm1A426OZY2w6jVQ== X-Google-Smtp-Source: AGHT+IHfoLKiL00z15A/gjGkoatJYEBf3+gXsQcarAfVKkU3E73nakoOVZuzdziQvBbZXREFpv9E X-Received: by 2002:a17:906:a1c9:b0:a45:f9c5:3024 with SMTP id bx9-20020a170906a1c900b00a45f9c53024mr1556591ejb.11.1709994317375; Sat, 09 Mar 2024 06:25:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709994317; cv=pass; d=google.com; s=arc-20160816; b=DkxYFqdxWo1Wi3FSlwhXZPKH7FCI1Fd5KTT0WuYlBQkcZGYwCN7wvhSztpFG05Fro5 AxRrlICIoXIWMiKv7sj1LOJeARTERVf7ClxGyurRa2jQ0JyS4U2VF9/kFls8KRD9Ft1e +EY2Y0bEDlwVPVF0yCIjwSTyB+4mIO1Uf4AnO+H4B+ZYbf5nJGwcWFk6D/1b/i1pwsZ9 BPRFNyE5QlYHBk9eIcDS5l1d6VY9EZZ9/aJ4DTYeOBxbaevFVwt8M5HbLROAD3bL5GZV QBwOhgswijPc3RxFSYGPLzZMGY4wDz2tDvK5bXv65kI5sfORp0sCvsfsLgyU8MDblPNg +DOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=sWu0zWM6Gt/3s5HXHnMeXlm4BpOxKwkdc6L5ArLy3gE=; fh=0NUXDwn6uVY53jREbV1kJiYxa9v5DuF60oWjK96VCrQ=; b=i4nNNT3YlJZ7vD+OUDffqMQmwVLpswnUBcP4CGwIH4w5le5gmkdVa0iuB0YffFAZdq mnn0txcRaH5C2pHS4x2eHfqJlzbfyxtg8Um4GkIuiS6csQjR7wIF0d7MDmdfUrnbY+Oi EE9n5jYgijVnbzZ2z0ystGCoS2zhWvAzalxiva8JhstymnDffqPEJ5m4dAuq0GrUU2Eg BZVvnYm2wvkDPogtwzJWi0pUmtVkYc/7Pum3IIIsHAw36BTH3tSXZ67kSsMnY/CN0Hgg zJwNYRuyZ+eOm3Wli4VbLLPMoTFgD8QDrJu50vAeNZFjytESisRUkr/TcgLlRmj7ICjC 8b9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/8AKRg3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-97917-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97917-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id um7-20020a170906cf8700b00a4415d8f3b5si779176ejb.492.2024.03.09.06.25.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 06:25:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97917-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/8AKRg3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-97917-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97917-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D8BD81F2170F for ; Sat, 9 Mar 2024 14:25:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64EF140877; Sat, 9 Mar 2024 14:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X/8AKRg3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D92C3C08E; Sat, 9 Mar 2024 14:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709994307; cv=none; b=bVbyh16fn+bgtk5R/PeDCQgwpqLfNhNTRW6CMPp9S43lQVyqX0qEEejoau4N7i6jtOaJMQEgOJNTg85aFHJlNJYkLp2m8FTLz9Q9VrYM5y2wp+UFIhOEEGQubJILVG2596/3uteIif4WH2N3qJnp9Uaqqn/wu0N6kC/00s/ujKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709994307; c=relaxed/simple; bh=aNVgWD8ilbHhgD7lp+ZEhfwJD+ID/RdcVUU+nXM53v8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SCsbsK62NCZFqmMN066wM765T5WmoghCGWyGh5QvLvgFsqIoyIgi6gtU2nNkd0t9n8yP9tSyjJ2vhl77AnZgOY1aig29VT6SYt0490JloL91p9xVsLfuFA+k0vF9zD1j0fVQsJ7Ls1CFePdXazIV+wt/bbI9+nb2H9A9r/WeLGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X/8AKRg3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 134A1C433F1; Sat, 9 Mar 2024 14:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709994307; bh=aNVgWD8ilbHhgD7lp+ZEhfwJD+ID/RdcVUU+nXM53v8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=X/8AKRg3FJlZyozYdI+Qp4tehKkeBDHvC7nEbT7tt+dNqUCNGJGnrbg5QnK8Wzmzd 8Q/aCvZozAAwButDuLgnqk54qhrFkPlGv74d85EO2SY2YXWNxRSTF8D3URqvJoEZVb X7lRYqTfW3Fh2+WAq/4kqhuYF/Wk+D/z2XN3AopI/RBJSb8x7yXfoDFySzDkB5k3YO j5mihan9DZq8EkTrrXrIjvkWnWsTPwxpm21BLEEE9fhRaJRnLzulx6D2QcS9ueHGCS QBx87ntrjgJeaONHr6IRnLEcqLGiVJM2sqbcajer792a0TIiiYo/4kpVyYz7uPhVJL LaVMWLGmH4Mxw== Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5135ab96dcbso3253491e87.1; Sat, 09 Mar 2024 06:25:06 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU6ZtpoEqiEbCl5cIaV4Gq6AOs6h7o6ZJThUZUTX4F/VqdkG+t3idaMsHBmDPp/yY9cPdYYKCZRZYOX7PJBIXTo3zBXeq1uIq79kb7ZKW0V72MDXSM3vw27GWdwK3MFB/jl4F5UdwQGm8JP X-Gm-Message-State: AOJu0YxoyeiT7pJa40qtbuK+57C96k0ZQ5YTDHKhtMC3BntMxTRbgHB/ wJNmyzmxYnbY0y4FuqMBRwKt/UwLJo8dDCX2vnrihpHRRVJoI5HZSVqkkkZWBWEP1TpE3ThtVoa 34GYGNoIZk8y7puGa1sCW6t+BjBs= X-Received: by 2002:ac2:4d8e:0:b0:513:3b3e:c361 with SMTP id g14-20020ac24d8e000000b005133b3ec361mr1136256lfe.2.1709994305575; Sat, 09 Mar 2024 06:25:05 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240305110915.184868-1-jtornosm@redhat.com> In-Reply-To: <20240305110915.184868-1-jtornosm@redhat.com> From: Masahiro Yamada Date: Sat, 9 Mar 2024 23:24:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: rpm-pkg: add dtb files in kernel rpm To: Jose Ignacio Tornos Martinez Cc: nathan@kernel.org, nicolas@fjasle.eu, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 5, 2024 at 8:09=E2=80=AFPM Jose Ignacio Tornos Martinez wrote: > > Some architectures, like aarch64 ones, need a dtb file to configure the > hardware. The default dtb file can be preloaded from u-boot, but the fina= l > and/or more complete dtb file needs to be able to be loaded later from > rootfs. > > Add the possible dtb files to the kernel rpm and mimic Fedora shipping > process, storing the dtb files in the module directory. These dtb files > will be copied to /boot directory by the install scripts, but add fallbac= k > just in case, checking if the content in /boot directory is correct. > > Mark the files installed to /boot as %ghost to make sure they will be > removed when the package is uninstalled. > > Tested with Fedora Rawhide (x86_64 and aarch64) with dnf and rpm tools. > In addition, fallback was also tested after modifying the install scripts= . > > Signed-off-by: Jose Ignacio Tornos Martinez > --- > scripts/package/kernel.spec | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec > index c256b73cca3e..5c4c1ffcba6c 100644 > --- a/scripts/package/kernel.spec > +++ b/scripts/package/kernel.spec > @@ -61,6 +61,9 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/l= ib/modules/%{KERNELRELEAS > %{make} %{makeflags} INSTALL_HDR_PATH=3D%{buildroot}/usr headers_install > cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE} > cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config > +if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ];then ${srctree} and ${SRCARCH} are not always defined in kernel.spec. They are not defined if you directly run 'rpmbuild -rb '. The following will correctly check the presence of ${srctree}/arch/${SRCARCH}/boot/dts. if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND=3D'test -d ${srctree}/arch/${SRCARCH}/boot/dts'; then > + %{make} %{makeflags} INSTALL_DTBS_PATH=3D%{buildroot}/lib/modules= /%{KERNELRELEASE}/dtb dtbs_install > +fi > ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KER= NELRELEASE}/build > %if %{with_devel} > %{make} %{makeflags} run-command KBUILD_RUN_COMMAND=3D'${srctree}/script= s/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE= }' > @@ -81,6 +84,14 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}= /lib/modules/%{KERNELRELEA > echo "%ghost /boot/${x}-%{KERNELRELEASE}" > done > > + if [ -d "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" ];then > + echo "/lib/modules/%{KERNELRELEASE}/dtb" > + for x in $(find "%{buildroot}/lib/modules/%{KERNELRELEASE= }/dtb" -name "*" \ > + -exec realpath --relative-to "%{buildroot= }/lib/modules/%{KERNELRELEASE}/dtb" {} \;); do > + echo "%ghost /boot/dtb-%{KERNELRELEASE}/${x}" > + done Instead of the for-loop, you can write it in one command: find "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" -printf "%%%ghost /boot/dtb-%{KERNELRELEASE}/%%P\n" Is the escaping % complex? > + fi > + > echo "%exclude /lib/modules/%{KERNELRELEASE}/build" > } > %{buildroot}/kernel.list > > @@ -96,6 +107,12 @@ for file in vmlinuz System.map config; do > cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}= -%{KERNELRELEASE}" > fi > done > +if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ]; then > + if ! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KE= RNELRELEASE}" &>/dev/null; then I do not recommend the bash'ism "&>/dev/null". The scriptlet is executed by /bin/sh, which may not be bash, although on most RPM-based distro, it is a symlink to bash. You can squash the nested if-conditionals: if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ] && \ ! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" >/dev/null 2>&1; then ... fi > + rm -rf "/boot/dtb-%{KERNELRELEASE}" > + cp -r "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KE= RNELRELEASE}" > + fi > +fi > if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then > /usr/sbin/depmod %{KERNELRELEASE} > fi > -- > 2.43.2 > > -- Best Regards Masahiro Yamada