Skip to content

Commit

Permalink
common/hooks: use file for managing provides
Browse files Browse the repository at this point in the history
python packages use this to automatically generate provides for each
module installed by the package.
  • Loading branch information
classabbyamp authored and ahesford committed Dec 14, 2024
1 parent a4b74b6 commit 232221e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/hooks/do-pkg/00-gen-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ genpkg() {
if [ -s ${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-provides ]; then
_shprovides="$(<${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-provides)"
fi
if [ -s ${XBPS_STATEDIR}/${pkgname}${suffix}-provides ]; then
_provides="$(<${XBPS_STATEDIR}/${pkgname}${suffix}-provides)"
fi
if [ -s ${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-requires ]; then
_shrequires="$(<${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-requires)"
fi
Expand All @@ -48,7 +51,6 @@ genpkg() {
fi

# Stripping whitespaces
local _provides="$(echo $provides)"
local _conflicts="$(echo $conflicts)"
local _replaces="$(echo $replaces)"
local _reverts="$(echo $reverts)"
Expand Down
29 changes: 29 additions & 0 deletions common/hooks/pre-pkg/04-generate-provides.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# vim: set ts=4 sw=4 et:
#
# This hook executes the following tasks:
# - Generates provides file with provides entries for xbps-create(1)

generate_python_provides() {
local py3_bin="${XBPS_MASTERDIR}/usr/bin/python3"

if [ -z "$nopyprovides" ] && [ -d "${PKGDESTDIR}/${py3_sitelib}" ] && [ -x "${py3_bin}" ]; then
PYTHONPATH="${XBPS_MASTERDIR}/${py3_sitelib}-bootstrap" "${py3_bin}" \
"${XBPS_COMMONDIR}"/scripts/parse-py-metadata.py \
-S "${PKGDESTDIR}/${py3_sitelib}" -v "${pkgver}" provides
fi
}

hook() {
local -a _provides=()

# include explicit values from the template
read -r -a _provides <<< "$provides"

# get the canonical python package names for each python module
mapfile -t _provides -O "${#_provides[@]}" < <( generate_python_provides )

if [ "${#_provides[@]}" -gt 0 ]; then
echo " ${_provides[*]}"
echo "${_provides[*]}" > "${XBPS_STATEDIR}/${pkgname}-provides"
fi
}

0 comments on commit 232221e

Please sign in to comment.