board_options: new portageq wrappers

- May be sourced early, so explicitly die if source fails.
 - Add a function for getting the latest version of a package.
 - Read PROVIDES metadata using portageq, enabling data to be read from
   binary packages in addition to installed packages. The performance
   issue is not an issue here and needed to support empty build roots.
This commit is contained in:
Michael Marineau 2016-02-20 14:17:45 -08:00
parent ab3f1ee0b8
commit bc5de30442
2 changed files with 13 additions and 7 deletions

View File

@ -12,7 +12,7 @@ BOARD_ROOT="/build/${BOARD}"
ARCH=$(get_board_arch ${BOARD})
# What cross-build are we targeting?
. "${BOARD_ROOT}/etc/portage/make.conf"
. "${BOARD_ROOT}/etc/portage/make.conf" || die
# check if any of the given use flags are enabled for a pkg
pkg_use_enabled() {
@ -25,12 +25,18 @@ pkg_use_enabled() {
return $?
}
# get a package's SONAMEs in soname.provided format
pkg_soname_provides() {
# Usage: pkg_version [installed|binary|ebuild] some-pkg/name
# Prints: some-pkg/name-1.2.3
# Note: returns 0 even if the package was not found.
pkg_version() {
portageq-"${BOARD}" best_visible "${BOARD_ROOT}" "$1" "$2"
}
# Usage: pkg_provides [installed|binary] some-pkg/name-1.2.3
# Prints: x86_32: libfoo.so.2 x86_64: libfoo.so.2
pkg_provides() {
local provides p
# We could run this command but it ugly and silly slow:
# portageq-"${BOARD}" metadata "${BOARD_ROOT}" installed "$1" PROVIDES
provides=$(<"${BOARD_ROOT}/var/db/pkg/$1/PROVIDES")
provides=$(portageq-"${BOARD}" metadata "${BOARD_ROOT}" "$1" "$2" PROVIDES)
if [[ -z "$provides" ]]; then
return

View File

@ -211,7 +211,7 @@ package_provided() {
for p in "$@"; do
info "Writing $p to package.provided and soname.provided"
echo "$p" >> "${profile}/package.provided"
pkg_soname_provides "$p" >> "${profile}/soname.provided"
pkg_provides binary "$p" >> "${profile}/soname.provided"
done
}