diff mbox series

[2/3] kconfig: define Lua in version 5.2 as default

Message ID 20241101110245.164173-3-oss@braunwarth.dev
State Changes Requested
Headers show
Series tree-wide: Kconfig update | expand

Commit Message

Daniel Braunwarth Nov. 1, 2024, 11:02 a.m. UTC
This removes the override in all of the defconfigs and makes the
defconfig buildable by default.

Signed-off-by: Daniel Braunwarth <oss@braunwarth.dev>
---
 Kconfig                                 | 2 +-
 configs/all_handlers_defconfig          | 1 -
 configs/bootloader_ebg_defconfig        | 1 -
 configs/bootloader_grub_defconfig       | 1 -
 configs/bootloader_uboot_defconfig      | 1 -
 configs/btrfs_defconfig                 | 1 -
 configs/cms1_defconfig                  | 1 -
 configs/cms_defconfig                   | 1 -
 configs/hawkbit_defconfig               | 1 -
 configs/mbedtls_defconfig               | 1 -
 configs/no_ssl_defconfig                | 1 -
 configs/nodwl_defconfig                 | 1 -
 configs/raspi_defconfig                 | 1 -
 configs/sha256_defconfig                | 1 -
 configs/suricatta_all_modules_defconfig | 1 -
 configs/suricatta_http_defconfig        | 1 -
 configs/swuforwarder_defconfig          | 1 -
 configs/test_defconfig                  | 1 -
 configs/with_ebg_defconfig              | 1 -
 configs/with_lua_handlers_defconfig     | 1 -
 configs/with_lua_nohandlers_defconfig   | 1 -
 configs/with_rdiff_defconfig            | 1 -
 configs/with_systemd_defconfig          | 1 -
 configs/with_ucfw_defconfig             | 1 -
 configs/without_libconfig_defconfig     | 1 -
 25 files changed, 1 insertion(+), 25 deletions(-)

Comments

Stefano Babic Nov. 1, 2024, 12:59 p.m. UTC | #1
Hi Daniel,

On 11/1/24 12:02, Daniel Braunwarth wrote:
> This removes the override in all of the defconfigs and makes the
> defconfig buildable by default.
>
> Signed-off-by: Daniel Braunwarth <oss@braunwarth.dev>
> ---
>   Kconfig                                 | 2 +-
>   configs/all_handlers_defconfig          | 1 -
>   configs/bootloader_ebg_defconfig        | 1 -
>   configs/bootloader_grub_defconfig       | 1 -
>   configs/bootloader_uboot_defconfig      | 1 -
>   configs/btrfs_defconfig                 | 1 -
>   configs/cms1_defconfig                  | 1 -
>   configs/cms_defconfig                   | 1 -
>   configs/hawkbit_defconfig               | 1 -
>   configs/mbedtls_defconfig               | 1 -
>   configs/no_ssl_defconfig                | 1 -
>   configs/nodwl_defconfig                 | 1 -
>   configs/raspi_defconfig                 | 1 -
>   configs/sha256_defconfig                | 1 -
>   configs/suricatta_all_modules_defconfig | 1 -
>   configs/suricatta_http_defconfig        | 1 -
>   configs/swuforwarder_defconfig          | 1 -
>   configs/test_defconfig                  | 1 -
>   configs/with_ebg_defconfig              | 1 -
>   configs/with_lua_handlers_defconfig     | 1 -
>   configs/with_lua_nohandlers_defconfig   | 1 -
>   configs/with_rdiff_defconfig            | 1 -
>   configs/with_systemd_defconfig          | 1 -
>   configs/with_ucfw_defconfig             | 1 -
>   configs/without_libconfig_defconfig     | 1 -
>   25 files changed, 1 insertion(+), 25 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index c09413c..51529ba 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -248,7 +248,7 @@ comment "Lua support needs a Lua interpreter"
>
>   config LUAPKG
>   	string "Lua pkg-config name"
> -	default "lua"
> +	default "lua5.2"
>   	depends on LUA

This is fine in a standard Linux distro, but it breaks build under OE.
Distros has distinct packages for each Lua version, resulting in 5.2,
5.3, 5.4 and luajit-5.1. But on OE, there is just oner version for a
specific Yocto's version, and it is identified with Lua. If this changes
get in, each build in OE even from dunfell is broken, because the only
Lua available is 5.3+.

The default "lua" here is unaware of the version, and bitbake can just
pick up the only available version.

Best regards,
Stefano

>   	help
>   	  Which pkg-config package supplies the Lua API.
> diff --git a/configs/all_handlers_defconfig b/configs/all_handlers_defconfig
> index 784a449..2bc29f4 100644
> --- a/configs/all_handlers_defconfig
> +++ b/configs/all_handlers_defconfig
> @@ -1,7 +1,6 @@
>   # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_SURICATTA=y
> diff --git a/configs/bootloader_ebg_defconfig b/configs/bootloader_ebg_defconfig
> index ad816ab..6aae668 100644
> --- a/configs/bootloader_ebg_defconfig
> +++ b/configs/bootloader_ebg_defconfig
> @@ -5,7 +5,6 @@ CONFIG_HW_COMPATIBILITY=y
>   CONFIG_HW_COMPATIBILITY_FILE="tests/etc/hwrevision"
>   CONFIG_SW_VERSIONS_FILE="tests/etc/sw-versions"
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_BOOTLOADER_EBG=y
>   CONFIG_DOWNLOAD=y
> diff --git a/configs/bootloader_grub_defconfig b/configs/bootloader_grub_defconfig
> index b7b23ff..118e473 100644
> --- a/configs/bootloader_grub_defconfig
> +++ b/configs/bootloader_grub_defconfig
> @@ -5,7 +5,6 @@ CONFIG_HW_COMPATIBILITY=y
>   CONFIG_HW_COMPATIBILITY_FILE="tests/etc/hwrevision"
>   CONFIG_SW_VERSIONS_FILE="tests/etc/sw-versions"
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_BOOTLOADER_GRUB=y
>   CONFIG_DOWNLOAD=y
> diff --git a/configs/bootloader_uboot_defconfig b/configs/bootloader_uboot_defconfig
> index 489e646..3ab816a 100644
> --- a/configs/bootloader_uboot_defconfig
> +++ b/configs/bootloader_uboot_defconfig
> @@ -5,7 +5,6 @@ CONFIG_HW_COMPATIBILITY=y
>   CONFIG_HW_COMPATIBILITY_FILE="tests/etc/hwrevision"
>   CONFIG_SW_VERSIONS_FILE="tests/etc/sw-versions"
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/btrfs_defconfig b/configs/btrfs_defconfig
> index 10ca37c..4244864 100644
> --- a/configs/btrfs_defconfig
> +++ b/configs/btrfs_defconfig
> @@ -1,7 +1,6 @@
>   # SPDX-FileCopyrightText: 2023 Stefano Babic <stefano.babic@swupdate.org>
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_UBOOT=y
>   CONFIG_BOOTLOADER_DEFAULT_NONE=y
> diff --git a/configs/cms1_defconfig b/configs/cms1_defconfig
> index 88891e2..32188e6 100644
> --- a/configs/cms1_defconfig
> +++ b/configs/cms1_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/cms_defconfig b/configs/cms_defconfig
> index 2a5a73a..887cf13 100644
> --- a/configs/cms_defconfig
> +++ b/configs/cms_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/hawkbit_defconfig b/configs/hawkbit_defconfig
> index 5f9f085..38ed2f1 100644
> --- a/configs/hawkbit_defconfig
> +++ b/configs/hawkbit_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_SURICATTA=y
> diff --git a/configs/mbedtls_defconfig b/configs/mbedtls_defconfig
> index 35e782a..62662e0 100644
> --- a/configs/mbedtls_defconfig
> +++ b/configs/mbedtls_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/no_ssl_defconfig b/configs/no_ssl_defconfig
> index 680a4e4..c4a7b40 100644
> --- a/configs/no_ssl_defconfig
> +++ b/configs/no_ssl_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/nodwl_defconfig b/configs/nodwl_defconfig
> index 2ebf2e7..e4d0483 100644
> --- a/configs/nodwl_defconfig
> +++ b/configs/nodwl_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_WEBSERVER=y
>   CONFIG_MONGOOSESSL=y
> diff --git a/configs/raspi_defconfig b/configs/raspi_defconfig
> index 52f0c9b..6ad78af 100644
> --- a/configs/raspi_defconfig
> +++ b/configs/raspi_defconfig
> @@ -1,7 +1,6 @@
>   # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
>   CONFIG_MONGOOSESSL=y
> diff --git a/configs/sha256_defconfig b/configs/sha256_defconfig
> index 2f45868..04cd2eb 100644
> --- a/configs/sha256_defconfig
> +++ b/configs/sha256_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/suricatta_all_modules_defconfig b/configs/suricatta_all_modules_defconfig
> index 0846aca..b12c944 100644
> --- a/configs/suricatta_all_modules_defconfig
> +++ b/configs/suricatta_all_modules_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_SYSTEMD=y
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_SURICATTA=y
> diff --git a/configs/suricatta_http_defconfig b/configs/suricatta_http_defconfig
> index d438d5d..3026b4e 100644
> --- a/configs/suricatta_http_defconfig
> +++ b/configs/suricatta_http_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_SYSTEMD=y
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_SURICATTA=y
> diff --git a/configs/swuforwarder_defconfig b/configs/swuforwarder_defconfig
> index b027b7e..d4c6721 100644
> --- a/configs/swuforwarder_defconfig
> +++ b/configs/swuforwarder_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_SURICATTA=y
> diff --git a/configs/test_defconfig b/configs/test_defconfig
> index 3eb6625..ac8fff6 100644
> --- a/configs/test_defconfig
> +++ b/configs/test_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/with_ebg_defconfig b/configs/with_ebg_defconfig
> index 9951a10..d4ad997 100644
> --- a/configs/with_ebg_defconfig
> +++ b/configs/with_ebg_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_BOOTLOADER_EBG=y
>   CONFIG_DOWNLOAD=y
> diff --git a/configs/with_lua_handlers_defconfig b/configs/with_lua_handlers_defconfig
> index c9647ef..7b3a49e 100644
> --- a/configs/with_lua_handlers_defconfig
> +++ b/configs/with_lua_handlers_defconfig
> @@ -1,7 +1,6 @@
>   # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/with_lua_nohandlers_defconfig b/configs/with_lua_nohandlers_defconfig
> index 2f9cb01..28040eb 100644
> --- a/configs/with_lua_nohandlers_defconfig
> +++ b/configs/with_lua_nohandlers_defconfig
> @@ -1,7 +1,6 @@
>   # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/with_rdiff_defconfig b/configs/with_rdiff_defconfig
> index 8f04f37..4ada36d 100644
> --- a/configs/with_rdiff_defconfig
> +++ b/configs/with_rdiff_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/with_systemd_defconfig b/configs/with_systemd_defconfig
> index c82fd53..ec0164b 100644
> --- a/configs/with_systemd_defconfig
> +++ b/configs/with_systemd_defconfig
> @@ -3,7 +3,6 @@
>   CONFIG_SYSTEMD=y
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
> diff --git a/configs/with_ucfw_defconfig b/configs/with_ucfw_defconfig
> index 83b6a6f..cd2dc7c 100644
> --- a/configs/with_ucfw_defconfig
> +++ b/configs/with_ucfw_defconfig
> @@ -2,7 +2,6 @@
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
>   # CONFIG_MTD is not set
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_SURICATTA=y
> diff --git a/configs/without_libconfig_defconfig b/configs/without_libconfig_defconfig
> index 68ca7f7..26f7c5a 100644
> --- a/configs/without_libconfig_defconfig
> +++ b/configs/without_libconfig_defconfig
> @@ -1,7 +1,6 @@
>   # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
>   # SPDX-License-Identifier: CC0-1.0
>   CONFIG_HW_COMPATIBILITY=y
> -CONFIG_LUAPKG="lua5.2"
>   CONFIG_EXTRA_CFLAGS="-g"
>   CONFIG_DOWNLOAD=y
>   CONFIG_WEBSERVER=y
Daniel Braunwarth Nov. 1, 2024, 1:12 p.m. UTC | #2
Hi Stefano

On 01.11.24 13:59, Stefano Babic wrote:
> This is fine in a standard Linux distro, but it breaks build under OE.
> Distros has distinct packages for each Lua version, resulting in 5.2,
> 5.3, 5.4 and luajit-5.1. But on OE, there is just oner version for a
> specific Yocto's version, and it is identified with Lua. If this changes
> get in, each build in OE even from dunfell is broken, because the only
> Lua available is 5.3+.
> 
> The default "lua" here is unaware of the version, and bitbake can just
> pick up the only available version.

OK. I'm not really a Yocto expert. I was only testing this with my 
Debian based development container.

There is no way to make the default configuration works for Yocto and 
standard distros as far as I understood, right?

Regards
Daniel
Stefano Babic Nov. 1, 2024, 1:42 p.m. UTC | #3
On 11/1/24 14:12, Daniel Braunwarth wrote:
> Hi Stefano
>
> On 01.11.24 13:59, Stefano Babic wrote:
>> This is fine in a standard Linux distro, but it breaks build under OE.
>> Distros has distinct packages for each Lua version, resulting in 5.2,
>> 5.3, 5.4 and luajit-5.1. But on OE, there is just oner version for a
>> specific Yocto's version, and it is identified with Lua. If this changes
>> get in, each build in OE even from dunfell is broken, because the only
>> Lua available is 5.3+.
>>
>> The default "lua" here is unaware of the version, and bitbake can just
>> pick up the only available version.
>
> OK. I'm not really a Yocto expert. I was only testing this with my
> Debian based development container.
>
> There is no way to make the default configuration works for Yocto and
> standard distros as far as I understood, right?
>

I haven't found - there should be an upper "lua" package in Debian that
default installs the last one, like this is done for rust, gcc, cpp,
etc. When we apt gcc, it works because one version is picked up, but
there is no default for lua (and "apt-get install lua" does not work).
Such a package had solved this issue here.

Best regards,
Stefano
Daniel Braunwarth Nov. 1, 2024, 2:37 p.m. UTC | #4
On 01.11.24 14:42, Stefano Babic wrote:
> On 11/1/24 14:12, Daniel Braunwarth wrote:
>> Hi Stefano
>>
>> On 01.11.24 13:59, Stefano Babic wrote:
>>> This is fine in a standard Linux distro, but it breaks build under OE.
>>> Distros has distinct packages for each Lua version, resulting in 5.2,
>>> 5.3, 5.4 and luajit-5.1. But on OE, there is just oner version for a
>>> specific Yocto's version, and it is identified with Lua. If this changes
>>> get in, each build in OE even from dunfell is broken, because the only
>>> Lua available is 5.3+.
>>>
>>> The default "lua" here is unaware of the version, and bitbake can just
>>> pick up the only available version.
>>
>> OK. I'm not really a Yocto expert. I was only testing this with my
>> Debian based development container.
>>
>> There is no way to make the default configuration works for Yocto and
>> standard distros as far as I understood, right?
>>
> 
> I haven't found - there should be an upper "lua" package in Debian that
> default installs the last one, like this is done for rust, gcc, cpp,
> etc. When we apt gcc, it works because one version is picked up, but
> there is no default for lua (and "apt-get install lua" does not work).
> Such a package had solved this issue here.
> 

Mh. I found an Debian issue from 2014 where this is requested without 
any response.

Maybe we can workaround this issue with something like this:
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -88,9 +88,9 @@ endif

  # Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
  define pkg_check_modules
-$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
-$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
-$(1)_LDLIBS := $(patsubst -l%,%,$(shell $(PKG_CONFIG) 
$(PKG_CONFIG_FLAGS) --libs-only-l $(2)))
+$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --exists $(2) 
&& $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
+$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --exists $(2) && 
$(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
+$(1)_LDLIBS := $(patsubst -l%,%,$(shell $(PKG_CONFIG) 
$(PKG_CONFIG_FLAGS) --exists $(2) && $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) 
--libs-only-l $(2)))
  endef

  ifneq ($(CONFIG_EXTRA_CFLAGS),)
@@ -110,7 +110,11 @@ LDLIBS += pthread ubootenv json-c
  # lua
  ifneq ($(CONFIG_LUA),)
  LDFLAGS_swupdate += -Wl,-E
+# First try to find "lua". If this fails, use whatever is defined in 
CONFIG_LUAPKG
+$(eval $(call pkg_check_modules, LUABUILD, lua))
+ifeq ($(LUABUILD_CFLAGS)$(LUABUILD_LIBS)$(LUABUILD_LDLIBS),)
  $(eval $(call pkg_check_modules, LUABUILD, ${CONFIG_LUAPKG}))
+endif
  KBUILD_CFLAGS += $(LUABUILD_CFLAGS)
  KBUILD_LIBS += $(LUABUILD_LIBS)
  LDLIBS += $(LUABUILD_LDLIBS)
--

Not really beautiful but it works.

What do you think?


Regards
Daniel
Stefano Babic Nov. 2, 2024, 6:58 p.m. UTC | #5
Hi Daniel,

On 01.11.24 15:37, Daniel Braunwarth wrote:
> On 01.11.24 14:42, Stefano Babic wrote:
>> On 11/1/24 14:12, Daniel Braunwarth wrote:
>>> Hi Stefano
>>>
>>> On 01.11.24 13:59, Stefano Babic wrote:
>>>> This is fine in a standard Linux distro, but it breaks build under OE.
>>>> Distros has distinct packages for each Lua version, resulting in 5.2,
>>>> 5.3, 5.4 and luajit-5.1. But on OE, there is just oner version for a
>>>> specific Yocto's version, and it is identified with Lua. If this
>>>> changes
>>>> get in, each build in OE even from dunfell is broken, because the only
>>>> Lua available is 5.3+.
>>>>
>>>> The default "lua" here is unaware of the version, and bitbake can just
>>>> pick up the only available version.
>>>
>>> OK. I'm not really a Yocto expert. I was only testing this with my
>>> Debian based development container.
>>>
>>> There is no way to make the default configuration works for Yocto and
>>> standard distros as far as I understood, right?
>>>
>>
>> I haven't found - there should be an upper "lua" package in Debian that
>> default installs the last one, like this is done for rust, gcc, cpp,
>> etc. When we apt gcc, it works because one version is picked up, but
>> there is no default for lua (and "apt-get install lua" does not work).
>> Such a package had solved this issue here.
>>
>
> Mh. I found an Debian issue from 2014 where this is requested without
> any response.
>
> Maybe we can workaround this issue with something like this:
> --- a/Makefile.flags
> +++ b/Makefile.flags
> @@ -88,9 +88,9 @@ endif
>
>   # Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
>   define pkg_check_modules
> -$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
> -$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
> -$(1)_LDLIBS := $(patsubst -l%,%,$(shell $(PKG_CONFIG)
> $(PKG_CONFIG_FLAGS) --libs-only-l $(2)))
> +$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --exists $(2)
> && $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
> +$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --exists $(2) &&
> $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
> +$(1)_LDLIBS := $(patsubst -l%,%,$(shell $(PKG_CONFIG)
> $(PKG_CONFIG_FLAGS) --exists $(2) && $(PKG_CONFIG) $(PKG_CONFIG_FLAGS)
> --libs-only-l $(2)))
>   endef
>
>   ifneq ($(CONFIG_EXTRA_CFLAGS),)
> @@ -110,7 +110,11 @@ LDLIBS += pthread ubootenv json-c
>   # lua
>   ifneq ($(CONFIG_LUA),)
>   LDFLAGS_swupdate += -Wl,-E
> +# First try to find "lua". If this fails, use whatever is defined in
> CONFIG_LUAPKG
> +$(eval $(call pkg_check_modules, LUABUILD, lua))
> +ifeq ($(LUABUILD_CFLAGS)$(LUABUILD_LIBS)$(LUABUILD_LDLIBS),)
>   $(eval $(call pkg_check_modules, LUABUILD, ${CONFIG_LUAPKG}))
> +endif
>   KBUILD_CFLAGS += $(LUABUILD_CFLAGS)
>   KBUILD_LIBS += $(LUABUILD_LIBS)
>   LDLIBS += $(LUABUILD_LDLIBS)
> --
>
> Not really beautiful but it works.

...just look around to check if I could find another way, but I couldn't....

>
> What do you think?

Not so nice, but well, yes. I could merge it.

Regards,
Stefano

>
>
> Regards
> Daniel
>
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index c09413c..51529ba 100644
--- a/Kconfig
+++ b/Kconfig
@@ -248,7 +248,7 @@  comment "Lua support needs a Lua interpreter"
 
 config LUAPKG
 	string "Lua pkg-config name"
-	default "lua"
+	default "lua5.2"
 	depends on LUA
 	help
 	  Which pkg-config package supplies the Lua API.
diff --git a/configs/all_handlers_defconfig b/configs/all_handlers_defconfig
index 784a449..2bc29f4 100644
--- a/configs/all_handlers_defconfig
+++ b/configs/all_handlers_defconfig
@@ -1,7 +1,6 @@ 
 # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_SURICATTA=y
diff --git a/configs/bootloader_ebg_defconfig b/configs/bootloader_ebg_defconfig
index ad816ab..6aae668 100644
--- a/configs/bootloader_ebg_defconfig
+++ b/configs/bootloader_ebg_defconfig
@@ -5,7 +5,6 @@  CONFIG_HW_COMPATIBILITY=y
 CONFIG_HW_COMPATIBILITY_FILE="tests/etc/hwrevision"
 CONFIG_SW_VERSIONS_FILE="tests/etc/sw-versions"
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_BOOTLOADER_EBG=y
 CONFIG_DOWNLOAD=y
diff --git a/configs/bootloader_grub_defconfig b/configs/bootloader_grub_defconfig
index b7b23ff..118e473 100644
--- a/configs/bootloader_grub_defconfig
+++ b/configs/bootloader_grub_defconfig
@@ -5,7 +5,6 @@  CONFIG_HW_COMPATIBILITY=y
 CONFIG_HW_COMPATIBILITY_FILE="tests/etc/hwrevision"
 CONFIG_SW_VERSIONS_FILE="tests/etc/sw-versions"
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_BOOTLOADER_GRUB=y
 CONFIG_DOWNLOAD=y
diff --git a/configs/bootloader_uboot_defconfig b/configs/bootloader_uboot_defconfig
index 489e646..3ab816a 100644
--- a/configs/bootloader_uboot_defconfig
+++ b/configs/bootloader_uboot_defconfig
@@ -5,7 +5,6 @@  CONFIG_HW_COMPATIBILITY=y
 CONFIG_HW_COMPATIBILITY_FILE="tests/etc/hwrevision"
 CONFIG_SW_VERSIONS_FILE="tests/etc/sw-versions"
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/btrfs_defconfig b/configs/btrfs_defconfig
index 10ca37c..4244864 100644
--- a/configs/btrfs_defconfig
+++ b/configs/btrfs_defconfig
@@ -1,7 +1,6 @@ 
 # SPDX-FileCopyrightText: 2023 Stefano Babic <stefano.babic@swupdate.org>
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_UBOOT=y
 CONFIG_BOOTLOADER_DEFAULT_NONE=y
diff --git a/configs/cms1_defconfig b/configs/cms1_defconfig
index 88891e2..32188e6 100644
--- a/configs/cms1_defconfig
+++ b/configs/cms1_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/cms_defconfig b/configs/cms_defconfig
index 2a5a73a..887cf13 100644
--- a/configs/cms_defconfig
+++ b/configs/cms_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/hawkbit_defconfig b/configs/hawkbit_defconfig
index 5f9f085..38ed2f1 100644
--- a/configs/hawkbit_defconfig
+++ b/configs/hawkbit_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_SURICATTA=y
diff --git a/configs/mbedtls_defconfig b/configs/mbedtls_defconfig
index 35e782a..62662e0 100644
--- a/configs/mbedtls_defconfig
+++ b/configs/mbedtls_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/no_ssl_defconfig b/configs/no_ssl_defconfig
index 680a4e4..c4a7b40 100644
--- a/configs/no_ssl_defconfig
+++ b/configs/no_ssl_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/nodwl_defconfig b/configs/nodwl_defconfig
index 2ebf2e7..e4d0483 100644
--- a/configs/nodwl_defconfig
+++ b/configs/nodwl_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_WEBSERVER=y
 CONFIG_MONGOOSESSL=y
diff --git a/configs/raspi_defconfig b/configs/raspi_defconfig
index 52f0c9b..6ad78af 100644
--- a/configs/raspi_defconfig
+++ b/configs/raspi_defconfig
@@ -1,7 +1,6 @@ 
 # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
 CONFIG_MONGOOSESSL=y
diff --git a/configs/sha256_defconfig b/configs/sha256_defconfig
index 2f45868..04cd2eb 100644
--- a/configs/sha256_defconfig
+++ b/configs/sha256_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/suricatta_all_modules_defconfig b/configs/suricatta_all_modules_defconfig
index 0846aca..b12c944 100644
--- a/configs/suricatta_all_modules_defconfig
+++ b/configs/suricatta_all_modules_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_SYSTEMD=y
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_SURICATTA=y
diff --git a/configs/suricatta_http_defconfig b/configs/suricatta_http_defconfig
index d438d5d..3026b4e 100644
--- a/configs/suricatta_http_defconfig
+++ b/configs/suricatta_http_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_SYSTEMD=y
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_SURICATTA=y
diff --git a/configs/swuforwarder_defconfig b/configs/swuforwarder_defconfig
index b027b7e..d4c6721 100644
--- a/configs/swuforwarder_defconfig
+++ b/configs/swuforwarder_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_SURICATTA=y
diff --git a/configs/test_defconfig b/configs/test_defconfig
index 3eb6625..ac8fff6 100644
--- a/configs/test_defconfig
+++ b/configs/test_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/with_ebg_defconfig b/configs/with_ebg_defconfig
index 9951a10..d4ad997 100644
--- a/configs/with_ebg_defconfig
+++ b/configs/with_ebg_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_BOOTLOADER_EBG=y
 CONFIG_DOWNLOAD=y
diff --git a/configs/with_lua_handlers_defconfig b/configs/with_lua_handlers_defconfig
index c9647ef..7b3a49e 100644
--- a/configs/with_lua_handlers_defconfig
+++ b/configs/with_lua_handlers_defconfig
@@ -1,7 +1,6 @@ 
 # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/with_lua_nohandlers_defconfig b/configs/with_lua_nohandlers_defconfig
index 2f9cb01..28040eb 100644
--- a/configs/with_lua_nohandlers_defconfig
+++ b/configs/with_lua_nohandlers_defconfig
@@ -1,7 +1,6 @@ 
 # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/with_rdiff_defconfig b/configs/with_rdiff_defconfig
index 8f04f37..4ada36d 100644
--- a/configs/with_rdiff_defconfig
+++ b/configs/with_rdiff_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/with_systemd_defconfig b/configs/with_systemd_defconfig
index c82fd53..ec0164b 100644
--- a/configs/with_systemd_defconfig
+++ b/configs/with_systemd_defconfig
@@ -3,7 +3,6 @@ 
 CONFIG_SYSTEMD=y
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y
diff --git a/configs/with_ucfw_defconfig b/configs/with_ucfw_defconfig
index 83b6a6f..cd2dc7c 100644
--- a/configs/with_ucfw_defconfig
+++ b/configs/with_ucfw_defconfig
@@ -2,7 +2,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_MTD is not set
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_SURICATTA=y
diff --git a/configs/without_libconfig_defconfig b/configs/without_libconfig_defconfig
index 68ca7f7..26f7c5a 100644
--- a/configs/without_libconfig_defconfig
+++ b/configs/without_libconfig_defconfig
@@ -1,7 +1,6 @@ 
 # SPDX-FileCopyrightText: 2021 Stefano Babic <stefano.babic@swupdate.org>
 # SPDX-License-Identifier: CC0-1.0
 CONFIG_HW_COMPATIBILITY=y
-CONFIG_LUAPKG="lua5.2"
 CONFIG_EXTRA_CFLAGS="-g"
 CONFIG_DOWNLOAD=y
 CONFIG_WEBSERVER=y