Tiny Core Linux

Tiny Core Base => TCB Bugs => Topic started by: GNUser on March 24, 2025, 03:59:07 PM

Title: bug in depends-on.sh (and fix)
Post by: GNUser on March 24, 2025, 03:59:07 PM
I found a bug in depends-on.sh:

Code: [Select]
$ depends-on.sh unbound
getdns.tcz
unbound-dev.tcz

The output is incorrect because prosody.tcz depends on unbound.tcz, so should appear in the command's output.

I found many other instances of unexpected behavior. Just one more example:
Code: [Select]
$ depends-on.sh protobuf-c

[no hits]
That's also incorrect. protobuf-c-dev.tcz should have been a hit because it depends on protobuf-c.tcz.

After close inspection of dep.db and much head-scratching, I discovered the problem: The default (exact match) searches fail when the lines with expected matches have trailing whitespace. Brutal.

There are at least two ways to fix this:
1. Make the logic in awk more complex so that exact searches can deal with trailing whitespace in dep.db
2. Remove trailing whitespace from dep.db before searching

Option #2 seems more obvious and straight-forward, so I went with that:
https://github.com/tinycorelinux/Core-scripts/pull/75/commits/8e84f192359af77ab7806389768d46897a0b57bc




Title: Re: bug in depends-on.sh (and fix)
Post by: Rich on March 24, 2025, 05:40:10 PM
Hi GNUser
I just checked TC16 x86_64 dep.db:
Code: [Select]
rich@tcbox:~$ grep -E ".* +$" dep.db
rich@tcbox:~$
I couldn't find any trailing whitespace.
Title: Re: bug in depends-on.sh (and fix)
Post by: GNUser on March 24, 2025, 07:22:49 PM
Hi Rich. Wow, my head is spinning. You're right!

I use a local mirror. It's exactly like the official repo except that I add a few custom extensions into it and have a shell script that adds my custom extensions to the local mirror's metadata files (e.g., dep.db). It seems my shell script is the culprit--it must be inadvertently adding trailing whitespace :(

Sorry for the noise.
Title: Re: bug in depends-on.sh (and fix)
Post by: Rich on March 24, 2025, 07:57:07 PM
Hi GNUser
Hi Rich. Wow, my head is spinning. You're right! ...

Well, I never doubted you for a second. That's why I triple checked by also
examining dep.db in the TC15 and TC14 repos before saying anything. :)
Title: Re: bug in depends-on.sh (and fix)
Post by: gadget42 on March 25, 2025, 02:27:24 PM
@GNUser, would be interested in your final disposition on this when you get it sorted. Thanks!
Title: Re: bug in depends-on.sh (and fix)
Post by: GNUser on March 25, 2025, 03:44:34 PM
Hi gadget42. Here's my final assessment:

1. trailing whitespace in dep.db does cause a problem for depends-on.sh
2. the official repo's dep.db does not contain trailing whitespace
3. my local repo's dep.db did contain trailing whitespace because of a bug in one of my shell scripts, which I have fixed