Improve how run-time deps (aka "depends") are handled in packages.

Run-time dependencies declared via "${depends}" are now also part of the
build process, but those are not installed to the master directory; rather
those dependencies are only checked if a binary package exists in a
local repository to satisfy the required version.

Thanks to @dominikh for idea and suggestions.
This commit is contained in:
Juan RP 2014-07-30 17:58:17 +02:00
parent b87dc98275
commit 933513adaa
2 changed files with 37 additions and 13 deletions

View File

@ -271,19 +271,23 @@ one digit is required.
#### Optional variables
- `hostmakedepends` The list of `host` dependencies required to build the package. Dependencies
- `hostmakedepends` The list of `host` dependencies required to build the package, and
that will be installed to the master directory. Dependencies
can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
or `foo-1.0_1` to match an exact version. If version comparator is not
defined (just a package name), the version comparator is automatically set to `>=0`.
Example `hostmakedepends="foo blah<1.0"`.
- `makedepends` The list of `target` dependencies required to build the package. Dependencies
- `makedepends` The list of `target` dependencies required to build the package, and that
will be installed to the master directory. Dependencies
can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
or `foo-1.0_1` to match an exact version. If version comparator is not
defined (just a package name), the version comparator is automatically set to `>=0`.
Example `makedepends="foo blah>=1.0"`.
- `depends` The list of dependencies required to run the package. Dependencies
- `depends` The list of dependencies required to run the package. These dependencies
are not installed to the master directory, rather are only checked if a binary package
in the local repository exists to satisfy the required version. Dependencies
can be specified with the following version comparators: `<`, `>`, `<=`, `>=`
or `foo-1.0_1` to match an exact version. If version comparator is not
defined (just a package name), the version comparator is automatically set to `>=0`.
@ -550,7 +554,7 @@ i.e `XBPS_PKG_OPTIONS_xorg_server=opt`.
The list of supported package build options and its description is defined in the
`common/options.description` file.
### Runtime dependencies
#### Runtime dependencies
Dependencies for ELF objects are detected automatically by `xbps-src`, hence runtime
dependencies must not be specified in templates via `$depends` with the following exceptions:
@ -580,6 +584,10 @@ libfoo.so.1 foo-1.0_1
- The second field specified the package name and minimal version required.
- A third optional field (usually set to `ignore`) can be used to skip checks in soname bumps.
Dependencies declared via `${depends}` are not installed to the master directory, rather are
only checked if they exist as binary packages, and are built automatically by `xbps-src` if
the specified version is not in the local repository.
### Creating system accounts/groups at runtime
There's a trigger along with some variables that are specifically to create

View File

@ -105,7 +105,8 @@ check_installed_pkg() {
# Installs all dependencies required by a package.
#
install_pkg_deps() {
local pkg="$1" cross="$2" i rval _realpkg curpkgdepname pkgn iver _props _exact
local pkg="$1" cross="$2" rval _realpkg curpkgdepname pkgn iver _props _exact
local i j found rundep
local -a host_binpkg_deps binpkg_deps
local -a host_missing_deps missing_deps
@ -114,7 +115,7 @@ install_pkg_deps() {
setup_pkg_depends
if [ -z "$build_depends" -a -z "$host_build_depends" ]; then
if [ -z "$build_depends" -a -z "$host_build_depends" -a -z "$run_depends" ]; then
return 0
fi
@ -176,7 +177,7 @@ install_pkg_deps() {
#
# Target build dependencies.
#
for i in ${build_depends}; do
for i in ${build_depends} ${run_depends}; do
_realpkg="${i%\?*}"
pkgn=$($XBPS_UHELPER_CMD getpkgdepname "${_realpkg}")
if [ -z "$pkgn" ]; then
@ -186,18 +187,29 @@ install_pkg_deps() {
fi
_exact=1
fi
# Check if dependency is a subpkg, if it is, ignore it.
unset found
for j in ${subpackages}; do
[ "$j" = "$pkgn" ] && found=1 && break
done
[ -n "$found" ] && continue
# Check if it's a runtime dependency.
unset rundep
for j in ${run_depends}; do
[ "$j" = "$i" ] && rundep="runtime" && break
done
check_pkgdep_matched "${_realpkg}" $cross
local rval=$?
if [ $rval -eq 0 ]; then
iver=$($XBPS_UHELPER_XCMD version "${pkgn}")
if [ $? -eq 0 -a -n "$iver" ]; then
echo " [target] ${_realpkg}: found '$pkgn-$iver'."
echo " [${rundep:-target}] ${_realpkg}: found '$pkgn-$iver'."
continue
fi
elif [ $rval -eq 1 ]; then
iver=$($XBPS_UHELPER_XCMD version "${pkgn}")
if [ $? -eq 0 -a -n "$iver" ]; then
echo " [target] ${_realpkg}: installed ${iver} (unresolved) removing..."
echo " [${rundep:-target}] ${_realpkg}: installed ${iver} (unresolved) removing..."
$XBPS_REMOVE_XCMD -iyf $pkgn >/dev/null 2>&1
fi
else
@ -211,16 +223,20 @@ install_pkg_deps() {
set -- ${_props}
$XBPS_UHELPER_CMD pkgmatch ${1} "${_realpkg}"
if [ $? -eq 1 ]; then
echo " [target] ${_realpkg}: found $1 in $2."
binpkg_deps+=("$1")
# If dependency is part of run_depends just check if the binpkg has
# been created, but don't install it.
if [ -z "$rundep" ]; then
binpkg_deps+=("$1")
fi
echo " [${rundep:-target}] ${_realpkg}: found $1 in $2."
shift 2
continue
else
echo " [target] ${_realpkg}: not found."
echo " [${rundep:-target}] ${_realpkg}: not found."
fi
shift 2
else
echo " [target] ${_realpkg}: not found."
echo " [${rundep:-target}] ${_realpkg}: not found."
fi
fi
missing_deps+=("${_realpkg}")