From: jrmarino Date: Mon, 10 Jun 2013 18:37:30 +0000 (-0700) Subject: Significantly improve the pkgng instructions including the new bootstrap functionality X-Git-Url: https://gitweb.dragonflybsd.org/ikiwiki.git/commitdiff_plain/676f236e2ac55db593b8fdad71a1a2b55dc710b2 Significantly improve the pkgng instructions including the new bootstrap functionality --- diff --git a/docs/howtos/HowToDPorts/index.mdwn b/docs/howtos/HowToDPorts/index.mdwn index 5ee136f6..50071030 100644 --- a/docs/howtos/HowToDPorts/index.mdwn +++ b/docs/howtos/HowToDPorts/index.mdwn @@ -1,30 +1,41 @@ -## DPorts background: +# DPorts and pkgng -Dports is an effort to use FreeBSD’s ports system as a base for DragonFly, and the pkg tool as a way to manage binary packages built from DPorts. This is complicated, so I’ll explain each part in order. +Dports 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. -FreeBSD ports are a FreeBSD-specific collection of software installation files that automate building 3rd-party software on FreeBSD. You’ve probably already heard of them. (Note there’s no mention of DragonFly.) +The __pkgng__ tool called "pkg" is a modern and fast binary package manager. It was developed for FreeBSD, but PC-BSD used in production first, followed soon after by DragonFly. In the future, it will be only binary package manager on FreeBSD just as it is for DPorts. -DPorts is a collection of files that map to existing FreeBSD ports, and contain any changes necessary to make that port also build on DragonFly. Many of those programs build without changes on DragonFly. DPorts builds from source. +__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. -pkg is used for package management, and is usable on FreeBSD, PC-BSD, and on DragonFly. The binary packages produced from building with DPorts can be installed from remote locations and managed separately using pkg, so that software upgrades and installation can be performed with binaries only. (It’s much faster that way.) +## Getting started with pkgng -Every port seen in DPorts is known to build on DragonFly. A port is added only after it builds successfully, using poudriere as a bulk software tool. Ports are only updated to a newer version when that newer version builds, too, so once something arrives in DPorts, it should never break from being updated at some point in the future. +DragonFly 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. -## Installing packages. +To bootstrap __pkgng___ on the system, run: -The 3.4 Release of DragonFly is the first to provide official repositories. It also provides pkg and pkg.conf preinstalled with the release repository pre-selected. + # cd /usr + # make pkg-bootstrap + # rehash + # pkg-static install -y pkg + # rehash -The /usr/local/etc/pkg.conf is predefined as: +If the DPorts source tree is already present on the system, pkg can quickly be built from source: - PACKAGESITE: http://avalon.dragonflybsd.org/dports/${ABI}/RELEASE + # cd /usr/dports/ports-mgmt/pkg + # make install + +## Configuring the pkgng Environment -The user would first run "pkg update" to download the inventory from the PACKAGES. From there the user can browse the repository, install packages, etc. "pkg help" and "man pkg" has a wealth of information and much of the FreeBSD handbook is pertinent: [5.5 Using pkgng for Binary Package Management](http://www.freebsd.org/doc/en/books/handbook/pkgng-intro.html). +The __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). -The RELEASE repository is static, but the LATEST repository is periodically updated. If bleeding edge is what you want, change pkg.conf to reflect that: +The pkg.conf file comes preinstalled with the latest release repository pre-selected. + + PACKAGESITE: http://avalon.dragonflybsd.org/dports/${ABI}/RELEASE + +The RELEASE repository is static, but the LATEST repository is periodically updated. If bleeding edge is wanted, change pkg.conf to reflect that: PACKAGESITE: http://avalon.dragonflybsd.org/dports/${ABI}/LATEST -DragonFly 3.5 users can also use pre-build binary packages, but they will need to override the ABI in pkg.conf: +DragonFly 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.: ABI: dragonfly:3.4:x86:32 # for i386 platform ABI: dragonfly:3.4:x86:64 # for x86-64 platform @@ -36,62 +47,195 @@ There are already a few mirrors available which can be set in pkg.conf * Europe: http://mirrors.ircam.fr/pub/DragonFlyBSD-dports/${ABI}/LATEST * Europe: http://dfly.schlundtech.de/dports/${ABI}/LATEST -** IPV6 Users please feel free to use dfly.schlundtech.de +IPV6 users are welcome to use dfly.schlundtech.de -## Building DPorts from source +## Basic pkgng Operations -The 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: +Usage information for __pkgng__ is available in the pkg(8) manual page, or by running `pkg` without additional arguments. -* The port is new and there's no pre-binary available yet -* The pre-built binaries use the default options and the user needs a package built with a different set of options -* Testing FreeBSD port in order to patch them and submit to dports -* The user just prefers building from source +Each __pkgng__ command argument is documented in a command-specific manual page. To read the manual page for `pkg install`, for example, run either: + + # pkg help install + # man pkg-install + +## Obtaining Information About Installed Packages with pkgng + +Information 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: + + # pkg info packagename + +For example, to see which version of __pkgng__ is installed on the system, run: + + # pkg info pkg + pkg-1.0.12 New generation package manager + +## Installing and Removing Packages with pkgng + +In general, most DragonFly users will install binary packages by typing: + + # pkg install + +For example, to install curl: + + # pkg install curl + + Updating repository catalogue + Repository catalogue is up-to-date, no need to fetch fresh copy + The following packages will be installed: + + Installing ca_root_nss: 3.13.5 + Installing curl: 7.24.0 + + The installation will require 4 MB more space + + 1 MB to be downloaded + + Proceed with installing packages [y/N]: y + ca_root_nss-3.13.5.txz 100% 255KB 255.1KB/s 255.1KB/s 00:00 + curl-7.24.0.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00 + Checking integrity... done + Installing ca_root_nss-3.13.5... done + Installing curl-7.24.0... done + +The new package and any additional packages that were installed as dependencies can be seen in the installed packages list: + + # pkg info + ca_root_nss-3.13.5 The root certificate bundle from the Mozilla Project + curl-7.24.0 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers + pkg-1.0.12 New generation package manager + +Packages that are no longer needed can be removed with `pkg delete`. For example, if it turns out that curl is not needed after all: + + # pkg delete curl + The following packages will be deleted: + + curl-7.24.0_1 + + The deletion will free 3 MB + + Proceed with deleting packages [y/N]: y + Deleting curl-7.24.0_1... done + +## Upgrading Installed Packages with pkgng + +Packages 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. -### Installing DPorts tree +Packages 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: -DragonFly 3.3 or later is the minimum version that can build dports from source. + # pkg upgrade + Updating repository catalogue + repo.txz 100% 297KB 296.5KB/s 296.5KB/s 00:00 + The following packages will be upgraded: + + Upgrading curl: 7.24.0 -> 7.24.0_1 + + 1 MB to be downloaded + + Proceed with upgrading packages [y/N]: y + curl-7.24.0_1.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00 + Checking integrity... done + Upgrading curl from 7.24.0 to 7.24.0_1... done -It's probable that pkgsrc binaries are already installed. It is necessary to -rename /usr/pkg so that the existing pkgsrc binary programs don’t get accidentally used while building DPorts, causing breakage. If anything goes wrong with DPorts when you are installing it, you can go back by removing all the DPorts packages with "pkg delete -ay" and renaming /usr/pkg back to normal. (Don’t confuse pkg, the management tool, with /usr/pkg, the normal installation directory for pkgsrc. ) For the installation of the base port files: +## Auditing Installed Packages with pkgng - cd /usr - make dports-create-shallow +Occasionally, software vulnerabilities may be discovered in software within DPorts. __pkgng__ includes built-in auditing. To audit the software installed on the system, type: -If you’ve already renamed your /usr/pkg directory, git won’t be in your path any more. You can instead download a tarball and unpack it, which also happens to be possible automatically via that same Makefile. + # pkg audit -F - cd /usr - make dports-download +# Advanced pkgng Operations -Downloading via git is fastest, so if you do need to use the tarball via make dports-download, build devel/git, delete /usr/dports, and then pull it again with make dports-create-shallow. This all comes from [John Marino’s Github site for DPorts](https://github.com/jrmarino/DPorts/#readme). +## Automatically Removing Leaf Dependencies with pkgng -### Managing DPorts +Removing 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: -DPorts doesn’t use pkg_info, pkg_add, and the other tools traditionally seen on DragonFly for pkgsrc. Instead, package management is done with pkg. Use pkg info, pkg install, pkg remove, and pkg update to list, install, delete, and upgrade various packages on your system. Packages built from source or downloaded as prebuilt binaries are managed the same way, using these tools. + # pkg autoremove + Packages to be autoremoved: + ca_root_nss-3.13.5 + + The autoremoval will free 723 kB + + Proceed with autoremoval of packages [y/N]: y + Deinstalling ca_root_nss-3.13.5... done -See some of the [other](https://mebsd.com/make-build-your-freebsd-word/pkgng-first-look-at-freebsds-new-package-manager.html) [writing](http://ivoras.net/blog/tree/2012-07-26.pkgng---best-thing-since-sliced-bread!.html) about pkg for FreeBSD for details on how it works. +## Backing Up the pkgng Package Database + +__pkgng__ includes its own package database backup mechanism. To manually back up the package database contents, type: + + # pkg backup -d + +Additionally, __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). + +To restore the contents of a previous package database backup, run: + + # pkg backup -r + +## Removing Stale pkgng Packages + +By 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. + +To remove the outdated binary packages, type: + + # pkg clean + +##Modifying pkgng Package Metadata + +__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: + + # pkg set -o : + +For example, to change the package origin for the above example, type: + + # pkg set -o lang/php5:lang/php53 + +As another example, to update lang/ruby18 to lang/ruby19, type: + + # pkg set -o lang/ruby18:lang/ruby19 + +As a final example, to change the origin of the libglut shared libraries from graphics/libglut to graphics/freeglut, type: + + # pkg set -o graphics/libglut:graphics/freeglut + +_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: + + # pkg install -Rf graphics/freeglut + +# Building DPorts from source + +The 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: + +* The port is new and there's no pre-binary available yet +* The pre-built binaries use the default options and the user needs a package built with a different set of options +* Testing FreeBSD port in order to patch them and submit to DPorts +* The user just prefers building from source -Since DPorts doesn’t update a package until it gets a successful build, and installations are of successfully built binary packages, upgrades with prebuilt packages should always succeed. Since they’re binary, they should be fast. There’s a lot of ‘shoulds’ in this sentence, but these are reasonable suppositions. +## Installing DPorts tree -### Building +DragonFly 3.4 or later is the minimum version that can build DPorts from source. -Building 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. +It'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: -*You will eventually want to do this:* Set BATCH=yes to take all default package options without having the build stop to ask questions. + # cd /usr + # make dports-create-shallow -If 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 BATCH=yes'. +If 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: -Note that this is only necessary if you want to build from source with a non-default config, or if you don't have a binary repository available to pull files from with pkg. + # cd /usr + # make dports-download -## What about pkgsrc? +For future updates, pull delta changes via `git` is fastest, so it is suggested to convert the static tree to a git repository by typing: -Pkgsrc and DPorts shouldn’t be used at the same time, since one system’s packages may be at different versions but still get picked up during building for the other system. That’s about it for restrictions. + # cd /usr/dports/devel/git + # make install + # cd /usr + # rm -rf /usr/dports + # make dports-create-shallow -DPorts is brand new so the normal caveats apply; don’t install it on a mission-critical machine, and be ready to deal with any surprises from using it if you do try it out. +The git repository is hosted on the [github account of John Marino](https://github.com/jrmarino/DPorts/#readme). -## Which ports are available? +## Final thoughts -Browsing the Github repo will show you all listed packages. It changes as more packages are built. Changes from DragonFly builds are sometimes relevant to the original FreeBSD port, so there’s benefits for everyone here. The pkg tool can show which packages were actually built and available for your platform (e.g. pkg search, pkg rquery, etc.) +Building 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. -## What next? +To 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. -This is experimental; this will not necessarily replace pkgsrc. It's available in this release for further testing and feedback. Remember, this is a new project, so a willingness to deal with problems and contribute to fixes is necessary. +If 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.