fix error caused by global find/replace command
[ikiwiki.git] / docs / howtos / HowToDPorts / index.mdwn
CommitLineData
676f236e 1# DPorts and pkgng
80be6ca4 2
676f236e 3Dports is DragonFly's own third-party software build system. It is based on FreeBSD's Ports Collection. Differences between ports and DPorts are intentionally kept to a minimum, both to maintain familiarity for mutual users of both operating systems and also to leverage the tremendous amount of work the FreeBSD contributors put into ports. DPorts can and does feature ports unique to DragonFly, so it's truly a native system.
80be6ca4 4
669d4d5a 5The __pkgng__ tool called "pkg" is a modern and fast binary package manager. It was developed for FreeBSD, but PC-BSD used it in production first, followed soon after by DragonFly. In the future, it will be the only binary package manager on FreeBSD just as it is for DPorts.
80be6ca4 6
676f236e 7__pkgng__ is not a replacement for port management tools like `ports-mgmt/portmaster` or `ports-mgmt/portupgrade`. While `ports-mgmt/portmaster` and `ports-mgmt/portupgrade` can install third-party software from both binary packages and DPorts, __pkgng__ installs only binary packages.
80be6ca4 8
676f236e 9## Getting started with pkgng
80be6ca4 10
676f236e 11DragonFly daily snapshots and Releases (starting with 3.4) come with __pkgng__ already installed. However upgrades from earlier releases won't have it. If the "pkg" program is missing on the system for any reason, it can be quickly bootstrapped without having to build it from source.
80be6ca4 12
f73c2e99 13To bootstrap __pkgng__ on the system, run:
5232b755 14
676f236e 15 # cd /usr
16 # make pkg-bootstrap
17 # rehash
18 # pkg-static install -y pkg
19 # rehash
5232b755 20
676f236e 21If the DPorts source tree is already present on the system, pkg can quickly be built from source:
5232b755 22
676f236e 23 # cd /usr/dports/ports-mgmt/pkg
24 # make install
25
26## Configuring the pkgng Environment
5232b755 27
676f236e 28The __pkgng__ package management system uses a package repository for most operations. The default package repository location is defined in `/usr/local/etc/pkg.conf` or the `PACKAGESITE` environment variable, which overrides the configuration file. Additional __pkgng__ configuration options are described in pkg.conf(5).
f60756b0 29
676f236e 30The pkg.conf file comes preinstalled with the latest release repository pre-selected.
31
32 PACKAGESITE: http://avalon.dragonflybsd.org/dports/${ABI}/RELEASE
33
34The RELEASE repository is static, but the LATEST repository is periodically updated. If bleeding edge is wanted, change pkg.conf to reflect that:
f60756b0 35
36 PACKAGESITE: http://avalon.dragonflybsd.org/dports/${ABI}/LATEST
37
676f236e 38DragonFly users on the development branch can also use pre-built binary packages from the last release, but they will need to override the ABI in pkg.conf, e.g.:
f60756b0 39
40 ABI: dragonfly:3.4:x86:32 # for i386 platform
41 ABI: dragonfly:3.4:x86:64 # for x86-64 platform
42
43There are already a few mirrors available which can be set in pkg.conf
5232b755 44
45* North America: http://avalon.dragonflybsd.org/dports/${ABI}/LATEST
46* Europe: http://pkg.wolfpond.org/${ABI}/LATEST
47* Europe: http://mirrors.ircam.fr/pub/DragonFlyBSD-dports/${ABI}/LATEST
7666fbf2 48* Europe: http://dfly.schlundtech.de/dports/${ABI}/LATEST
5232b755 49
669d4d5a 50All the above european mirrors are IPV6-enabled.
ff963ca1 51
676f236e 52## Basic pkgng Operations
f60756b0 53
676f236e 54Usage information for __pkgng__ is available in the pkg(8) manual page, or by running `pkg` without additional arguments.
5232b755 55
676f236e 56Each __pkgng__ command argument is documented in a command-specific manual page. To read the manual page for `pkg install`, for example, run either:
57
58 # pkg help install
59 # man pkg-install
60
61## Obtaining Information About Installed Packages with pkgng
62
63Information about the packages installed on a system can be viewed by running `pkg info`. Similar to pkg_info(1), the package version and description for all packages will be listed. Information about a specific package is available by running:
64
65 # pkg info packagename
66
67For example, to see which version of __pkgng__ is installed on the system, run:
68
69 # pkg info pkg
70 pkg-1.0.12 New generation package manager
71
72## Installing and Removing Packages with pkgng
73
74In general, most DragonFly users will install binary packages by typing:
75
76 # pkg install <packagename>
77
78For example, to install curl:
79
80 # pkg install curl
81
82 Updating repository catalogue
83 Repository catalogue is up-to-date, no need to fetch fresh copy
84 The following packages will be installed:
85
86 Installing ca_root_nss: 3.13.5
87 Installing curl: 7.24.0
88
89 The installation will require 4 MB more space
90
91 1 MB to be downloaded
92
93 Proceed with installing packages [y/N]: y
94 ca_root_nss-3.13.5.txz 100% 255KB 255.1KB/s 255.1KB/s 00:00
8a3d16f3 95 curl-7.24.0.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00
676f236e 96 Checking integrity... done
97 Installing ca_root_nss-3.13.5... done
98 Installing curl-7.24.0... done
99
100The new package and any additional packages that were installed as dependencies can be seen in the installed packages list:
101
102 # pkg info
103 ca_root_nss-3.13.5 The root certificate bundle from the Mozilla Project
104 curl-7.24.0 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
105 pkg-1.0.12 New generation package manager
106
107Packages that are no longer needed can be removed with `pkg delete`. For example, if it turns out that curl is not needed after all:
108
109 # pkg delete curl
110 The following packages will be deleted:
111
112 curl-7.24.0_1
113
114 The deletion will free 3 MB
115
116 Proceed with deleting packages [y/N]: y
117 Deleting curl-7.24.0_1... done
118
119## Upgrading Installed Packages with pkgng
120
121Packages that are outdated can be found with `pkg version`. If a local ports tree does not exist, pkg-version(8) will use the remote repository catalogue, otherwise the local ports tree will be used to identify package versions.
80be6ca4 122
676f236e 123Packages can be upgraded to newer versions with __pkgng__. Suppose a new version of curl has been released. The local package can be upgraded to the new version:
80be6ca4 124
676f236e 125 # pkg upgrade
126 Updating repository catalogue
127 repo.txz 100% 297KB 296.5KB/s 296.5KB/s 00:00
128 The following packages will be upgraded:
129
130 Upgrading curl: 7.24.0 -> 7.24.0_1
131
132 1 MB to be downloaded
133
134 Proceed with upgrading packages [y/N]: y
135 curl-7.24.0_1.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00
136 Checking integrity... done
137 Upgrading curl from 7.24.0 to 7.24.0_1... done
80be6ca4 138
676f236e 139## Auditing Installed Packages with pkgng
80be6ca4 140
676f236e 141Occasionally, software vulnerabilities may be discovered in software within DPorts. __pkgng__ includes built-in auditing. To audit the software installed on the system, type:
80be6ca4 142
676f236e 143 # pkg audit -F
80be6ca4 144
676f236e 145# Advanced pkgng Operations
80be6ca4 146
676f236e 147## Automatically Removing Leaf Dependencies with pkgng
80be6ca4 148
676f236e 149Removing a package may leave behind unnecessary dependencies, like `security/ca_root_nss` in the example above. Such packages are still installed, but nothing depends on them any more. Unneeded packages that were installed as dependencies can be automatically detected and removed:
80be6ca4 150
676f236e 151 # pkg autoremove
152 Packages to be autoremoved:
153 ca_root_nss-3.13.5
154
155 The autoremoval will free 723 kB
156
157 Proceed with autoremoval of packages [y/N]: y
158 Deinstalling ca_root_nss-3.13.5... done
80be6ca4 159
676f236e 160## Backing Up the pkgng Package Database
161
162__pkgng__ includes its own package database backup mechanism. To manually back up the package database contents, type:
163
164 # pkg backup -d <pkgng.db>
165
2cae69b5 166Additionally, __pkgng__ includes a periodic(8) script to automatically back up the package database daily if `daily_backup_pkgng_enable` is set to `YES` in periodic.conf(5). To prevent the `pkg_install` periodic script from also backing up the package database, set `daily_backup_pkgdb_enable` to `NO` in periodic.conf(5).
676f236e 167
168To restore the contents of a previous package database backup, run:
169
170 # pkg backup -r </path/to/pkgng.db>
171
172## Removing Stale pkgng Packages
173
174By default, __pkgng__ stores binary packages in a cache directory as defined by `PKG_CACHEDIR` in pkg.conf(5). When upgrading packages with pkg upgrade, old versions of the upgraded packages are not automatically removed.
175
176To remove the outdated binary packages, type:
177
178 # pkg clean
179
180##Modifying pkgng Package Metadata
181
182__pkgng__ has a built-in command to update package origins. For example, if `lang/php5` was originally at version 5.3, but has been renamed to lang/php53 for the inclusion of version 5.4, the package database can be updated to deal with this. For __pkgng__, the syntax is:
183
184 # pkg set -o <category/oldport>:<category/newport>
185
186For example, to change the package origin for the above example, type:
187
188 # pkg set -o lang/php5:lang/php53
189
190As another example, to update lang/ruby18 to lang/ruby19, type:
191
192 # pkg set -o lang/ruby18:lang/ruby19
193
194As a final example, to change the origin of the libglut shared libraries from graphics/libglut to graphics/freeglut, type:
195
196 # pkg set -o graphics/libglut:graphics/freeglut
197
198_Note_: When changing package origins, in most cases it is important to reinstall packages that are dependent on the package that has had the origin changed. To force a reinstallation of dependent packages, type:
199
200 # pkg install -Rf graphics/freeglut
201
202# Building DPorts from source
203
204The average user will probably not build packages from source. However, it's easy to do and it can be done even when packages have already been pre-installed on the system. Common reasons to build from source are:
205
206* The port is new and there's no pre-binary available yet
207* The pre-built binaries use the default options and the user needs a package built with a different set of options
208* Testing FreeBSD port in order to patch them and submit to DPorts
209* The user just prefers building from source
80be6ca4 210
676f236e 211## Installing DPorts tree
80be6ca4 212
676f236e 213DragonFly 3.4 or later is the minimum version that can build DPorts from source.
80be6ca4 214
676f236e 215It's probably that pkgsrc binaries are already installed because it comes bootstrapped with new systems. It is necessary to rename `/usr/pkg` directory so that the existing pkgsrc binary tools and libraries don’t get accidentally used while building DPorts, causing breakage. For the installation of the DPorts tree, type:
0fcf3e89 216
676f236e 217 # cd /usr
218 # make dports-create-shallow
0fcf3e89 219
676f236e 220If the `/usr/pkg directory` has already been renamed, `git` won’t be in the search path any more. One option is to download a tarball of DPorts and unpack it. To do this, type:
80be6ca4 221
676f236e 222 # cd /usr
223 # make dports-download
80be6ca4 224
676f236e 225For future updates, pull delta changes via `git` is fastest, so it is suggested to convert the static tree to a git repository by typing:
80be6ca4 226
676f236e 227 # cd /usr/dports/devel/git
228 # make install
229 # cd /usr
230 # rm -rf /usr/dports
231 # make dports-create-shallow
80be6ca4 232
676f236e 233The git repository is hosted on the [github account of John Marino](https://github.com/jrmarino/DPorts/#readme).
80be6ca4 234
676f236e 235## Final thoughts
80be6ca4 236
676f236e 237Building from source works similar to ports and pkgsrc: cd into the appropriate program's directory, and type 'make'. 'make install' to install the software, 'make clean' to clean up work files, and so on. Use 'make config-recursive' if you want to set all the port's options, and the options of its dependencies, immediately instead of during the build.
80be6ca4 238
676f236e 239To take all the default build options and avoid getting the pop-up dialog box, set `NO_DIALOG=yes` on either the command line or the make.conf file.
80be6ca4 240
676f236e 241If you just want to set the options for one package, and accept the default for all of its dependencies, do 'make config' in the package in you want non-default options, and then 'make NO_DIALOG=yes'. Note that this is only necessary if you want to build from source with a non-default set of options, or if no pre-built binary package is available yet.