Package management tool for FreeBSD. Help at #pkg on Libera Chat or pkg@FreeBSD.org
  • C 81.5%
  • Shell 17.2%
  • Makefile 0.9%
  • SmPL 0.4%
Find a file
Gleb Popov 0b34606850 pkg_add.c: Resolve the shlib symlink before recursing into pkg_add
This subtle bug can be reproduced when pkg_add recurses through different
types of dependencies - deps and requires. The path passed into
pkg_add_check_pkg_archive() is expected to start with "All/", but after
handling a shlib requirement and recursing down it changes to "shlibs/".
At the bottom the code ends up doing

access("/../shlibs/libconsumer.so.1/package1-1.pkg",F_OK) ERR#2 'No such file or directory'

instead of

access("/../All/libconsumer.so.1/package1-1.pkg",F_OK) 0 = (0x0)

The added test case fails without this fix.
2026-11-04 21:13:52 +01:00
.builds alpine: fix the 15 failing tests 2026-08-21 12:38:48 +02:00
.github/workflows build: clean up dev build logic 2026-08-20 10:34:27 +02:00
compat libfetch: use a C locale for the protocol dates 2026-11-04 08:57:01 +01:00
docs scripts: a script exiting with status 3 made pkg exit(0) mid-transaction 2026-11-04 08:57:01 +01:00
external libfetch: use a C locale for the protocol dates 2026-11-04 08:57:01 +01:00
libpkg pkg_add.c: Resolve the shlib symlink before recursing into pkg_add 2026-11-04 21:13:52 +01:00
mk build: recreate static archives instead of updating them in place 2026-10-28 21:28:21 +01:00
scripts install|upgrade: add -N/--no-remove and NEVER_REMOVE 2026-09-25 15:24:53 +02:00
src scripts: a script exiting with status 3 made pkg exit(0) mid-transaction 2026-11-04 08:57:01 +01:00
tests pkg_add.c: Resolve the shlib symlink before recursing into pkg_add 2026-11-04 21:13:52 +01:00
.clang-format Update clang-format to match style(9) 2026-06-02 23:57:25 +02:00
.editorconfig Add editorconfig 2024-04-05 08:39:02 +02:00
.gitignore Revert "fetch: download packages concurrently with repository limits" 2026-10-29 08:58:52 +01:00
.gitlab-ci.yml Add .gitlab-ci.yml 2018-09-07 10:33:17 -06:00
AUTHORS Add andrej in the authors 2015-01-17 21:29:58 +01:00
autogen.sh Convert to autosetup 2018-05-02 10:03:56 +02:00
configure Sync with latest bbuild 2026-06-02 23:57:25 +02:00
configure.def build: do not abort when xlocale.h is missing 2026-11-04 09:02:35 +01:00
CONTRIBUTING.md Add initial CONTRIBUTING 2012-09-20 12:37:35 -05:00
COPYING Welcome to 2019 2019-01-02 10:44:25 +01:00
Doxyfile.in New Release 1.1.a1.20121222 2012-12-22 13:32:49 +00:00
FAQ.md Fix typos in source code 2026-04-29 15:52:25 +02:00
features.md Fix typos in source code 2026-04-29 15:52:25 +02:00
freebsd.cfg Style: Consider STAILQ_FOREACH as for, add braces around single lined if/for/while 2014-08-28 21:12:18 +02:00
Kyuafile build: replace autosetup by bbuild 2026-04-23 16:34:08 +02:00
Leak.suppress hash: rename pkghash "hash" because it is now shared with other projects 2026-09-21 20:11:16 +02:00
Makefile.in restore compat lib 2026-08-20 21:32:55 +02:00
NEWS checksum: do not free an unallocated pointer on a read error 2026-11-04 19:45:29 +01:00
README.md Revert "fetch: download packages concurrently with repository limits" 2026-10-29 08:58:52 +01:00
TODO.md Fix typos in source code 2026-04-29 15:52:25 +02:00
UndefinedBehaviour.suppress Directrly call the suppress file from the sourcetree and Kyua from the 2026-04-24 11:26:51 +02:00

pkg - a package manager for FreeBSD

  • Sourcehut FreeBSD: builds.sr.ht status
  • Sourcehut Alpine: builds.sr.ht status
  • Sourcehut Debian: builds.sr.ht status
  • Github Actions: build

Table of Contents:

libpkg

pkg is built on top of libpkg, a new library to interface with the package registration backends. It abstracts package management details such as registration, remote repositories, package creation, updating, etc.

pkg package format

The pkg package format is a tar archive that may be raw or compressed using one of the following algorithms: gz, bzip2, zstd, or xz. The default compression algorithm is zstd.

The tar archive itself is composed of two types of elements:

  • the special files at the beginning of the archive, starting with a "+"
  • the data.

Installing packages

pkg can install a package archive from the local disk, remote HTTP server or remote SSH server.

Pkg bootstrap

All supported versions of FreeBSD now contain /usr/sbin/pkg a.k.a pkg(7). This is a small placeholder that has just the minimum functionality required to install the real pkg(8).

To use, simply run any pkg(8) command line. pkg(7) will intercept the command, and if you confirm that is your intention, download the pkg(8) tarball, install pkg(8) from it, bootstrap the local package database and then proceed to run the command you originally requested.

More recent versions of pkg(7) understand pkg -N as a test to see if pkg(8) is installed without triggering the installation, and conversely, pkg bootstrap [-f] to install pkg(8) (or force it to be reinstalled) without performing any other actions.

Additional resources

To contact us, you can find us in the #pkg channel on Libera Chat IRC Network.

If you hit a bug when using pkg, you can always submit an issue in the pkg issue tracker.