diff mbox series

[kirkstone] kernel.bbclass: check, if directory exists before removing empty module directory

Message ID 20240411080548.264541-1-heiko.thole@entwicklung.eq-3.de
State Rejected
Delegated to: Steve Sakoman
Headers show
Series [kirkstone] kernel.bbclass: check, if directory exists before removing empty module directory | expand

Commit Message

Heiko Thole April 11, 2024, 8:05 a.m. UTC
If the kernel folder does not exist, find will result in an error.
This can occur if the kernel has no modules but, for example, custom modules are created.

Add check before deleting.

Signed-off-by: Heiko Thole <heiko.thole@entwicklung.eq-3.de>
---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.41.0

eQ-3 Entwicklung GmbH, Maiburger Str. 36, 26789 Leer
Geschäftsführer: Prof. Heinz-G. Redeker
Registergericht: Amtsgericht Aurich, HRB 110388
eQ-3 AG, Maiburger Str. 29, 26789 Leer
Vorstand: Prof. Heinz-G. Redeker (Vorsitzender), Helga Redeker
Vorsitzende des Aufsichtsrats: Irmgard Keplin
Registergericht: Amtsgericht Aurich, HRB 200335

Comments

Quentin Schulz April 11, 2024, 8:16 a.m. UTC | #1
Hi Heiko,

On 4/11/24 10:05, Heiko via lists.openembedded.org wrote:
> [You don't often get email from heiko.thole=entwicklung.eq-3.de@lists.openembedded.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> If the kernel folder does not exist, find will result in an error.
> This can occur if the kernel has no modules but, for example, custom modules are created.
> 
> Add check before deleting.
> 
> Signed-off-by: Heiko Thole <heiko.thole@entwicklung.eq-3.de>
> ---
>   meta/classes/kernel.bbclass | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index dbd89057f3..988a489396 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -452,7 +452,7 @@ kernel_do_install() {
>                  rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>                  rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
>                  # Remove empty module directories to prevent QA issues
> -               find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
> +               [ -d "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" ] && find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete

What about using

rm --dir --force 
"${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel"

instead?

        -f, --force
               ignore nonexistent files and arguments, never prompt

        -d, --dir
               remove empty directories

Cheers,
Quentin
Heiko Thole April 11, 2024, 8:32 a.m. UTC | #2
Hi Quentin,

On Thu, Apr 11, 2024 at 10:16 AM, Quentin Schulz wrote:

> 
> rm --dir --force
> "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel"
> 
> instead?
> 
> -f, --force
> ignore nonexistent files and arguments, never prompt
> 
> -d, --dir
> remove empty directories
> 
> Cheers,
> Quentin

rm --dir --force does not work if the directory exists:

rm: cannot remove '/yocto/source/build-cm4/tmp/work/raspberrypi4_64-poky-linux/linux-yocto/6.6.25+git-r0/image/lib/modules/6.6.25-hcu/kernel': Directory not empty

Best regards
Heiko
Steve Sakoman April 11, 2024, 1:26 p.m. UTC | #3
This patch doesn't apply for me:

Applying: kernel.bbclass: check, if directory exists before removing
empty module directory
Using index info to reconstruct a base tree...
error: patch failed: meta/classes/kernel.bbclass:452
error: meta/classes/kernel.bbclass: patch does not apply
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
Patch failed at 0001 kernel.bbclass: check, if directory exists before
removing empty module directory

Steve

On Thu, Apr 11, 2024 at 1:06 AM Heiko <heiko.thole@entwicklung.eq-3.de> wrote:
>
> If the kernel folder does not exist, find will result in an error.
> This can occur if the kernel has no modules but, for example, custom modules are created.
>
> Add check before deleting.
>
> Signed-off-by: Heiko Thole <heiko.thole@entwicklung.eq-3.de>
> ---
>  meta/classes/kernel.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index dbd89057f3..988a489396 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -452,7 +452,7 @@ kernel_do_install() {
>                 rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>                 rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
>                 # Remove empty module directories to prevent QA issues
> -               find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
> +               [ -d "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" ] && find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
>         else
>                 bbnote "no modules to install"
>         fi
> --
> 2.41.0
>
> eQ-3 Entwicklung GmbH, Maiburger Str. 36, 26789 Leer
> Geschäftsführer: Prof. Heinz-G. Redeker
> Registergericht: Amtsgericht Aurich, HRB 110388
> eQ-3 AG, Maiburger Str. 29, 26789 Leer
> Vorstand: Prof. Heinz-G. Redeker (Vorsitzender), Helga Redeker
> Vorsitzende des Aufsichtsrats: Irmgard Keplin
> Registergericht: Amtsgericht Aurich, HRB 200335
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#198117): https://lists.openembedded.org/g/openembedded-core/message/198117
> Mute This Topic: https://lists.openembedded.org/mt/105458549/3620601
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [steve@sakoman.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Heiko Thole April 11, 2024, 1:40 p.m. UTC | #4
Hi Steve,

I created the patch as described here: https://docs.yoctoproject.org/4.0.17/contributor-guide/submit-changes.html#contributing-through-mailing-lists-why-not-using-web-based-workflows

Only one line has been changed. Is it possible for you to change it?

Best regards,
Heiko
Matthias Schiffer April 12, 2024, 9:03 a.m. UTC | #5
On Thu, 2024-04-11 at 06:40 -0700, Heiko wrote:
> 
>  Hi Steve,
> 
> I created the patch as described
> here: https://docs.yoctoproject.org/4.0.17/contributor-guide/submit-changes.html#contributing-thro
> ugh-mailing-lists-why-not-using-web-based-workflows
> 
> Only one line has been changed. Is it possible for you to change it?
> 
> Best regards,
> Heiko


Thanks for sending the patch, I was about to submit a very similar one just yesterday. Note that
this should be fixed in OE-core master/scarthgap first, then backported to kirkstone.

The issue with your patch is that it uses spaces instead of tabs for indentation, which doesn't
match the original file. This may have happenen if you copied the patch content from a terminal, or
due to your mail user agent - issues like this are unfortunately common, which is why `git send-
email` is the recommended way to submit patches.

Best regards,
Matthias
Heiko Thole April 12, 2024, 9:52 a.m. UTC | #6
I used " git send- email". I don`t know, why the tabs were replaced.

I have attached the patch with tabs. (Or do I have to create a new post?)

Best regards,
Heiko
Steve Sakoman April 12, 2024, 12:18 p.m. UTC | #7
On Fri, Apr 12, 2024 at 2:52 AM Heiko <heiko.thole@entwicklung.eq-3.de> wrote:
>
> I used "git send-email". I don`t know, why the tabs were replaced.
>
> I have attached the patch with tabs. (Or do I have to create a new post?)

You should send a new patch targeted for the master branch since we
need to fix this there first before I can backport it to kirkstone.

Thanks!

Steve
diff mbox series

Patch

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index dbd89057f3..988a489396 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -452,7 +452,7 @@  kernel_do_install() {
                rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
                rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
                # Remove empty module directories to prevent QA issues
-               find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
+               [ -d "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" ] && find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
        else
                bbnote "no modules to install"
        fi