View previous topic :: View next topic |
Author |
Message |
jaduff n00b
Joined: 04 Feb 2003 Posts: 15
|
Posted: Thu Feb 06, 2003 11:04 am Post subject: Emerge --feature request |
|
|
This is actually a feature request, but I couldn't see where else I should post this...
Anyways, I, like many people have a download limit per month on my internet connection, and I can find out at any point how much I have left for that month. Would it be possible to add an emerge argument that reports the total download of an install? ie emerge -p<arg> kde, would report the total download required for kde and all dependencies.
This way I could know whether or not I could afford to install something during any given month.
Thanks
--James (Dugite on #gentoo)-- bumbling along through linux. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Thu Feb 06, 2003 2:23 pm Post subject: |
|
|
bugs.gentoo.org _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
duff Guru
Joined: 19 Jun 2002 Posts: 466 Location: Clemson, SC
|
Posted: Thu Feb 06, 2003 7:43 pm Post subject: |
|
|
Sounds useful and interesting, so here's a script I whipped up that should do what you're looking for. You need to emerge "bc" if you haven't already.
Code: | #!/bin/sh
NOCOLOR="true"
if [ "$1" = "world" ]
then
emerge -pu $1 | sed -e "s:\[.*\] ::g" > /tmp/tobuild
else
emerge -p $1 | sed -e "s:\[.*\] ::g" > /tmp/tobuild
fi
TOTALLINES=`cat /tmp/tobuild | wc -l`
LINES=`echo "${TOTALLINES} - 4" | bc`
echo "0" > /tmp/sizes
tail -n ${LINES} /tmp/tobuild |
while read ebuild
do
PKG=`echo ${ebuild} | sed -e "s:\/: :" | awk '{print $1}'`
VER=`echo ${ebuild} | sed -e "s:\/: :" | awk '{print $2}'`
DIGEST="/usr/portage/${PKG}/*/files/digest-${VER}"
if [ -f ${DIGEST} ]
then
cat ${DIGEST} |
while read line
do
echo "+" >> /tmp/sizes
echo ${line} | awk '{print $4}' >> /tmp/sizes
done
fi
done
SIZES=`cat /tmp/sizes`
echo ${SIZES} | bc
rm -f /tmp/tobuild
rm -f /tmp/sizes
|
Without KDE installed, the script produces this:
Code: | # ./totalsize.sh kde
103948410
|
So, it's about a 103MB download for me.
EDIT: Checks to see if you're testing the download size of world, and uses the --update flag if you are |
|
Back to top |
|
|
tecknojunky Veteran
Joined: 19 Oct 2002 Posts: 1937 Location: Montréal
|
Posted: Fri Feb 07, 2003 2:11 am Post subject: |
|
|
Same, but only use sed and does not create files. Code: | #!/bin/sh
NOCOLOR="true"
UPDATE=""
[ "$1" ] || exit
[ "$1" = "world" ] && UPDATE="u"
SIZES=0
for PKG in `emerge -p$UPDATE $1 | sed '6,$!d;s:.*\]\ ::'`; do
CATEGORY="`echo $PKG | sed 's:/.*::'`"
DNAME="`echo $PKG | sed 's:^.*/::'`"
NAME="`echo $DNAME | sed 's:-[0-9].*::'`"
DIGEST="/usr/portage/$CATEGORY/$NAME/files/digest-$DNAME"
[ -f "$DIGEST" ] || continue
cat $DIGEST
for THIS in `sed 's:.*\ ::' $DIGEST`; do
SIZES=$((SIZES + THIS))
done
done
echo "Total: $SIZES" |
_________________ (7 of 9) Installing star-trek/species-8.4.7.2::talax.
Last edited by tecknojunky on Fri Feb 07, 2003 3:58 am; edited 2 times in total |
|
Back to top |
|
|
jaduff n00b
Joined: 04 Feb 2003 Posts: 15
|
Posted: Fri Feb 07, 2003 3:41 am Post subject: Thanks! |
|
|
Thanks for those, seems to be just what I need. I'm also gonna go through those scripts with a fine tooth comb, in an attempt to teach myself some basic scripting, at the moment, I know very little.
Thanks! _________________ --James (Dugite) |
|
Back to top |
|
|
|