mk.conf magic
mk.conf is a Makefile snippet.
- We typically see assignments and some
.if branches in there to limit some assignments to only happen when building packages or alternatively rebuilding the system. (.ifdef BSD_PKG_MK ... .else ... .endif)
- What about daring to add a target in there?
Automagically building the packages summary after creating a package
I only use self baked packages on some systems, so my /usr/pkg/etc/pkgin/repositories.conf contains only one active line there pointing to the packages/All directory as file:/// URL.
Additionally pkgin wants to see pkg_summary.gz there, which I want to be generated automagically.
After adding...
release-package-lock: ; ( cd ${PACKAGES}/All && pkg_bin_summary | gzip -9 > pkg_summary.gz )
...in the .ifdef BSD_PKG_MK section, it indeed does the trick.
Background:
See pkgsrc/mk/package/package.mk for more context.
Additional targets just are executed additionally. They don't overlay the original one. The execution order of the original and the added target may be not predictive, better don't rely on a reproducible order.
[2021-12-01]: A while ago I switched from using pkg_bin_summary to pkg_info -X *.tgz and added sudo pkgin update to that target.
Other ideas what to hook in there?
I'm curious what else we can do by exploiting(?) the Makefile nature of mk.conf.
Are there reasons not to do it?
If so, even that insight should be documented.
Still business as usual, but...
Having per package CCACHE_DIR locations might make sense. A simple ...
CCACHE_DIR=${PKGSRCDIR}.ccache.d/${PKGPATH}
... in the .ifdef PKGPATH context could add that.
But it would really be nice to ...
- detect the end of the first package build
- look up the
CCACHE_DIR size
- limit the maximum
CCACHE_DIR size to e.g. 150 or 200 percent of the first build's size
...to keep that herd of cache directories automagically moderated. Probably the right "hooks" (target names) for adding own targets for this job to mk.conf can be found in mk/build/build.mk but I didn't have enough patience to track them down yet.