Solved pkg-static error when registering installation


I am porting siegfried to FreeBSD, more info on it here:

make stage works without problems. When I try to make install, it fails with

root@nemesis /usr/ports/sysutils/siegfried]# make install
===>  License APACHE20 accepted by the user
===>  siegfried-1.5.0 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by siegfried-1.5.0 for building
===>  Extracting for siegfried-1.5.0
=> SHA256 Checksum OK for richardlehane-siegfried-v1.5.0_GH0.tar.gz.
===>  Patching for siegfried-1.5.0
===>  siegfried-1.5.0 depends on executable: go - found
===>  Configuring for siegfried-1.5.0
===>  Building for siegfried-1.5.0
===>  Staging for siegfried-1.5.0
===>  Generating temporary packing list
install  -m 555 /usr/ports/sysutils/siegfried/work/siegfried-1.5.0/richardlehane/siegfried/bin/siegfried /usr/local/bin/siegfried
====> Compressing man pages (compress-man)
====> Running Q/A tests (stage-qa)
===>  Installing for siegfried-1.5.0
===>  Checking if siegfried already installed
===>  Registering installation for siegfried-1.5.0
pkg-static: Unable to access file /usr/ports/sysutils/siegfried/work/stage/usr/local/bin/siegfried: No such file or directory
*** Error code 74

make: stopped in /usr/ports/sysutils/siegfried

The binary siegfried is installed into /usr/local/bin, but it seems that pkg-static tries to register siegfried from the work directory. What am I missing?

You can find the Makefile on github:


This line
	${INSTALL_PROGRAM} ${WRKSRC}/${GH_ACCOUNT}/${PORTNAME}/bin/siegfried ${PREFIX}/bin/siegfried
is missing ${STAGEDIR} and needs to be
	${INSTALL_PROGRAM} ${WRKSRC}/${GH_ACCOUNT}/${PORTNAME}/bin/siegfried ${STAGEDIR}${PREFIX}/bin/siegfried
Currently siegfried is installed directly on your system, and not in the port's stage directory from which packages are created.
pkg-static: Unable to access file [b]/usr/ports/sysutils/siegfried/work/stage[/b]/usr/local/bin/siegfried: No such file or directory
At least that's what I think is going on. I'm currently not on a FreeBSD machine so haven't tried it out.
Yep. The process is basically to build a binary, "install" it in the staging area, create a package from the staging area and finally install the package into the system. Ports build packages and it's the packages that get installed. This is slightly different from the old days where a port would install directly into the system and a package was created afterwards only if requested ( make package).
The porter's handbook has instructions how to use the built in stage violations checker, namely make check-plist and make stage-qa. These checks would have caught the binary that was installed directly on the host and not in the stage directory:

There's also the ports-mgmt/portlint tool that is quite mandatory for port maintainers.

Next step in testing your port is using a package builder such as ports-mgmt/poudriere with its subcommand poudriere testport. This will run the port build in DEVELOPER mode and also does the mentioned stage-qa testing with couple of other checks that are very good at finding problems in the port. Poudriere can be told to use the mentioned ports-mgmt/portlint too automatically as part of the port builds.