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

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Eugene Yarmash
  • 2,383
  • 5
  • 32
  • 54

4 Answers4

6

Sequentially:

portmaster --check-depends 
portmaster --check-port-dbdir 
portmaster -s 
portmaster -y --clean-distfiles
Kondybas
  • 6,864
  • 2
  • 19
  • 24
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/*
michele
  • 575
  • 3
  • 7
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.

hmallett
  • 2,425
  • 14
  • 26
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/*
Eugene Yarmash
  • 2,383
  • 5
  • 32
  • 54
  • 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 Yarmash Jul 16 '12 at 09: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