pkgsrc/mk/buildlink3
jlam 95fd1f6ec9 Massive cleanup of buildlink3.mk and builtin.mk files in pkgsrc.
Several changes are involved since they are all interrelated.  These
changes affect about 1000 files.

The first major change is rewriting bsd.builtin.mk as well as all of
the builtin.mk files to follow the new example in bsd.builtin.mk.
The loop to include all of the builtin.mk files needed by the package
is moved from bsd.builtin.mk and into bsd.buildlink3.mk.  bsd.builtin.mk
is now included by each of the individual builtin.mk files and provides
some common logic for all of the builtin.mk files.  Currently, this
includes the computation for whether the native or pkgsrc version of
the package is preferred.  This causes USE_BUILTIN.* to be correctly
set when one builtin.mk file includes another.

The second major change is teach the builtin.mk files to consider
files under ${LOCALBASE} to be from pkgsrc-controlled packages.  Most
of the builtin.mk files test for the presence of built-in software by
checking for the existence of certain files, e.g. <pthread.h>, and we
now assume that if that file is under ${LOCALBASE}, then it must be
from pkgsrc.  This modification is a nod toward LOCALBASE=/usr.  The
exceptions to this new check are the X11 distribution packages, which
are handled specially as noted below.

The third major change is providing builtin.mk and version.mk files
for each of the X11 distribution packages in pkgsrc.  The builtin.mk
file can detect whether the native X11 distribution is the same as
the one provided by pkgsrc, and the version.mk file computes the
version of the X11 distribution package, whether it's built-in or not.

The fourth major change is that the buildlink3.mk files for X11 packages
that install parts which are part of X11 distribution packages, e.g.
Xpm, Xcursor, etc., now use imake to query the X11 distribution for
whether the software is already provided by the X11 distribution.
This is more accurate than grepping for a symbol name in the imake
config files.  Using imake required sprinkling various builtin-imake.mk
helper files into pkgsrc directories.  These files are used as input
to imake since imake can't use stdin for that purpose.

The fifth major change is in how packages note that they use X11.
Instead of setting USE_X11, package Makefiles should now include
x11.buildlink3.mk instead.  This causes the X11 package buildlink3
and builtin logic to be executed at the correct place for buildlink3.mk
and builtin.mk files that previously set USE_X11, and fixes packages
that relied on buildlink3.mk files to implicitly note that X11 is
needed.  Package buildlink3.mk should also include x11.buildlink3.mk
when linking against the package libraries requires also linking
against the X11 libraries.  Where it was obvious, redundant inclusions
of x11.buildlink3.mk have been removed.
2005-06-01 18:02:37 +00:00
..
bsd.buildlink3.mk Massive cleanup of buildlink3.mk and builtin.mk files in pkgsrc. 2005-06-01 18:02:37 +00:00
bsd.builtin.mk Massive cleanup of buildlink3.mk and builtin.mk files in pkgsrc. 2005-06-01 18:02:37 +00:00
buildcmd-libtool Initial commit of a new wrapper script framework that encapsulates 2004-09-21 15:01:38 +00:00
BUILDLINK3_DG USE_BUILDLINK3 is no longer optional (and cannot be turned off). Per mail 2005-03-24 17:46:00 +00:00
cleanup-libtool Initial commit of a new wrapper script framework that encapsulates 2004-09-21 15:01:38 +00:00
cmd-sink-libtool Initial commit of a new wrapper script framework that encapsulates 2004-09-21 15:01:38 +00:00
find-files.mk Massive cleanup of buildlink3.mk and builtin.mk files in pkgsrc. 2005-06-01 18:02:37 +00:00
find-libs.mk Massive cleanup of buildlink3.mk and builtin.mk files in pkgsrc. 2005-06-01 18:02:37 +00:00
libtool-fix-la Initial commit of a new wrapper script framework that encapsulates 2004-09-21 15:01:38 +00:00
PKGVIEWS_UG "the the" -> "the" 2004-12-01 09:52:59 +00:00
README USE_BUILDLINK3 is no longer optional (and cannot be turned off). Per mail 2005-03-24 17:46:00 +00:00
scan-libtool Teach the libtool wrapper about the "clean" and "uninstall" modes, where 2004-09-24 20:44:28 +00:00
TODO +less obfuscated errors 2004-02-17 08:59:44 +00:00
transform-libtool Don't cache transformations of "-lfoo" into "rel/path/to/libfoo.la" because 2004-10-03 21:39:07 +00:00

$NetBSD: README,v 1.6 2005/03/24 17:46:01 tv Exp $

 0 Package Views
 ===============

Package views is a pkgsrc technology that supports building and
installing multiple versions of the same software such that they
co-exist on a single system.  Individual packages are installed into
their own directory tree and their files are symlinked into "views".
Users can choose amongst different software collections provided by
different views by appropriately setting shell environment variables,
e.g., PATH, MANPATH, etc.

Package views is similar in spirit to the Encap Package Management
System, the GNU Stow Project, and the Carnegie Mellon University Depot
Configuration Management system:

	http://www.encap.org/
	http://www.gnu.org/software/stow/stow.html
	http://asg.web.cmu.edu/andrew2/depot/

However, these projects have a philosophy of "install anywhere, use in
one place", whereas package views departs from that model with a
philosophy that can roughly be summarized as "install in one place,
use anywhere".


 0.1 A short history of package views
 ====================================

Package views was proposed as a solution to the problem of not being
able to install multiple versions of the same software simultaneously
via pkgsrc.  Alistair Crooks presented a paper on package views at
EuroBSDCon in November 2002 that described the work he did on the
"pkgviews" branch of pkgsrc where he implemented his ideas.  The paper
is highly-recommended reading for a more complete understanding of
package views principles and is available at:

	http://www.NetBSD.org/Documentation/software/pkgviews.pdf

Unfortunately, Alistair ran out of time to devote to integrating his
work into the main pkgsrc branch.  The code he developed languished on
the "pkgviews" branch for over a year, and in the meantime much code
was added to pkgsrc that increased the complexity and the capabilities
of pkgsrc, including buildlink2, which conflicted with Alistair's
implementation of package views.  In September 2003, Johnny Lam
integrated the functionality on the pkgviews branch into modern
pkgsrc.  As part of the integration, a new buildlink3 framework was
created so that the ability to isolate builds from differences in
the environment wouldn't be lost.


 0.2 Package views terminology
 =============================

The terminology for packages in the package views world is as
follows:  a "pkgviews" package is a package that has been converted to
build and install using package views.  An "overwrite" package is one
that hasn't.  A "depoted" package describes a pkgviews package
installed into /usr/pkg/packages in its "depot" directory.  A package
"instance" in a view describes a depoted package symlinked into a
view.


 0.3 What's been done
 ====================

The pkg_install tools have been enhanced to handle both binary depoted
packages and binary "overwrite" packages.  The pkgsrc internals have
been modified to allow building and installing depoted packages and to
automatically add a depoted package in the default view.
"Overwrite" packages shouldn't be affected by the changes, and can be
freely mixed with pkgviews packages.

Packages that have been converted to use "pkgviews" should add the
following line to their Makefiles:

	PKG_INSTALLATION_TYPES=	overwrite pkgviews

PKG_INSTALLATION_TYPES can also just be one value or the other to
explicitly note that the package only supports that one type of
installation style.  Users may add the following line to /etc/mk.conf:

	PKG_INSTALLATION_PREFS=	pkgviews overwrite

to note that they prefer building using pkgviews if the package
supports it, otherwise to build using the "overwrite" installation
style.  However, users should not change PKG_INSTALLATION_PREFS from
the default value unless they're sure that they want to start
migrating their package system over to using pkgviews.  The default,
"overwrite pkgviews", will cause all packages to build using the
"overwrite" installation style.

Some highlight of pkgviews packages include:

	* fully dynamic PLISTs
	* multiple versions of the same package can co-exist


 0.4 buildlink3 pkgsrc build framework
 =====================================

A new buildlink3 framework that takes advantage of depoted packages
has been added to pkgsrc as part of the package views changes.
Buildlink3 uses wrapper scripts much like buildlink2.  However, when
building pkgviews packages, it doesn't symlink files into
${BUILDLINK_DIR} since it can safely refer to only a specific
package's files by passing the appropriate -I<dir> and -L<dir> flags
to the compiler, where <dir> points to a location in the package's
depot directory.  When building "overwrite" packages, buildlink3 will
act and feel very much like buildlink2 but with more advanced wrapper
scripts, and there are provisions for allowing an "overwrite" package
to build against the viewed instance of a depoted package.  The
implementation currently allows "overwrite" to depend on either
"overwrite" or pkgviews packages, but pkgviews packages are restricted
to only being able to depend on other pkgviews packages.


 0.5 Future Work
 ===============

There may be some way around the problem of pkgviews packages not
being able to depend on "overwrite" packages.  That's the only thing
standing in the way between allowing an arbitrary package to be built
using either installation style and working seamlessly with any other
package.  The problem has to do with proper handling of metadata in
the +REQUIRED_BY and +CONTENTS files that are split in two separate
places.  One possible route to a solution is that for each overwrite
package, we can symlink /usr/pkg/packages/<pkg> -> /var/db/pkg/<pkg>.
This allows depoted packages to record themselves directly in the
+REQUIRED_BY files of "overwrite" packages.  If a user happens to run

	pkg_delete -K /usr/pkg/packages <overwrite_pkg>

then it still uses the correct +CONTENTS, +INSTALL, and +DEINSTALL
scripts, so the package will still remove itself properly from
/usr/pkg.  However, there are some remaining issues with properly
removing both the /var/db/pkg/<pkg> directory and the
/usr/pkg/packages/<pkg> symlink, so the deletion won't be completely
clean until this issue can be resolved.