Clean up a dirty FreeBSD ports tree
March 2018
Sun Mon Tue Wed Thu Fri Sat
        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
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments
Recent Trackbacks
OpenBSD (9 items)
BSD (0 items)
FreeBSD (19 items)
Linux (3 items)
Security (3 items)
Python (22 items)
Zope (13 items)
Daily (144 items)
e-shell (9 items)
Hacks (14 items)
PostgreSQL (3 items)
OSX (8 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (1 items)
Django (24 items)
Music (12 items)
Plone (7 items)
Varnish (0 items)
Lugo (2 items)
Sendmail (0 items)
europython (7 items)
Cherokee (1 items)
self (1 items)
Nature (1 items)
Hiking (0 items)
uwsgi (0 items)
nginx (0 items)
cycling (10 items)
Networking (1 items)
DNS (0 items)

Syndicate this site (XML)

RSS/RDF 0.91

19 enero

Clean up a dirty FreeBSD ports tree

Use this if you don't need to perform a full-tree cleanup

This is a quick hack for those of you who (as me) usually forget to perform a make clean after make install when installing software using the FreeBSD ports collection.

This is the shell script:

# Search for ports that contain a "work" subdirectory,
# then go into that port directory and perform a
# make clean

for i in `find /usr/ports -name work -type d`
  cd `echo "$i" | sed 's/\/[^\/]*$/\//'`
  make clean

It simply searchs for directories called work within the ports tree (because this is the name of subdirectories created by the ports tree when building software before installing it), then it removes the last part of the path (the work directory itself) and then it goes into the port directory and performs a make clean to clean up this port (and all the dependencies of the port).

This could be helpful if you only need to clean a given number of ports (10, 20, whatever) and you don't want to perform a full clean:

cd /usr/ports && make clean

This will clean up the whole ports tree, but it will take a loooong time to finish.

Oh!, obviously you need root privileges to execute the script (use sudo to call the script or edit the script and replace make clean with sudo make clean for example).

Posted by wu at 12:33 | Comments (2) | Trackbacks (0)
<< Soekris BIOS upgrade using MacOSx Snow Leopard | Main | Short summary of the first three months of 2011 >>
Re: Clean up a dirty FreeBSD ports tree

portclean -CD goes fast.
Is this the same thing?

it is part of the portupgrade tool.

Posted by: name at junio 14,2012 16:19
Re: Clean up a dirty FreeBSD ports tree

TOP=`pwd`; find . -type d -name work |\
xargs dirname | while read d ; do
cd $d && make clean
cd $TOP

Posted by: m at septiembre 18,2014 14:26
Re: Clean up a dirty FreeBSD ports tree

rm -rf /usr/ports/*/*/work

Posted by: pixel at noviembre 06,2014 10:08
Please send trackback to:
There are no trackbacks.
Post a comment