How to use pkgsrc on Linux

From NetBSD Wiki

Jump to: navigation, search
This page should use cross references to avoid duplicate content. Please help us by cleaning it up. ☺

Contents

What is pkgsrc

pkgsrc is the NetBSD build framework for third party software that works on a lot of Unix™ like platforms and of course on Linux. In this chapter, I will explain how to set up and use pkgsrc on Linux.

Software requirements

Before you can use pkgsrc, you need a few packages installed on your Linux system upfront.

  • gcc (and libstdc++)
  • libncurses-devel
  • zlib and zlib-devel
  • openssl-devel (optional but required for some packages)

The names may vary, depending on what Linux distribution you are using. Also be mindful of the platform you are using (eg. i686 vs. x86_64 - some have different pre-required packages). Also note that some very basic tools such as file, patch, sed, and others are required, as well.

Disk space requirements

Pkgsrc is growing continuesly each month and contains currently about 6387 packages. You will need a minimum of 170 MB disk space at the moment. The pkgsrc tree doesn't contain all the software, but the scripts to build them from the source code.

Obtaining the pkgsrc tree

For being able to use the pkgsrc framework, you have to get the pkgsrc tree first. The recommended way to do that and to keep your tree up to date is to use CVS. Alternatively you can use cvsup or mercurial. But before you can check out the tree, you have to define where from. For that, please choose an anoncvs mirror close to you. In this example I will use the german anoncvs mirror anoncvs.de.netbsd.org

Setting CVSROOT

Please set your CVSROOT Environment Variable

export CVSROOT=anoncvs@anoncvs.de.netbsd.org:/cvsroot

or if you are using the csh:

setenv CVSROOT anoncvs@anoncvs.de.netbsd.org:/cvsroot

Setting CVS_RSH

Unless otherwise noted, you have to set the CVS_RSH variable to use ssh

export CVS_RSH=ssh

or if you are using csh

setenv CVS_RSH ssh

Creating the pkgsrc directory

This is a matter of taste, but the commonly used path for pkgsrc is /usr/pkgsrc/

# mkdir /usr/pkgsrc

If you are checking out for the first time, change to /usr

# cd /usr

and check out the sources.

# cvs checkout -PA pkgsrc

Checking out will take a while and a minimum of 170 MB of disk space. Please ensure enough free disk space, if you wish to work with pkgsrc. A minimum of 1024 MB should be available.

You need to checkout only once. If you have already checked out, you only need to update the sources. The Options -d allows to create new directories and -P to prune old directories.

# cd /usr/pkgsrc
# cvs update -dP

Please be aware, that updating your sources will take much more time than checking out. Please be patient when you're updating. If you wish to update regularly, say once a day, use cron to do that for you.

Building the toolchain

The toolchain contains the software that is needed to build bsd make (bmake) and other tools.

Please change your directory to /usr/pkgsrc/bootstrap and run ./bootstrap

# cd /usr/pkgsrc/bootstrap
# ./bootstrap

Pkgsrc will now determine what kind of operating system you are using and will build the toolchain.

===========================================================================

Please remember to add /usr/pkg/bin to your PATH environment variable
and /usr/pkg/man to your MANPATH environment variable, if necessary.

An example mk.conf file with the settings you provided to "bootstrap"
has been created for you. It can be found in:

      /usr/pkgsrc/bootstrap/work/mk.conf.example

Please copy it to /usr/pkg/etc/mk.conf to use it.

You can find extensive documentation of the NetBSD Packages Collection
in /usr/pkgsrc/doc/pkgsrc.txt and packages(7).

Hopefully everything is now complete.
Thank you

===========================================================================

===> bootstrap started: Sun Dec 17 14:01:49 CET 2006
===> bootstrap ended:   Sun Dec 17 14:02:50 CET 2006

It is now necessary to add /usr/pkg/bin to your PATH environment variable (/etc/profile) to be able to run bmake.

Installing software

Now, let's test pkgsrc, by installing a software package. The software is sorted by categories. I've chosen figlet, a small program to print big letters. Figlet is in the category misc. Change to the figlet directory

# cd /usr/pkgsrc/misc/figlet/

and build the software. Pkgsrc will download the sourcefile for figlet, uncompress it and build it.

# bmake 

and clean the working directories afterwards

# bmake clean

and clean all dependencies

# bmake clean-depends

or short:

# bmake install clean clean-depends

Running the new software

When the software has been successfully installed, it will reside by default in /usr/pkg/bin/. To run figlet just run:

# figlet

You need the /usr/pkg/bin in your PATH Variable as described above to do that.

If you have already installed a linux version of figlet on your system, run pkgsrc figlet with the absolute path.

# /usr/pkg/bin/figlet

That's it. Have fun. Please write comments and questions to the pkgsrc user mailing list: pkgsrc-users@netbsd.org

See also

README.Linux

Personal tools