[3/5] image: Do not inherit multiarch

Message ID 20251001105929.3731537-4-anaumann@emlix.com
State RFC
Headers show
Series Improving multiarch support for arch-incompatible packages | expand

Commit Message

Andreas Naumann Oct. 1, 2025, 10:59 a.m. UTC
Images don't need multiarch functionality. Remove the inheritance.

In order to keep the bb2deb conversion function in scope for the image class,
move it to rootfs, which it inherits from.

Signed-off-by: Andreas Naumann <anaumann@emlix.com>
---
 meta/classes/image.bbclass     |  1 -
 meta/classes/multiarch.bbclass | 16 ----------------
 meta/classes/rootfs.bbclass    | 16 ++++++++++++++++
 3 files changed, 16 insertions(+), 17 deletions(-)

Comments

Jan Kiszka Oct. 2, 2025, 12:09 p.m. UTC | #1
On 01.10.25 12:59, 'Andreas Naumann' via isar-users wrote:
> Images don't need multiarch functionality. Remove the inheritance.
> 

Either you didn't test it, or the inheritance still comes implicitly
because it IS needed: isar_multiarch_packages

Jan

> In order to keep the bb2deb conversion function in scope for the image class,
> move it to rootfs, which it inherits from.
> 
> Signed-off-by: Andreas Naumann <anaumann@emlix.com>
> ---
>  meta/classes/image.bbclass     |  1 -
>  meta/classes/multiarch.bbclass | 16 ----------------
>  meta/classes/rootfs.bbclass    | 16 ++++++++++++++++
>  3 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 57e66632..354ec85e 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -62,7 +62,6 @@ DEPENDS += "${IMAGE_INSTALL}"
>  ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags --dirty --match 'v[0-9].[0-9]*'"
>  ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>  
> -inherit multiarch
>  inherit essential
>  
>  ROOTFSDIR = "${IMAGE_ROOTFS}"
> diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.bbclass
> index ae465aec..5b67d779 100644
> --- a/meta/classes/multiarch.bbclass
> +++ b/meta/classes/multiarch.bbclass
> @@ -101,19 +101,3 @@ python multiarch_virtclass_handler() {
>  }
>  addhandler multiarch_virtclass_handler
>  multiarch_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
> -
> -# function to convert bitbake targets to installable debian packages,
> -# e.g., "hello-compat" to "hello:i386".
> -def isar_multiarch_packages(var, d):
> -    bb_targets = (d.getVar(var) or '').split()
> -    packages = []
> -    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
> -    host_arch = d.getVar('HOST_ARCH')
> -    for t in bb_targets:
> -        if t.endswith('-compat') and compat_distro_arch is not None:
> -            packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)
> -        elif t.endswith('-native'):
> -            packages.append(t[:-len('-native')] + ':' + host_arch)
> -        else:
> -            packages.append(t)
> -    return ' '.join(packages)
> diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
> index 53e60a81..f60be99c 100644
> --- a/meta/classes/rootfs.bbclass
> +++ b/meta/classes/rootfs.bbclass
> @@ -632,3 +632,19 @@ python do_rootfs_install_setscene() {
>      sstate_setscene(d)
>  }
>  addtask do_rootfs_install_setscene
> +
> +# function to convert bitbake targets to installable debian packages,
> +# e.g., "hello-compat" to "hello:i386".
> +def isar_multiarch_packages(var, d):
> +    bb_targets = (d.getVar(var) or '').split()
> +    packages = []
> +    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
> +    host_arch = d.getVar('HOST_ARCH')
> +    for t in bb_targets:
> +        if t.endswith('-compat') and compat_distro_arch is not None:
> +            packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)
> +        elif t.endswith('-native'):
> +            packages.append(t[:-len('-native')] + ':' + host_arch)
> +        else:
> +            packages.append(t)
> +    return ' '.join(packages)
Andreas Naumann Oct. 2, 2025, 2:17 p.m. UTC | #2
Am 02.10.25 um 14:09 schrieb Jan Kiszka:
> On 01.10.25 12:59, 'Andreas Naumann' via isar-users wrote:
>> Images don't need multiarch functionality. Remove the inheritance.
>>
> Either you didn't test it, or the inheritance still comes implicitly
> because it IS needed: isar_multiarch_packages
>
> Jan

See below, I moved the function to rootfs.

Andreas


>> In order to keep the bb2deb conversion function in scope for the image class,
>> move it to rootfs, which it inherits from.
>>
>> Signed-off-by: Andreas Naumann <anaumann@emlix.com>
>> ---
>>   meta/classes/image.bbclass     |  1 -
>>   meta/classes/multiarch.bbclass | 16 ----------------
>>   meta/classes/rootfs.bbclass    | 16 ++++++++++++++++
>>   3 files changed, 16 insertions(+), 17 deletions(-)
>>
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index 57e66632..354ec85e 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -62,7 +62,6 @@ DEPENDS += "${IMAGE_INSTALL}"
>>   ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags --dirty --match 'v[0-9].[0-9]*'"
>>   ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>>   
>> -inherit multiarch
>>   inherit essential
>>   
>>   ROOTFSDIR = "${IMAGE_ROOTFS}"
>> diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.bbclass
>> index ae465aec..5b67d779 100644
>> --- a/meta/classes/multiarch.bbclass
>> +++ b/meta/classes/multiarch.bbclass
>> @@ -101,19 +101,3 @@ python multiarch_virtclass_handler() {
>>   }
>>   addhandler multiarch_virtclass_handler
>>   multiarch_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
>> -
>> -# function to convert bitbake targets to installable debian packages,
>> -# e.g., "hello-compat" to "hello:i386".
>> -def isar_multiarch_packages(var, d):
>> -    bb_targets = (d.getVar(var) or '').split()
>> -    packages = []
>> -    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
>> -    host_arch = d.getVar('HOST_ARCH')
>> -    for t in bb_targets:
>> -        if t.endswith('-compat') and compat_distro_arch is not None:
>> -            packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)
>> -        elif t.endswith('-native'):
>> -            packages.append(t[:-len('-native')] + ':' + host_arch)
>> -        else:
>> -            packages.append(t)
>> -    return ' '.join(packages)
>> diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
>> index 53e60a81..f60be99c 100644
>> --- a/meta/classes/rootfs.bbclass
>> +++ b/meta/classes/rootfs.bbclass
>> @@ -632,3 +632,19 @@ python do_rootfs_install_setscene() {
>>       sstate_setscene(d)
>>   }
>>   addtask do_rootfs_install_setscene
>> +
>> +# function to convert bitbake targets to installable debian packages,
>> +# e.g., "hello-compat" to "hello:i386".
>> +def isar_multiarch_packages(var, d):
>> +    bb_targets = (d.getVar(var) or '').split()
>> +    packages = []
>> +    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
>> +    host_arch = d.getVar('HOST_ARCH')
>> +    for t in bb_targets:
>> +        if t.endswith('-compat') and compat_distro_arch is not None:
>> +            packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)
>> +        elif t.endswith('-native'):
>> +            packages.append(t[:-len('-native')] + ':' + host_arch)
>> +        else:
>> +            packages.append(t)
>> +    return ' '.join(packages)
>
Jan Kiszka Oct. 2, 2025, 2:55 p.m. UTC | #3
On 02.10.25 16:17, Andreas Naumann wrote:
> 
> Am 02.10.25 um 14:09 schrieb Jan Kiszka:
>> On 01.10.25 12:59, 'Andreas Naumann' via isar-users wrote:
>>> Images don't need multiarch functionality. Remove the inheritance.
>>>
>> Either you didn't test it, or the inheritance still comes implicitly
>> because it IS needed: isar_multiarch_packages
>>
>> Jan
> 
> See below, I moved the function to rootfs.
> 

Then the description is highly misleading.

Jan

> 
> 
>>> In order to keep the bb2deb conversion function in scope for the
>>> image class,
>>> move it to rootfs, which it inherits from.
>>>
>>> Signed-off-by: Andreas Naumann <anaumann@emlix.com>
>>> ---
>>>   meta/classes/image.bbclass     |  1 -
>>>   meta/classes/multiarch.bbclass | 16 ----------------
>>>   meta/classes/rootfs.bbclass    | 16 ++++++++++++++++
>>>   3 files changed, 16 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>>> index 57e66632..354ec85e 100644
>>> --- a/meta/classes/image.bbclass
>>> +++ b/meta/classes/image.bbclass
>>> @@ -62,7 +62,6 @@ DEPENDS += "${IMAGE_INSTALL}"
>>>   ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags
>>> --dirty --match 'v[0-9].[0-9]*'"
>>>   ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>>>   -inherit multiarch
>>>   inherit essential
>>>     ROOTFSDIR = "${IMAGE_ROOTFS}"
>>> diff --git a/meta/classes/multiarch.bbclass b/meta/classes/
>>> multiarch.bbclass
>>> index ae465aec..5b67d779 100644
>>> --- a/meta/classes/multiarch.bbclass
>>> +++ b/meta/classes/multiarch.bbclass
>>> @@ -101,19 +101,3 @@ python multiarch_virtclass_handler() {
>>>   }
>>>   addhandler multiarch_virtclass_handler
>>>   multiarch_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
>>> -
>>> -# function to convert bitbake targets to installable debian packages,
>>> -# e.g., "hello-compat" to "hello:i386".
>>> -def isar_multiarch_packages(var, d):
>>> -    bb_targets = (d.getVar(var) or '').split()
>>> -    packages = []
>>> -    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
>>> -    host_arch = d.getVar('HOST_ARCH')
>>> -    for t in bb_targets:
>>> -        if t.endswith('-compat') and compat_distro_arch is not None:
>>> -            packages.append(t[:-len('-compat')] + ':' +
>>> compat_distro_arch)
>>> -        elif t.endswith('-native'):
>>> -            packages.append(t[:-len('-native')] + ':' + host_arch)
>>> -        else:
>>> -            packages.append(t)
>>> -    return ' '.join(packages)
>>> diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
>>> index 53e60a81..f60be99c 100644
>>> --- a/meta/classes/rootfs.bbclass
>>> +++ b/meta/classes/rootfs.bbclass
>>> @@ -632,3 +632,19 @@ python do_rootfs_install_setscene() {
>>>       sstate_setscene(d)
>>>   }
>>>   addtask do_rootfs_install_setscene
>>> +
>>> +# function to convert bitbake targets to installable debian packages,
>>> +# e.g., "hello-compat" to "hello:i386".
>>> +def isar_multiarch_packages(var, d):
>>> +    bb_targets = (d.getVar(var) or '').split()
>>> +    packages = []
>>> +    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
>>> +    host_arch = d.getVar('HOST_ARCH')
>>> +    for t in bb_targets:
>>> +        if t.endswith('-compat') and compat_distro_arch is not None:
>>> +            packages.append(t[:-len('-compat')] + ':' +
>>> compat_distro_arch)
>>> +        elif t.endswith('-native'):
>>> +            packages.append(t[:-len('-native')] + ':' + host_arch)
>>> +        else:
>>> +            packages.append(t)
>>> +    return ' '.join(packages)
>>
Andreas Naumann Oct. 6, 2025, 7:05 a.m. UTC | #4
Am 02.10.25 um 16:55 schrieb Jan Kiszka:
> On 02.10.25 16:17, Andreas Naumann wrote:
>> Am 02.10.25 um 14:09 schrieb Jan Kiszka:
>>> On 01.10.25 12:59, 'Andreas Naumann' via isar-users wrote:
>>>> Images don't need multiarch functionality. Remove the inheritance.
>>>>
>>> Either you didn't test it, or the inheritance still comes implicitly
>>> because it IS needed: isar_multiarch_packages
>>>
>>> Jan
>> See below, I moved the function to rootfs.
>>
> Then the description is highly misleading.

Ok, I'll change the description.
Would rootfs be an ok place for isar_multiarch_packages? I perceived it 
to be a helper more or less.

Andreas

> Jan
>
>>
>>>> In order to keep the bb2deb conversion function in scope for the
>>>> image class,
>>>> move it to rootfs, which it inherits from.
>>>>
>>>> Signed-off-by: Andreas Naumann <anaumann@emlix.com>
>>>> ---
>>>>    meta/classes/image.bbclass     |  1 -
>>>>    meta/classes/multiarch.bbclass | 16 ----------------
>>>>    meta/classes/rootfs.bbclass    | 16 ++++++++++++++++
>>>>    3 files changed, 16 insertions(+), 17 deletions(-)
>>>>
>>>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>>>> index 57e66632..354ec85e 100644
>>>> --- a/meta/classes/image.bbclass
>>>> +++ b/meta/classes/image.bbclass
>>>> @@ -62,7 +62,6 @@ DEPENDS += "${IMAGE_INSTALL}"
>>>>    ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags
>>>> --dirty --match 'v[0-9].[0-9]*'"
>>>>    ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>>>>    -inherit multiarch
>>>>    inherit essential
>>>>      ROOTFSDIR = "${IMAGE_ROOTFS}"
>>>> diff --git a/meta/classes/multiarch.bbclass b/meta/classes/
>>>> multiarch.bbclass
>>>> index ae465aec..5b67d779 100644
>>>> --- a/meta/classes/multiarch.bbclass
>>>> +++ b/meta/classes/multiarch.bbclass
>>>> @@ -101,19 +101,3 @@ python multiarch_virtclass_handler() {
>>>>    }
>>>>    addhandler multiarch_virtclass_handler
>>>>    multiarch_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
>>>> -
>>>> -# function to convert bitbake targets to installable debian packages,
>>>> -# e.g., "hello-compat" to "hello:i386".
>>>> -def isar_multiarch_packages(var, d):
>>>> -    bb_targets = (d.getVar(var) or '').split()
>>>> -    packages = []
>>>> -    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
>>>> -    host_arch = d.getVar('HOST_ARCH')
>>>> -    for t in bb_targets:
>>>> -        if t.endswith('-compat') and compat_distro_arch is not None:
>>>> -            packages.append(t[:-len('-compat')] + ':' +
>>>> compat_distro_arch)
>>>> -        elif t.endswith('-native'):
>>>> -            packages.append(t[:-len('-native')] + ':' + host_arch)
>>>> -        else:
>>>> -            packages.append(t)
>>>> -    return ' '.join(packages)
>>>> diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
>>>> index 53e60a81..f60be99c 100644
>>>> --- a/meta/classes/rootfs.bbclass
>>>> +++ b/meta/classes/rootfs.bbclass
>>>> @@ -632,3 +632,19 @@ python do_rootfs_install_setscene() {
>>>>        sstate_setscene(d)
>>>>    }
>>>>    addtask do_rootfs_install_setscene
>>>> +
>>>> +# function to convert bitbake targets to installable debian packages,
>>>> +# e.g., "hello-compat" to "hello:i386".
>>>> +def isar_multiarch_packages(var, d):
>>>> +    bb_targets = (d.getVar(var) or '').split()
>>>> +    packages = []
>>>> +    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
>>>> +    host_arch = d.getVar('HOST_ARCH')
>>>> +    for t in bb_targets:
>>>> +        if t.endswith('-compat') and compat_distro_arch is not None:
>>>> +            packages.append(t[:-len('-compat')] + ':' +
>>>> compat_distro_arch)
>>>> +        elif t.endswith('-native'):
>>>> +            packages.append(t[:-len('-native')] + ':' + host_arch)
>>>> +        else:
>>>> +            packages.append(t)
>>>> +    return ' '.join(packages)
>

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 57e66632..354ec85e 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -62,7 +62,6 @@  DEPENDS += "${IMAGE_INSTALL}"
 ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags --dirty --match 'v[0-9].[0-9]*'"
 ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
 
-inherit multiarch
 inherit essential
 
 ROOTFSDIR = "${IMAGE_ROOTFS}"
diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.bbclass
index ae465aec..5b67d779 100644
--- a/meta/classes/multiarch.bbclass
+++ b/meta/classes/multiarch.bbclass
@@ -101,19 +101,3 @@  python multiarch_virtclass_handler() {
 }
 addhandler multiarch_virtclass_handler
 multiarch_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
-
-# function to convert bitbake targets to installable debian packages,
-# e.g., "hello-compat" to "hello:i386".
-def isar_multiarch_packages(var, d):
-    bb_targets = (d.getVar(var) or '').split()
-    packages = []
-    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
-    host_arch = d.getVar('HOST_ARCH')
-    for t in bb_targets:
-        if t.endswith('-compat') and compat_distro_arch is not None:
-            packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)
-        elif t.endswith('-native'):
-            packages.append(t[:-len('-native')] + ':' + host_arch)
-        else:
-            packages.append(t)
-    return ' '.join(packages)
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 53e60a81..f60be99c 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -632,3 +632,19 @@  python do_rootfs_install_setscene() {
     sstate_setscene(d)
 }
 addtask do_rootfs_install_setscene
+
+# function to convert bitbake targets to installable debian packages,
+# e.g., "hello-compat" to "hello:i386".
+def isar_multiarch_packages(var, d):
+    bb_targets = (d.getVar(var) or '').split()
+    packages = []
+    compat_distro_arch = d.getVar('COMPAT_DISTRO_ARCH')
+    host_arch = d.getVar('HOST_ARCH')
+    for t in bb_targets:
+        if t.endswith('-compat') and compat_distro_arch is not None:
+            packages.append(t[:-len('-compat')] + ':' + compat_distro_arch)
+        elif t.endswith('-native'):
+            packages.append(t[:-len('-native')] + ':' + host_arch)
+        else:
+            packages.append(t)
+    return ' '.join(packages)