File:  [NetBSD Developer Wiki] / wikisrc / pkgsrc / how_to_use_pkgsrc.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Sun Nov 20 20:28:27 2011 UTC (2 years, 5 months ago) by mspo
Branches: MAIN
CVS tags: HEAD
import a bunch of pkgsrc articles from the old pkgsrc.se wiki

**Contents**

[[!toc levels=2]]

#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 this files together are mostly referred as the pkgsrc tree. This tree is maintained by the pkgsrc developers, that 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](http://www.netbsd.org/docs/pkgsrc/) 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

* [[How to use pkgsrc mounted over NFS]]
* [[How to use pkgsrc on AIX]]
* [[How to use pkgsrc on A/UX]]
* [[How to use pkgsrc on IRIX]]
* [[How to use pkgsrc on Linux]]
* [[How] to use pkgsrc on Mac OS X]
* [[How to use pkgsrc on OSF1]]
* [[How to use pkgsrc on Solaris]]

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb