diff mbox series

scripts/package/Makefile: put proper config in source tarball

Message ID 20190221215901.23970-1-ar@cs.msu.ru (mailing list archive)
State New, archived
Headers show
Series scripts/package/Makefile: put proper config in source tarball | expand

Commit Message

Arseny Maslennikov Feb. 21, 2019, 9:58 p.m. UTC
It is widely known that one can build a kernel without a .config in the
source tree by setting KCONFIG_CONFIG equal to the actual configuration
file path.

When making a *-pkg target, make(1) prepares a source tarball and tries
to pack `.config' in there regardless of the value of KCONFIG_CONFIG,
failing spectacularly if .config is absent and packing the wrong config
if it exists.
Let's fix that.

Signed-off-by: Arseny Maslennikov <ar@cs.msu.ru>
---
 scripts/package/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel March 1, 2019, 1:34 p.m. UTC | #1
Hi,

> It is widely known that one can build a kernel without a .config in the
> source tree by setting KCONFIG_CONFIG equal to the actual configuration
> file path.

> When making a *-pkg target, make(1) prepares a source tarball and tries
> to pack `.config' in there regardless of the value of KCONFIG_CONFIG,
> failing spectacularly if .config is absent and packing the wrong config
> if it exists.
> Let's fix that.

> Signed-off-by: Arseny Maslennikov <ar@cs.msu.ru>
Reviewed-by: Petr Vorel <pvorel@suse.cz>


Kind regards,
Petr
Masahiro Yamada March 7, 2019, 3:32 p.m. UTC | #2
On Fri, Feb 22, 2019 at 7:19 AM Arseny Maslennikov <ar@cs.msu.ru> wrote:
>
> It is widely known that one can build a kernel without a .config in the
> source tree

"without a .config in the source file"  means
KCONFIG_CONFIG will probably contain '..' or absolute path.



ex1)  KCONFIG_CONFIG=../my_dir/.config

ex2)  KCONFIG_CONFIG=/absolute/pass/to/my/.config





> by setting KCONFIG_CONFIG equal to the actual configuration
> file path.
>
> When making a *-pkg target, make(1) prepares a source tarball and tries
> to pack `.config' in there regardless of the value of KCONFIG_CONFIG,
> failing spectacularly if .config is absent and packing the wrong config
> if it exists.
> Let's fix that.


Did you notice the log 'Removing leading ...' from tar
for case ex1), ex2) ?


masahiro@grover:~/ref/linux$ make -j8  KCONFIG_CONFIG=../.config  deb-pkg
make clean
/bin/bash ./scripts/package/mkdebian
  TAR     linux-5.0.0+.tar.gz
tar: Removing leading `../' from member names
   ...


Even if I apply 3/3, it will produce a broken source package
since the tar will rip off the leading directory path,
then it mismatches to KCONFIG_CONFIG recorded in debian/rules.

A simple case like KCONFIG_CONFIG=my.config will work,
but I am not convinced with 3/3.




> Signed-off-by: Arseny Maslennikov <ar@cs.msu.ru>
> ---
>  scripts/package/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 453fecee62f0..100a0d28ad25 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -27,7 +27,7 @@ KDEB_SOURCENAME ?= linux-$(KERNELRELEASE)
>  KBUILD_PKG_ROOTCMD ?="fakeroot -u"
>  export KDEB_SOURCENAME
>  # Include only those top-level files that are needed by make, plus the GPL copy
> -TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
> +TAR_CONTENT := $(KBUILD_ALLDIRS) $(KCONFIG_CONFIG) .scmversion Makefile \
>                 Kbuild Kconfig COPYING $(wildcard localversion*)
>  MKSPEC     := $(srctree)/scripts/package/mkspec
>
> --
> 2.20.1
>


--
Best Regards
Masahiro Yamada
Arseny Maslennikov March 7, 2019, 7:05 p.m. UTC | #3
On Fri, Mar 08, 2019 at 12:32:11AM +0900, Masahiro Yamada wrote:
> On Fri, Feb 22, 2019 at 7:19 AM Arseny Maslennikov <ar@cs.msu.ru> wrote:
> >
> > It is widely known that one can build a kernel without a .config in the
> > source tree
> 
> "without a .config in the source file"  means
> KCONFIG_CONFIG will probably contain '..' or absolute path.
> 
> 
> 
> ex1)  KCONFIG_CONFIG=../my_dir/.config
> 
> ex2)  KCONFIG_CONFIG=/absolute/pass/to/my/.config
> 

Hmm, I did not consider that; my bad, sorry.

> 
> 
> 
> 
> > by setting KCONFIG_CONFIG equal to the actual configuration
> > file path.
> >
> > When making a *-pkg target, make(1) prepares a source tarball and tries
> > to pack `.config' in there regardless of the value of KCONFIG_CONFIG,
> > failing spectacularly if .config is absent and packing the wrong config
> > if it exists.
> > Let's fix that.
> 
> 
> Did you notice the log 'Removing leading ...' from tar
> for case ex1), ex2) ?
> 
> 
> masahiro@grover:~/ref/linux$ make -j8  KCONFIG_CONFIG=../.config  deb-pkg
> make clean
> /bin/bash ./scripts/package/mkdebian
>   TAR     linux-5.0.0+.tar.gz
> tar: Removing leading `../' from member names

Yes, I know tar does that. I mostly use KCONFIG_CONFIG with a bunch of
config files in the source tree, so did not experience this while making
sure the change makes sense.

>    ...
> 
> 
> Even if I apply 3/3, it will produce a broken source package
> since the tar will rip off the leading directory path,
> then it mismatches to KCONFIG_CONFIG recorded in debian/rules.
> 
> A simple case like KCONFIG_CONFIG=my.config will work,
> but I am not convinced with 3/3.
> 

So instead of this one and 3/3 we could ensure the source tarball
contains a .config equal to the contents of KCONFIG_CONFIG provided to
make(1), so the source package is fixed and its users are not confused.

If the following is ok, I'll send a v2.
A quick look at the generated orig tarball tells me it ought to work
well.

Something like this:

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 100a0d28ad25..8530fe267a76 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -44,6 +44,7 @@ if test "$(objtree)" != "$(srctree)"; then \
 fi ; \
 $(srctree)/scripts/setlocalversion --save-scmversion; \
 tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
+	--absolute-names --transform 's:^$(KCONFIG_CONFIG):.config:S' \
 	--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
 rm -f $(objtree)/.scmversion
Arseny Maslennikov March 7, 2019, 7:08 p.m. UTC | #4
On Thu, Mar 07, 2019 at 10:05:30PM +0300, Arseny Maslennikov wrote:
> On Fri, Mar 08, 2019 at 12:32:11AM +0900, Masahiro Yamada wrote:
> > On Fri, Feb 22, 2019 at 7:19 AM Arseny Maslennikov <ar@cs.msu.ru> wrote:
> > >
> > > It is widely known that one can build a kernel without a .config in the
> > > source tree
> > 
> > "without a .config in the source file"  means
> > KCONFIG_CONFIG will probably contain '..' or absolute path.
> > 
> > 
> > 
> > ex1)  KCONFIG_CONFIG=../my_dir/.config
> > 
> > ex2)  KCONFIG_CONFIG=/absolute/pass/to/my/.config
> > 
> 
> Hmm, I did not consider that; my bad, sorry.
> 
> > 
> > 
> > 
> > 
> > > by setting KCONFIG_CONFIG equal to the actual configuration
> > > file path.
> > >
> > > When making a *-pkg target, make(1) prepares a source tarball and tries
> > > to pack `.config' in there regardless of the value of KCONFIG_CONFIG,
> > > failing spectacularly if .config is absent and packing the wrong config
> > > if it exists.
> > > Let's fix that.
> > 
> > 
> > Did you notice the log 'Removing leading ...' from tar
> > for case ex1), ex2) ?
> > 
> > 
> > masahiro@grover:~/ref/linux$ make -j8  KCONFIG_CONFIG=../.config  deb-pkg
> > make clean
> > /bin/bash ./scripts/package/mkdebian
> >   TAR     linux-5.0.0+.tar.gz
> > tar: Removing leading `../' from member names
> 
> Yes, I know tar does that. I mostly use KCONFIG_CONFIG with a bunch of
> config files in the source tree, so did not experience this while making
> sure the change makes sense.
> 
> >    ...
> > 
> > 
> > Even if I apply 3/3, it will produce a broken source package
> > since the tar will rip off the leading directory path,
> > then it mismatches to KCONFIG_CONFIG recorded in debian/rules.
> > 
> > A simple case like KCONFIG_CONFIG=my.config will work,
> > but I am not convinced with 3/3.
> > 
> 
> So instead of this one and 3/3 we could ensure the source tarball
> contains a .config equal to the contents of KCONFIG_CONFIG provided to
> make(1), so the source package is fixed and its users are not confused.
> 
> If the following is ok, I'll send a v2.
> A quick look at the generated orig tarball tells me it ought to work
> well.
> 
> Something like this:
> 
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 100a0d28ad25..8530fe267a76 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -44,6 +44,7 @@ if test "$(objtree)" != "$(srctree)"; then \
>  fi ; \
>  $(srctree)/scripts/setlocalversion --save-scmversion; \
>  tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
> +	--absolute-names --transform 's:^$(KCONFIG_CONFIG):.config:S' \

GNU tar seems to trim the paths of archive members first and only then
consider the --transform rules, so it does not work with
KCONFIG_CONFIG=../../my.config and the likes if -P/--absolute-names is
not provided.

>  	--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
>  rm -f $(objtree)/.scmversion
>
diff mbox series

Patch

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 453fecee62f0..100a0d28ad25 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -27,7 +27,7 @@  KDEB_SOURCENAME ?= linux-$(KERNELRELEASE)
 KBUILD_PKG_ROOTCMD ?="fakeroot -u"
 export KDEB_SOURCENAME
 # Include only those top-level files that are needed by make, plus the GPL copy
-TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
+TAR_CONTENT := $(KBUILD_ALLDIRS) $(KCONFIG_CONFIG) .scmversion Makefile \
                Kbuild Kconfig COPYING $(wildcard localversion*)
 MKSPEC     := $(srctree)/scripts/package/mkspec