h3. Initial install
pkgsrc
can be obtained in two main ways. The first is via anonymous CVS checkout, the second is via quarterly tarball releases. Since the whole tree is several hundred megabytes (even without sources) and the NetBSD CVS servers are permanently overloaded a tarball is the way to go for the initial install. The tarballs can be found in the NetBSD mirror structure, the main mirror being here. At the time of this writing pkgsrc-2008Q4 is current.
The tarball already contains a pkgsrc directory at the top level, so it has to be unpacked under /usr
.
# wget ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz
# gtar -xzf pkgsrc.tar.gz -C /usr
# chown -R builder: /usr/pkgsrc
This will unpack the tarball into the filesystem mounted at /usr/pkgsrc
and change the ownership to the build user created earlier.
h3. Patching gcc
Unfortunately the gcc suite as delivered with Solaris has a small flaw, which will cause some packages to be built incorrectly (the most famous example is openssl, which will build but not work afterwards). Fortunately the bug has been tracked down and a bandaid is available here.
This file is a nice little hack in itself as it is a shell script and a C source file at the same time. If executed by a shell this file will be put though gcc three times to produce three object files, which are placed into a directory where the compiler can find them and use them instead of files that were delivered with the compiler.
# bash ./values.c /usr/sfw/bin/gcc
[....]
# ls -l $(dirname $(/usr/sfw/bin/gcc -print-libgcc-file-name))
[...]
-rw-r--r-- 1 root root 763 2009-02-21 17:34 values-Xa.o
-rw-r--r-- 1 root root 763 2009-02-21 17:34 values-Xc.o
-rw-r--r-- 1 root root 763 2009-02-21 17:34 values-Xt.o
#
h3. Bootstrapping
With this particular bug out of the way pkgsrc
needs to be bootstrapped. This means that the initial set of programs needed to build further packages (the package management itself and some helper programs) need to be built and installed on the host system. This has to be done as root. In order to find some programs it is necessary to expand the $PATH
a bit.
# cd /usr/pkgsrc/bootstrap
# PATH="$PATH:/usr/sfw/bin:/usr/xpg4/bin" ./bootstrap
[....]
#
Bootstrapping will take a while, but it should run though cleanly. Afterwards there should be some files in /usr/pkg
and running /usr/pkg/sbin/pkg_info
should list a handful of installed packages.
h3. Vulnerabilities and updates
Packages need to be kept up-to-date, for new features as much as for possible vulnerabilites. In the latter department the bootstrap installed two programs to help with identifying such programs.
/usr/pkg/sbin/download-vulnerability-list
will fetch a list of vulnerable program versions. Builds of such versions will fail, unless explicitly requested otherwise. For already installed programs there is /usr/sbin/pkg/audit-packages
which will identify and list installed vulnerable versions.
Both programs should be used on a regular basis.
Updates of packages (whether due to a vulnerability or not) are best done via CVS. Updates can be done on the whole package tree or on individual subtrees, as needed. Assuming an older installed version the following command will update the whole tree to 2008Q4:
# su - builder
$ cd /usr/pkgsrc
$ cvs up -dPR -rpkgsrc-2008Q4
[...]
$
It's important to check the output of the CVS command for eventual problems, especially if local modifications to packages have been done.
h3. Host tools
There are a number of tools that are used by a large number of packages during the build process. pkgsrc
will build all of these from source if necessary, but most of them can be supplied by the host system instead.
Among these tools are
- GNU m4
- GNU make
- GNU gettext
- GNU tar
- Perl
- GNU patch
- unzip
- BISON & FLEX
GNU make and GNU tar are already installed, the rest of the packages can be found on the Solaris install media. The rest can easily be installed:
# gkp.pl -d /mnt/Solaris_11/Product SUNWgm4 SUNWgnu-gettext SUNWgpch SUNWunzip \
SUNWbison SUNWflexlex
[...]
#
Now pkgsrc
has to be made aware of these tools in order to use them. The main config file is /usr/pkg/etc/mk.conf
. Adding the following statements somewhere above the final .endif
will make pkgsrc
use the host version of the above mentioned tools instead of building it's own:
# SUNWgm4
TOOLS_PLATFORM.m4= /usr/bin/gm4
TOOLS_PLATFORM.gm4= /usr/bin/gm4
# SUNWgmake
TOOLS_PLATFORM.gmake= /usr/bin/gmake
# SUNWgnu-gettext
TOOLS_PLATFORM.msgfmt= /usr/bin/gmsgfmt
# SUNWgtar
TOOLS_PLATFORM.tar= /usr/bin/gtar
TOOLS_PLATFORM.bsdtar= /usr/bin/gtar
# SUNWgpch
TOOLS_PLATFORM.patch= /usr/bin/gpatch
TOOLS_PLATFORM.gpatch= /usr/bin/gpatch
#
TOOLS_PLATFORM.perl= /usr/bin/perl
# SUNWunzip
TOOLS_PLATFORM.unzip= /usr/bin/unzip
# SUNWbison
TOOLS_PLATFORM.bison= /usr/bin/bison
TOOLS_PLATFORM.bison-yacc= /usr/bin/bison -y
# SUNWflexlex
TOOLS_PLATFORM.lex= /usr/bin/flex