macports


How to get the size of the installed package via MacPort?


port installed displays all the installed packages on the local machine, but is there any way to list the size of each one? Thanks!
I don't believe there's a build in command from Macports to list the size of your installs, but you can do this:
Try this command in the terminal:
du -sh /opt/local/var/macports/software/*
This will give you the size of every package in /opt/local/var/macports/software/*, which I believe is the default install location.
Obviously, if you install your ports somewhere else you can use
du -sh [directory]
Without a built in Macports command, this is the probably the best you can do.
One alternative that comes to mind is creating a script that would take the output of
port installed
and echo the size of each install.
edit:
I was mistaken. /opt/local/var/macports/software/* contains the tarbells that the installations were extracted from, so the sizes will be smaller.
If you do du -sh /opt/local, it should list the size of everything, but there may be a few non-macports packages in the list.
The command port contents installed will show you the directory of everything macports has installed.
port space --units MB installed
Nice and easy, has been available since version 2.0 all the way back in 2011!
Here's a small bash function that will take any valid macports query
function port_size {
size=0
pkg_size=0
for pkg in $(port $# | tail -n +2 | awk '{ print $1 }')
do
pkg_size=$(port contents $pkg \
| sed -r 's/^[[:space:]]*(.*)[[:space:]]*$/\1/g;s/ /\\ /g' \
| tail -n +2 | xargs du | cut -f1 | paste -sd '+' | bc)
size=$(( $size + $pkg_size ))
printf "%10d %s\n" $pkg_size $pkg
done
printf "%10d %s\n" $size "Total Size (KB)"
}
I've only tested it with GNU versions of sed and awk but it should work regardless.
port_size installed # will print out all installed packages and their size
port_size installed gcc* # will print out all packages matching gcc* wildcard
Again, any valid macports query will work (including installed inactive or outdated.

Related Links

Macport self update failed
Is it possible to use MacPorts to distribute custom software?
How do I make libgc work in Mac OS X?
500 OOPS: vsftpd: not configured for standalone, must be started from inetd
Mac Ports Update Failing
Macports ncurses error when trying to upgrade [closed]
macports: list out my own ports
why does macports “--set ipython ipython32” fail?
Prevent MacPorts from installing pre-built package?
Wine is extremely slow, how do I find out why?
Problems with macports
Where can I view tools or packages availble in Homebrew
See what has been installed via MacPorts
Installing a php extension with Macports
Lost ability to run as sudo following MacPorts upgrade
Error: Failed to install atk with mac ports

Categories

HOME
xpath
plesk
mpdf
activex
theano
vsts-build
histogram
consul
lvm
elk-stack
repair
impala
fedora
tweepy
reportviewer
swarm
lapack
colors
clish
dma
corona
reselect
web-deployment
mixpanel
cloudsim
codefluent
home
opam
spring-ldap
activeadmin
backtracking
candlestick-chart
pyopencl
uilocalnotification
sales
dnsmasq
substance
intune
location-services
djcelery
text-decorations
gitolite
linq.js
jacoco-maven-plugin
classnotfoundexception
viewcontroller
opal-framework
latexml
audio-converter
directwrite
tinyioc
brightscript
sigsegv
android-sharing
aurelia-fetch-client
pecl
business-rules
dymola
hmmlearn
adobe-reader
pbx
scheduledexecutorservice
streamwriter
nvda
always-on-top
seccomp
msbuild-4.0
meld
yii2-model
gnucash
exists
mnesia
taco
voronoi
enunciate
helm
nette
astropy
asp.net-web-api-helppages
sqlbase
knife
gql
replicaset
phpredis
erlog
deque
shell-extensions
sablecc
jcheckbox
microsoft-expression-web
comctl32
ildasm
mobile-country-code
communicate
refit
tabletools
xmi
hotswap
django-settings
hints
ax
examine
idispatch
gitx
clearinterval
border-box
coordinate
gamesalad
servercontrol
asp.net-mvc-views
3des
qcar-sdk
reliability
ppc
3270
sqlsitemapprovider
html-generation

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App