![]() ![]() |
Jun 1 2005, 10:09 AM
Post
#1
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
Any ideas how to find memory occupied by programs from installed ipks?
For example: 10 MB - a.ipk 5MB - b.ipk 3MB - c.ipk I need to clean a bit my internal memory but have no ideas what packages have more "weight" and what less. suruaZ |
|
|
|
Jun 1 2005, 01:34 PM
Post
#2
|
|
![]() Group: Members Posts: 1,248 Joined: 6-July 04 Member No.: 3,928 |
QUOTE(suruaZ @ Jun 1 2005, 06:09 PM) Any ideas how to find memory occupied by programs from installed ipks? For example: 10 MB - a.ipk 5MB - b.ipk 3MB - c.ipk I need to clean a bit my internal memory but have no ideas what packages have more "weight" and what less. suruaZ There isn't a standard way of doing this. ipkg files ipkname will give you the list of files uncompressed from the Tarball and you could check their sizes individually. It won't tell you about files created by those apps or by the preinst/postinst scripts though. - Andy |
|
|
|
Jun 1 2005, 01:42 PM
Post
#3
|
|
![]() Group: Members Posts: 692 Joined: 27-January 04 From: Canada Member No.: 1,564 |
I wrote a script for myself that 'wraps' around ipkg to allow easier manipulation of ipk files & I also included an installed size calculator. See attached. Just put the script in your path & then create several symbolic links to it & then run one of the symbolic links. For example:
CODE # cd /usr/bin/ # ln -s ipkg-wrapper ipkg-size # ln -s ipkg-wrapper ipkg-info # ln -s ipkg-wrapper ipkg-files # ipkg-size xmms-embedded Total installed size: 461kb HTH EDIT: It wouldn't alow me to attach the file, so I'll just paste it here: CODE #!/usr/bin/env sh
# ipkg-wrapper # # This is a wrapper script for ipkg. The script performs various functions when called from the following valid symlinks: # ipkg-files - lists the files in the given package. # ipkg-info - shows the info of the given package. # ipkg-size - calculates the installed size of the given package. Note that the calculated size can be different from # the file versus an installed package due to differences in block size, the size that ls returns rather # than what's recorded in the package, the phase of the moon, etc. IOW, don't sweat the small stuff! # # 2005-05-09 Written by GROG! <Uber[dot]GROG[at]Gmail[dot]Com> # set -x # TESTING if [ $# -ne 1 ]; then echo "Usage: ${0##*/} (pkgname|pkgfile)" >&2 exit 1 fi ACTION=${0##*-} case $ACTION in size) if [ -s $1 ]; then ipkg-files $1 2>/dev/null | while read line; do set -- $line echo $3 done else ipkg-files $1 | xargs ls -l 2>/dev/null | while read line; do set -- $line echo $5 done fi | (while read line; do TOTALSIZE=$((TOTALSIZE+$line)) done echo "Total installed size: $((TOTALSIZE/1024))kb") ;; files|info) if [ -s $1 -a ! -d $1 ]; then TMPDIR=/tmp/${1##*/} TMPDIR=${TMPDIR%%_*} \mkdir $TMPDIR >/dev/null \cp $1 $TMPDIR >/dev/null \cd $TMPDIR >/dev/null (ar -xv $1 || tar -xzf $1) >/dev/null 2>&1 case $ACTION in files) echo "File listing of package file $1:" >&2 tar -tzvf data.tar.gz ;; info) tar -xzf control.tar.gz cat control echo ;; esac cd - >/dev/null rm -Rf $TMPDIR >/dev/null else ipkg $ACTION $1 fi ;; *) echo "This script must be called via one of the following symlink's:" >&2 echo " ipkg-files ipkg-info ipkg-size" >&2 exit 1;; esac exit 0 |
|
|
|
Jun 1 2005, 11:35 PM
Post
#4
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
Thanks guys. grog's script looks exactly what I'm looking for. Just:
ipkg-size: arith: syntax error: "TOTALSIZE+1234" or in case of Opera: ipkg-size: arith: syntax error: "TOTALSIZE/1024" ipkg-files works fine. ipkg-info shows nothing? |
|
|
|
Jun 1 2005, 11:35 PM
Post
#5
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
Thanks guys. grog's script looks exactly what I'm looking for. Just:
ipkg-size: arith: syntax error: "TOTALSIZE+1234" or in case of Opera: ipkg-size: arith: syntax error: "TOTALSIZE/1024" ipkg-files works fine. ipkg-info shows nothing? suruaZ |
|
|
|
Jun 1 2005, 11:49 PM
Post
#6
|
|
![]() Group: Members Posts: 1,099 Joined: 17-December 03 From: Athens, Greece Member No.: 1,210 |
Hmm another problem might be that files stored on a jffs2 file system are compressed...
I don't know if the size given by ls take this into account so the size calculated with ls might be quite different from the actual place a file takes on the internal flash..depending on the compression. |
|
|
|
Jun 2 2005, 03:06 AM
Post
#7
|
|
![]() Group: Members Posts: 692 Joined: 27-January 04 From: Canada Member No.: 1,564 |
pgas: I have no clue about the effects of jffs2 compression. Don't use it.
suruaZ: Do you get those errors multiple times? What's the output of this? CODE $ ls -l $(which opera) If you want, uncomment this line: CODE # set -x # TESTING And then run this command: CODE $ ipkg-size opera 2>&1 | tee /var/tmp/wrapper.log And attach the log file & I'll figure out what's wrong. |
|
|
|
Jun 2 2005, 06:38 AM
Post
#8
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
QUOTE Do you get those errors multiple times? What's the output of this? Every time I use ipks-size. Just error differ - sometimes it's "TOTALSIZE+number" but sometimes "TOTALSIZE/1024" QUOTE CODE $ ls -l $(which opera) lrwxrwxrwx root root /home/QtPalmtop/bin/opera -> /usr/QtPalmtop.rom/bin/opera QUOTE CODE # set -x # TESTING And then run this command: CODE $ ipkg-size opera 2>&1 | tee /var/tmp/wrapper.log And attach the log file & I'll figure out what's wrong. + [ 1 -ne 1 ] + ACTION=size + [ -s opera ] + ipkg-files opera + xargs ls -l + read line + read line + [ 1 -ne 1 ] + ACTION=files + [ -s opera -a ! -d opera ] + ipkg files opera + exit 0 /home/QtPalmtop/bin/ipkg-size: arith: syntax error: "TOTALSIZE/1024" + exit 0 What I found - if I issued the command with non-existed file ("ipkg-size zzz" for example) the output is the same. Seems it cann't find opera. More problems with existed packages. For example: ipkg-size zip 2>&1 | tee /var/tmp/wrapper.log creates a big log (attached) with scanning of a lot unrelated files while zip instalation is only single file /usr/bin/zip Thanks, suruaZ
Attached File(s)
|
|
|
|
Jun 2 2005, 11:34 AM
Post
#9
|
|
![]() Group: Members Posts: 692 Joined: 27-January 04 From: Canada Member No.: 1,564 |
QUOTE(suruaZ @ Jun 2 2005, 08:38 AM) CODE $ ls -l $(which opera) lrwxrwxrwx root root /home/QtPalmtop/bin/opera -> /usr/QtPalmtop.rom/bin/opera $ ipkg-size opera 2>&1 | tee /var/tmp/wrapper.log + [ 1 -ne 1 ] + ACTION=size + [ -s opera ] + ipkg-files opera + xargs ls -l + read line + read line + [ 1 -ne 1 ] + ACTION=files + [ -s opera -a ! -d opera ] + ipkg files opera + exit 0 /home/QtPalmtop/bin/ipkg-size: arith: syntax error: "TOTALSIZE/1024" + exit 0 What I found - if I issued the command with non-existed file ("ipkg-size zzz" for example) the output is the same. Seems it cann't find opera. Interesting. 'ls' doesn't seem to be returning the file size. That would cause a problem right? What do these commands come back with? CODE $ ls -l $(which ls) $ ls -f As well, does 'ipkg-files opera' return anything at all? I suspect it doesn't. Does this output look similar to yours (similar being it results in a list of numbers followed by the file name, not this list exactly)? CODE $ du /bin/* | head 1 /bin/addgroup 1 /bin/adduser 1 /bin/ash 1 /bin/bash 1 /bin/bashbug 536 /bin/busybox 1 /bin/cat 1 /bin/chgrp 1 /bin/chmod 1 /bin/chown If it's similar, then this script modification might work better for you. It's not as accurate, but I don't think we're going for the gold as far as accuracy which in the busybox version only returns block size not byte size. Let me know how it goes. CODE #!/usr/bin/env sh
# ipkg-wrapper # # This is a wrapper script for ipkg. The script performs various functions when called from the following valid symlinks: # ipkg-files - lists the files in the given package. # ipkg-info - shows the info of the given package. # ipkg-size - calculates the installed size of the given package. Note that the calculated size can be different from # the file versus an installed package due to differences in block size, the size that ls returns rather # than what's recorded in the package, the phase of the moon, etc. IOW, don't sweat the small stuff! # # 2005-05-09 GROG! <Uber[dot]GROG[at]Gmail[dot]Com>: Written # 2005-06-02 GROG! <Uber[dot]GROG[at]Gmail[dot]Com>: Updated to use du if ls doesn't return size. # set -x # TESTING if [ $# -ne 1 ]; then echo "Usage: ${0##*/} (pkgname|pkgfile)" >&2 exit 1 fi ACTION=${0##*-} case $ACTION in size) if [ -s $1 ]; then ipkg-files $1 2>/dev/null | while read line; do set -- $line echo $3 done else LISTSIZE=$(set -- $(ls -l $(which ${0##*/})); echo $#) if [ $LISTSIZE -ge 9 ]; then ipkg-files $1 | xargs ls -l 2>/dev/null | while read line; do set -- $line echo $5 done else ipkg-files $1 | xargs du 2>/dev/null | while read line; do set -- $line echo $(($1*1024)) done fi fi | (while read size; do TOTALSIZE=$((TOTALSIZE+$size)) done echo "Total installed size: $((TOTALSIZE/1024))kb") ;; files|info) if [ -s $1 -a ! -d $1 ]; then TMPDIR=/tmp/${1##*/} TMPDIR=${TMPDIR%%_*} \mkdir $TMPDIR >/dev/null \cp $1 $TMPDIR >/dev/null \cd $TMPDIR >/dev/null (ar -xv $1 || tar -xzf $1) >/dev/null 2>&1 case $ACTION in files) echo "File listing of package file $1:" >&2 tar -tzvf data.tar.gz ;; info) tar -xzf control.tar.gz cat control echo ;; esac cd - >/dev/null rm -Rf $TMPDIR >/dev/null else ipkg $ACTION $1 fi ;; *) echo "This script must be called via one of the following symlink's:" >&2 echo " ipkg-files ipkg-info ipkg-size" >&2 exit 1;; esac exit 0 |
|
|
|
Jun 3 2005, 06:54 AM
Post
#10
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
QUOTE Interesting. 'ls' doesn't seem to be returning the file size. That would cause a problem right? Sure. QUOTE What do these commands come back with? CODE $ ls -l $(which ls) lrwxrwxrwx 1 root root 7 Jun 2 17:21 /bin/ls -> busybox QUOTE CODE $ ls -f ls: invalid option -- f QUOTE As well, does 'ipkg-files opera' return anything at all? I suspect it doesn't. Nothing returns back, guess opera has other name for ipkg. QUOTE Does this output look similar to yours (similar being it results in a list of numbers followed by the file name, not this list exactly)? CODE $ du /bin/* | head 1 ? ? ? /bin/addgroup 1 ? ? ? /bin/adduser 1 ? ? ? /bin/ash 1 ? ? ? /bin/bash 1 ? ? ? /bin/bashbug 536 ? ? /bin/busybox 1 ? ? ? /bin/cat 1 ? ? ? /bin/chgrp 1 ? ? ? /bin/chmod 1 ? ? ? /bin/chown Yes very similar. Here is mine: CODE 0 /bin/addgroup 0 /bin/adduser 106 /bin/ash 548 /bin/bash 228 /bin/busybox 0 /bin/cat 0 /bin/chgrp 4 /bin/chkmntsh 0 /bin/chmod 0 /bin/chown QUOTE If it's similar, then this script modification might work better for you. It's not as accurate, but I don't think we're going for the gold as far as accuracy which in the busybox version only returns block size not byte size. Let me know how it goes. Unfortunately not - the same error like was before BTW you could attach scripts after renaming to .txt May be I got some copy-paste error? suruaZ |
|
|
|
Jun 3 2005, 09:49 AM
Post
#11
|
|
|
Group: Members Posts: 242 Joined: 31-March 04 Member No.: 2,592 |
QUOTE(suruaZ @ Jun 1 2005, 10:09 AM) Any ideas how to find memory occupied by programs from installed ipks? For example: 10 MB - a.ipk 5MB - b.ipk 3MB - c.ipk I need to clean a bit my internal memory but have no ideas what packages have more "weight" and what less. suruaZ Since files from a pkg can be installed in many directories, it is difficult to "search" them out and come up with a total. However, Here's another idea. On a terminal type 'df -h' _before_ you install the pkg, then type it again afterwards. It will give you a quck and easy way to see just how much room that last pkg consumes. Naturally you can reverse the process if you already have the pkg installed (assuming you still keep the pkg around to re-install). I hope this helps, Craig... |
|
|
|
Jun 9 2005, 09:22 AM
Post
#12
|
|
![]() Group: Members Posts: 692 Joined: 27-January 04 From: Canada Member No.: 1,564 |
Sorry for my absence, suruaZ. If you're still interested in pursuing this, here's the ipkg-wrapper script arttached instead of pasted. It's not any different from my last post, but yah never know.
Looking back again at the first debug output you provided (wrapper.txt), it seems that the root of the problem is that your ipkg isn't finding any files. What ROM are you using? What does 'ipkg --version' return? Can you copy-n-paste the output of 'ipkg files opera' (or whatever the real package name is) & I'll take another look. seeyah
Attached File(s)
|
|
|
|
Jun 10 2005, 07:22 AM
Post
#13
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
QUOTE Looking back again at the first debug output you provided (wrapper.txt), it seems that the root of the problem is that your ipkg isn't finding any files. What ROM are you using? Sharp ROM 3.13 QUOTE What does 'ipkg --version' return? ipkg: unknown option --version As I can see /home/QtPalmtop/bin/ipkg is link to the /usr/QtPalmtop.rom/bin/ipkg shell script. No ipkg executables found. QUOTE Can you copy-n-paste the output of 'ipkg files opera' (or whatever the real package name is) & I'll take another look. # ipkg files zip #//usr #//usr/bin #//usr/bin/zip After I have installed ipkg version 0.99.37 and have changed the link the output slightly changed: # ipkg files zip #/usr #/usr/bin #/usr/bin/zip But ipkg-size linked to the latest wrapper retutns the same error Attached is wrapper-log. Seems it scans more files than needs to find the size if zip installation. suruaZ
wrapper_log.txt ( 3.72K )
Number of downloads: 16 |
|
|
|
Jun 10 2005, 09:21 AM
Post
#14
|
|
![]() Group: Members Posts: 692 Joined: 27-January 04 From: Canada Member No.: 1,564 |
QUOTE(suruaZ @ Jun 10 2005, 09:22 AM) Sharp ROM 3.13 That explains why there's problems in the first place. I use OZ, so some (most?) of the tools would be different. Not wrong, just different QUOTE # ipkg files zip #//usr #//usr/bin #//usr/bin/zip After I have installed ipkg version 0.99.37 and have changed the link the output slightly changed: # ipkg files zip #/usr #/usr/bin #/usr/bin/zip Both of these outputs have me worried. Are they copy-n-paste? Does ipkg really return hash marks '#' at the beginning of each line? That would be the source of the problem if it does. Assuming that the output of 'which sed' returns the path to the program, try this latest version (attached). If you don't have sed installed, you'd have to find & install that package before you can try this out. I've since added a '-remove' option, but that won't affect us trying to fix the '-size'. let's keep the fun going
Attached File(s)
|
|
|
|
Jun 11 2005, 06:15 AM
Post
#15
|
|
|
Group: Members Posts: 123 Joined: 12-April 04 Member No.: 2,809 |
grog,
QUOTE Both of these outputs have me worried. Are they copy-n-paste? Does ipkg really return hash marks '#' at the beginning of each line? That would be the source of the problem if it does. No, I typed this. # means root's prompt QUOTE Assuming that the output of 'which sed' returns the path to the program, try this latest version (attached). If you don't have sed installed, you'd have to find & install that package before you can try this out. I've since added a '-remove' option, but that won't affect us trying to fix the '-size'. I have sed installed. I have tested your last ipkg-wrapper with the same error... Well I have a closer look onto wrapper debug output. This time I tried with file.ipkg installed. Please take a look onto wrapper-files.txt attached to see what files are installed first. Then look onto wrapper-size.txt. What is wrong there from my point of view: 1. The script processed lines with folders and links what is useless. The first three echos (224,304,2048) are folders and only forth (9612) is actually the filesize we need to sum in TOTALSIZE variable. Then again folder (1024) and link (15)... Must be something here to filter out folders and links; 2. After it processed all the lines from ipkg-files it starts to sum all echos and fails on the first step - /home/QtPalmtop/bin/ipkg-size: arith: syntax error: "TOTALSIZE+224". Note that 224 is the size of root folder echoed first. It looks like command "TOTALSIZE=$((TOTALSIZE+$line))" has syntax error. After I have changed it to "$TOTALSIZE=$TOTALSIZE+$line" it starts to fails on the next line - "$((TOTALSIZE/1024))". suruaZ
Attached File(s)
wrapper_files.txt ( 340bytes )
Number of downloads: 13
wrapper_size.txt ( 1.56K )
Number of downloads: 16 |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 17th May 2013 - 11:26 PM |