mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] Problems building kernel image with initramfs with no tty
@ 2019-02-18 16:11 Jon Ringle
  2019-02-22  8:11 ` [ptxdist] [PATCH] kernel: rework prepare stage Michael Olbrich
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Ringle @ 2019-02-18 16:11 UTC (permalink / raw)
  To: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 3325 bytes --]

I've recently updated to ptxdist-2019.01.0 and have noted some changes with
my project that builds a kernel image with initramfs:

1) In rules/kernel.make, there is the following code:

#
# Don't keep the expanded path to INITRAMS_SOURCE in $(KERNEL_CONFIG),
# because it contains local workdir path which is not relevant to
# other developers.
#
ifdef KERNEL_INITRAMFS_SOURCE_y
        @sed -i -e
's,^CONFIG_INITRAMFS_SOURCE.*$$,CONFIG_INITRAMFS_SOURCE=\"# Automatically
set by PTXDist\",g' \
                "$(<)"
endif


However, this is no longer having the intended behavior. The
$(KERNEL_CONFIG) is being modified after doing a `ptxdist images`:

$ ptxdist print KERNEL_CONFIG
/home/local/GRIDPOINT/jringle/git/linux-initramfs/ptxconf/ec1k/kernelconfig-3.12
$ ptxdist print KERNEL_INITRAMFS_SOURCE_y
/home/local/GRIDPOINT/jringle/git/linux-initramfs/platform-ec1k/state/empty.cpio
$ git diff
diff --git a/ptxconf/ec1k/kernelconfig-3.12 b/ptxconf/ec1k/kernelconfig-3.12
index 247c3bb..c77037f 100644
--- a/ptxconf/ec1k/kernelconfig-3.12
+++ b/ptxconf/ec1k/kernelconfig-3.12
@@ -116,7 +116,7 @@ CONFIG_NET_NS=y
 # CONFIG_SYSFS_DEPRECATED is not set
 # CONFIG_RELAY is not set
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE="# Automatically set by PTXDist"
+CONFIG_INITRAMFS_SOURCE="/home/local/GRIDPOINT/jringle/git/linux-initramfs/platform-ec1k/state/empty.cpio"
 CONFIG_INITRAMFS_ROOT_UID=0
 CONFIG_INITRAMFS_ROOT_GID=0
 # CONFIG_RD_GZIP is not set


2) As a result of the above, the build behavior is different between a
build with a tty, and a build without a tty (build by a CI build
environment), because the kernel config file has changed and
ptxd_make_kconfig_sync() in scripts/lib/ptxd_make_world_kconfig.sh is
called:

ptxd_make_kconfig_sync() {
    local mode
    if [ "${ptx_config_mode}" = run ]; then
        if tty -s; then
            ptx_config_mode=update
        else
            ptx_config_mode=check
        fi
    fi
    if [ -n "${ref_file_dotconfig}" ]; then
        file_dotconfig="${ref_file_dotconfig}" ptxd_normalize_config &&
        relative_ref_file_dotconfig="${relative_file_dotconfig}"
    fi &&
    ptxd_normalize_config &&
    ptxd_kconfig_sync_config "${ptx_config_mode}"
"${pkg_build_dir}/.config" \
        "${relative_file_dotconfig}" "${file_dotconfig}"
"${relative_ref_file_dotconfig}"
}


A build failure without a tty can be simulated with: `ssh localhost "cd
$(pwd); ptxdist images"`:

----------------------
target: kernel.prepare
----------------------

Using config file: 'linux-initramfs/ptxconf/ec1k/kernelconfig-3.12'

make[1]: Entering directory `/home/local/GRIDPOINT/jringle/git/linux'
scripts/kconfig/conf --oldconfig Kconfig
#
# configuration written to .config
#
make[1]: Leaving directory `/home/local/GRIDPOINT/jringle/git/linux'

ptxdist: error: Outdated config for 'linux-initramfs'
ptxdist: error: 'oldconfig' changes the file. Run 'oldconfig kernel' to
update.

make: ***
[/home/local/GRIDPOINT/jringle/git/linux-initramfs/platform-ec1k/state/kernel.prepare]
Error 1


I worked around this by modifying the ptxdist used by our build server so
that ptxd_make_kconfig_sync() always used ptx_config_mode=update even if
there is no tty. But I know that this is not the right solution. But I also
don't know what the proper solution should be.

Regards,
-Jon

[-- Attachment #1.2: Type: text/html, Size: 8570 bytes --]

[-- Attachment #2: Type: text/plain, Size: 91 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ptxdist] [PATCH] kernel: rework prepare stage
  2019-02-18 16:11 [ptxdist] Problems building kernel image with initramfs with no tty Jon Ringle
@ 2019-02-22  8:11 ` Michael Olbrich
  2019-02-22 17:23   ` Jon Ringle
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Olbrich @ 2019-02-22  8:11 UTC (permalink / raw)
  To: ptxdist, Jon Ringle; +Cc: Michael Olbrich

The old implementation is broken, when a initramfs is used.
Changing the kconfig symbol back to '# Automatically set by PTXDist' is
broken because '$(<)' is not the kernel config any more (Broken since
cd920ab716bab0c190666e0273c10b19c7cdaeec "barebox/kernel: drop explicit
dependency").
Also, world/kconfig-sync compares .config and KERNEL_CONFIG and this does
not work because CONFIG_INITRAMFS_SOURCE in .config has been modified.

Instead, make sure that KERNEL_CONFIG contains the path independent dummy
text before copying it to .config.
Then run the default prepare stage that checks or updates the config.
Insert the path for the empty initramfs after all checks are done.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---

Hi Jon,

The initramfs handling is completely broken :-/. Can you try this patch?
That should fix your problem. I've queued this for master, but I'm still
waiting for some test results before pushing this.

Michael

 rules/kernel.make | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/rules/kernel.make b/rules/kernel.make
index 99ad37b85ea7..6a9666df196b 100644
--- a/rules/kernel.make
+++ b/rules/kernel.make
@@ -105,30 +105,31 @@ KERNEL_INITRAMFS_SOURCE_$(PTXCONF_IMAGE_KERNEL_INITRAMFS) += $(STATEDIR)/empty.c
 
 $(STATEDIR)/kernel.prepare:
 	@$(call targetinfo)
-
-	@$(call world/kconfig-setup, KERNEL)
+#
+# Make sure there is a non empty INITRAMFS_SOURCE in $(KERNEL_CONFIG), but
+# not the real expanded path because it contains local workdir path which
+# is not relevant to other developers.
+#
+ifdef KERNEL_INITRAMFS_SOURCE_y
+	@sed -i -e 's,^CONFIG_INITRAMFS_SOURCE.*$$,CONFIG_INITRAMFS_SOURCE=\"# Automatically set by PTXDist\",g' \
+		"$(KERNEL_CONFIG)"
+endif
 ifdef PTXCONF_KERNEL_IMAGE_SIMPLE
 	cp $(PTXCONF_KERNEL_IMAGE_SIMPLE_DTS) \
 		$(KERNEL_DIR)/arch/$(PTXCONF_KERNEL_ARCH_STRING)/boot/dts/$(PTXCONF_KERNEL_IMAGE_SIMPLE_TARGET).dts
 endif
 
-ifdef KERNEL_INITRAMFS_SOURCE_y
-	@touch "$(KERNEL_INITRAMFS_SOURCE_y)"
-	@sed -i -e 's,^CONFIG_INITRAMFS_SOURCE.*$$,CONFIG_INITRAMFS_SOURCE=\"$(KERNEL_INITRAMFS_SOURCE_y)\",g' \
-		"$(KERNEL_DIR)/.config"
-endif
-
-	@$(call ptx/oldconfig, KERNEL)
-	@$(call world/kconfig-sync, KERNEL)
+	@$(call world/prepare, KERNEL)
 
 #
-# Don't keep the expanded path to INITRAMS_SOURCE in $(KERNEL_CONFIG),
-# because it contains local workdir path which is not relevant to
-# other developers.
+# Use a existing dummy INITRAMFS_SOURCE for the fist 'make' call. The
+# kernel image will be rebuilt in the image-kernel package with the real
+# initramfs.
 #
 ifdef KERNEL_INITRAMFS_SOURCE_y
-	@sed -i -e 's,^CONFIG_INITRAMFS_SOURCE.*$$,CONFIG_INITRAMFS_SOURCE=\"# Automatically set by PTXDist\",g' \
-		"$(<)"
+	@touch "$(KERNEL_INITRAMFS_SOURCE_y)"
+	@sed -i -e 's,^CONFIG_INITRAMFS_SOURCE.*$$,CONFIG_INITRAMFS_SOURCE=\"$(KERNEL_INITRAMFS_SOURCE_y)\",g' \
+		"$(KERNEL_DIR)/.config"
 endif
 	@$(call touch)
 
-- 
2.20.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ptxdist] [PATCH] kernel: rework prepare stage
  2019-02-22  8:11 ` [ptxdist] [PATCH] kernel: rework prepare stage Michael Olbrich
@ 2019-02-22 17:23   ` Jon Ringle
  0 siblings, 0 replies; 3+ messages in thread
From: Jon Ringle @ 2019-02-22 17:23 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: ptxdist



On Fri, 22 Feb 2019, Michael Olbrich wrote:

> The old implementation is broken, when a initramfs is used.
> Changing the kconfig symbol back to '# Automatically set by PTXDist' is
> broken because '$(<)' is not the kernel config any more (Broken since
> cd920ab716bab0c190666e0273c10b19c7cdaeec "barebox/kernel: drop explicit
> dependency").
> Also, world/kconfig-sync compares .config and KERNEL_CONFIG and this does
> not work because CONFIG_INITRAMFS_SOURCE in .config has been modified.
>
> Instead, make sure that KERNEL_CONFIG contains the path independent dummy
> text before copying it to .config.
> Then run the default prepare stage that checks or updates the config.
> Insert the path for the empty initramfs after all checks are done.
>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>
> Hi Jon,
>
> The initramfs handling is completely broken :-/. Can you try this patch?
> That should fix your problem. I've queued this for master, but I'm still
> waiting for some test results before pushing this.
>

Tested with 'ssh localhost "cd $(pwd); ptxdist images"'
Looks good.

Tested-by: Jon Ringle <jringle@gridpoint.com>

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-22 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 16:11 [ptxdist] Problems building kernel image with initramfs with no tty Jon Ringle
2019-02-22  8:11 ` [ptxdist] [PATCH] kernel: rework prepare stage Michael Olbrich
2019-02-22 17:23   ` Jon Ringle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox