[[!toc levels=2 ]] ## History and Overview [Pkgsrc](http://www.pkgsrc.org) is a packaging system that was originally created for NetBSD. It has been ported to DragonFly, along with other operating systems. Pkgsrc is very similar to FreeBSD's ports mechanism. ## Installing pkgsrc The basic pkgsrc tools are provided with every DragonFly system as part of installation. However, you still need to download the pkgsrc tree for building applications with these tools. As root: # cd /usr # make pkgsrc-create to fetch the intial pkgsrc repository from the net, or # cd /usr # make pkgsrc-update to update. Edit /usr/Makefile to select a different download location, if desired. This downloads the absolute most recent version of pkgsrc. In a production environment, you may want a more stable release. Check the section below titled "Tracking the stable branch" for more details. ## Installing packages from source Packages are built by going into the appropriate directory and issuing 'bmake install clean'. For example, to build the screen package you need to issue the following commands. # cd /usr/pkgsrc/misc/screen # bmake install clean To find out the options that can affect how a program is built: # bmake show-options To change options: # bmake PKG_OPTIONS.="-option1 option2" install clean Listing an option enables it. Listing an option with a "-" before it disables the option. To make these option changes permanent for every future build or upgrade of this package, put a similar line in /usr/pkg/etc/mk.conf: . PKG_OPTIONS.=-option1 option2 ## Installing pre-built packages Binary packages can be installed using pkg_radd: # pkg_radd screen This program works by setting the PKG_PATH enviroment variable to the appropriate path for the operating system and architecture to a remote repository of binary packages, and then using pkg_add to get packages. You can manually set PKG_PATH and use pkg_add to get the same effect, using a different server. # setenv PKG_PATH http://avalon.dragonflybsd.org/packages/i386/DragonFly-2.7/stable # pkg_add screen This will install most packages, but will not upgrade packages that are already installed. ***Note that the default remote repository for binary packages tracks quarterly pkgsrc releases, so your local install of pkgsrc should be the same quarterly release.*** Some packages are not licensed for distribution in binary form, so they may be able to build on DragonFly but won't be available with pkg_radd. If pkg_radd fails, try going to that package's directory in /usr/pkgsrc and using 'bmake install clean'. ### Tracking the stable branch There are quarterly releases of pkgsrc that are specifically designed for stability. You should in general follow the latest branch, rather than bleeding edge pkgsrc. To see the available branches: cd /usr/pkgsrc git branch -r To switch to a recent branch: cd /usr/pkgsrc git branch pkgsrc-2010Q3 origin/pkgsrc-2010Q3 Branch naming format is 'pkgsrc-YYYYQX', where YYYY is the year and QX is quarters 1-4 of the year. Check [pkgsrc.org](http://www.pkgsrc.org/) to see the name of the most recently released branch. After switching to a new branch, it can be downloaded with: cd /usr/pkgsrc git checkout vendor git pull ### List all installed packages To obtain a list of all the packages that are installed on your system: # pkg_info To see if certain packages have been installed, filter for the name of the package. This example will show all xorg-related packages currently installed on the system: # pkg_info | grep xorg ### Searching available packages Packages can be found using one of two ways. You can issue the command # cd /usr/pkgsrc/ # bmake search key='package you are looking for' from the /usr/pkgsrc directory. There is also the pkglocate tool that comes with pkgsrc: # /usr/pkgsrc/pkglocate 'package name' Normal UNIX file finding commands will work (whereis, locate, or find). It's also possible to browse website that show all the available pkgsrc packages, such as [http://pkgsrc.se/](pkgsrc.se) ## Upgrading packages There's a number of ways to upgrade pkgsrc; some of these are built in and some are packages installable with pkgsrc. This list is not necessarily comprehensive. pkg_rolling-replace: Rebuilds packages from source in dependency order. pkgin: Downloads and installs binary packages. Check the [[mirrors]] page for sites carrying binary packages to use with pkgin. pkg_chk: will update package by removing them and rebuilding them. Warning: programs are unavailable until a rebuild finishes. If they don't rebuild, it won't work. 'bmake update': Performed in the /usr/pkgsrc directory that correlates with the installed package, the software is deleted and rebuilt. The same warning applies as with pkg_chk. 'pkg_add -u': point at a local or online binary archive location to download and update packages. ## Removing packages If a program was installed as a package: # pkg_delete packagename If a package was installed from the source files, you can also change to the directory they were installed from and issue the command: # bmake deinstall ### Remove associated files needed for building a package To remove the work file from building package # bmake clean This can be combined with other steps: # bmake install clean ## Additional /usr/pkg/etc/mk.conf notes Packages often install rc.d scripts to control software running on startup. To specify where the rc.d scripts from the installed packages should go: RCD_SCRIPTS_DIR=/etc/rc.d PKG_RCD_SCRIPTS=YES This option can be set in the environment to activate it for binary packages. These packages will still have to be enabled in rc.conf to run at boot. If these options aren't set, the rc file will be placed in /usr/pkg/share/examples/rc.d/ and will need to be manually copied over to /etc/rc.d. ## What is WIP? Packages that can be built within the pkgsrc framework but are not yet necessarily ready for production use can be found in [http://pkgsrc-wip.sourceforge.net](pkgsrc-wip). These packages need to be downloaded separately; check the website for details. Packages in this collection are in development and may not build successfully. ## Links * [http://www.netbsd.org/Documentation/pkgsrc/](http://www.netbsd.org/Documentation/pkgsrc/) * [http://www.pkgsrc.se](http://www.pkgsrc.se) * To search and/or report bugs against packages in pkgsrc, look at [http://www.netbsd.org/support/send-pr.html](http://www.netbsd.org/support/send-pr.html) - use category 'pkg'. * [http://pkgsrc-wip.sourceforge.net](pkgsrc-wip), **w**ork **i**n **p**rogress packages not yet in offical pkgsrc release * The #pkgsrc IRC channel on Freenode * The #dragonflybsd IRC channel on EFnet