$ 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