View Single Post
  #1   (View Single Post)  
Old 13th May 2014
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,983
Default Cheap Trick: Minimize dependency builds for OpenBSD ports

This trick may be helpful to -current users: # pkg_add -za `make full-build-depends`

From time to time I build a package from its port. As a -current user, minor differences in sync between the project's available "snapshot packages" and the ports tree can sometimes mean that many dependent packages get built, even if FETCH_PACKAGES is set to YES. On a single slow build machine that can extend elapsed build time to many hours or days for complex ports with large numbers of build dependencies.

I've found a simple pkg_add(1) minimizes dependency building, when combined with the full-build-depends target described in bsd.port.mk(5):
Code:
     full-{build,run,all}-depends
           Print all dependencies a package depends upon for building,
           running, or both, as a list of package names.
And so:
# cd /usr/ports/<branch>/<leaf>
# pkg_add -za `make full-build-depends`
The backticks around the make(1) command apply its output as operands to pkg_add. The -z option does fuzzy matching of package versions, and the -a option sets any newly installed packages as automatically installed, which is the norm for dependencies.

After the package build is complete and installed, I can elimintate any unneeded dependencies with a simple pkg_delete(1):
# pkg_delete -a
Along with speeding builds, utilizing all possible available packages minimizes storage consumption by unnecessary distfiles and reduces pobj capacity requirements.

Last edited by jggimi; 14th May 2014 at 02:01 AM. Reason: clarity, typo
Reply With Quote