# Preserve port configuration



## cahimira (Jun 24, 2013)

Hi,

Is it possible to preserve the port configuration (`make config`) after upgrade and or clean the port tree?

Thanks.


----------



## wblock@ (Jun 25, 2013)

It does that by default.  Have you had problems with it?


----------



## cahimira (Jun 25, 2013)

wblock@ said:
			
		

> It does that by default.  Have you had problems with it?



Hi,

Thanks for answering. Where is the custom configuration stored? Thanks.


----------



## wblock@ (Jun 25, 2013)

The user-selected options are stored in /var/db/ports/_portname_/options.


----------



## ShelLuser (Jun 25, 2013)

cahimira said:
			
		

> Where is the custom config stored?


They are stored in /var/db/ports where you still need to use the right ports name of course. There you'll find a file options which contains this information.

But even more important, in my opinion, is where you could find this kind of information yourself. I'd like to point you to the ports(7) manual page which honestly is your swiss army knife to common (and sometimes not so common) ports questions.

In this case the PORT_DBDIR environment option gives it all away:



> Directory where the results of configuring OPTIONS are stored.  Defaults to /var/db/ports.  Each port where OPTIONS have been configured will have a uniquely named sub-directory, containing a single file options.


"When in doubt about the Ports collection, check the Ports manual page first" (my own motto).

For the record: the only reason I'm writing it out as I do now is because I realize like no other how easy it is to overlook this. Truth be told I've been doing that myself the first weeks when I started using FreeBSD.


----------



## kpa (Jun 25, 2013)

wblock@ said:
			
		

> The user-selected options are stored in /var/db/ports/_portname_/options.



Close but it's actually /var/db/ports/${UNIQUENAME}/options. The difference is quite subtle. For example all the perl5.x ports share the same UNIQUENAME that is just perl.


----------



## wblock@ (Jun 25, 2013)

More detail does not always make it clearer.  Now we've introduced make(1) variables and notation.  I said _portname_, meaning "the name of the port" and the italics indicating it's a user-replaced value, not PORTNAME the make(1) variable.


----------

