Gentoo: per-package PORTAGE_TMPDIR settings

I don’t know how many people know about per-package environment variables in portage since 2.1.9 or so. (ref: bug 44796) It is a worthwhile enhancement to know about, regardless. Like most people, I have my PORTAGE_TMPDIR on tmpfs to speed up compilation times and reduce I/O usage. My 2G tmpfs mounted on /var/tmp/portage is large enough for almost all packages, even multiple jobs at once, however, not all. Solution:

% cat /etc/portage/package.env
app-office/libreoffice notmpfs.conf
% cat /etc/portage/env/notmpfs.conf
PORTAGE_TMPDIR=”/var/tmp/notmpfs”

(More info available in the portage man page)

Now, when I find my next package that needs notmpfs, it is as easy as: echo "cat-egory/pkg notmpfs.conf" >> /etc/portage/package.env which is much easier than bashrc hacks or something else insane that I have seen. Of course you can extend that to most make.conf settings, hope that helps someone.

13 Comments

  • Szymek
    September 16, 2011 - 11:32 am | Permalink

    Thanks! It is just what I need.

  • September 16, 2011 - 12:41 pm | Permalink

    Thanks. I have exactly the same problem with libreoffice. Appreciate the tip – this is the first I’ve heard of per-package settings.

  • September 16, 2011 - 1:53 pm | Permalink

    Great! I always had to umount /var/tmp/portage to compile Libreoffice. =D

  • September 16, 2011 - 2:45 pm | Permalink

    Cool! Thanks for sharing … Portage really needs some wiki/docs site … Though Zac will always say that everything’s in the manpages for Portage.

    • September 16, 2011 - 5:09 pm | Permalink

      Yea, the man page for this one was hard to figure out. Well, not hard but I had to read package.env and env/ sections multiple times to see what it was really meaning.

  • Cynyr
    September 16, 2011 - 7:59 pm | Permalink

    perhaps http://en.gentoo-wiki.com/wiki/Portage_TMPDIR_on_tmpfs should get an update for this much cleaner method.

    Maybe I’ll give it a shot later.

  • Nan
    September 17, 2011 - 10:09 am | Permalink

    Very interesting. In the past I had tried to set PORTAGE_TMPDIR in /etc/portage/env/cat-egory/package but emerge complained about PORTAGE_TMPDIR being read-only so I didn’t think it was possible. Thanks for the tip.

  • Jack
    September 17, 2011 - 8:49 pm | Permalink

    www-client/chromium is another one

    • September 21, 2011 - 9:36 am | Permalink

      Well, yes. I never intended to have an exhaustive list. :) Depends on your tmpfs size, etc, anyway.

  • avx
    September 18, 2011 - 6:46 am | Permalink

    So, to get this right, I *can* use everything here, which I normally set as defaults in make.conf? I.e. set C/LDFLAGS, USE, FEATURES, ACCEPT_KEYWORDS, LICENSE, etc?

    • September 18, 2011 - 12:01 pm | Permalink

      Just about everything, the only thing that I know that doesn’t work is FEATURES=buildpkg. If you run across anything, please open a bug report.

  • September 22, 2011 - 2:30 pm | Permalink

    no more hand fapping distcc out of make.conf :D awesome!

  • Josiah
    April 28, 2012 - 9:49 pm | Permalink

    Good looking out! Save me on an old machine firefox compile… 4gigs to compile firefox! What happened to a lighter faster browser?!? Thank bro, I can see some mad uses for the per-package variable.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>