Author Topic: How To Find Memory Occupied By Installed *.ipk  (Read 9626 times)

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« 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
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB

iamasmith

  • Hero Member
  • *****
  • Posts: 1248
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #1 on: June 01, 2005, 05:34:20 pm »
Quote
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
OpenBSD 4.2 -current on full 4Gb of SL-C3000
Microdrive replaced with 4Gb SanDisk Extreme III card

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #2 on: June 01, 2005, 05:42:26 pm »
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: [Select]
# 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: [Select]
#!/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
« Last Edit: June 01, 2005, 05:45:51 pm by grog »
GROG!

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #3 on: June 02, 2005, 03:35:14 am »
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?
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #4 on: June 02, 2005, 03:35:45 am »
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
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB

pgas

  • Hero Member
  • *****
  • Posts: 1097
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #5 on: June 02, 2005, 03:49:12 am »
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.
SLC-860 cacko / senao wifi

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #6 on: June 02, 2005, 07:06:49 am »
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: [Select]
$ ls -l $(which opera)If you want, uncomment this line:

Code: [Select]
# set -x # TESTINGAnd then run this command:

Code: [Select]
$ ipkg-size opera 2>&1 | tee /var/tmp/wrapper.logAnd attach the log file & I'll figure out what's wrong.
GROG!

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #7 on: June 02, 2005, 10:38:48 am »
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: [Select]
$ ls -l $(which opera)

lrwxrwxrwx root root /home/QtPalmtop/bin/opera -> /usr/QtPalmtop.rom/bin/opera

Quote
Code: [Select]
# set -x # TESTINGAnd then run this command:

Code: [Select]
$ ipkg-size opera 2>&1 | tee /var/tmp/wrapper.logAnd 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
« Last Edit: June 02, 2005, 11:09:59 am by suruaZ »
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #8 on: June 02, 2005, 03:34:22 pm »
Quote
Code: [Select]
$ 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?

Code: [Select]
$ 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: [Select]
$ 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.

Code: [Select]
#!/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
GROG!

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #9 on: June 03, 2005, 10:54:40 am »
Quote
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.

Quote
What do these commands come back with?

Code: [Select]
$ ls -l $(which ls)

lrwxrwxrwx    1 root     root            7 Jun  2 17:21 /bin/ls -> busybox

Quote
Code: [Select]
$ 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: [Select]
$ 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: [Select]
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
. 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
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB

cvmiller

  • Full Member
  • ***
  • Posts: 242
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #10 on: June 03, 2005, 01:49:12 pm »
Quote
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...
SL-6000
ROM v1.12 (Sharp)
Belkin F8U1500 IR Keyboard
1 GB SD Card by SanDisk (ext2)

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #11 on: June 09, 2005, 01:22:02 pm »
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
GROG!

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #12 on: June 10, 2005, 11:22:49 am »
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 [ Invalid Attachment ]
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
How To Find Memory Occupied By Installed *.ipk
« Reply #13 on: June 10, 2005, 01:21:07 pm »
Quote
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[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!

suruaZ

  • Full Member
  • ***
  • Posts: 123
    • View Profile
How To Find Memory Occupied By Installed *.ipk
« Reply #14 on: June 11, 2005, 10:15:26 am »
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
« Last Edit: June 12, 2005, 10:07:20 am by suruaZ »
SL-5500, Sharp ROM 3.13, Pretec GSM/GPRS CF, IBM Microdrive 340 MB