pkg-serve(8)

pkg-serve8

Serve pkg repositories over tcp via inetd

Usage

pkg-serve basedir

Overview

The pkg-serve utility serves pkg(8) repositories using the pkg TCP protocol. It is designed to be invoked by inetd(8) and communicates via standard input and output.

The basedir argument specifies the root directory containing the package repositories. All file requests are resolved relative to this directory.

On startup, pkg-serve enters a Capsicum sandbox, restricting filesystem access to basedir.

Protocol

The protocol is line-oriented. Upon connection, the server sends a greeting:

ok: pkg-serve <version>

The client may then issue commands:

get file age

Request a file. If the file's modification time is newer than age (a Unix timestamp), the server responds with:

ok: <size>

followed by size bytes of file data. If the file has not been modified, the server responds with:

ok: 0

On error, the server responds with:

ko: <error message>
quit

Close the connection.

Inetd configuration

Add the following line to inetd.conf(5):

pkg  stream  tcp  nowait  nobody  /usr/libexec/pkg-serve  pkg-serve /usr/local/poudriere/data/packages

And define the service in services(5):

pkg     62000/tcp

Repository configuration

On the client side, configure a repository in /usr/local/etc/pkg/repos/myrepo.conf to use the tcp:// scheme:

myrepo: {
    url: "tcp://pkgserver.example.com:62000/myrepo",
}

The path component of the URL is resolved relative to the basedir given to pkg-serve. For example, if pkg-serve is started with /usr/local/poudriere/data/packages as basedir, the above configuration will serve files from /usr/local/poudriere/data/packages/myrepo/.

Authors

Baptiste Daroussin ⟨[email protected]⟩

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.