3

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)?

4 Answers 4

6

Sequentially:

portmaster --check-depends 
portmaster --check-port-dbdir 
portmaster -s 
portmaster -y --clean-distfiles
2

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/*
0

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.

0

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/*
3
  • 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, 2012 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. Jul 16, 2012 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, 2012 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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