pkgsize(1)

NAME

pkgsize - display the disk usage of a package

SYNOPSIS

pkgsize [-v] [-r <alt_root>] [-w|--wget] <name_of_port>

pkgsize -h

DESCRIPTION
pkgsize shows disk usage (in kilobytes) of an installed port, or the size of all the remote sources (whether already downloaded or not). In verbose mode (option -v), it can also show disk usage of each file owned by the port.

OPTIONS

-w, --wget
    online mode: queries the remote server to determine the size of each source file. Default mode when the port is not installed. In this mode, the port must be available among the active repositories configured in /etc/prt-get.conf(5). The flag is an anachronism in the latest CRUX release (now that curl has supplanted wget as the default download utility) but is retained for backward compatibility.

-r <alt_root>
    specifies the root directory of a different CRUX installation (e.g., /mnt). This option determines which package database is queried for the file list (of an installed port), but does not affect the active port collections used for online mode (when constructing the list of sources and remote hosts). Although it is uncommon to maintain a CRUX installation on a mounted filesystem and not have any ports collections installed there, the safest assumption is to treat the parent filesystem as the place where the most up-to-date ports reside.

-v  be more verbose (displays the disk usage of each file in a package)

-h  print help and exit

EXAMPLES

pkgsize -w gimp
    opens a HTTPS connection to download.gimp.org and parses the Content-Length field to determine the size of the tarball

pkgsize -r /mnt glslang
    shows disk usage of glslang, on the CRUX installation mounted under /mnt

prt-get listinst | xargs pkgsize
    shows disk usage of every installed port

prt-get listinst | shuf -n 10 | xargs pkgsize \
| awk 'BEGIN{count=0} {if ($6>600) ++count} END{print(count)}'

    generates a random sample of ten installed packages, and calculate how many in the sample occupy more than 600 kilobytes of disk space

prt-get listinst | xargs pkgsize -v
    shows disk usage of every file in every installed port

mapfile -t myPortUsage < <(prt-get listinst | xargs pkgsize | cut -d" " -f6)
BC_CMD="scale=4; "
for ((s=0; s<100; s++)); do
   BC_CMD+=" ($(shuf -e -n 30 "${myPortUsage[@]}" | tr '\n' '+')0)/30;";
done
echo "$BC_CMD" | bc

    generates a sampling distribution of the disk usage, using 100 samples of 30 packages each and computing the sample means. A histogram of the results can be obtained by appending a pipeline to awk, for example:

| awk 'BEGIN{print(" kB range | frequency")}
       { hist[int($1/500)]=(hist[int($1/500)] "*")) }
       END {for (h in hist) {
         printf("%3i--%3i|%s\n",(h-1)*500,h*500,hist[h]) }
       }'

AUTHORS

Damir Saric <damir.saric at du.hinet dot hr>

John McQuah <jmcquah at disroot dot org>

SEE ALSO
prt-get(8), ports(8)