From: Nicolas Schier <nsc@kernel.org>
To: David Disseldorp <ddiss@suse.de>
Cc: linux-kbuild@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check
Date: Wed, 21 Jan 2026 12:34:49 +0100 [thread overview]
Message-ID: <aXC52UIHjmsNJG4B@derry.ads.avm.de> (raw)
In-Reply-To: <20260107205239.6390-3-ddiss@suse.de>
[Cc+=nathan]
On Thu, Jan 08, 2026 at 07:39:43AM +1100, David Disseldorp wrote:
> headers_install runs a sed script to check that any GPL variant
> SPDX-License-Identifier line carries a "WITH Linux-syscall-note".
> A subsequent sed invocation then handles removal of a few things that
> aren't desired in installed headers (e.g. __attribute_const__).
>
> Combine these two sed scripts to avoid re-processing the same file.
> License check errors, as opposed to write errors, are indicated via a
> special sed exit status of 9.
>
> Signed-off-by: David Disseldorp <ddiss@suse.de>
> ---
> scripts/headers_install.sh | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
> index 2181abd1c9b70..ef952cbbb8fde 100755
> --- a/scripts/headers_install.sh
> +++ b/scripts/headers_install.sh
> @@ -23,20 +23,25 @@ TMPFILE=$OUTFILE.tmp
>
> trap 'rm -f $OUTFILE $TMPFILE' EXIT
>
> -# SPDX-License-Identifier with GPL variants must have "WITH Linux-syscall-note"
> -if [ -n "$(sed -n -e "/SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p}" $INFILE)" ]; then
> - echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2
> - exit 1
> -fi
> -
> +# returns 9 if GPL SPDX-License-Identifier omits "WITH Linux-syscall-note"
> sed -E -e '
> + /SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/! Q9}
thanks, I like the idea of combining the sed calls. According to the
manual 'Q' (or 'q' with argument) is a GNU extension (non-POSIX).
May we expect GNU sed on all system running headers_install?
> s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
> s/__attribute_const__([[:space:]]|$)/\1/g
> s@^#include <linux/compiler.h>@@
> s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
> s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
> s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
> -' $INFILE > $TMPFILE || exit 1
> +' $INFILE > $TMPFILE
> +case $? in
> +9)
> + echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2
> + exit 1
> + ;;
> +1)
> + exit 1
> + ;;
> +esac
This silently ignores all other exit codes. What about this:
9)
...
;;
0) ;;
*)
exit 1
;;
esac
Kind regards,
Nicolas
next prev parent reply other threads:[~2026-01-21 11:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 20:39 [PATCH v2 0/2] scripts: headers_install: avoid some reprocessing David Disseldorp
2026-01-07 20:39 ` [PATCH v2 1/2] scripts: headers_install: filter ignored configs via sed David Disseldorp
2026-01-12 10:51 ` Thomas Weißschuh
2026-01-12 11:14 ` David Disseldorp
2026-01-07 20:39 ` [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check David Disseldorp
2026-01-21 11:34 ` Nicolas Schier [this message]
2026-01-29 12:27 ` David Disseldorp
2026-01-08 8:38 ` [PATCH v2 0/2] scripts: headers_install: avoid some reprocessing David Disseldorp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXC52UIHjmsNJG4B@derry.ads.avm.de \
--to=nsc@kernel.org \
--cc=ddiss@suse.de \
--cc=linux-kbuild@vger.kernel.org \
--cc=nathan@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox