Transferring ports

Dmitry Marakasov amdmi3 at
Thu Mar 13 21:02:45 UTC 2008

* Ivan Voras (ivoras at wrote:

> I have an idea and a request for people familiar with ports & pkgdb
> infrastructure: a utility (preferably written in C, Python or as a shell
> script) that would transfer *installed* ports from one system tree to
> the other, including their dependencies. It would transfer only some
> ports, specified on the command line.
There's no way to do it clearly. Not only such utility will have
to deal with dependencies anyway, but also there are ports that do more
than just copy files on installation (such as registering uids/gids,
handling user-modified configs nicely etc.).

> The details: imagine there are two or more full FreeBSD installation
> trees in the file system (e.g. complete jails). The utility would
> transfer (installed) packages from one tree to the other. The easy,
> brute-force way would be to generate package files (tbz) from the
> installed tree and then install them to the other tree, but I can't do
> that because of performance and disk space reasons.
I think that the easiest and most correct way will be to use packages.
You can share packages/ directory between jails via nullfs (or
between hosts via nfs) - single set of packages surely will take
no more space than a single set of installed ports in a jail. And
the only performance overhead is bzipping a package one time and
bunzipping number_of_jails times.

And actually, what you want is done pretty easily, like this:


pkg_info -q -L <port1> <port2> [...] | while read file; do
	mkdir -p $JAIL/`dirname "$file"`
	cp -pP "$file" $JAIL/"$file"

(this is just a scratch, use with care)

> Is there a utility that would do that, and if not, does anyone have the
> time to write one?
Actually, I've already had an idea of utility with pretty similar
functionality for a long time. The utility would copy directory
hierarchies recursively based on file include/exclude list, like this:


so `my_cool_copy_utility / /path/to/jail` will copy /etc,/bin,/sbin,/lib
and /usr dirs to jail, but in /usr/share/locale will only copy
russian locales, but no others, and in usr/local it won't copy
man, include and other dirs not needed in a jail.

The purpose is similar - creating jails out of host system in fast
and easy way, possibility to strip everything unneeded (useful for
secure minimal jails or flash/livecd/embedded installations of
minimal size) and add something extra, like stuff from /usr/local
without installing full packages in a jail, or, say, copying over
additional tree of jail-specific changes (mostly stuff under /etc
and /usr/local/etc).

Such an utility is something I still might start working on.

Dmitry A. Marakasov    | jabber: amdmi3 at
amdmi3 at       |

More information about the freebsd-ports mailing list