Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: GNUser on February 28, 2024, 01:25:23 PM

Title: would /usr merge be advantageous for TCL in any way?
Post by: GNUser on February 28, 2024, 01:25:23 PM
Several *nixes (Debian, Devuan, Arch, Fedora, Solaris, possibly others) either have already implemented or will soon be implementing "merged /usr" where /{bin,sbin,lib,lib64} are just symlinks to /usr/{bin,sbin,lib,lib64}

Supposed advantages of this filesystem hierarchy are outlined here (https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/).

I know that in TCL there is the convention of /usr/local/{bin,sbin,lib} being reserved for extensions. A merged /usr would not interfere with this.

Would a merged /usr in TCL be more trouble than it's worth? More elegant but not actually beneficial? No trouble to implement and potentially beneficial in the long term?

I'd be curious to know the TCL developers' opinion about merged /usr. I admire you guys and greatly value your opinions because they have proven to lead to the best result (Tiny Core Linux).
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: mocore on February 28, 2024, 01:38:39 PM

Supposed advantages of this filesystem hierarchy are outlined here (https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/).
related (coincidentally i was just reading about this topic @ )
https://www.devuan.org/os/announce/excalibur-usrmerge-announce-2024-02-20.html
... i guess Debian adaptation would affect any future? dcore.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: GNUser on February 28, 2024, 08:32:15 PM
FYI - I remastered TCL15's corepure64.gz with merged /usr as an experiment. Steps were completely naive:
1. Put all of /bin contents into /usr/bin. Then repeat for /sbin and /lib
2. Delete the now-empty /bin, /sbin, and /lib directories
3. In terminal:
Code: [Select]
# for i in bin sbin lib; do ln -s /usr/$i /$i; done

I'm happy to report that a remaster created in this way 100% Just Works.

Not that I'd use such a TCL mod as daily driver, of course--only vanilla TCL is acceptable to me. I just wanted you guys to know that if it would be advantageous for the TCL project to jump on this merged /usr bandwagon at some point in the future, it would be a trivial change with no breakage as far as I can tell.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: patrikg on February 28, 2024, 11:38:05 PM
Funny facts about this issue you can see this part of video with Rob Landley explain the funny way why!!

https://youtu.be/Sk9TatW9ino?t=4768 (https://youtu.be/Sk9TatW9ino?t=4768)
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: curaga on February 28, 2024, 11:52:49 PM
My opinion is that it doesn't matter either way for TC. No advantages and no downsides, and as you found, symlinking just works.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: gadget42 on February 29, 2024, 12:12:59 AM
i would like to see all the previously written documentation/textbooks/tutorials/etc stay as accurate and relevant as possible for as long as possible
(and in my honest humble dinasour opinion the systemd/windowsification crowd believes it cannot sever these links fast enough to suit whatever change-agents they serve)
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: patrikg on February 29, 2024, 12:41:20 AM
I like this idea a lot, you can then remove some search path's, in the PATH.

To throw some wood on the fire, so how do we approach the /opt directory.
Maybe we should also talk a little about it too.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: polikuo on February 29, 2024, 01:03:11 AM
This idea is new to me and I like it.
I write awk script a lot, it annoys me that the paths across distros are not consistent.
Just a quick example to show you all.

Normally, you'd think finding the path with env would be simple enough
Code: [Select]
#/usr/bin/env awk
However, the proper way to invoke an awk script is actually (note the '-f' flag)
Code: [Select]
#/usr/bin/awk -f
If you think appending that flag to the first method would do, you're wrong.
(This won't work)
Code: [Select]
#/usr/bin/env awk -f
The shebang of a linux script is always treated as literal.
Which means, the system will look for an executable called 'awk -f'
Obviously, it won't find anything, the script won't run.

I believe this is the scenario what they are trying to fix.
By putting everything in the same place so nobody has to fix file path again and again.
Come to think of it, it annoys me whenever the downloaded python modules are yelling for file path.
Perhaps they are after this one.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: GNUser on February 29, 2024, 02:40:25 AM
(This won't work)
Code: [Select]
#/usr/bin/env awk -f
Hi polikuo. I've run into that problem before and it's a pain in the neck.

Dealing with the problem of /usr/bin/foo vs. /bin/foo in hardcoded paths is annoying because the purpose of the distinction is unclear at best. So the main selling point for me is that by merging and providing symlinks at filesystem root for compatibility, we eliminate needless complexity and never have to deal with a broken hardcoded path because of this distinction again because either path works!

Dealing with broken hardcoded paths because of applications that are unaware of the TCL convention of using local for extension-derived executables and libraries is a different story. Here the distinction serves a clear purpose for us.

My opinion is that it doesn't matter either way for TC. No advantages and no downsides, and as you found, symlinking just works.
Hi curaga. Thank you for sharing your thoughts on this. If it's "no advantages and no downsides" from a technical perspective but a small cosmetic advantage (leaner root filesystem) and a small practical advantage for users (fewer broken hardcoded paths), would you consider /usr merge for TCL16?
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: curaga on February 29, 2024, 06:24:30 AM
Yes, fine for TC16.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: GNUser on February 29, 2024, 07:03:07 AM
Well, that's exciting! Thank you. I do think it is a slightly less complex setup, which suits TCL well :)
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: polikuo on February 29, 2024, 07:21:13 PM
FYI - I remastered TCL15's corepure64.gz with merged /usr as an experiment.
My opinion is that it doesn't matter either way for TC. No advantages and no downsides, and as you found, symlinking just works.

Just sharing some thoughts, my ideas keep sparking.

It can actually be beneficial for our extensions.

When making extensions for scripting languages such as bash, perl, python, php ...etc,
it's quite often that we have to make symbolic links manually. (usually via startup script)

Code: [Select]
ln -s /usr/local/bin/bash /bin/bash
When doing that again and again across all the architectures, it's inevitable for the maintainers to leave things out when ones get tired. (such as permissions or typos regarding to the startup script)

If we create symbolic links in INITRD instead
Code: [Select]
cd ROOT
mkdir -p usr/bin
for i in bin sbin lib; do ln -s /usr/$i $i; done
ln -fs /usr/local/bin/bash usr/bin/bash

It relieves the pain and prevents unintended omissions.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: GNUser on March 02, 2024, 07:07:03 PM
Hi curaga. Another thing to consider for TCL16 is "sbin merge". The Gentoo script (https://wiki.gentoo.org/wiki/Merge-usr) that does "usr merge" does "sbin merge" at the same time. FWIW Arch adopted both merges in 2013.

I tested "usr merge" + "sbin merge" on TCL15 x86_64. It is trouble-free, as expected. I love the beautiful simplicity of the end result: No need to guess if an executable is in /bin, /sbin, /usr/bin, or /usr/sbin because they all live together in /usr/bin :) The gain in cross-distro compatibility (due to support for any and all hardcoded paths) is just an added bonus.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: curaga on March 02, 2024, 10:54:16 PM
sbin still has a purpose, root-requiring stuff, so not sure on that one.
Title: Re: would /usr merge be advantageous for TCL in any way?
Post by: GNUser on March 03, 2024, 03:41:03 AM
Yes, at least sbin has a purpose. Debian/Devuan did not do sbin merge (i.e., kept /usr/sbin as a real directory).