Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Mar 2012 08:44:24 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        freebsd-questions@freebsd.org
Subject:   Why you have to install a port to create a package (was Re: port to package amd64 to i386)
Message-ID:  <4F571FE8.3040708@infracaninophile.co.uk>
In-Reply-To: <4F56BC66.5000908@herveybayaustralia.com.au>
References:  <4F547C59.1040604@bananmonarki.se> <4F548571.1050203@gmail.com> <4F54ED12.1090409@bananmonarki.se> <20120305175551.ae24b6f0.freebsd@edvax.de> <4F564B17.1010700@bananmonarki.se> <CA%2BtpaK2tjz8NDD0e=vLkfN27pcTW_-k=bSAjzBiQ5CpusGGyfQ@mail.gmail.com> <4F56BC66.5000908@herveybayaustralia.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig604BECA04AC63871861E39CC
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<bah@bananmonarki.se>=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=
s
> 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 bsd.ports.mk

[[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
step.

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
implemented.

	Cheers,

	Matthew

[*] 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.

--=20
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew@infracaninophile.co.uk               Kent, CT11 9PW


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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9XH/IACgkQ8Mjk52CukIzpQACgiTqCosCtd8mmo8bh34cSXr4s
Yt8AoJNLJMyccyOOoxmZPr1blHgPWAsC
=1XC9
-----END PGP SIGNATURE-----

--------------enig604BECA04AC63871861E39CC--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F571FE8.3040708>