xbps-src: re-introduce etc/virtual.

The `etc/virtual` file declares the default package to be built for
virtual dependencies declared as "virtual?foo" in $depends.

Before this change, the run-time dependency was added as is to the final
binary package but no pkg providing this virtual pkg was built.

With this file we declare the *default* pkg to be built.

NOTE: "virtual?foo" is only applicable to *run* time dependencies, i.e
only those declared in $depends.
This commit is contained in:
Juan RP 2016-04-27 20:16:59 +02:00
parent 78c601e18e
commit d2bac19750
4 changed files with 248 additions and 173 deletions

View File

@ -118,6 +118,14 @@ Native and cross compiler/linker flags are set per architecture in `common/build
and `common/cross-profiles` respectively. Ideally those settings are good enough by default,
and there's no need to set your own unless you know what you are doing.
#### Virtual packages
The `etc/defaults.virtual` file contains the default replacements for virtual packages,
used as dependencies in the source packages tree.
If you want to customize those replacements, copy `etc/defaults.virtual` to `etc/virtual`
and edit it accordingly to your needs.
### Directory hierarchy
The following directory hierarchy is used with a default configuration file:

View File

@ -1,6 +1,8 @@
# vim: set ts=4 sw=4 et:
#
# This hook executes the following tasks:
# - Generates rdeps file with run-time dependencies for xbps-create(8)
# - Generates shlib-requires file for xbps-create(8)
# - Generates rdeps file with run-time dependencies for xbps-create(1)
# - Generates shlib-requires file for xbps-create(1)
add_rundep() {
local dep="$1" i= rpkgdep= _depname= _rdeps= found=
@ -30,8 +32,22 @@ add_rundep() {
fi
}
store_pkgdestdir_rundeps() {
if [ -n "$run_depends" ]; then
: > ${PKGDESTDIR}/rdeps
for f in ${run_depends}; do
_curdep="$(echo "$f" | sed -e 's,\(.*\)?.*,\1,')"
if [ -z "$($XBPS_UHELPER_CMD getpkgdepname ${_curdep} 2>/dev/null)" -a \
-z "$($XBPS_UHELPER_CMD getpkgname ${_curdep} 2>/dev/null)" ]; then
_curdep="${_curdep}>=0"
fi
printf "${_curdep} " >> ${PKGDESTDIR}/rdeps
done
fi
}
hook() {
local depsftmp f j tmplf mapshlibs sorequires
local depsftmp f j tmplf mapshlibs sorequires _curdep
# Disable trap on ERR, xbps-uhelper cmd might return error... but not something
# to be worried about because if there are broken shlibs this hook returns
@ -42,8 +58,7 @@ hook() {
tmplf=$XBPS_SRCPKGDIR/$pkgname/template
if [ -n "$noarch" -o -n "$noverifyrdeps" ]; then
echo "$run_depends" > ${PKGDESTDIR}/rdeps
sed 's,virtual?,,g' -i ${PKGDESTDIR}/rdeps
store_pkgdestdir_rundeps
return 0
fi
@ -155,12 +170,8 @@ hook() {
msg_error "$pkgver: cannot guess required shlibs, aborting!\n"
fi
if [ -n "$run_depends" ]; then
echo "$run_depends" > ${PKGDESTDIR}/rdeps
fi
if [ -s ${PKGDESTDIR}/rdeps ]; then
sed 's,virtual?,,g' -i ${PKGDESTDIR}/rdeps
fi
store_pkgdestdir_rundeps
for f in ${shlib_requires}; do
sorequires+="${f} "
done

View File

@ -17,15 +17,30 @@ setup_pkg_depends() {
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then
_replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2)
elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then
_replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2)
fi
if [ "${_rpkgname}" = "virtual" ]; then
if [ -z "${_replacement}" ]; then
msg_error "$pkgver: failed to resolve virtual dependency for '$j' (missing from etc/virtual)\n"
fi
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_replacement} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_replacement} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="${_replacement}>=0"
fi
run_depends+=" ${_depname}?${_pkgdepname}"
#echo "Adding dependency virtual: ${_depname}?${_pkgdepname}"
else
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
if [ "${_rpkgname}" = "virtual" ]; then
run_depends+=" virtual?${_pkgdep}"
else
run_depends+=" ${_pkgdep}"
fi
done
@ -165,7 +180,7 @@ srcpkg_get_pkgver() {
#
install_pkg_deps() {
local pkg="$1" targetpkg="$2" target="$3" cross="$4" cross_prepare="$5"
local rval _realpkg curpkgdepname pkgn iver
local rval _realpkg _vpkg _curpkg curpkgdepname pkgn iver
local i j found rundep repo
local -a host_binpkg_deps binpkg_deps host_missing_deps missing_deps missing_rdeps
@ -259,10 +274,12 @@ install_pkg_deps() {
#
for i in ${run_depends}; do
_realpkg="${i%\?*}"
if [ "${_realpkg}" = "virtual" ]; then
# ignore virtual dependencies
echo " [runtime] ${i#*\?}: virtual dependency."
continue
_curpkg="${_realpkg}"
_vpkg="${i#*\?}"
if [ "${_realpkg}" != "${_vpkg}" ]; then
_realpkg="${_vpkg}"
else
unset _curpkg
fi
pkgn=$($XBPS_UHELPER_CMD getpkgdepname "${_realpkg}")
if [ -z "$pkgn" ]; then
@ -282,16 +299,28 @@ install_pkg_deps() {
set -- ${_props}
$XBPS_UHELPER_CMD pkgmatch ${1} "${_realpkg}"
if [ $? -eq 1 ]; then
echo " [runtime] ${_realpkg}: found ($2)"
if [ -n "${_curpkg}" ]; then
echo " [runtime] ${_curpkg}:${_realpkg} (virtual dependency): found $1 ($2)"
else
echo " [runtime] ${_realpkg}: found $1 ($2)"
fi
shift 2
continue
else
if [ -n "${_curpkg}" ]; then
echo " [runtime] ${_curpkg}:${_realpkg} (virtual dependency): not found."
else
echo " [runtime] ${_realpkg}: not found."
fi
fi
shift 2
else
if [ -n "${_curpkg}" ]; then
echo " [runtime] ${_curpkg}:${_realpkg} (virtual dependency): not found."
else
echo " [runtime] ${_realpkg}: not found."
fi
fi
missing_rdeps+=("${_realpkg}")
done

27
etc/defaults.virtual Normal file
View File

@ -0,0 +1,27 @@
# --*-- shell --*--
#
# etc/defaults.virtual
# default configuration of etc/virtual
#
# DO NOT EDIT THIS FILE DIRECTLY; IT MAY BE REPLACED DURING UPDATES,
# EDIT etc/virtual INSTEAD.
#
# This file specifies a mapping between virtual packages and real packages
# available in the source packages collection (srcpkgs).
#
# The format uses 2 arguments delimited by a blank: <vpkgname> <realpkgname>
#
# When building a package with "xbps-src", those dependencies declared like
# "virtual?foo" will use the replacement package defined in `etc/virtual`.
#
# NOTE: this mapping is only there to be able to build a default package
# to resolve the virtual package dependency later on with xbps-install(1).
#
# NOTE: Create your own etc/virtual file to override these defaults.
awk gawk
java-environment openjdk
java-runtime openjdk-jre
ntp-daemon chrony
xserver-abi-input xorg-server
xserver-abi-video xorg-server