pkg-config support with wpkg

wpkg offers many of the pkg-config command line operations so one does not need to have pkg-config installed to gather said information.

pkg-config is used primarily to gather information so one can compile a package without having to guess what the C/C++ command line options are. This is done with the use of a pkg-config file, a so called .pc file.

The follow are wpkg commands that are duplicates of the pkg-config tool commands:

  • --atleast-version <version> <package> — check that <package> version is at least <version>
  • --atleast-wpkg-version <version> — check that wpkg is at least <version>; we also support --atleast-pkgconfig-version as an alias, although note that the version being checked in that case is the version of wpkg, not pkg-config
  • --cflags <package> ... — list the compile time flags to access <package> ...
  • --define-variable <varname>=<value> — set a variable on the command line; it is an alias of --field-variables
  • --exact-version <version> <package> — check that <package> is version <version> specifically
  • --exists <package> — check whether <package> is currently installed; this is an alias of --is-installed
  • --libs <package> ... — list the link time flags to link against <package> ...
  • --list-all — list all the installed packages
  • --max-version <version> <package> — check that <package> has a version smaller or equal to <version>
  • --modversion <package> ... — print the version of each <package> ...
  • --print-variables <package> ... — print the variables of <package> ...; each list is separated by an empty line
  • --variable <name> <package> ... — print the value of variable <name> from each <package> ...

Note that the --atleast-version is an equivalent to the --verify option used with a --verify-fields expression such as:

wpkg --verify <package> --verify-fields 'versioncmp(getfield("version"), "<version>") >= 0'

Where <package> and <version> are replaced with the values passed to --atleast-version. The --atleast-wpkg-version command uses wpkg for <package> and the value passed to the command as <version>.

Note that the --modversion is an equivalent to the --field option with the Version field name:

wpkg --field <package> Version

The wpkg system requires that the package names listed on the command line correspond to packages that were installed in the specified target (i.e. installed under --instdir which defaults to --root if you do not explicitly set the installation dirctory.) This way, it gives it the power to prevent queries to invalid packages (packages that are only unpacked, not properly installed, or were removed.)

Also, the fact that we have access to the main definition of the package gives as access to a pletoria of paramaters that can be transmitted to the .pc file via variables. The following are the variables that get initialized by wpkg before parsing the .pc file:

Variable Name Contents
rootdir The value of the --root option.
admindir The value of the --admindir option, or whatever default sub-directory determined from --root (/var/lib/wpkg).
instdir The value of the --instdir option, or whatever default sub-directory determine from --root (/).
name The Package field of the package.
version The Version field of the package.
description The first line of the Description field of the package. This is also called the short description.
homepage The Homepage field of the package, this variable does not get defined if the Homepage field is not defined.
install_prefix The Install-Prefix field as defined by the --install-prefix option while running --build against a source package.