Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Emerge --feature request
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
jaduff
n00b
n00b


Joined: 04 Feb 2003
Posts: 15

PostPosted: Thu Feb 06, 2003 11:04 am    Post subject: Emerge --feature request Reply with quote

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 :D

--James (Dugite on #gentoo)-- bumbling along through linux.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Thu Feb 06, 2003 2:23 pm    Post subject: Reply with quote

bugs.gentoo.org
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
duff
Guru
Guru


Joined: 19 Jun 2002
Posts: 466
Location: Clemson, SC

PostPosted: Thu Feb 06, 2003 7:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
tecknojunky
Veteran
Veteran


Joined: 19 Oct 2002
Posts: 1937
Location: Montréal

PostPosted: Fri Feb 07, 2003 2:11 am    Post subject: Reply with quote

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
View user's profile Send private message
jaduff
n00b
n00b


Joined: 04 Feb 2003
Posts: 15

PostPosted: Fri Feb 07, 2003 3:41 am    Post subject: Thanks! Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum