create ports from list

Doug Barton dougb at FreeBSD.org
Fri Jan 25 23:51:42 PST 2008


c.mm at gmx.net wrote:
> Hello,
> 
> I have a server with round about 200 installed Ports. I need
> to setup a second server with the same, but slightly newer,
> ports recompiled from source.
> 
> Is there an easy way to crate a port list with compile options
> and feed a build command on the second server with it?

You've had a few responses to this already, but I think each missed a 
piece of the puzzle. The suggestion to use portmaster -l to generate a 
list is a good one, but I'm biased of course. :) So, install 
ports-mgmt/portmaster, then do 'portmaster -l > ~/port-list'. Then edit 
that file to remove the headers, and the trunk and branch ports.

Now for the key step. On the new server, assuming that it has no ports 
installed at all, you'll need to know what port directories to install 
from, not the names of the installed ports from the first server. So, 
you'll want to do something like this:

while read port; do
grep ' ORIGIN' /var/db/$port/+CONTENTS | cut -f 2 -d ':'
done > ~/port-origin-list

Then if it were me on the new server I would download all the distfiles 
first (copy over any current ones from the old server, then):
while read orig; do
portmaster -F $orig
done < port-origin-list

This would have the additional benefit of running through the OPTIONS 
dialogs so that you can choose the options you want. Then:

while read orig; do
portmaster -Dt $orig
done < port-origin-list

You could also concatenate the list of ports onto one long line, 
separated by spaces, and do 'portmaster <options> `cat list` which would 
use one parent process to run all the configs, then all the builds, so 
you could do it (hopefully) "unattended" after it starts building. 
(Where "unattended" assumes that no builds fail.) This has the benefit 
of caching all the dependency data, so once something is up to date it 
doesn't have to be checked again.

As for the configure options, you can copy /var/db/ports and 
/etc/make.conf (and/or /usr/local/etc/ports.conf if it exists) from the 
existing server to the new one. That way portmaster will only prompt you 
during the 'make config' phase if there are new options to choose.

Now, all that said, if the two systems have similar architectures you 
could just do 'portmaster -a' on the first one, and then do:

for pkg in /var/db/pkg/*; do
pkg_create -b $pkg
done

and install all your shiny new packages on the new system.

hope this helps,

Doug

-- 

     This .signature sanitized for your protection


More information about the freebsd-ports mailing list