Persistant port compile options

A while ago I was again frustrated by the limitations in FreeBSD ports. I did a few portupgrade's on some software only to discover later on that I did not specify the same environment variables as last time I did it, the result was a bunch of badly behaving ports.

After some discussion on IRC we all agreed it would be pretty simply to just store a per-directory environment somewhere. I mentioned this to Neil who pointed me at penv.

penv is a utility which helps manage persistent per-directory environment settings. In other words, it saves you the trouble of setting or specifying the same environment variables over and over again when executing programs in a specific directory. The main reason for the initial development of penv was its use with the FreeBSD Ports Collection , but it may be used for other day-to-day tasks, too.

While this sounds very nice, it has some issues, if you install port a which required port b something has to run penv when building port b else it won't work. The penv author has a patch to make which works very nice but is a bit drastic to my liking.

Some reading of the portupgrade man page got me to the -M command line option which the man page is something to prepend to the commandline of make. Did not sound right at the beginning but eventually this turned out to be just the ticket.

In my /usr/local/etc/pkgtools.conf file I put the following:

PORTUPGRADE_ARGS = ENV['PORTUPGRADE'] || '-M penv'

and now for each port that I have specific build requirements I simply do:

# cd /usr/ports/net/centericq/
# penv -c mkdir
# penv -S WITH_MSN=1
# penv -L
WITH_MSN=1

And any further portinstall or portupgrade operations on the centericq port will always build it with MSN support.

2 Comments

Yes, nice, and might be usefull for what I'd like to do - namely, Getting it to keep backups of certain ports (wine, precisely) that have the habbit of loosing functionality with upgrades.

But for what you need, what's wrong with the MAKE_ARGS feature in pkgtools.conf?
MAKE_ARGS = {
'emulators/bochs*' => 'WITH_NE2000=yes WITH_SOUND=yes',
'textproc/ispell*' => 'ISPELL_BRITISH=yes',
'print/ghostscript*' => 'A4=yes',
}

hey,

That will work as well. I considered it as an option but in the end personal preference is not to edit a config file each time I want to modify a port, I'd rather issue a command it just seems like less work.

On backing up ports, why do you not use :

pkg_create -b <package name>

this will give you a binary package of a currently installed port. It may not contain the original pre and post install scripts, but may be worth a try.

Leave a comment

Recent Entries

  • flashpolicyd 2.0

    I wrote a multi threaded server for Adobe Flash Policy requests, some background from Adobe:Since policy files were first introduced, Flash Player has recognized /crossdomain.xml...

  • Adventures with Ruby

    Some more about my continuing experiences with ruby, in my last post I saidthe language does what you'd expect and as you'll see in my...

  • New programming language of choice - Ruby

    I have fallen out of love with Perl some time ago, I cannot point to one specific thing about it that put me off, I...

  • On working from home

    I've not been posting much here, work has been incredibly manic the last while, especially I need to still finish off my SSO posts with...

  • Rework of puppet facts for /etc/facts.txt

    Previously I blogged a custom fact that reads /etc/facts.txt to build up some custom facts for use in Puppet manifests, well I've since learned a...

Close