Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-08 Thread Klemens Nanni
On Tue, Nov 08, 2022 at 10:23:23AM +, Stuart Henderson wrote:
> On 2022/11/07 23:54, Theo de Raadt wrote:
> > Klemens Nanni  wrote:
> > 
> > > > I know this makes rc(8) a bit noisier but it really does improve my
> > > > (for want of a better term) "user experience" as I wait for my machine
> > > > to boot.
> > > 
> > > I like this and it doesn't add more **lines** to the boot log, but maybe
> > > print library names without versions to reduces noise?
> > 
> > Only if it is the short names.
> 
> No need for the .so really either. ld.so libc libcrypto is enough.
> 
> > But I am not sure people need to see this detail.  It just takes a bit
> > of time.  How does knowing what steps are being taken help...
> 
> Sometimes it's a bit of time, sometimes it's a _lot_ of time until
> people get a new computer or raid battery or something and it's less
> annoying if you can see _some_ progress.

Here's a simple diff that prints "ld.so" and "libc".
Not trying to take over Scott's diff, just helping out on shell bits.

Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.564
diff -u -p -r1.564 rc
--- rc  29 Aug 2022 11:51:05 -  1.564
+++ rc  8 Nov 2022 10:32:32 -
@@ -193,7 +193,7 @@ reorder_libs() {
# Remount the (read-only) filesystems in _ro_list as read-write.
for _mp in $_ro_list; do
if ! mount -u -w $_mp; then
-   echo ' failed.'
+   echo '(failed).'
return
fi
done
@@ -215,6 +215,7 @@ reorder_libs() {
cd $_tmpdir
ar x $_liba
if [[ $_lib == ld.so ]]; then
+   echo -n " $_lib"
args="-g -x -e _dl_start \
--version-script=Symbols.map --shared -Bsymbolic \
--no-undefined"
@@ -225,6 +226,7 @@ reorder_libs() {
$_install /usr/libexec/ld.so /usr/libexec/ld.so.save
$_install ld.so.test $_lib_dir/ld.so
else
+   echo -n " ${_lib%%.*}"
cc -shared -o $_lib $(ls *.so | sort -R) $(<.ldadd)
[[ -s $_lib ]] && file $_lib | fgrep -q 'shared object'
LD_BIND_NOW=1 LD_LIBRARY_PATH=$_tmpdir awk 'BEGIN {exit 
0}'
@@ -243,9 +245,9 @@ reorder_libs() {
done
 
if $_error; then
-   echo ' failed.'
+   echo '(failed).'
else
-   echo ' done.'
+   echo '.'
fi
 }
 



Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-08 Thread Theo de Raadt
Stuart Henderson  wrote:

> > But I am not sure people need to see this detail.  It just takes a bit
> > of time.  How does knowing what steps are being taken help...
> 
> Sometimes it's a bit of time, sometimes it's a _lot_ of time until
> people get a new computer or raid battery or something and it's less
> annoying if you can see _some_ progress.

Sigh.

Do we need a spinny thingy?



Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-08 Thread Theo de Raadt
Klemens Nanni  wrote:

> On Tue, Nov 08, 2022 at 10:23:23AM +, Stuart Henderson wrote:
> > On 2022/11/07 23:54, Theo de Raadt wrote:
> > > Klemens Nanni  wrote:
> > > 
> > > > > I know this makes rc(8) a bit noisier but it really does improve my
> > > > > (for want of a better term) "user experience" as I wait for my machine
> > > > > to boot.
> > > > 
> > > > I like this and it doesn't add more **lines** to the boot log, but maybe
> > > > print library names without versions to reduces noise?
> > > 
> > > Only if it is the short names.
> > 
> > No need for the .so really either. ld.so libc libcrypto is enough.
> 
> Yes, but that needs a little more shell tweaking as ${_lib%%.*} will
> turn "ld.so" into "ld", so I suggested a simple middle ground before
> blowing up the diff...

Sorry, but I insist on the shorters cute names.



Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-08 Thread Klemens Nanni
On Tue, Nov 08, 2022 at 10:23:23AM +, Stuart Henderson wrote:
> On 2022/11/07 23:54, Theo de Raadt wrote:
> > Klemens Nanni  wrote:
> > 
> > > > I know this makes rc(8) a bit noisier but it really does improve my
> > > > (for want of a better term) "user experience" as I wait for my machine
> > > > to boot.
> > > 
> > > I like this and it doesn't add more **lines** to the boot log, but maybe
> > > print library names without versions to reduces noise?
> > 
> > Only if it is the short names.
> 
> No need for the .so really either. ld.so libc libcrypto is enough.

Yes, but that needs a little more shell tweaking as ${_lib%%.*} will
turn "ld.so" into "ld", so I suggested a simple middle ground before
blowing up the diff...

> 
> > But I am not sure people need to see this detail.  It just takes a bit
> > of time.  How does knowing what steps are being taken help...
> 
> Sometimes it's a bit of time, sometimes it's a _lot_ of time until
> people get a new computer or raid battery or something and it's less
> annoying if you can see _some_ progress.

That and it just goes well in line with how rc.d scripts are printed.



Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-08 Thread Stuart Henderson
On 2022/11/07 23:54, Theo de Raadt wrote:
> Klemens Nanni  wrote:
> 
> > > I know this makes rc(8) a bit noisier but it really does improve my
> > > (for want of a better term) "user experience" as I wait for my machine
> > > to boot.
> > 
> > I like this and it doesn't add more **lines** to the boot log, but maybe
> > print library names without versions to reduces noise?
> 
> Only if it is the short names.

No need for the .so really either. ld.so libc libcrypto is enough.

> But I am not sure people need to see this detail.  It just takes a bit
> of time.  How does knowing what steps are being taken help...

Sometimes it's a bit of time, sometimes it's a _lot_ of time until
people get a new computer or raid battery or something and it's less
annoying if you can see _some_ progress.



Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-07 Thread Theo de Raadt
Klemens Nanni  wrote:

> > I know this makes rc(8) a bit noisier but it really does improve my
> > (for want of a better term) "user experience" as I wait for my machine
> > to boot.
> 
> I like this and it doesn't add more **lines** to the boot log, but maybe
> print library names without versions to reduces noise?

Only if it is the short names.

But I am not sure people need to see this detail.  It just takes a bit
of time.  How does knowing what steps are being taken help...



Re: rc(8): reorder_libs(): print names of relinked libraries

2022-11-07 Thread Klemens Nanni
On Fri, Jul 29, 2022 at 07:33:50PM -0500, Scott Cheloha wrote:
> Recently I've been doing some MIPS64 stuff on my EdgeRouter PoE.  It
> has a USB disk, two 500MHz processors, and 512MB of RAM.
> 
> So, every time I reboot to test the next iteration of my kernel
> patch, I get to here:
> 
>   reordering libraries: 
> 
> and I sit there for half a minute or more and wonder what the hell
> it's doing.
> 
> And, in my intellectual brain, I know it's relinking the libraries
> and that this is slow because it needs to link a bunch of object files
> and my machine is slow and my disk is slow and I have almost no RAM.
> 
> But!  My animal brain wishes I could see some indication of progress.
> Because the script has told me it is linking more than one library.
> So, as with daemon startup, I am curious which library it is working
> on at any given moment.
> 
> Can we print the library names as they are being relinked?
> 
> With the attached patch the boot now looks like this:
> 
>   reordering libraries: ld.so libc.so.96.1 libcrypto.so.49.1.
> 
> We print the library name before it is relinked, so you can know which
> library it is linking.
> 
> If for some reason we fail on a particular library, it instead looks
> like this:
> 
>   reordering libraries: ld.so(failed).
> 
> ... which is me trying to imitate what we do for daemon startup.
> 
> Thoughts?
> 
> I know this makes rc(8) a bit noisier but it really does improve my
> (for want of a better term) "user experience" as I wait for my machine
> to boot.

I like this and it doesn't add more **lines** to the boot log, but maybe
print library names without versions to reduces noise?

> 
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.563
> diff -u -p -r1.563 rc
> --- rc28 Jul 2022 16:06:04 -  1.563
> +++ rc30 Jul 2022 00:15:26 -
> @@ -193,7 +193,7 @@ reorder_libs() {
>   # Remount the (read-only) filesystems in _ro_list as read-write.
>   for _mp in $_ro_list; do
>   if ! mount -u -w $_mp; then
> - echo ' failed.'
> + echo '(failed).'
>   return
>   fi
>   done
> @@ -210,6 +210,7 @@ reorder_libs() {
>   _install='install -F -o root -g bin -m 0444'
>   _lib=${_liba##*/}
>   _lib=${_lib%.a}
> + echo -n " $_lib"

This would make it print "libc.so":
echo -n " ${lib_%%.[0-9]*}

>   _lib_dir=${_liba#$_relink}
>   _lib_dir=${_lib_dir%/*}
>   cd $_tmpdir
> @@ -243,9 +244,9 @@ reorder_libs() {
>   done
>  
>   if $_error; then
> - echo ' failed.'
> + echo '(failed).'
>   else
> - echo ' done.'
> + echo '.'
>   fi
>  }
>  
> 



rc(8): reorder_libs(): print names of relinked libraries

2022-07-29 Thread Scott Cheloha
Recently I've been doing some MIPS64 stuff on my EdgeRouter PoE.  It
has a USB disk, two 500MHz processors, and 512MB of RAM.

So, every time I reboot to test the next iteration of my kernel
patch, I get to here:

reordering libraries: 

and I sit there for half a minute or more and wonder what the hell
it's doing.

And, in my intellectual brain, I know it's relinking the libraries
and that this is slow because it needs to link a bunch of object files
and my machine is slow and my disk is slow and I have almost no RAM.

But!  My animal brain wishes I could see some indication of progress.
Because the script has told me it is linking more than one library.
So, as with daemon startup, I am curious which library it is working
on at any given moment.

Can we print the library names as they are being relinked?

With the attached patch the boot now looks like this:

reordering libraries: ld.so libc.so.96.1 libcrypto.so.49.1.

We print the library name before it is relinked, so you can know which
library it is linking.

If for some reason we fail on a particular library, it instead looks
like this:

reordering libraries: ld.so(failed).

... which is me trying to imitate what we do for daemon startup.

Thoughts?

I know this makes rc(8) a bit noisier but it really does improve my
(for want of a better term) "user experience" as I wait for my machine
to boot.

Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.563
diff -u -p -r1.563 rc
--- rc  28 Jul 2022 16:06:04 -  1.563
+++ rc  30 Jul 2022 00:15:26 -
@@ -193,7 +193,7 @@ reorder_libs() {
# Remount the (read-only) filesystems in _ro_list as read-write.
for _mp in $_ro_list; do
if ! mount -u -w $_mp; then
-   echo ' failed.'
+   echo '(failed).'
return
fi
done
@@ -210,6 +210,7 @@ reorder_libs() {
_install='install -F -o root -g bin -m 0444'
_lib=${_liba##*/}
_lib=${_lib%.a}
+   echo -n " $_lib"
_lib_dir=${_liba#$_relink}
_lib_dir=${_lib_dir%/*}
cd $_tmpdir
@@ -243,9 +244,9 @@ reorder_libs() {
done
 
if $_error; then
-   echo ' failed.'
+   echo '(failed).'
else
-   echo ' done.'
+   echo '.'
fi
 }