pkgsrc on MirOS

Sponsored by
SpeedPartner logo

pkgsrc is a “ports tree” developed by the NetBSD project and portable to several other operating systems. Support for MirOS has existed since 2006 in the form of a private patch. Since January 2011, MirOS support is contained in the upstream pkgsrc repository.

pkgsrc allows the easy installation of third-party software not contained in the base system. It is very similar to MirPorts, the ports framework developed by the MirOS project, “native” on MirOS. However, pkgsrc generally contains more and newer software.

For more information on pkgsrc, see http://www.pkgsrc.org/.

MirPorts and pkgsrc can be installed and used in parallel. However, there is one caveat: the package tools are incompatible but they have the same names. Thus, when installing packages, you must assure that the right ones are used. Moreover, when bootstrapping pkgsrc on MirOS, the MirPorts directories (normally /usr/mpkg/bin and /usr/mpkg/sbin) must not be in your PATH.

Starting from pkgsrc-2011Q2, you no longer need to apply any MirBSD-specific patches to install pkgsrc.

Binary packages

Pre-built binary packages of the 2011Q3 branch (from October 2011), built for recent MirOS-current (from 2011), are available. They can be used even if you did not install a compiler on the system. The binary repository contains 5330 packages. The packages have been built with /usr/pkg as the prefix and /usr/pkg/var as VARBASE, so that they are self-contained. This means that you need root rights to use them as the system. pkgsrc can also be installed as an unprivileged user but you will need to build from source in this case.

To install pkgsrc from binary packages, follow these steps:

  1. Download the bootstrap kit:
    ftp ftp://ftp.netbsd.org/pub/pkgsrc/packages/MirBSD/i386/10uAE_2011Q3/bootstrap.tar.gz
  2. Extract the file:
    cd / ; tar xvpzf /path/to/bootstrap.tar.gz
  3. Set the PATH to include /usr/pkg before any MirPorts directories. The reason is that the package tools have the same names, and using e.g. pkg_add(1) from MirPorts to install a pkgsrc package will not work. For example, to replace MirPorts by pkgsrc in your path, run:
    export PATH=$(echo $PATH|sed s,mpkg,pkg,g)
  4. Set the path to the binary packages:
    export PKG_PATH="ftp://ftp.netbsd.org/pub/pkgsrc/packages/MirBSD/i386/10uAE_2011Q3/All/"
  5. Now you can easily install additional packages, for example:
    pkg_add python27

More information can be found in Section 4.1 of the pkgsrc guide.

Installation from source

  1. Make sure there are no mentions of MirPorts in your current environment. Most importantly, remove /usr/mpkg/bin and /usr/mpkg/sbin from your PATH. This is needed when building or installing packages; the reason is that the package tools from MirPorts and pkgsrc have the same name but are incompatible with each other.
  2. Check out pkgsrc, for example to /usr/pkgsrc:
    cvs -qd anoncvs@anoncvs.netbsd.org:/cvsroot co -P pkgsrc
  3. Bootstrap pkgsrc. In this example, we install (using sudo) into /usr/pkg. The dbdir should be inside the prefix to avoid conflicts with MirPorts.
    cd bootstrap
    ./bootstrap --prefix /usr/pkg --pkgdbdir /usr/pkg/db
  4. Add /usr/pkg/bin and /usr/pkg/sbin to your path:
    export PATH=/usr/pkg/bin:${PATH}:/usr/pkg/sbin
  5. pkgsrc can be configured by editing the /usr/pkg/etc/mk.conf file. See the pkgsrc Guide for details.
  6. To build and install a package, use the bmake command. For example, to install Perl:
    cd ../lang/perl5
    bmake package-install clean
MirOS Logo