blob: 8770db72f102eb89a2898804f09e55be43bc1e3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/sh
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header$
# Author: Karl Trygve Kalleberg <karltk@gentoo.org>
echo
echo -e "\x1b[31;01m!!! As of Gentoolkit 0.2.0, this tool is deprecated."
echo -e "!!!\x1b[0;0m Refer to 'equery size' for a replacement."
echo
spec=$1
if [ -z "$spec" ] ; then
echo "Usage: pkg-size package"
exit 1
fi
name=`echo $1 | sed "s/\([^/]*\)\///"`
category=`echo $1 | sed "s/\/.*//"`
if [ "$category" == "$name" ] ; then
category=
fi
function tryfile() {
local foo
foo=/var/db/pkg/$1/CONTENTS
bar=`ls $foo 2> /dev/null`
for i in $bar ; do
if [ -f "$i" ] ; then
echo $i
break
fi
done
}
file=`tryfile "${category}/${name}"`
if [ -z $file ] ; then
file=`tryfile "${category}/${name}*"`
if [ -z $file ] ; then
file=`tryfile "${category}*/${name}"`
if [ -z $file ] ; then
file=`tryfile "${category}*/${name}*"`
if [ -z $file ] ; then
echo "!!! Package resembling ${category}/${name} not found"
exit 1
fi
fi
fi
fi
pkgname=`echo $file | sed -e "s:\/var\/db\/pkg\/::" -e "s:\/CONTENTS::"`
totals=`cat $file|grep "obj"|awk '{ print $2 }' | sed "s/ /\\ /" | xargs du -scb | grep total | cut -f 1`
size=0
for i in $totals ; do
size=$[size+i]
done
echo "$pkgname $size ($[size/1024]KB)"
|