build: kernel2minor: work around path length limit
authorFrançois Chavant <francois@chavant.info>
Fri, 7 May 2021 15:58:11 +0000 (17:58 +0200)
committerPaul Spooren <mail@aparcar.org>
Wed, 12 May 2021 11:39:29 +0000 (13:39 +0200)
When building for MikroTik devices the kernel2minor tool will sometimes
fail with:

  Can't get lstat from kernel file!: No such file or directory.

This is because kernel2minor expects paths no longer than 250 chars.
To work around this the include/image-commands.mk has been modified
to copy the kernel to a temporary file (/tmp/tmp.XXXXXXXXXX) before
calling kernel2minor.

Signed-off-by: François Chavant <francois@chavant.info>
include/image-commands.mk

index 9702d029d75dd6a4d1b42ea63aab8dffe7bbec0b..afb2dde5ba3789247804551bd529e4fa2bce1705 100644 (file)
@@ -272,8 +272,11 @@ define Build/jffs2
 endef
 
 define Build/kernel2minor
-       kernel2minor -k $@ -r $@.new $(1)
-       mv $@.new $@
+       $(eval temp_file := $(shell mktemp))
+       cp $@ $(temp_file)
+       kernel2minor -k $(temp_file) -r $(temp_file).new $(1)
+       mv $(temp_file).new $@
+       rm -f $(temp_file)
 endef
 
 define Build/kernel-bin