3 ## History and Overview
4 [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.
8 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.
15 to fetch the intial pkgsrc repository from the net, or
22 Edit /usr/Makefile to select a different download location, if desired.
24 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.
26 ## Installing packages from source
28 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.
30 # cd /usr/pkgsrc/misc/screen
33 To find out the options that can affect how a program is built:
39 # bmake PKG_OPTIONS.<package_name>="-option1 option2" install clean
41 Listing an option enables it. Listing an option with a "-" before it disables the option.
43 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:
45 . PKG_OPTIONS.<package_name>=-option1 option2
47 ## Installing pre-built packages
49 Binary packages can be installed using pkg_radd:
53 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.
55 You can manually set PKG_PATH and use pkg_add to get the same effect, using a different server.
57 # setenv PKG_PATH http://avalon.dragonflybsd.org/packages/i386/DragonFly-2.7/stable
60 This will install most packages, but will not upgrade packages that are already installed.
62 ***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.***
64 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'.
66 ### Tracking the stable branch
68 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.
70 To see the available branches:
75 To switch to a recent branch:
78 git branch pkgsrc-2010Q3 origin/pkgsrc-2010Q3
80 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.
82 After switching to a new branch, it can be downloaded with:
88 ### List all installed packages
90 To obtain a list of all the packages that are installed on your system:
94 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:
96 # pkg_info | grep xorg
98 ### Searching available packages
100 Packages can be found using one of two ways. You can issue the command
103 # bmake search key='package you are looking for'
105 from the /usr/pkgsrc directory.
107 There is also the pkglocate tool that comes with pkgsrc:
109 # /usr/pkgsrc/pkglocate 'package name'
111 Normal UNIX file finding commands will work (whereis, locate, or find).
113 It's also possible to browse website that show all the available pkgsrc packages, such as [http://pkgsrc.se/](http://pkgsrc.se)
115 ## Upgrading packages
117 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.
119 pkg_rolling-replace: Rebuilds packages from source in dependency order.
121 pkgin: Downloads and installs binary packages. Check the [[mirrors]] page for sites carrying binary packages to use with pkgin. Just remember that our x86_64 branch used to be called amd64. The amd64 alias is preserved in order to support older installations
123 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.
125 '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.
127 'pkg_add -u': point at a local or online binary archive location to download and update packages.
133 If a program was installed as a package:
135 # pkg_delete packagename
137 If a package was installed from the source files, you can also change to the directory they were installed from and issue the command:
141 ### Remove associated files needed for building a package
143 To remove the work file from building package
147 This can be combined with other steps:
149 # bmake install clean
151 ## Additional /usr/pkg/etc/mk.conf notes
153 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:
155 RCD_SCRIPTS_DIR=/etc/rc.d
158 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.
162 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](http://pkgsrc-wip.sourceforge.net). These packages need to be downloaded separately; check the website for details. Packages in this collection are in development and may not build successfully.
166 * [http://www.netbsd.org/Documentation/pkgsrc/](http://www.netbsd.org/Documentation/pkgsrc/)
168 * [http://www.pkgsrc.se](http://www.pkgsrc.se)
170 * 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'.
172 * [http://pkgsrc-wip.sourceforge.net](http://pkgsrc-wip.sourceforge.net), **w**ork **i**n **p**rogress packages not yet in official pkgsrc release
174 * The #pkgsrc IRC channel on Freenode
176 * The #dragonflybsd IRC channel on EFnet