Add "More reading"
[ikiwiki.git] / docs / howtos / HowToDPorts / index.mdwn
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
fa3eabfe 13To bootstrap __pkgng__ from source on a pkgsrc-using system, run:
5232b755 14
676f236e 15 # cd /usr
743c7cfa 16 # make dports-create
17 # rm -rf pkg ( as in /usr/pkg )
18 # pkg install some-package
3bcc74c7 19
fa3eabfe 20To bootstrap __pkgng__ with a download on a pkgsrc-using system, run:
3bcc74c7 21
676f236e 22 # make pkg-bootstrap
23 # rehash
24 # pkg-static install -y pkg
25 # rehash
5232b755 26
fa3eabfe 27Note that this step is unnecessary for any newly installed release from DragonFly 3.4 onwards.
676f236e 28
29## Configuring the pkgng Environment
5232b755 30
676f236e 31The __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 32
676f236e 33The pkg.conf file comes preinstalled with the latest release repository pre-selected.
37The RELEASE repository is static, but the LATEST repository is periodically updated. If bleeding edge is wanted, change pkg.conf to reflect that:
f60756b0 38
676f236e 41DragonFly 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 42
43 ABI: dragonfly:3.4:x86:32 # for i386 platform
44 ABI: dragonfly:3.4:x86:64 # for x86-64 platform
46There are already a few mirrors available which can be set in pkg.conf
5232b755 47
48* North America:${ABI}/LATEST
49* Europe:${ABI}/LATEST
50* Europe:${ABI}/LATEST
7666fbf2 51* Europe:${ABI}/LATEST
5232b755 52
669d4d5a 53All the above european mirrors are IPV6-enabled.
ff963ca1 54
676f236e 55## Basic pkgng Operations
f60756b0 56
676f236e 57Usage information for __pkgng__ is available in the pkg(8) manual page, or by running `pkg` without additional arguments.
5232b755 58
676f236e 59Each __pkgng__ command argument is documented in a command-specific manual page. To read the manual page for `pkg install`, for example, run either:
61 # pkg help install
62 # man pkg-install
64## Obtaining Information About Installed Packages with pkgng
66Information 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:
68 # pkg info packagename
70For example, to see which version of __pkgng__ is installed on the system, run:
72 # pkg info pkg
73 pkg-1.0.12 New generation package manager
75## Installing and Removing Packages with pkgng
77In general, most DragonFly users will install binary packages by typing:
79 # pkg install <packagename>
81For example, to install curl:
83 # pkg install curl
85 Updating repository catalogue
86 Repository catalogue is up-to-date, no need to fetch fresh copy
87 The following packages will be installed:
89 Installing ca_root_nss: 3.13.5
90 Installing curl: 7.24.0
92 The installation will require 4 MB more space
94 1 MB to be downloaded
96 Proceed with installing packages [y/N]: y
97 ca_root_nss-3.13.5.txz 100% 255KB 255.1KB/s 255.1KB/s 00:00
8a3d16f3 98 curl-7.24.0.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00
676f236e 99 Checking integrity... done
100 Installing ca_root_nss-3.13.5... done
101 Installing curl-7.24.0... done
103The new package and any additional packages that were installed as dependencies can be seen in the installed packages list:
105 # pkg info
106 ca_root_nss-3.13.5 The root certificate bundle from the Mozilla Project
107 curl-7.24.0 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
108 pkg-1.0.12 New generation package manager
110Packages that are no longer needed can be removed with `pkg delete`. For example, if it turns out that curl is not needed after all:
112 # pkg delete curl
113 The following packages will be deleted:
115 curl-7.24.0_1
117 The deletion will free 3 MB
119 Proceed with deleting packages [y/N]: y
120 Deleting curl-7.24.0_1... done
122## Upgrading Installed Packages with pkgng
124Packages 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 125
676f236e 126Packages 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 127
676f236e 128 # pkg upgrade
129 Updating repository catalogue
130 repo.txz 100% 297KB 296.5KB/s 296.5KB/s 00:00
131 The following packages will be upgraded:
133 Upgrading curl: 7.24.0 -> 7.24.0_1
135 1 MB to be downloaded
137 Proceed with upgrading packages [y/N]: y
138 curl-7.24.0_1.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00
139 Checking integrity... done
140 Upgrading curl from 7.24.0 to 7.24.0_1... done
80be6ca4 141
676f236e 142## Auditing Installed Packages with pkgng
80be6ca4 143
676f236e 144Occasionally, software vulnerabilities may be discovered in software within DPorts. __pkgng__ includes built-in auditing. To audit the software installed on the system, type:
80be6ca4 145
676f236e 146 # pkg audit -F
80be6ca4 147
676f236e 148# Advanced pkgng Operations
80be6ca4 149
676f236e 150## Automatically Removing Leaf Dependencies with pkgng
80be6ca4 151
676f236e 152Removing 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 153
676f236e 154 # pkg autoremove
155 Packages to be autoremoved:
156 ca_root_nss-3.13.5
158 The autoremoval will free 723 kB
160 Proceed with autoremoval of packages [y/N]: y
161 Deinstalling ca_root_nss-3.13.5... done
80be6ca4 162
676f236e 163## Backing Up the pkgng Package Database
165__pkgng__ includes its own package database backup mechanism. To manually back up the package database contents, type:
167 # pkg backup -d <pkgng.db>
2cae69b5 169Additionally, __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 170
171To restore the contents of a previous package database backup, run:
173 # pkg backup -r </path/to/pkgng.db>
175## Removing Stale pkgng Packages
177By 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.
179To remove the outdated binary packages, type:
181 # pkg clean
183##Modifying pkgng Package Metadata
185__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:
187 # pkg set -o <category/oldport>:<category/newport>
189For example, to change the package origin for the above example, type:
191 # pkg set -o lang/php5:lang/php53
193As another example, to update lang/ruby18 to lang/ruby19, type:
195 # pkg set -o lang/ruby18:lang/ruby19
197As a final example, to change the origin of the libglut shared libraries from graphics/libglut to graphics/freeglut, type:
199 # pkg set -o graphics/libglut:graphics/freeglut
201_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:
203 # pkg install -Rf graphics/freeglut
205# Building DPorts from source
207The 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:
209* The port is new and there's no pre-binary available yet
210* The pre-built binaries use the default options and the user needs a package built with a different set of options
211* Testing FreeBSD port in order to patch them and submit to DPorts
212* The user just prefers building from source
80be6ca4 213
676f236e 214## Installing DPorts tree
80be6ca4 215
676f236e 216DragonFly 3.4 or later is the minimum version that can build DPorts from source.
80be6ca4 217
676f236e 218It'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 219
676f236e 220 # cd /usr
221 # make dports-create-shallow
0fcf3e89 222
676f236e 223If 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 224
676f236e 225 # cd /usr
226 # make dports-download
80be6ca4 227
676f236e 228For 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 229
676f236e 230 # cd /usr/dports/devel/git
231 # make install
232 # cd /usr
233 # rm -rf /usr/dports
234 # make dports-create-shallow
80be6ca4 235
676f236e 236The git repository is hosted on the [github account of John Marino](
80be6ca4 237
676f236e 238## Final thoughts
80be6ca4 239
676f236e 240Building 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 241
676f236e 242To 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 243
676f236e 244If 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.
44526695 245
246## More reading
247* How fix/add broken ports: [[docs/howtos/fixdports]]
248* [Trick: How to get i386-only software via dports](