2019-02-21 22:20:07

by Arseny Maslennikov

[permalink] [raw]
Subject: [PATCH] scripts/package/Makefile: put proper config in source tarball

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 <[email protected]>
---
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



2019-02-21 22:20:13

by Arseny Maslennikov

[permalink] [raw]
Subject: [PATCH] scripts/package/mkdebian: expose KCONFIG_CONFIG to debian/rules

If KCONFIG_CONFIG is passed to `make deb-pkg` as a makeflag or
environment variable, the source tarball produced contains whatever
specified by that variable instead of the usual `.config'.

While `make deb-pkg' yields a correct Debian binary package (at least
on amd64), the generated source package's debian/rules does not pass
KCONFIG_CONFIG to make(1), thus rendering the source package unable to
be rebuilt.

Steps to reproduce the kind of failure being fixed:
1) Produce a source and binary package with:
% KCONFIG_CONFIG=my.config make deb-pkg
2) In the parent directory:
% dpkg-source -x linux-*.dsc
3) In the unpacked source directory:
% debuild -i -us -uc

Here is an excerpt from an example output of `debuild -i -us -uc':

make[2]: *** No rule to make target '.config', needed by 'kernel/config_data.gz'. Stop.
make[1]: *** [Makefile:1043: kernel] Error 2
make[1]: Leaving directory '/home/ar/linux-kernel/deb/linux-5.0.0-rc5-tks-gitd6ff78479ec5-57-5.0.0-rc5-tks-gitd6ff78479ec5-57'
make: *** [debian/rules:4: build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -i failed

Signed-off-by: Arseny Maslennikov <[email protected]>
---
scripts/package/mkdebian | 2 ++
1 file changed, 2 insertions(+)

diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index edcad61fe3cd..130d3f6696eb 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -207,10 +207,12 @@ cat <<EOF > debian/rules

build:
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
+ KCONFIG_CONFIG=${KCONFIG_CONFIG} \
KBUILD_BUILD_VERSION=${revision} KBUILD_SRC=

binary-arch:
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
+ KCONFIG_CONFIG=${KCONFIG_CONFIG} \
KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg

clean:
--
2.20.1


2019-03-01 14:02:51

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH] scripts/package/mkdebian: expose KCONFIG_CONFIG to debian/rules

Hi,

> If KCONFIG_CONFIG is passed to `make deb-pkg` as a makeflag or
> environment variable, the source tarball produced contains whatever
> specified by that variable instead of the usual `.config'.

> While `make deb-pkg' yields a correct Debian binary package (at least
> on amd64), the generated source package's debian/rules does not pass
> KCONFIG_CONFIG to make(1), thus rendering the source package unable to
> be rebuilt.

> Steps to reproduce the kind of failure being fixed:
> 1) Produce a source and binary package with:
> % KCONFIG_CONFIG=my.config make deb-pkg
> 2) In the parent directory:
> % dpkg-source -x linux-*.dsc
> 3) In the unpacked source directory:
> % debuild -i -us -uc

> Here is an excerpt from an example output of `debuild -i -us -uc':

> make[2]: *** No rule to make target '.config', needed by 'kernel/config_data.gz'. Stop.
> make[1]: *** [Makefile:1043: kernel] Error 2
> make[1]: Leaving directory '/home/ar/linux-kernel/deb/linux-5.0.0-rc5-tks-gitd6ff78479ec5-57-5.0.0-rc5-tks-gitd6ff78479ec5-57'
> make: *** [debian/rules:4: build] Error 2
> dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
> debuild: fatal error at line 1182:
> dpkg-buildpackage -us -uc -ui -i failed

Reviewed-by: Petr Vorel <[email protected]>


Kind regards,
Petr

2019-03-01 14:04:03

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH] scripts/package/Makefile: put proper config in source tarball

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 <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>


Kind regards,
Petr

2019-03-07 15:32:21

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] scripts/package/mkdebian: expose KCONFIG_CONFIG to debian/rules

On Fri, Feb 22, 2019 at 7:21 AM Arseny Maslennikov <[email protected]> wrote:
>
> If KCONFIG_CONFIG is passed to `make deb-pkg` as a makeflag or
> environment variable, the source tarball produced contains whatever
> specified by that variable instead of the usual `.config'.
>
> While `make deb-pkg' yields a correct Debian binary package (at least
> on amd64), the generated source package's debian/rules does not pass
> KCONFIG_CONFIG to make(1), thus rendering the source package unable to
> be rebuilt.
>
> Steps to reproduce the kind of failure being fixed:
> 1) Produce a source and binary package with:
> % KCONFIG_CONFIG=my.config make deb-pkg
> 2) In the parent directory:
> % dpkg-source -x linux-*.dsc
> 3) In the unpacked source directory:
> % debuild -i -us -uc
>
> Here is an excerpt from an example output of `debuild -i -us -uc':
>
> make[2]: *** No rule to make target '.config', needed by 'kernel/config_data.gz'. Stop.
> make[1]: *** [Makefile:1043: kernel] Error 2
> make[1]: Leaving directory '/home/ar/linux-kernel/deb/linux-5.0.0-rc5-tks-gitd6ff78479ec5-57-5.0.0-rc5-tks-gitd6ff78479ec5-57'
> make: *** [debian/rules:4: build] Error 2
> dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
> debuild: fatal error at line 1182:
> dpkg-buildpackage -us -uc -ui -i failed



I am not convinced with this patch.

People would be upset if they got a source package and
they did not find the .config in the standard location.

It is difficult to notice the .config has been moved
to somewhere until they check debian/rules.

Why do we need to create such a strange package?





> Signed-off-by: Arseny Maslennikov <[email protected]>
> ---
> scripts/package/mkdebian | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index edcad61fe3cd..130d3f6696eb 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -207,10 +207,12 @@ cat <<EOF > debian/rules
>
> build:
> \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
> + KCONFIG_CONFIG=${KCONFIG_CONFIG} \
> KBUILD_BUILD_VERSION=${revision} KBUILD_SRC=
>
> binary-arch:
> \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
> + KCONFIG_CONFIG=${KCONFIG_CONFIG} \
> KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg
>
> clean:
> --
> 2.20.1
>


--
Best Regards
Masahiro Yamada

2019-03-07 15:35:01

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] scripts/package/Makefile: put proper config in source tarball

On Fri, Feb 22, 2019 at 7:19 AM Arseny Maslennikov <[email protected]> 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 <[email protected]>
> ---
> 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

2019-03-07 19:06:33

by Arseny Maslennikov

[permalink] [raw]
Subject: Re: [PATCH] scripts/package/Makefile: put proper config in source tarball

On Fri, Mar 08, 2019 at 12:32:11AM +0900, Masahiro Yamada wrote:
> On Fri, Feb 22, 2019 at 7:19 AM Arseny Maslennikov <[email protected]> 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


Attachments:
(No filename) (2.49 kB)
signature.asc (849.00 B)
Download all attachments

2019-03-07 19:09:49

by Arseny Maslennikov

[permalink] [raw]
Subject: Re: [PATCH] scripts/package/Makefile: put proper config in source tarball

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 <[email protected]> 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
>



Attachments:
(No filename) (2.93 kB)
signature.asc (849.00 B)
Download all attachments