Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm playing with a FreeBSD installation inside a Virtualbox vm, and I want to keep the size of the image relatively small. How can I configure FreeBSD to clean distfiles after installing a port (using make, portupgrade, etc)?

share|improve this question

4 Answers 4

Sequentially:

portmaster --check-depends 
portmaster --check-port-dbdir 
portmaster -s 
portmaster -y --clean-distfiles
share|improve this answer

How can I configure FreeBSD to clean distfiles after installing a port (using make, portupgrade, etc)?

If "after installing a port", just use the distclean target:

make install distclean

This will clean the work directory and the distfile after installing.

If you want to clean distfiles separately from installation, just run

rm -rf /usr/ports/distfiles/*
share|improve this answer

If you're using portupgrade, you can use portsclean.

portsclean -CDD

...will clean out the working directories of the ports tree and clean out the distfiles of any port that is not installed.

share|improve this answer
up vote 0 down vote accepted

There's more than one way to do it:

  • set DISTDIR in make.conf to /tmp/distfiles, or symlink /usr/ports/distfiles to /tmp/distfiles. /tmp will be cleared on the next reboot.
  • add this job to /etc/crontab: @reboot root rm -rf /usr/ports/distfiles/*
share|improve this answer
    
Bear in mind that /tmp is often a small file system, and some distfiles can be quite big, so don't be surprised if a port build fails with a "file system full" error during the fetch stage, if you adopt this approach. If you want the distfiles to be deleted automatically, you can script one of the other suggested approaches. An @boot system cronjob, for example, could be set up to carry out the steps in one of the other answers at startup. –  D_Bye Jul 13 '12 at 11:20
    
@D_Bye: I guess you meant @reboot. As for the separate /tmp partition, I doubt it is needed for my vm at all. –  eugene y Jul 16 '12 at 9:47
    
Yes, I meant @reboot - sorry about the typo. If you're not using a separate /tmp, then my comment doesn't really apply. It's still something to be aware of, I think. I haven't done a fresh install of FreeBSD for a while (I do source upgrades in-place) so I don't know what the default layout is like these days, so it could well be a single partition, in which case this point is moot. –  D_Bye Jul 16 '12 at 11:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.