diff mbox series

ARM: Don't mention the full path of the source directory in mach-types.h

Message ID 20240213092835.754462-2-u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series ARM: Don't mention the full path of the source directory in mach-types.h | expand

Commit Message

Uwe Kleine-König Feb. 13, 2024, 9:28 a.m. UTC
To make package building reproducible independent of the location of the
source tree, the absolute path of this source tree must not be mentioned
in the built artifact. So strip $abs_srctree from FILENAME in the
output.

This fixes a warning issued by Yocto:
	WARNING: linux-lxatac-6.7-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-lxatac/6.7-r0/arch/arm/include/generated/asm/mach-types.h in package linux-lxatac-src contains reference to TMPDIR

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/tools/gen-mach-types | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Lucas Stach July 24, 2024, 1:45 p.m. UTC | #1
Hi Uwe,

Am Dienstag, dem 13.02.2024 um 10:28 +0100 schrieb Uwe Kleine-König:
> To make package building reproducible independent of the location of the
> source tree, the absolute path of this source tree must not be mentioned
> in the built artifact. So strip $abs_srctree from FILENAME in the
> output.
> 
> This fixes a warning issued by Yocto:
> 	WARNING: linux-lxatac-6.7-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-lxatac/6.7-r0/arch/arm/include/generated/asm/mach-types.h in package linux-lxatac-src contains reference to TMPDIR
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  arch/arm/tools/gen-mach-types | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
> index cbe1c33bb871..9592ceb8a102 100644
> --- a/arch/arm/tools/gen-mach-types
> +++ b/arch/arm/tools/gen-mach-types
> @@ -21,10 +21,21 @@ NF == 3 {
>  	  num[nr] = ""; nr++
>  	}
>  
> +# prepend a \ to all special chars in a regexp
> +function quote(s) {
> +	return gensub("[][\\^$.|()*+?{}]", "\\\\&", "g", s)

gensub is a gawk extension and thus will break on systems with a
different awk implementation.

Are you still pursuing this patch?

Regards,
Lucas

> +}
> +
> +# Strip the absolute path of the source tree from the parameter
> +# to make the result independent of where the source is located.
> +function relsrcfile(fn) {
> +	sub("^" quote(ENVIRON["abs_srctree"]) "/", "", fn)
> +	return fn
> +}
>  
>  END	{
>  	  printf("/*\n");
> -	  printf(" * This was automagically generated from %s!\n", FILENAME);
> +	  printf(" * This was automagically generated from %s!\n", relsrcfile(FILENAME));
>  	  printf(" * Do NOT edit\n");
>  	  printf(" */\n\n");
>  	  printf("#ifndef __ASM_ARM_MACH_TYPE_H\n");
Uwe Kleine-König July 25, 2024, 6:16 a.m. UTC | #2
Hallo Lucas,

On Wed, Jul 24, 2024 at 03:45:17PM +0200, Lucas Stach wrote:
> Am Dienstag, dem 13.02.2024 um 10:28 +0100 schrieb Uwe Kleine-König:
> > To make package building reproducible independent of the location of the
> > source tree, the absolute path of this source tree must not be mentioned
> > in the built artifact. So strip $abs_srctree from FILENAME in the
> > output.
> > 
> > This fixes a warning issued by Yocto:
> > 	WARNING: linux-lxatac-6.7-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-lxatac/6.7-r0/arch/arm/include/generated/asm/mach-types.h in package linux-lxatac-src contains reference to TMPDIR
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  arch/arm/tools/gen-mach-types | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
> > index cbe1c33bb871..9592ceb8a102 100644
> > --- a/arch/arm/tools/gen-mach-types
> > +++ b/arch/arm/tools/gen-mach-types
> > @@ -21,10 +21,21 @@ NF == 3 {
> >  	  num[nr] = ""; nr++
> >  	}
> >  
> > +# prepend a \ to all special chars in a regexp
> > +function quote(s) {
> > +	return gensub("[][\\^$.|()*+?{}]", "\\\\&", "g", s)
> 
> gensub is a gawk extension and thus will break on systems with a
> different awk implementation.

Oh, wasn't aware of that.

It seems for Debian the only packaged alternative awk implementation is
goawk. This one knows about gensub, too.

Other tools in the kernel seem to assume gawk is available, but
explicitly call it as gawk. gen-mach-types is called using $(AWK) which
defaults to "awk".

So I guess the easiest fix would be:

diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index 28b6da8ac5f6..84107bb7ddf1 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -32,7 +32,7 @@ uapi:	$(uapi-hdrs-y)
 $(shell mkdir -p $(kapi) $(uapi))
 
 quiet_cmd_gen_mach = GEN     $@
-      cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@
+      cmd_gen_mach = gawk -f $(real-prereqs) > $@
 
 $(kapi)/mach-types.h: $(src)/gen-mach-types $(src)/mach-types FORCE
 	$(call if_changed,gen_mach)

maybe together with removing the shebang line from the script which is
unused and (then) misleading.

If we want to stick to plain awk, I'd ask for someone with a different
implementation to work on a patch.

Best regards
Uwe
Marco Felsch Nov. 14, 2024, 1:15 p.m. UTC | #3
Hi Uwe, Lucas,

On 24-07-25, Uwe Kleine-König wrote:
> Hallo Lucas,
> 
> On Wed, Jul 24, 2024 at 03:45:17PM +0200, Lucas Stach wrote:
> > Am Dienstag, dem 13.02.2024 um 10:28 +0100 schrieb Uwe Kleine-König:
> > > To make package building reproducible independent of the location of the
> > > source tree, the absolute path of this source tree must not be mentioned
> > > in the built artifact. So strip $abs_srctree from FILENAME in the
> > > output.
> > > 
> > > This fixes a warning issued by Yocto:
> > > 	WARNING: linux-lxatac-6.7-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-lxatac/6.7-r0/arch/arm/include/generated/asm/mach-types.h in package linux-lxatac-src contains reference to TMPDIR
> > > 
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > ---
> > >  arch/arm/tools/gen-mach-types | 13 ++++++++++++-
> > >  1 file changed, 12 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
> > > index cbe1c33bb871..9592ceb8a102 100644
> > > --- a/arch/arm/tools/gen-mach-types
> > > +++ b/arch/arm/tools/gen-mach-types
> > > @@ -21,10 +21,21 @@ NF == 3 {
> > >  	  num[nr] = ""; nr++
> > >  	}
> > >  
> > > +# prepend a \ to all special chars in a regexp
> > > +function quote(s) {
> > > +	return gensub("[][\\^$.|()*+?{}]", "\\\\&", "g", s)
> > 
> > gensub is a gawk extension and thus will break on systems with a
> > different awk implementation.
> 
> Oh, wasn't aware of that.
> 
> It seems for Debian the only packaged alternative awk implementation is
> goawk. This one knows about gensub, too.
> 
> Other tools in the kernel seem to assume gawk is available, but
> explicitly call it as gawk. gen-mach-types is called using $(AWK) which
> defaults to "awk".
> 
> So I guess the easiest fix would be:
> 
> diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
> index 28b6da8ac5f6..84107bb7ddf1 100644
> --- a/arch/arm/tools/Makefile
> +++ b/arch/arm/tools/Makefile
> @@ -32,7 +32,7 @@ uapi:	$(uapi-hdrs-y)
>  $(shell mkdir -p $(kapi) $(uapi))
>  
>  quiet_cmd_gen_mach = GEN     $@
> -      cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@
> +      cmd_gen_mach = gawk -f $(real-prereqs) > $@
>  
>  $(kapi)/mach-types.h: $(src)/gen-mach-types $(src)/mach-types FORCE
>  	$(call if_changed,gen_mach)
> 
> maybe together with removing the shebang line from the script which is
> unused and (then) misleading.
> 
> If we want to stick to plain awk, I'd ask for someone with a different
> implementation to work on a patch.

I wasn't aware of this patch, therefore I send a simpler one which drops
the filename mention:

https://lore.kernel.org/all/20241114130021.2802803-1-m.felsch@pengutronix.de/T/#u

Regards,
  Marco
Russell King (Oracle) Nov. 14, 2024, 4:40 p.m. UTC | #4
On Thu, Nov 14, 2024 at 02:15:30PM +0100, Marco Felsch wrote:
> Hi Uwe, Lucas,
> 
> On 24-07-25, Uwe Kleine-König wrote:
> > Hallo Lucas,
> > 
> > On Wed, Jul 24, 2024 at 03:45:17PM +0200, Lucas Stach wrote:
> > > Am Dienstag, dem 13.02.2024 um 10:28 +0100 schrieb Uwe Kleine-König:
> > > > To make package building reproducible independent of the location of the
> > > > source tree, the absolute path of this source tree must not be mentioned
> > > > in the built artifact. So strip $abs_srctree from FILENAME in the
> > > > output.
> > > > 
> > > > This fixes a warning issued by Yocto:
> > > > 	WARNING: linux-lxatac-6.7-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-lxatac/6.7-r0/arch/arm/include/generated/asm/mach-types.h in package linux-lxatac-src contains reference to TMPDIR
> > > > 
> > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > > ---
> > > >  arch/arm/tools/gen-mach-types | 13 ++++++++++++-
> > > >  1 file changed, 12 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
> > > > index cbe1c33bb871..9592ceb8a102 100644
> > > > --- a/arch/arm/tools/gen-mach-types
> > > > +++ b/arch/arm/tools/gen-mach-types
> > > > @@ -21,10 +21,21 @@ NF == 3 {
> > > >  	  num[nr] = ""; nr++
> > > >  	}
> > > >  
> > > > +# prepend a \ to all special chars in a regexp
> > > > +function quote(s) {
> > > > +	return gensub("[][\\^$.|()*+?{}]", "\\\\&", "g", s)
> > > 
> > > gensub is a gawk extension and thus will break on systems with a
> > > different awk implementation.
> > 
> > Oh, wasn't aware of that.
> > 
> > It seems for Debian the only packaged alternative awk implementation is
> > goawk. This one knows about gensub, too.
> > 
> > Other tools in the kernel seem to assume gawk is available, but
> > explicitly call it as gawk. gen-mach-types is called using $(AWK) which
> > defaults to "awk".
> > 
> > So I guess the easiest fix would be:
> > 
> > diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
> > index 28b6da8ac5f6..84107bb7ddf1 100644
> > --- a/arch/arm/tools/Makefile
> > +++ b/arch/arm/tools/Makefile
> > @@ -32,7 +32,7 @@ uapi:	$(uapi-hdrs-y)
> >  $(shell mkdir -p $(kapi) $(uapi))
> >  
> >  quiet_cmd_gen_mach = GEN     $@
> > -      cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@
> > +      cmd_gen_mach = gawk -f $(real-prereqs) > $@
> >  
> >  $(kapi)/mach-types.h: $(src)/gen-mach-types $(src)/mach-types FORCE
> >  	$(call if_changed,gen_mach)
> > 
> > maybe together with removing the shebang line from the script which is
> > unused and (then) misleading.
> > 
> > If we want to stick to plain awk, I'd ask for someone with a different
> > implementation to work on a patch.
> 
> I wasn't aware of this patch, therefore I send a simpler one which drops
> the filename mention:
> 
> https://lore.kernel.org/all/20241114130021.2802803-1-m.felsch@pengutronix.de/T/#u

Or just leave it as is. It's in a comment, it doesn't get into the
executable, and thus is harmless.
Marco Felsch Nov. 14, 2024, 8:39 p.m. UTC | #5
On 24-11-14, Russell King (Oracle) wrote:
> On Thu, Nov 14, 2024 at 02:15:30PM +0100, Marco Felsch wrote:
> > Hi Uwe, Lucas,
> > 
> > On 24-07-25, Uwe Kleine-König wrote:
> > > Hallo Lucas,
> > > 
> > > On Wed, Jul 24, 2024 at 03:45:17PM +0200, Lucas Stach wrote:
> > > > Am Dienstag, dem 13.02.2024 um 10:28 +0100 schrieb Uwe Kleine-König:
> > > > > To make package building reproducible independent of the location of the
> > > > > source tree, the absolute path of this source tree must not be mentioned
> > > > > in the built artifact. So strip $abs_srctree from FILENAME in the
> > > > > output.
> > > > > 
> > > > > This fixes a warning issued by Yocto:
> > > > > 	WARNING: linux-lxatac-6.7-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-lxatac/6.7-r0/arch/arm/include/generated/asm/mach-types.h in package linux-lxatac-src contains reference to TMPDIR
> > > > > 
> > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > > > ---
> > > > >  arch/arm/tools/gen-mach-types | 13 ++++++++++++-
> > > > >  1 file changed, 12 insertions(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
> > > > > index cbe1c33bb871..9592ceb8a102 100644
> > > > > --- a/arch/arm/tools/gen-mach-types
> > > > > +++ b/arch/arm/tools/gen-mach-types
> > > > > @@ -21,10 +21,21 @@ NF == 3 {
> > > > >  	  num[nr] = ""; nr++
> > > > >  	}
> > > > >  
> > > > > +# prepend a \ to all special chars in a regexp
> > > > > +function quote(s) {
> > > > > +	return gensub("[][\\^$.|()*+?{}]", "\\\\&", "g", s)
> > > > 
> > > > gensub is a gawk extension and thus will break on systems with a
> > > > different awk implementation.
> > > 
> > > Oh, wasn't aware of that.
> > > 
> > > It seems for Debian the only packaged alternative awk implementation is
> > > goawk. This one knows about gensub, too.
> > > 
> > > Other tools in the kernel seem to assume gawk is available, but
> > > explicitly call it as gawk. gen-mach-types is called using $(AWK) which
> > > defaults to "awk".
> > > 
> > > So I guess the easiest fix would be:
> > > 
> > > diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
> > > index 28b6da8ac5f6..84107bb7ddf1 100644
> > > --- a/arch/arm/tools/Makefile
> > > +++ b/arch/arm/tools/Makefile
> > > @@ -32,7 +32,7 @@ uapi:	$(uapi-hdrs-y)
> > >  $(shell mkdir -p $(kapi) $(uapi))
> > >  
> > >  quiet_cmd_gen_mach = GEN     $@
> > > -      cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@
> > > +      cmd_gen_mach = gawk -f $(real-prereqs) > $@
> > >  
> > >  $(kapi)/mach-types.h: $(src)/gen-mach-types $(src)/mach-types FORCE
> > >  	$(call if_changed,gen_mach)
> > > 
> > > maybe together with removing the shebang line from the script which is
> > > unused and (then) misleading.
> > > 
> > > If we want to stick to plain awk, I'd ask for someone with a different
> > > implementation to work on a patch.
> > 
> > I wasn't aware of this patch, therefore I send a simpler one which drops
> > the filename mention:
> > 
> > https://lore.kernel.org/all/20241114130021.2802803-1-m.felsch@pengutronix.de/T/#u
> 
> Or just leave it as is. It's in a comment, it doesn't get into the
> executable, and thus is harmless.

Right but why do we need the comment with the filename? Isn't it enough
to say that this file is auto-generated?

I don't see the profit of keeping the filename instead of warn that this
file is autogenerated.

Regards,
  Marco


> 
> -- 
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
>
diff mbox series

Patch

diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
index cbe1c33bb871..9592ceb8a102 100644
--- a/arch/arm/tools/gen-mach-types
+++ b/arch/arm/tools/gen-mach-types
@@ -21,10 +21,21 @@  NF == 3 {
 	  num[nr] = ""; nr++
 	}
 
+# prepend a \ to all special chars in a regexp
+function quote(s) {
+	return gensub("[][\\^$.|()*+?{}]", "\\\\&", "g", s)
+}
+
+# Strip the absolute path of the source tree from the parameter
+# to make the result independent of where the source is located.
+function relsrcfile(fn) {
+	sub("^" quote(ENVIRON["abs_srctree"]) "/", "", fn)
+	return fn
+}
 
 END	{
 	  printf("/*\n");
-	  printf(" * This was automagically generated from %s!\n", FILENAME);
+	  printf(" * This was automagically generated from %s!\n", relsrcfile(FILENAME));
 	  printf(" * Do NOT edit\n");
 	  printf(" */\n\n");
 	  printf("#ifndef __ASM_ARM_MACH_TYPE_H\n");