Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Mar 2012 08:44:24 +0000
From:      Matthew Seaman <>
Subject:   Why you have to install a port to create a package (was Re: port to package amd64 to i386)
Message-ID:  <>
In-Reply-To: <>
References:  <> <> <> <> <> <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 07/03/2012 01:39, Da Rock wrote:
> On 03/07/12 04:13, Adam Vande More wrote:
>> On Tue, Mar 6, 2012 at 11:36 AM, Bernt Hansson<>=20
>> wrote:

>>> Again, a "problem" is that packages can only be generated

>>>> if the port has been installed

>>> Why is that. I hope you can educate me on that.

>> Because a package is the result of what is installed.  It
>> essentially works somewhat like Debian's checkinstall by keeping
>> track of what's installed by the installation script, then using
>> the info of what's installed to build the package.  I'm not exactly
>> sure how "make package" works internally, but it wouldn't surprise
>> me if it's almost the same as "pkg_create -b".

> From what I understand of ports (as a maintainer) that is the case; plu=
> some other bits and pieces for checking, verification, and cleanup.

DaRock has the essentials of how it works correct.  When a port is
installed, the first step is to install the software, typically using
the standard install target from upstream, although it's not unusual for
the port to just copy files into place itself[*].

That miscellaneous collection of files is then turned into a package by
collecting the data on file names and checksums in the packing list, the
package comment, any install messages or install/deinstall scripts into
the package directory /var/db/pkg/pkgname-0.99 If you're interested,
this stage is dealt with by the 'fake-pkg' target in

[[pkgng works almost identically, except the data is stored in a sqlite
DB rather than separate directories in the filesystem.]]

Note that technically, a package is that combination of the collection
of files and the metadata about those files in the package registry.  A
package can be in two different states: installed, with the files spread
around the directory tree or as a tarball -- for the original pkg
format,  /var/db/pkgname-0.99 and all the files owned by the package;
for pkgng, the metadata is held as a YAML file.  pkg_add(1) converts
from the tarball to the installed state, 'pkg_create -b' goes in the
other direction.  The difference between 'make install' and 'make
package' in the ports is simply the addition of a final pkg_create

Now, there is no a priori reason why all of this has to be done using
the live /usr/local directory tree on your system.  OpenBSD ports has
entirely switched to using a chroot for building package tarballs, and
in fact the FreeBSD package build cluster and Tinderbox basically work
that way already.  The procedure is to install all of the required
{FETCH,PATCH,BUILD,RUN,PKG} dependencies into a chroot filesystem (from
previously built package tarballs), install the port into the same
chroot and generate a package tarball from it.

There are advantages and disadvantages either way.  Building in a chroot
requires a lot more copying files around and general faff.  On the other
hand; it makes it easier to build as a non-privileged user, it makes
cross-building for different architectures feasible and it completely
avoids problems to do with software arbitrarily deciding to link against
random shared libraries it finds around the system -- or indeed to
accidentally use header files from a completely different piece of
software.  Converting ports to build in a chroot is one of those ideas
that is constantly bubbling up, but that never quite seems to get



[*] For completeness, the 'port' is the collection of instructions for
downloading the sources, patching, building and installing the software,
managing the dependency hierarchy required to do all that and dealing
with tracking all those files by creating the package metadata.
Although it is common to speak of 'installing a port' in fact what gets
installed is a package, and it is the port that does the installing.

Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP:     Ramsgate
JID:               Kent, CT11 9PW

Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla -



Want to link to this message? Use this URL: <>