[build2] How to import local dependencies with bpkg ?

Boris Kolpackov boris at codesynthesis.com
Mon Aug 15 06:13:01 UTC 2022


Michael Martín Moro via users <users at build2.org> writes:

> First of all: I've been using build2 for a couple of days now, and it's
> been a blast. It's got a steep learning curve, but the results are worth it.

Glad to hear that.


> Right now, I'm having trouble getting a bpkg configured directory to act as
> a repository, and I was looking for some help.
> 
> I've got a library called libmy. I created a build directory for it using
> bpkg create. From there, I can run `bpkg build libmy`, and when I run `bpkg
> status libmy`, it tells me that it is "configured".
> 
> I want this directory to be used as a repository for another package.

You cannot use a build configuration directory (output) as a repository
directory (source). In this scenario you have two sensible choices:

1. Use libmy's source directory as the repository. In this case, however,
   libmy will be built in the build configuration of another package.

2. Link libmy's build configuration directory to another package's
   build configuration directory. For details on configuration linking,
   see:

   https://build2.org/release/0.14.0.xhtml#config-link

   The bpkg command for linking two configurations is bpkg-cfg-link(1):

   https://build2.org/bpkg/doc/bpkg-cfg-link.xhtml


> ## Attempting to link libmy from the system:
> I've also tried installing libmy on my system. I ran a `bpkg install`,
> before checking that `pkg-config libmy` was exiting with success status.
> Then I tried running `bpkg build [package] ?sys:libmy`. It failed, telling
> me that the `sys:libmy` package is unknown.

The correct command for this is:

bpkg build [package] ?sys:libmy/*

That is, because there is no stub package for libmy, you need to explicitly
tell bpkg that its version satisfies any constraint. (We don't make the same
assumption for just ?sys:libmy because in the future we plan to automatically
query the version by calling the system package manager; see bpkg-pkg-build(1)
for details).


> ## `bpkg add --type pkg` ?
> I've also noticed there was a `--type pkg` option for `bpkg add`, but I've
> found little to no details about it. Is it pkg-config based ? Any
> documentation as to how it works ?

Quoting from the DESCRIPTION section of bpkg-cfg-add(1):

"Currently three types of repositories are supported: archive-based pkg,
directory-based dir, and version control-based git. See
bpkg-repository-types(1) for details on their structure and URL format.

Normally the repository type can be automatically guessed by examining its 
URL (for example, the presence of the .git extension) or, in case of a local
repository, its content (for example, the presence of the .git/ subdirectory).
Without any identifying information the pkg type is assumed unless explicitly
specified with the --type option or in the URL scheme. Note, however, that the
dir repository type is never guessed since it is not easily distinguishable
from local pkg and git repositories."



More information about the users mailing list