site  contact  subhomenews

'free' Busybox applet "broken"

April 05, 2011 — BarryK
Well, not broken, but changed, and it breaks some scripts.

The Busybox 'free' applet is used in many scripts. The initramfs has Busybox 1.14.x, recent Woof-built puppies have 1.16.x. For these, this is the output of free:

# free

total used free shared buffers
Mem: 505608 397120 108488 0 26648
Swap: 1012052 0 1012052
Total: 1517660 397120 1120540

However, this is running free in Busybox 1.18.4:

             total         used         free       shared      buffers

Mem: 505608 415620 89988 0 27360
-/+ buffers: 388260 117348
Swap: 1012052 0 1012052

If you parse that output in a pipe in a script, the lack of spaces before "Mem:" and "Swap:", plus no "Total:" line can break a script.

I have fixed the following scripts in Woof to work with old and new versions of free:

/etc/rc.d/rc.shutdown, rc.sysinit
/usr/sbin/chooselocale, alsaconf

I also fixed the 'init' script in the initramfs, in anticipation of future upgrade of Busybox.

If you are a developer of any application for Puppy and you have used the 'free' applet, please check your script!

I hope that Busybox 1.18.4 has no more surprises!


Username: shinobar
I guess you have already got the solution... [code]RAMSIZE=`free | grep 'Mem:' | cut -f 2 -d ':' | tr -s ' ' | cut -f 2 -d ' '` #total physical ram (less shared video). # 2Mar11 shinobar[/code]

Tags: woof