NetBSD Wiki (prerelease)/pkgsrc/ how to use pkgsrc

Contents

  1. What is pkgsrc
  2. Requirements
  3. Preparing pkgsrc
    1. Creating the pkgsrc directory
    2. Obtaining the current pkgsrc source tree
    3. Creating WRKOBJDIR
    4. Creating DISTDIR
  4. Installing packages
  5. List Packages
  6. Removing Packages
  7. Updating Packages
  8. Rolling Replace
  9. On-line help

What is pkgsrc

Pkgsrc [spoken: package source] is the main package management framework for NetBSD. With pkgsrc you can easily add, remove and manage software on your system. Pkgsrc is basically a set of files, grouped by categories which contain information to install the software you have selected. All these files together are mostly referred to as the pkgsrc tree. This tree is maintained by the pkgsrc developers, who make changes to it every day. Therefore it is necessary to update the pkgsrc tree regularly.

Requirements

The pkgsrc source tree, which contains all the files, will need a minimum of 200 MB disk space.

Preparing pkgsrc

Creating the pkgsrc directory

This is a matter of taste, but most people create the directory in /usr/pkgsrc/

# mkdir /usr/pkgsrc

Change owner of pkgsrc to a user, so you can update later it with user rights.

# chown john pkgsrc

Obtaining the current pkgsrc source tree

There are many ways to get the pkgsrc tree. For example via ftp, cvs, sup or cvsup. My recommended way is to use csup, a leightweight cvsup protocol client written in C. But, before we can use csup we have to install it first, which in turn needs pkgsrc aswell. Therefore we will use for csup a precompiled binary package, instead of doing the work twice.

# ftp ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/5.0/All/csup-20070216.tgz

and then installing it with

# pkg_add csup-20070216.tgz

csup needs one configuration file, the supfile, which contains the information to sync what from which server to where. Please create a file called pkgsrc-supfile in your home directory which contains:

*default tag=.
*default release=cvs
*default delete use-rel-suffix
*default umask=002
*default host=cvsup.se.netbsd.org
*default base=/home/john
*default prefix=/usr

netbsd-pkgsrc

base points to your home directory and prefix to the directory, where the repo goes.

To get and to keep your pkgsrc tree in sync, just run:

$ csup pkgsrc-supfile

To update regularly, say once a day, use ?cron.

Creating WRKOBJDIR

To keep the tree clean and your work directories out of it, define WRKOBJDIR in /etc/mk.conf and add:

WRKOBJDIR=/usr/work

and then create that directory.

# mkdir /usr/work

Creating DISTDIR

We also want our distfiles to be stored, outside of the pkgsrc directory. Therefore we add the DISTDIR variable to /etc/mk.conf

DISTDIR=/usr/distfiles

and create it with:

# mkdir /usr/distfiles

Installing packages

To install packages, we need to become root.

$ su 

then we change to the directory (category) and then to the package we want to install.

# cd /usr/pkgsrc/misc/figlet

to install we enter

# make install

afterwards we clean up and enter

# make clean

if this was a package with dependencies, we also enter

# make clean-depends

You can put them all in one line too.

# make install clean clean-depends

If you wish to clean the distfiles, the files that have been downloaded, you enter

# make distclean

List Packages

$ pkg_info

Removing Packages

# pkg_delete packagename

Updating Packages

You can update a single package using make update.

# make update

Rolling Replace

pkgtools/pkg_rolling-replace is a very nice programm to update all outdated packages on your system.

That's it. Have fun.

Since the framework is complex, there are millions of other options.

On-line help

Besides The pkgsrc Guide there is also a built-in on-line help system.

# make help

gives you the usage information. This requires you to already know the name of the target or variable you want more info on (just like man does).

Most targets and variable names are documented, but not all are. See also

Add a comment
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.