How to configure the pkgsrc portable package system

Home | Documentation | Practical notes

How to configure the pkgsrc portable package system
Pierre-Philipp Braun <pbraun@nethence.com>


Introduction
pkgsrc is NetBSD's package system for all plateforms. It may nevertheless be used on other operating systems, as it automates compilations from source.
As for the NetBSD system itself see pbraun.nethence.com/doc/sysutils/NetBSD.html


Usage for binaries
Once NetBSD is installed, find your relevant binary repository depending on your NetBSD version (release and architecture) and country (choose your NetBSD mirror),
export PKG_PATH=ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/4.0/All
pkg_add -v screen
Eventually do,
export PASSIVE_FTP=yes
to get through firewall, but ftp(1) should switch to that by default.
Once this is working add the PKG_PATH export line into root's ~/.profile.

Binaries are more convenient but you may also compile the packages using the pkgsrc tree.


Usage from source
Either get pkgsrc.tar.gz from your NetBSD FTP mirror and extract it,
cd /root
ftp -a ftp.fr.netbsd.org/pub/NetBSD/NetBSD-current/tar_files/pkgsrc.tar.gz
tar xzf pkgsrc.tar.gz -C /usr

Or get the tree from CVS,
export CVSROOT=anoncvs@anoncvs.fr.netbsd.org:/cvsroot
export CVS_RSH=ssh
cd /usr
cvs -q co pkgsrc
Note. you may specify a branche using "-r". See cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/ (at the bottom)

To update the tree,
cd /usr/pkgsrc
cvs -q update -dP

To compile & install pacakges using pkgsrc,
cd /usr/pkgsrc/misc/screen
make install
To do the same while keeping a copy of the binary package into /usr/pkgsrc/packages,
make package
Note you may create a small binary addon repository with that, without the use of bulk.sh.

To quickly show dependencies, besides looking at the Makefile,
make clean-depends
Note. use that +" cvs up -dP" on the relevant packages' directories before installing them, if you don't want to update the whole tree.

Eventually create /etc/mk.conf to define a few specifics,
vi /etc/mk.conf
MASTER_SITE_SOURCEFORGE=ovh.dl.sourceforge.net/sourceforge \
heanet.dl.sourceforge.net/sourceforge/ \
belnet.dl.sourceforge.net/sourceforge/
USA_RESIDENT=NO
PASSIVE_FETCH=YES
Note. a more recent way to deal with master sites is the use of those,
#MASTER_SORT=
#MASTER_SORT_RANDOM=NO

Some additionnal examples,
#ACCEPTABLE_LICENSES+=pine-license
#ACCEPTABLE_LICENSES+=lame-license
#ACCEPTABLE_LICENSES+=majordomo-license
#MOZILLA_USE_LINUX=YES
#IRSSI_USE_PERL=YES
#PINE_USE_LDAP=YES
#X11_TYPE=xorg
#USE_X11BASE=YES
#X11BASE=/usr/X11R6
#PKGSRCDIR=/usr/pkgsrc
#PACKAGES=/alternatepath/packages
#DISTDIR=/alternatepath/distfiles
#WITH_DVDCSS=YES
#USE_OPENLDAP=NO
#USE_SASL=NO
#USE_SASL2=NO
#ALLOW_VULNERABLE_PACKAGES=YES

Note. IRSSI_USE_PERL is the new syntax. Before it was,
#PKG_OPTIONS.irssi=irssi-perl

For NetBSD only, this copies newly created /usr/pkg/share/examples/rc.d/* script to /etc/rc.d,
#PKG_RCD_SCRIPTS=YES
#RCD_SCRIPTS_DIR=/etc/rc.d

Note. you may play with CPU optimizations too. Although one could edit /etc/mk.conf and do one of those,
#
# Those are just examples, it might break things
#
#CFLAGS+=-O2 -march=i686 -mcpu=i386
#CXXFLAGS=-O2 -march=i686 -mcpu=i386
#COPTS+=-O2 -mcpu=i686 -fexpensive-optimizations -ffast-math -msoft-float \
# -fmemoize-lookups -fthread-jumps -m486 -fomit-frame-pointer \
# -finline-functions
it's preferable to use the relevant cpuflags package but I'm hearing it doesn't work for the latest CPUs,
  devel/cpuflags
  sysutils/cpuid might be helpful too
Note. gentoo's optimization pages may be worth visiting anyways,
www.gentoo.org/doc/en/gcc-optimization.xml
fr.gentoo-wiki.com/HOWTO_CFLAGS


pkgsrc security
Install the audit-packages package to check for vulnerabilites,
cd /usr/pkgsrc/security/audit-packages
make install
vi /usr/pkg/etc/audit-packages.conf
  VUL_SOURCE="ftp.fr.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities"
If there's definitely some vulnerable package you need to install, add this to /etc/mk.conf,
ALLOW_VULNERABLE_PACKAGES=YES


Making bulks
Edit bulk.conf and execute bulk.sh. Alternatively, use this little wrapper,
#!/bin/sh
PATH=/usr/pkg/bin:/usr/pkg/sbin:$PATH
export PATH=/usr/pkg/bin:/usr/pkg/sbin:$PATH
cd /usr/pkgsrc/mk/bulk
sh build --config /usr/pkgsrc/mk/bulk/build.conf -r


References
Pkgsrc's Home Page,
www.netbsd.org/docs/software/packages.html

Pkgsrc's CVS frontend,
cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/

Pkgsrc guide
www.netbsd.org/docs/pkgsrc/using.html

Some great web pkgsrc browser,
pkgsrc.se


Mon Sep 1 11:48:20 CEST 2008
       © 2008 Pierre-Philipp Braun