Skip to content

Commit 232221e

Browse files
classabbyampahesford
authored andcommitted
common/hooks: use file for managing provides
python packages use this to automatically generate provides for each module installed by the package.
1 parent a4b74b6 commit 232221e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

common/hooks/do-pkg/00-gen-pkg.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ genpkg() {
4040
if [ -s ${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-provides ]; then
4141
_shprovides="$(<${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-provides)"
4242
fi
43+
if [ -s ${XBPS_STATEDIR}/${pkgname}${suffix}-provides ]; then
44+
_provides="$(<${XBPS_STATEDIR}/${pkgname}${suffix}-provides)"
45+
fi
4346
if [ -s ${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-requires ]; then
4447
_shrequires="$(<${XBPS_STATEDIR}/${pkgname}${suffix}-shlib-requires)"
4548
fi
@@ -48,7 +51,6 @@ genpkg() {
4851
fi
4952

5053
# Stripping whitespaces
51-
local _provides="$(echo $provides)"
5254
local _conflicts="$(echo $conflicts)"
5355
local _replaces="$(echo $replaces)"
5456
local _reverts="$(echo $reverts)"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# vim: set ts=4 sw=4 et:
2+
#
3+
# This hook executes the following tasks:
4+
# - Generates provides file with provides entries for xbps-create(1)
5+
6+
generate_python_provides() {
7+
local py3_bin="${XBPS_MASTERDIR}/usr/bin/python3"
8+
9+
if [ -z "$nopyprovides" ] && [ -d "${PKGDESTDIR}/${py3_sitelib}" ] && [ -x "${py3_bin}" ]; then
10+
PYTHONPATH="${XBPS_MASTERDIR}/${py3_sitelib}-bootstrap" "${py3_bin}" \
11+
"${XBPS_COMMONDIR}"/scripts/parse-py-metadata.py \
12+
-S "${PKGDESTDIR}/${py3_sitelib}" -v "${pkgver}" provides
13+
fi
14+
}
15+
16+
hook() {
17+
local -a _provides=()
18+
19+
# include explicit values from the template
20+
read -r -a _provides <<< "$provides"
21+
22+
# get the canonical python package names for each python module
23+
mapfile -t _provides -O "${#_provides[@]}" < <( generate_python_provides )
24+
25+
if [ "${#_provides[@]}" -gt 0 ]; then
26+
echo " ${_provides[*]}"
27+
echo "${_provides[*]}" > "${XBPS_STATEDIR}/${pkgname}-provides"
28+
fi
29+
}

0 commit comments

Comments
 (0)