busybox extras

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#21 Post by Ibidem »

jamesbond wrote:
Ibidem wrote:With busybox 1.21.0, it will produce no output (tested with /dev/sda4)
This is proper behavior, since that device has no UUID.
Also, it seems LABEL is now supported. TYPE, however, isn't.
Well :shock: It wasn't obvious from the code. Perhaps it's time to upgrade :evil: I'm quite sure it supports type because in 1.19.4 it does show type. Perhaps you didn't enable a compile-time option.
Hmm...I wonder if an mdev hook could use blkid for /dev/disks/by-*
Probably.
And I believe busybox has code to detect filesystems, but good luck finding it.
It does, in util-linux/volume_id. That's what my patch is for :wink: to make a standalone executable out of these filesystem detection code.
You are correct, I hadn't enabled it.:oops:
TYPE is conditional.

LABEL support, however, was present by 2008 according to the git log (one commit from just before 1.13.0 was tagged shows sample output with LABEL included)...
Edit: Whoops, you meant the change of behavior when the device specified doesn't have a UUID. That would be this commit:

Code: Select all

commit e8cfc3f693e8a0cbfc489564c76e00c074f63066
Author: Denys Vlasenko
Date:   Sat Mar 3 15:09:07 2012 +0100

    blkid: if parameters are given, do not scan /dev
    
    Signed-off-by: Denys Vlasenko

Also, here's something I'd forgotten about.

Code: Select all

#!/bin/busybox ash
#Assume $MDEV is the device name
#Make /dev/disk/by-* symlinks

if [ -z "$MDEV" ]
then 
 echo 'Use from mdev/conf'; env >>/var/log/mdev-blk.log
# This expands to "export" when no output, or to a sequence of assignments
else
 export `blkid "/dev/$MDEV" |cut -d : -f 2` >/dev/null|| true
 [ -n "$LABEL" ] && mkdir -p /dev/disk/by-label && \
 ln -sf "/dev/$MDEV" "/dev/disk/by-label/`echo $LABEL|tr -d '"'`" || true
 [ -n "$UUID" ] && mkdir -p /dev/disk/by-uuid && \
 ln -sf "/dev/$MDEV" "/dev/disk/by-uuid/`echo $UUID|tr -d '"'`" || true

 exec >>/var/log/mdev-blk.log
 echo "blkln $@"
 env
 echo ===
fi
There may be issues with this, I didn't throw any pathological cases at it.
Last edited by Ibidem on Thu 23 May 2013, 00:03, edited 1 time in total.

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#22 Post by Ibidem »

And here's the old nroff applet (as gzipped patch)
Part of this is a tweak to man that deletes the use of gtbl.

md5sum:
93ab39ade0b6f8b4c85750e0aed55ee4 bb-nroff.diff.gz
Attachments
bb-nroff.diff.gz
gzip'd git diff: use zcat bb-nroff.diff.gz |patch -p1 to apply.
(3.06 KiB) Downloaded 739 times

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#23 Post by Ibidem »

jamesbond wrote: Anyway, as it is now, busybox guess_fstype takes 2.5 times the time of the original guess_fstype :shock:, but I'll take use it anyway because it is still in milliseconds range and it is more maintainable. I am re-posting the patch because the original one I posted was buggy (forgot to return pointer value in xzalloc :evil: - but it worked previously as long as I didn't turn on optimisation ...).
Just for reference: here's a "guess_fs" patch based on the previous patches that provides an applet.
I did a bit of cleanup and used the //config: //applet: //kbuild: approach, which reduces the risk of patches getting stale.
Also, I added support for multiple device names.
Attachments
guessfs.diff.gz
(2.55 KiB) Downloaded 681 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#24 Post by musher0 »

Ibidem wrote:
musher0 wrote:To whom it may concern:

At least reintroduce the prompt function and the command function in busybox's less (-P and !<command> parameters).

Or remove less from busybox altogether. Because, as it is now, busybox's less is a joke.

It's a shame that such an excellent pager/reader with so many useful options be reduced to not even a workable skeleton of itself in busybox.

It's also misrepresentation, on an ethical level, but that is another subject.

musher0
From "reintroduce" I get the impression that you are saying it was in busybox at one point...if that is correct, when was that? (I couldn't find any indications in the git log.)

By the way, for my own purposes, (current) busybox less is quite adequate in a way that more falls far short of.
Hello, Ibidem.

"Re-introduce" in the sense of putting back in the busybox less some of the functions it removed from the real less. I don't think those functions mentioned above were ever in the busybox less.

The difference can be illustrated by the size of the --help :
if I remember correctly : busybox less -> 4 lines
the real less -> 4 pages.

In my mind, it's clear that the busybox less is mis-representing the real less. Is there a doc telling the user what functions busybox has removed from the utilities it is supposed to replace? If not...

BTW, if you look in the /bin directory, you'll see quite a few busybox functions that BK himself has marked as "BB-NOT-USED". And he then provided the real program or a suitable replacement.

The problem here is that the user is not made aware of what (s)he is missing. If I had not searched the Internet, I would still not know all the possibilities of the real less. But not all users are as persistent.

You never know when you will need the full version of the utility replaced by a busybox "applet".

Best regards.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#25 Post by jamesbond »

Ibidem wrote:Just for reference: here's a "guess_fs" patch based on the previous patches that provides an applet.
I did a bit of cleanup and used the //config: //applet: //kbuild: approach, which reduces the risk of patches getting stale.
Also, I added support for multiple device names.
Thanks Ibidem,

This is indeed excellent! Image.
There is no reason to keep the old guess_fstype anymore :)
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#26 Post by Ibidem »

musher0 wrote:
Ibidem wrote:
musher0 wrote:To whom it may concern:

At least reintroduce the prompt function and the command function in busybox's less (-P and !<command> parameters).

Or remove less from busybox altogether. Because, as it is now, busybox's less is a joke.

It's a shame that such an excellent pager/reader with so many useful options be reduced to not even a workable skeleton of itself in busybox.

It's also misrepresentation, on an ethical level, but that is another subject.

musher0
From "reintroduce" I get the impression that you are saying it was in busybox at one point...if that is correct, when was that? (I couldn't find any indications in the git log.)

By the way, for my own purposes, (current) busybox less is quite adequate in a way that more falls far short of.
Hello, Ibidem.

"Re-introduce" in the sense of putting back in the busybox less some of the functions it removed from the real less. I don't think those functions mentioned above were ever in the busybox less.

The difference can be illustrated by the size of the --help :
if I remember correctly : busybox less -> 4 lines
the real less -> 4 pages.

In my mind, it's clear that the busybox less is mis-representing the real less. Is there a doc telling the user what functions busybox has removed from the utilities it is supposed to replace? If not...

BTW, if you look in the /bin directory, you'll see quite a few busybox functions that BK himself has marked as "BB-NOT-USED". And he then provided the real program or a suitable replacement.

The problem here is that the user is not made aware of what (s)he is missing. If I had not searched the Internet, I would still not know all the possibilities of the real less. But not all users are as persistent.

You never know when you will need the full version of the utility replaced by a busybox "applet".

Best regards.

musher0
Standard Busybox policy (documented somewhere-I-forget-where-it-was ;) ) is to implement what is needed for scripts to work; SUSv3 conformance is not essential (especially when it's obscure options that aren't used anywhere...), but is considered desireable.

It is designed primarily as a scripting environment, but one that happens to be quite functional if you need to login to some embedded device.
That "embedded device" is a key part of the design process though. If busybox included every option of all the commands implemented, it would likely be a 20MB binary instead of 1-2 MB, and it would take half an hour to build instead of a couple minutes... And if that were the case, there would be many areas where busybox would fall out of use due to bloat. And we'd get stuck with even crappier alternatives.

But I'd like to ask you one question: when was the last time you needed
!<command> in less? I could see the reason if it were vi you were talking about, but have never desired that in a pager.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#27 Post by musher0 »

Hi, Ibidem.

Ibidem wrote:
> But I'd like to ask you one question: when was the last time you needed
!<command> in less? I could see the reason if it were vi you were
talking about, but have never desired that in a pager.


Oh! I find quite handy. I use it a lot. It saves me the trouble of going
back to the menu or to a desktop icon to launch urxvt, for example, or
a script, or any other program. I now use it even to see what drives
are mounted and for access to them (see attached pic).

What I find particularly interesting in the full less is that it can act a real
reader (its main purpose). Through proper setting of its variables, it can
launch an editor (say, geany, or joe) if you need to edit anything.

I have made it my "defaulttextviewer"; it's much faster than the current
practice in Puppy, of using leafpad or nicoedit as the viewer. Also, since
you can't edit anything in less, while reading the text, you can't introduce
accidental errors if you press a wrong key.

Other uses:
You can team it up with cal to see a month or a year (see pic 2, and
code below)

Use less instead of gtk-dialog or yaf-splash; if you use the transparent
effect (-tr, -tint, and/or -sh parameters) in urxvt, it makes for a more
visually interesting message.

Highlight important words in a text you're sending to friends, members
or subscribers.

Etc., etc.

Thanks for reading this. BFN.

musher0

~~~~~~~~~~~~~~
Example: Script to view previous, current, or next year in less.

Code: Select all

#!/bin/ash
# $BINS/annee.sh
#
# annee, sans paramètre ou avec le paramètre 0, donne 
#	le calendrier de l'annee courante;
# annee +, celui de l'année suivante;
# annee -, celui de l'année précédente.
#
#(c) musher0, June 5, 2013.
####
a="`date +\"%Y\"`"
case $@ in
	+) an="`expr $a + 1`" ;;
	-) an="`expr $a - 1`" ;;
	0|*) an=$a ;;
esac
cal -s $an > /tmp/$an
AN="`head -n 1 /tmp/$an`"
GM="g 66x36+280+280"
urxvt -fn "xft:Proc2:pixelsize=12:autohint=true" +sb -$GM -tr -e less -L -j 36 -~ -P "$AN" /tmp/$an
rm /tmp/$an
Console usage (translated):
annee.sh 0 -> calendar of current year
annee.sh + -> ... of next year
annee.sh - -> ... of previous year

You can integrate the above directly in a pekwm, icewm or aewm
menu. Or you can create *.desktop files for the three possibilities for
other wm's. Or link to an icon on your desktop.

Note. The proportional Proc2 font is used here on purpose to create
the "wider" effect. Usually, for ease of reading, you'd use a "mono"
font (e.g., Monaco or Liberation Mono) with urxvt/less.
Attachments
Less_showing_current_year.jpg
(65.74 KiB) Downloaded 963 times
Less_showing_free_mem_on_drives.jpg
(40.72 KiB) Downloaded 954 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

#28 Post by scsijon »

I sugest that you have a look at toybox and see what they have needed to added in there to extend busybox's functions.

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#29 Post by Ibidem »

scsijon wrote:I sugest that you have a look at toybox and see what they have needed to added in there to extend busybox's functions.
Current toybox implements these commands (with expr find ifconfig mdev xzcat being partially implemented; toysh might work by chance on some platforms) :

Code: Select all

$ ./toybox 
basename bzcat cal cat catv chgrp chmod chown chroot chvt cksum clear 
cmp comm count cp cut date df dirname dmesg dos2unix du echo env expand 
expr false find free groups head help hostname id ifconfig insmod 
kill killall link ln login logname losetup ls lsmod lsusb md5sum mdev 
mkdir mkfifo mknod mkswap mktemp modinfo mountpoint nc netcat nice 
nohup od oneit passwd patch pidof printenv pwd readahead readlink 
realpath rev rm rmdir rmmod seq setsid sha1sum sleep sort stat swapoff 
swapon switch_root sync tac tail taskset tee time touch true truncate 
tty uname uniq unix2dos unlink unshare uptime usleep uudecode uuencode 
vconfig vmstat w wc which who whoami xargs xzcat yes 
(I'm the one who prepared xzcat.)
As you can see, there's a lot of work left to do...
Which is why Rob Landley is putting together an indiegogo project to fund work on it.
The main objective for toybox is ostensibly to provide a POSIX cli mcb that takes care of whatever a self-hosting Android needs. But Rob has a good bit more on the agenda, per his notes (basically, toybox should eventually replace all the minor collections of CLI tools, like busybox nash s6...besides being enough to build LFS.)
See http://landley.net/code/toybox/roadmap.html for more details on that score.
Currently the toybox license is pretty much PD.

The ones that are lacking for boot: grep (maybe sed awk tr), mount (beware! this should be ~600 lines; Rob got a 1400 line submission that he has not merged yet)

route is needed for networking, and a dhcp client also.

scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

#30 Post by scsijon »

thank you ibidem,

I was was leading to the idea that maybe we should add toybox to our 'standard puppy' like aborigonal and others have done to extend some commands without having to use the 'full' command due to lack of functionality with the current busybox's version of a command. It may even allow us to remove some of the full commands we use now.

Alternately, the busybox group maybe need to revisit it's command set and extend a number of them with what users actually now need to have.

My apologies technosaurus for taking your ropic off-topic.

regards to all

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#31 Post by Ibidem »

scsijon wrote:thank you ibidem,

I was was leading to the idea that maybe we should add toybox to our 'standard puppy' like aborigonal and others have done to extend some commands without having to use the 'full' command due to lack of functionality with the current busybox's version of a command. It may even allow us to remove some of the full commands we use now.

Alternately, the busybox group maybe need to revisit it's command set and extend a number of them with what users actually now need to have.

My apologies technosaurus for taking your ropic off-topic.

regards to all
What are the BB-NOTUSED applets? Currently on Debian, and I also use a pure busybox system (ie busybox, no gnu coreutils, no fileutils, no utils-linux, no extra text editor, no gnu sed, no gawk, ...), so I can't check atm.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#32 Post by Karl Godt »

bash-3.00#

Code: Select all

for i in /bin /sbin /usr/bin /usr/sbin ; do find $i -type l -iname "*notused"; done
/bin/cp-BB-NOTUSED
/bin/rm-BB-NOTUSED
/bin/sh-BB-NOTUSED
/bin/uname-BB-NOTUSED
/bin/cat-BB-NOTUSED
/bin/mount-BB-NOTUSED
/bin/chmod-BB-NOTUSED
/bin/ps-BB-NOTUSED
/bin/ln-BB-NOTUSED
/bin/head-BB-NOTUSED
/bin/ls-BB-NOTUSED
/bin/df-BB-NOTUSED
/bin/stat-BB-NOTUSED
/bin/dd-BB-NOTUSED
/bin/umount-BB-NOTUSED
/bin/touch-BB-NOTUSED
/bin/sleep-BB-NOTUSED
/bin/mv-BB-NOTUSED
/bin/rmdir-BB-NOTUSED
/bin/xargs-BB-NOTUSED
/sbin/insmod-BB-NOTUSED
/sbin/reboot-BB-NOTUSED
/sbin/mkswap-BB-NOTUSED
/sbin/man-BB-NOTUSED
/sbin/hwclock-BB-NOTUSED
/sbin/lsmod-BB-NOTUSED
/sbin/modprobe-BB-NOTUSED
/sbin/rmmod-BB-NOTUSED
/sbin/fdisk-BB-NOTUSED
/sbin/poweroff-BB-NOTUSED
/usr/bin/find-BB-NOTUSED
/usr/bin/cut-BB-NOTUSED
/usr/bin/uniq-BB-NOTUSED
/usr/bin/sort-BB-NOTUSED
/usr/bin/od-BB-NOTUSED
/usr/bin/head-BB-NOTUSED
/usr/bin/du-BB-NOTUSED
/usr/bin/xargs-BB-NOTUSED
/usr/bin/tac-BB-NOTUSED
/usr/bin/cmp-BB-NOTUSED
/usr/sbin/setfont-BB-NOTUSED
bash-3.00#

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#33 Post by Karl Godt »

Am a fan of busybox modprobe , its missing the -D --show-depends option i think . I hate modprobe[-FULL] !

Some are scripts to adjust vars ie reboot, poweroff, df , calling busybox applets in them .
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#34 Post by Ibidem »

Karl Godt wrote:Am a fan of busybox modprobe , its missing the -D --show-depends option i think . I hate modprobe[-FULL] !

Some are scripts to adjust vars ie reboot, poweroff, df , calling busybox applets in them .
(bb=busybox)
bb modprobe (without "simplified modutils") has -D since at least 1.20.2.
...Does Barry disable "simplified modutils" ?

sh I can see the reason for.
man is replaced with a script + browser (not my own preference, but...)
lsmod I see no logic to: neither bb nor standard has any options.
similar with sleep;
for rmdir bb lacks "--verbose".
for head bb lacks long options and metric units.
...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#35 Post by sunburnt »

As I understand it... Puppy`s BusyBox isn`t compiled for Puppy.
So Barry disables the BusyBox links and uses the exec. files instead.

BusyBox could be built with the full exec. files instead of the trimmed down ones.
And probably many other apps. could be included; file browser, media player, etc.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#36 Post by technosaurus »

The biggest difference is to configure with :
Prefer applets
Standalone shell
Run nofork applets directly

There are several options to prefer speed over size, desktop options etc...

Its also useful to change some applets to nofork ... mknod as nofork can cut boot time in half.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#37 Post by musher0 »

Hi.

Me grouching again.

Another thing: the busybox cal function always begins the week on Mondays.
I believe half the world finds it less confusing when their week begins on a Sunday.

Maybe the code for busybox cal is a few lines of code shorter that way, but what's
the motive behind ignoring the Christian tradition of beginning the week on a Sunday?
Annoying people?

No one with even a small exposure to social sciences -- better still: nobody tactful --
would have done that.

Developers : please re-instate the full cal in the next Puppy or in your next derivative.

My 2 cents. BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#38 Post by amigo »

Here in Germany, the first day of the week -by law- is Monday. This was probably done to clear up a glaring inconsistency in modern Christianity -namely, if one is supposed to observe the 'Sabbath', why is Sunday the Holy Day? Having Monday as the first day of the week makes Sunday the last day of the week.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#39 Post by Karl Godt »

Code: Select all

bash-3.00# cal
     June 2013
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
bash-3.00# which cal
/bin/cal
bash-3.00# file /bin/cal
/bin/cal: symbolic link to `busybox'
bash-3.00# busybox |head -n2
BusyBox v1.19.4 (2012-04-19 16:14:01 GMT+1) multi-call binary.
Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko
bash-3.00# 
My BB cal currently defaults to Sunday as first day of the week .

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Begin of Week

#40 Post by L18L »

Code: Select all

# cal
     Juni 2013
So Mo Di Mi Do Fr Sa  
Users: Use osmo if you like to see your weekend include Sunday :lol:

Post Reply