partview problem with dc

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

partview problem with dc

broomdodger
Barry suggested I post here.

I installed dc_1.06.95-2 via PPM
because I am a curious rpn calculator user.

It can interfere with 'busybox dc', in particular 'partview'
returns '0' for both drive capacity and free.

Would it be better to use the phrase 'busybox dc' in 'partview'?
and other places where dc is used?

Functionally they are similar,
but the full version needs '-e' to precede the calculation.

Bill
Santa Cruz, California
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

Karl Godt
Administrator
Appears that dc-FULL finds in the same location as bb dc .

dc is used in quite a few scripts .

petget could take care of such like installing into /root/my-applications/ if it would overwrite existing files .

dc is locale sensitive .

Will check regular dc(-FULL) .


About RPN I had to google : Reverse Polish Notation. Im Deutschen sagt man oft auch UPN für Umgekehrte Polnische Notation.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

Karl Godt
Administrator
compiled dc , which is part of bc : http://packages.debian.org/source/wheezy/bc

HOLY CRAP !

ldd ./bc
	linux-gate.so.1 =>  (0xb77ec000)
	libc.so.6 => /lib/libc.so.6 (0xb76f0000)
	/lib/ld-linux.so.2 (0xb77ed000) 
ldd ./dc
	linux-gate.so.1 =>  (0xb78c3000)
	libc.so.6 => /lib/libc.so.6 (0xb77c7000)
	/lib/ld-linux.so.2 (0xb78c4000)

Examples :

./dc -e "123.6  567 \/ p"
dc: '\' (0134) unimplemented
0

./dc -e "123.6  567 /"
NULL

./dc -e "123.6  567 / p"
0

./dc -e "123123.6  567 / p"
217

busybox dc 123.6 567 \/ p
0.217989

A honest 100 to 0 for busybox here  !



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

Karl Godt
Administrator
In reply to this post by Karl Godt
Debian installs dc into /usr/bin/ directory : http://packages.debian.org/wheezy/i386/dc/filelist

./configure --prefix=/opt/calc installs everything into top directory ( bin, man, info ) .

busybox since version ??? can be compiled to support the --list option :
busybox --list | while read applet; do echo $applet;[ -e /bin/$applet ] || { echo "$applet missing in /bin..creating now";ln -s busybox /bin/$applet; }; done
would make all busybox applets that are not found in /bin as regular name become first in PATH - PATH set in /etc/profile or in the shell source at compile time .
technosaurus might have posted about the --list option at the murga-forum longer back.
This would resemble the layout of the initrd.gz : Everything in /bin --except /sbin is short for /script_bin - not  /superuser_bin .

Programs that might become second in PATH and likely break scripts probably are :
acpid, wget, chat, mkfs.ext2
to name a couple .
So here watch out using --list !

busybox actually can be configured to not support /usr - just support /bin and /sbin .
That way the user would complain about having dc installed , but typing dc in the console does not changed it.

Here a petget patch might be helpful to

1) Inform about files being overwritten ( Xdialog --logbox onto $DECOMPRESSOR --list-content ) .
2) Check if file elsewhere exist in PATH and is link to bb, then rename file to file-FULL and inform the user about this.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

Karl Godt
Administrator
In reply to this post by Karl Godt
woof-code/0pre:  SIZEK=`dc $SIZEM 1024 mul p | cut -f 1 -d '.'`
woof-code/boot/initrd-tree0/bin/bb-create-symlinks:#BBAPPLETS="'[' '[[' acpid addgroup adduser ash base64 basename bbconfig beep blkid blockdev bunzip2 busybox bzcat bzip2 cal cat chgrp chmod chown chpasswd chroot chvt cksum clear cmp cp cpio crond crontab cryptpw cut date dc very_long_list_here__ "
woof-code/rootfs-skeleton/sbin/init:  for ONEBIN in "[" "[[" ash autologinroot basename busybox cat chmod chown clear cp cut date dc dd df dirname dmesg du _long_list_here__
woof-code/rootfs-skeleton/sbin/initNEW:  for ONEBIN in "[" "[[" ash autologinroot basename busybox cat chmod chown clear cp cut date dc dd df dirname dmesg du ed long_list_here__
woof-code/rootfs-skeleton/usr/local/pup_event/frontend_funcs:  SIZE="`LANG=$OLDLANG dc $SIZE 1048576 \/ p`" #100613 dc o/p '.' if LANG=C.
woof-code/rootfs-skeleton/usr/sbin/puppyinstaller:[ "`echo "$DRVSIZE" | grep "GiB"`" != "" ] && DRVSIZM="`LANG=C dc $DRVSIZM 1000 \* p`" #120202
woof-code/rootfs-skeleton/usr/sbin/partview:  ONEFREE="`dc $AFREE 1048576 \/ p`"
woof-code/rootfs-skeleton/usr/sbin/remasterpup2:SIZETOTALK=`LANG=C dc $SIZEBIN $SIZESBIN + $SIZELIB + $SIZEUSR + $SIZEOPT + p`
woof-code/rootfs-skeleton/usr/sbin/background_reshape:#111013 Karl Godt: 'dc' can return , instead of . in numeric values, for non-english locale.
woof-code/rootfs-skeleton/usr/sbin/shutdownconfig:     AFREE=`dc $FFREE 1000 \/ p` #not 1024
woof-code/rootfs-skeleton/usr/sbin/xinitrc_test:CLOCKHZ=`dc $2 1000000 \* p`
woof-code/rootfs-skeleton/usr/sbin/pmount:                      ONESIZE="`dc $ONESIZEK 1048576 \/ p`"
woof-code/rootfs-skeleton/usr/bin/pupx:MOUSEACCEL=`dc ${MOUSEACCEL10} ${MOUSEACCELDIV} div p`

Thats a list of files that use dc .

The check for busybox applet or not then theoretically needs to be done for every applet.

The list lines of /sbin/init for example could be fiddled into a function in functions4puppy .

alias
BB_LINKS=`busybox --list`
for applet in $BB_LINKS ; do
eval "alias ${applet}=\"busybox $applet\"";
alias | grep -w "$applet"
done
is a working code example in bash-3.2 .


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

Karl Godt
Administrator
This post was updated on .
Karl Godt wrote
alias
BB_LINKS=`busybox --list`
for applet in $BB_LINKS ; do
eval "alias ${applet}=\"busybox $applet\"";
alias | grep -w "$applet"
done
is a working code example in bash-3.2 .
And also works in ash (bb v1.18.3) .

Here would be a code example for a functions4puppy function :

EDIT1 : reworked, was
for ONEBIN in
instead of
for applet in

and uname -r said busybox uname : command not found , so using /bin/busybox .

EDIT2 : reworked the line with applets,
added stub to return if no busybox,
added file test, which is very heavy and slow
use_busybox_applets(){

## [ "`which busybox`" ] && BBEXE=`which busybox`
## [ "$BBEXE" ] || { [ -s /bin/busybox -a -x /bin/busybox ] && BBEXE='/bin/busybox'; }
## [ "$BBEXE" ] || return 2  ##errno.h:define ENOENT 2 /* No such file or directory */

#for applet in "[" "[[" ash autologinroot basename  cat chmod chown clear cp cut \
#date dc dd df dirname dmesg du e3 ed expr false find free grep \
#head kill ln login ls lsmod mkdir mknod more mv nice ntfs-3g pidof pwd \
#readlink rev rm rmdir sed sleep sort stat su sync tail tar touch tr true \
#uname usleep waitmax wc which xargs

for applet in basename cat chmod chown clear cut \
date dc dd dirname dmesg du ed expr false find free \
head kill ln login ls lsmod mkdir mknod more mv nice pidof \
readlink rev rm rmdir sleep sort stat su sync tail tar touch tr true \
uname usleep waitmax wc which xargs
do
#echo $applet
#file "`which $applet`" | grep 'link' | grep busybox || continue
eval "alias ${applet}=\"/bin/busybox $applet\"";
done
}

And in scripts that file needs to be sourced and use_busybox_applets run :
. /etc/rc.d/functions4puppy
use_busybox_applets
This of course would increase the load average and delay apps a little,
but since "Binary compatible" or "Based upon" persuades that the user can install anything from the repository , it is worth it I think .



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

broomdodger
In reply to this post by Karl Godt
Karl Godt wrote
Appears that dc-FULL finds in the same location as bb dc
dc is used in quite a few scripts
Yes... that is the problem.

busybox dc is very good and has bitwise logic functions, which 'full' dc does not.

Below are mappings to do calculations from within a vim text file.
(Commented code best viewed using a monospaced font.)

First is the Mac verion using the 'full' version,
Second is the busybox version.

" postfix calculate LINE RPN - result on new line
" :help :put - escape both '|' and '"'
" 'dc' Mac Linux
" + - * / % ~ ^ v |     k - pop precision
" d - dup               r - swap
" p - dup print \n      n - pop print
" o - pop output radix  i - pop input radix
imap <silent> \cc <esc>:put=system('dc \"-e2k'.getline('.').'n\"').' '<cr>A
" '''''''''''''''      |   |        |      |  |            |      |   |   +eol
" '''''''''''''''      |   |        |      |  |            |      |   +run
" '''''''''''''''      |   |        |      |  |            |      +space
" '''''''''''''''      |   |        |      |  |            +print
" '''''''''''''''      |   |        |      |  +calc
" '''''''''''''''      |   |        |      +precision
" '''''''''''''''      |   |        +build command
" '''''''''''''''      |   +expression register
" '''''''''''''''      +result after current line

" 'dc' busybox Tiny RPN calculator - remove \n escape *
" + add - sub * mul / div % mod and or not xor
" p - dup print \n
" o - pop output radix (2 8 10 16)
imap <silent> \bb <esc>:put=substitute(system('busybox dc '.escape(getline('.'),'*').' p'),'\n',' ','')<cr>A

Bill
Santa Cruz, California
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: partview problem with dc

Karl Godt
Administrator
Fact is that it is always a problem when some packages overwrite existing files .
This fact applies not only for dc .

So a commit about using busybox dc  instead of just dc in the code may be welcome, but
1) Someone has to do the commit .
2) This would only fix it for dc and each next problem would need next fixes .

I would prefer a general solution like the function to alias wanted utilities .
This has some problems, too :
1) The function needs to be maintained if busybox introduce new behaviour for its applets.
2) Every(?) script needs to implement the call to source and execute the function.
3) We or I need to find out, which busybox applets are when and where.
4) Crashing sourced files in my observations also crash the script that sources them, if no controlling tty ( forked & or exec(by rox) ) .

Overall I am pretty fond of busybox, just had it's modprobe needed and it' modprobe still has the -l option
( I compile it with advanced options ),
that was dropped or forgotten in the current kmod multi-call binary - but it's code needs clean up for sure.

My personal interests are to make as much #!/bin/sh #!/bin/ash as possible,
and fix the code for busybox compiled to look for it's applets first before using the PATH .
Mainly puppy scripts like /bin/df, /bin/ps, /bin/mount and /bin/umount need to be called with absolute path then,
puppy scripts like /usr/local/bin/drive_all, /bin/mount, /bin/umount, /sbin/init, /etc/rc.d/rc.shutdown;
but also likely /bin/grep; but one problem with grep I could solve lately using -F for grep -Fw '/'

Busybox sed as another note, is working flawlessly for me .
Loading...