OESF Portables Forum
Everything Else => General Support and Discussion => Zaurus General Forums => Archived Forums => Software => Topic started by: suruaZ on June 01, 2005, 02:09:24 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
-
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
[div align=\"right\"][a href=\"index.php?act=findpost&pid=82395\"][{POST_SNAPBACK}][/a][/div]
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
-
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:
# 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:
#!/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!
# 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
-
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?
-
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
-
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.
-
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?
$ ls -l $(which opera)
If you want, uncomment this line:
# set -x # TESTING
And then run this command:
$ ipkg-size opera 2>&1 | tee /var/tmp/wrapper.log
And attach the log file & I'll figure out what's wrong.
-
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"
$ ls -l $(which opera)
lrwxrwxrwx root root /home/QtPalmtop/bin/opera -> /usr/QtPalmtop.rom/bin/opera
# set -x # TESTING
And then run this command:
$ 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
-
$ 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.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=82511\"][{POST_SNAPBACK}][/a][/div]
Interesting. 'ls' doesn't seem to be returning the file size. That would cause
a problem . You are issuing the command 'ls -l', that's 'el es space dash el',
right? What do these commands come back with?
$ 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)?
$ 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
. This version should use the du command on your box to get the file sizes,
which in the busybox version only returns block size not byte size.
Let me know how it goes.
#!/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! : Written
# 2005-06-02 GROG! : 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
-
Interesting. 'ls' doesn't seem to be returning the file size. That would cause
a problem . You are issuing the command 'ls -l', that's 'el es space dash el',
right?
Sure.
What do these commands come back with?
$ ls -l $(which ls)
lrwxrwxrwx 1 root root 7 Jun 2 17:21 /bin/ls -> busybox
$ ls -f
ls: invalid option -- f
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.
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)?
$ 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:
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
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
. This version should use the du command on your box to get the file sizes,
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
-
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
[div align=\"right\"][a href=\"index.php?act=findpost&pid=82395\"][{POST_SNAPBACK}][/a][/div]
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...
-
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
-
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
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.
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 [ You are not allowed to view attachments ]
-
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 .
# 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[div align=\"right\"][a href=\"index.php?act=findpost&pid=83722\"][{POST_SNAPBACK}][/a][/div]
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
-
grog,
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
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
-
Hi again. You made some good suggestions in you last post, thanks. Those and the output your 'ipkg-files file' made me realize what the problem might be. The version of ipkg that is used in OZ doesn't return directory names, just file names, whereas it seems the one in the sharp rom returns everything. And while directories & symlinks themselves do take up space, that's negligable compared to the files, so I've tweaked the script a bit to take this into account. As well, I discovered another potential problem depending on what directory you're in at the time the script is run, so I've fixed that too.
Try out the latest version & let me know how it goes. This copy won't spit out the debugging output, so if it still doesn't work (cross our fingers), uncomment the TESTING line & attach the output. thks
-
Hi grog,
Seems you attached the wrong script - there're no changes compared to previous one.
suruaZ
-
oops. Here here's the new one.
-
Unfortunately no luck
Nearly the same debug output as before and failed on the same line:
/home/QtPalmtop/bin/ipkg-size: arith: syntax error: "TOTALSIZE+224"
224 is the first echo - size of /
suruaZ
-
Ok, I don't know what I may have been imbidding to much of yesterday, but I *still* gave you the wrong version of the script. Here's the right one. Give'er another go. haveAhappy
-
No echos for a folders now but still for a links.
Unfortunately again it stopped on "TOTALSIZE=$((TOTALSIZE+$line))" line.
I believe something wrong with syntax here.
suruaZ
-
No echos for a folders now but still for a links.
Shouldn't be a problem. Like I said before, directories & links on a unix filesystem are still just special files that take up space, albeit a small amount compared to other 'regular' files.
Unfortunately again it stopped on "TOTALSIZE=$((TOTALSIZE+$line))" line.
I believe something wrong with syntax here.[div align=\"right\"][a href=\"index.php?act=findpost&pid=84296\"][{POST_SNAPBACK}][/a][/div]
The syntax is correct for all modern bourne- & korn-based shells I'm aware of, which includes the version of sh provided by busybox, but let's see. What's the exact output of these commands on your Z?
root@grond[~]# N=4
root@grond[~]# T=$((T+N))
root@grond[~]# echo $N $T
4 4
root@grond[~]# T=$((T+N))
root@grond[~]# echo $N $T
4 8
root@grond[~]# T=$((T+N))
root@grond[~]# echo $N $T
4 12
There's another way the math can be done, using a utility called bc. See if you can find a package that's installable on your Z (search elsi if necessary) & depending on your output of the above commands & that I'll make another mod & see if that'll make a difference.
-
Shouldn't be a problem. Like I said before, directories & links on a unix filesystem are still just special files that take up space, albeit a small amount compared to other 'regular' files.
Yes I agree with you. I just thought this could be the cause of error.
The syntax is correct for all modern bourne- & korn-based shells I'm aware of, which includes the version of sh provided by busybox, but let's see. What's the exact output of these commands on your Z?
root@grond[~]# N=4
root@grond[~]# T=$((T+N))
root@grond[~]# echo $N $T
4 4
root@grond[~]# T=$((T+N))
root@grond[~]# echo $N $T
4 8
root@grond[~]# T=$((T+N))
root@grond[~]# echo $N $T
4 12
Here is the error!!!
If I typed this in my default shell (/bin/bash) I got the same output as you.
But if I first typed:
/usr/bin/env sh
and after switched to the shell environment typed:
$ N=4
$ T=$((T+N))
the error returned:
arith: syntax error: "T+N"
I dodn't know in which shell I went after "/usr/bin/env sh" but after I have changed in your script the first line to the "/bin/bash" everything start to work and I found that my file.ipkg has installed size 966kb
Thank you grog for your time and the nice script
suruaZ
-
What's the exact output of these commands on your Z?
Here is the error!!!
I dodn't know in which shell I went after "/usr/bin/env sh" but after I have changed in your script the first line to the "/bin/bash" everything start to work
kewl. I figured it wa a shell problem. The sharp rom must come with an older version of busybox that doesn't have emulation for integer math calculation. It's good that you had bash so you could figure that out.
FYI, you could have changed the '/usr/bin/env sh' to '/usr/bin/env bash' & it would have worked as well (that convention works even if bash wasn't installed under /usr/bin, as it searches your path. That's why I use it.).
Thank you grog for your time and the nice script [div align=\"right\"][a href=\"index.php?act=findpost&pid=84498\"][{POST_SNAPBACK}][/a][/div]
I'm just glad that by working together we managed to finally figure it out.
Thanks for you help in improving my script .
havefun!!