2009-10-18 11:17:26 +02:00
|
|
|
#-
|
2010-01-17 08:50:36 +01:00
|
|
|
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
2009-10-18 11:17:26 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#-
|
|
|
|
|
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
|
|
|
|
|
|
|
#
|
|
|
|
# Recursive function that installs all direct and indirect
|
|
|
|
# dependencies of a package.
|
|
|
|
#
|
|
|
|
install_pkg_deps()
|
|
|
|
{
|
|
|
|
local curpkg="$1"
|
2009-11-07 05:01:00 +01:00
|
|
|
local curpkgname="$(${XBPS_PKGDB_CMD} getpkgdepname $1)"
|
|
|
|
local saved_prevpkg="$(${XBPS_PKGDB_CMD} getpkgdepname $2)"
|
2009-10-18 11:17:26 +02:00
|
|
|
local j jver jname reqver
|
|
|
|
|
2010-05-12 17:23:35 +02:00
|
|
|
[ -z "$curpkg" -o -z "$curpkgname" ] && return 2
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
if [ -n "$prev_pkg" ]; then
|
|
|
|
curpkg=$prev_pkg
|
2009-11-07 05:01:00 +01:00
|
|
|
curpkgname="$(${XBPS_PKGDB_CMD} getpkgdepname ${curpkg})"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-14 00:07:47 +02:00
|
|
|
if [ -z "$saved_prevpkg" -a -n "${_ORIGINPKG}" ]; then
|
|
|
|
msg_normal "Installing '${_ORIGINPKG}' dependency: '$curpkg'."
|
|
|
|
else
|
|
|
|
msg_normal "Installing '$saved_prevpkg' dependency: '$curpkg'."
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-05-12 17:23:35 +02:00
|
|
|
setup_tmpl "$curpkgname"
|
2009-10-18 11:17:26 +02:00
|
|
|
check_build_depends_pkg
|
|
|
|
if [ $? -eq 0 ]; then
|
2010-05-14 00:07:47 +02:00
|
|
|
msg_normal "Package dependency '$curpkgname' requires:"
|
2009-10-18 11:17:26 +02:00
|
|
|
for j in ${build_depends}; do
|
2009-11-07 05:01:00 +01:00
|
|
|
jname="$(${XBPS_PKGDB_CMD} getpkgdepname ${j})"
|
|
|
|
jver="$($XBPS_PKGDB_CMD version ${jname})"
|
|
|
|
check_pkgdep_matched "${j}"
|
|
|
|
if [ $? -eq 0 ]; then
|
2010-05-14 00:07:47 +02:00
|
|
|
echo " ${j}: found '$jname-$jver'."
|
2009-11-07 05:01:00 +01:00
|
|
|
else
|
|
|
|
echo " ${j}: not found."
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2009-11-07 05:01:00 +01:00
|
|
|
for j in ${build_depends}; do
|
|
|
|
#
|
|
|
|
# Check if dep is satisfied.
|
|
|
|
#
|
|
|
|
check_pkgdep_matched "${j}"
|
|
|
|
[ $? -eq 0 ] && continue
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-11-07 05:01:00 +01:00
|
|
|
#
|
2009-10-18 11:17:26 +02:00
|
|
|
# Iterate again, this will check if there are more
|
|
|
|
# required deps for current pkg.
|
2009-11-07 05:01:00 +01:00
|
|
|
#
|
|
|
|
prev_pkg="$j"
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg_deps "${j}" "${curpkg}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
msg_red "install_pkg_deps: cannot install '$curpkg' ($j)."
|
|
|
|
return 1
|
|
|
|
fi
|
2009-11-07 05:01:00 +01:00
|
|
|
done
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-01-16 02:11:44 +01:00
|
|
|
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
2010-04-27 23:09:08 +02:00
|
|
|
install_pkg_with_binpkg "${curpkg}"
|
2010-01-16 02:11:44 +01:00
|
|
|
if [ $? -eq 255 ]; then
|
|
|
|
# xbps-bin returned unexpected error
|
|
|
|
return $?
|
|
|
|
elif [ $? -eq 1 ]; then
|
|
|
|
# Package not found, build from source.
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg "${curpkgname}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
msg_red "cannot install '$curpkgname'!"
|
|
|
|
return 1
|
|
|
|
fi
|
2010-01-16 02:11:44 +01:00
|
|
|
fi
|
|
|
|
else
|
2010-05-12 17:23:35 +02:00
|
|
|
if [ -n "$saved_prevpkg" ]; then
|
2010-05-14 00:07:47 +02:00
|
|
|
msg_normal "Installing package '${curpkgname}' required by '${saved_prevpkg}'."
|
2010-05-12 17:23:35 +02:00
|
|
|
else
|
2010-05-14 00:07:47 +02:00
|
|
|
msg_normal "Installing package: '${curpkg}'."
|
2010-05-12 17:23:35 +02:00
|
|
|
fi
|
|
|
|
install_pkg "${curpkgname}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
msg_red "install_pkg_deps: cannot install '$curpkgname'!"
|
|
|
|
return 1
|
|
|
|
fi
|
2010-01-16 02:11:44 +01:00
|
|
|
fi
|
2010-05-12 17:23:35 +02:00
|
|
|
unset prev_pkg
|
2009-10-18 11:17:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Installs all dependencies required by a package.
|
|
|
|
#
|
|
|
|
install_dependencies_pkg()
|
|
|
|
{
|
2010-04-27 23:09:08 +02:00
|
|
|
local pkg="$1" rval pkgdep_list
|
2009-11-22 08:31:44 +01:00
|
|
|
local lpkgname=$(${XBPS_PKGDB_CMD} getpkgname ${pkg})
|
2010-05-12 17:23:35 +02:00
|
|
|
local i j pkgn iver reqver notinstalled_deps lver
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-05-12 17:23:35 +02:00
|
|
|
[ -z "$pkg" ] && return 2
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
doing_deps=true
|
|
|
|
|
|
|
|
if [ -n "$revision" ]; then
|
|
|
|
lver="${version}_${revision}"
|
|
|
|
else
|
|
|
|
lver="${version}"
|
|
|
|
fi
|
|
|
|
|
2010-12-11 01:46:55 +01:00
|
|
|
if [ -n "$build_depends" ]; then
|
2010-05-14 00:07:47 +02:00
|
|
|
msg_normal "$pkgname: installing required package dependencies..."
|
2009-11-19 17:56:27 +01:00
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
for i in ${build_depends}; do
|
2009-11-07 05:01:00 +01:00
|
|
|
pkgn="$($XBPS_PKGDB_CMD getpkgdepname ${i})"
|
|
|
|
iver="$($XBPS_PKGDB_CMD version $pkgn)"
|
|
|
|
check_pkgdep_matched "${i}"
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2010-05-14 00:07:47 +02:00
|
|
|
echo " ${i}: found '$pkgn-$iver'."
|
2009-10-18 11:17:26 +02:00
|
|
|
continue
|
|
|
|
else
|
2010-05-13 22:22:05 +02:00
|
|
|
echo " ${i}: not found."
|
2009-10-18 11:17:26 +02:00
|
|
|
notinstalled_deps="$notinstalled_deps $i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
[ -z "$notinstalled_deps" ] && return 0
|
|
|
|
|
2010-04-27 23:09:08 +02:00
|
|
|
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
|
|
|
for i in ${notinstalled_deps}; do
|
|
|
|
pkgdeplist="${pkgdeplist} \"${i}\" "
|
|
|
|
done
|
2010-05-14 00:07:47 +02:00
|
|
|
msg_normal "$pkgname: installing required dependencies from binpkgs..."
|
2010-04-27 23:09:08 +02:00
|
|
|
${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} \
|
|
|
|
-y install ${pkgdeplist}
|
|
|
|
rval=$?
|
|
|
|
if [ $rval -eq 255 ]; then
|
|
|
|
# xbps-bin returned unexpected error (-1)
|
|
|
|
return $?
|
|
|
|
elif [ $rval -eq 0 ]; then
|
|
|
|
# Install successfully
|
|
|
|
echo
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-05-12 17:23:35 +02:00
|
|
|
for j in ${notinstalled_deps}; do
|
2010-01-14 17:45:41 +01:00
|
|
|
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg_with_binpkg "${j}"
|
2010-04-27 23:09:08 +02:00
|
|
|
rval=$?
|
|
|
|
if [ $rval -eq 255 ]; then
|
2010-01-16 02:11:44 +01:00
|
|
|
# xbps-bin returned unexpected error (-1)
|
|
|
|
return $?
|
2010-04-27 23:09:08 +02:00
|
|
|
elif [ $rval -eq 0 ]; then
|
2010-01-16 02:11:44 +01:00
|
|
|
# installed successfully
|
|
|
|
continue
|
|
|
|
fi
|
2010-01-14 17:45:41 +01:00
|
|
|
fi
|
2010-05-12 17:23:35 +02:00
|
|
|
pkgn=$($XBPS_PKGDB_CMD getpkgdepname ${j})
|
|
|
|
check_pkgdep_matched "${j}"
|
2009-10-18 11:17:26 +02:00
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
|
2010-05-12 17:23:35 +02:00
|
|
|
setup_tmpl "$pkgn"
|
2009-10-18 11:17:26 +02:00
|
|
|
check_build_depends_pkg
|
|
|
|
if [ $? -eq 1 ]; then
|
2010-05-14 00:07:47 +02:00
|
|
|
msg_normal "Installing '$lpkgname' dependency: '$pkgn'."
|
2010-01-16 02:11:44 +01:00
|
|
|
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg_with_binpkg "${j}"
|
2010-04-27 23:09:08 +02:00
|
|
|
rval=$?
|
|
|
|
if [ $rval -eq 255 ]; then
|
2010-01-16 02:11:44 +01:00
|
|
|
# xbps-bin returned unexpected error
|
|
|
|
return $?
|
2010-04-27 23:09:08 +02:00
|
|
|
elif [ $rval -eq 0 ]; then
|
2010-01-16 02:11:44 +01:00
|
|
|
# installed successfully
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
# package not found, build source.
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg "${pkgn}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
msg_red "cannot install '$pkgn'!"
|
|
|
|
return 1
|
|
|
|
fi
|
2010-01-16 02:11:44 +01:00
|
|
|
fi
|
|
|
|
else
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg "${pkgn}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
msg_red "cannot install '$pkgn'!"
|
|
|
|
return 1
|
|
|
|
fi
|
2010-01-16 02:11:44 +01:00
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
else
|
2010-05-12 17:23:35 +02:00
|
|
|
install_pkg_deps "${j}" "${pkg}"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
msg_red "install_dependencies_pkg: cannot install pkgdeps required by $pkg ($j)."
|
|
|
|
return 1
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2009-11-07 05:01:00 +01:00
|
|
|
# Checks if installed pkg dependency is matched against pattern.
|
|
|
|
#
|
|
|
|
check_pkgdep_matched()
|
|
|
|
{
|
|
|
|
local pkg="$1" pkgname iver
|
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 2
|
|
|
|
|
|
|
|
pkgname="$($XBPS_PKGDB_CMD getpkgdepname ${pkg})"
|
2009-11-23 06:30:04 +01:00
|
|
|
setup_tmpl $pkgname
|
2009-11-07 05:01:00 +01:00
|
|
|
|
|
|
|
iver="$($XBPS_PKGDB_CMD version $pkgname)"
|
|
|
|
if [ -n "$iver" ]; then
|
|
|
|
${XBPS_PKGDB_CMD} pkgmatch "${pkgname}-${iver}" "${pkg}"
|
|
|
|
[ $? -eq 1 ] && return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check if installed package is installed.
|
2009-10-18 11:17:26 +02:00
|
|
|
#
|
|
|
|
check_installed_pkg()
|
|
|
|
{
|
2009-11-07 05:01:00 +01:00
|
|
|
local pkg="$1" pkgname iver
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 2
|
|
|
|
|
2009-11-07 05:01:00 +01:00
|
|
|
pkgname="$($XBPS_PKGDB_CMD getpkgname ${pkg})"
|
2009-11-23 06:30:04 +01:00
|
|
|
setup_tmpl $pkgname
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-10-30 22:14:09 +01:00
|
|
|
iver="$($XBPS_PKGDB_CMD version $pkgname)"
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ -n "$iver" ]; then
|
2009-11-07 05:01:00 +01:00
|
|
|
${XBPS_CMPVER_CMD} "${pkgname}-${iver}" "${pkg}"
|
2009-10-18 11:17:26 +02:00
|
|
|
[ $? -eq 0 -o $? -eq 1 ] && return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Checks the build depends db file and returns 0 if pkg has dependencies,
|
|
|
|
# otherwise returns 1.
|
|
|
|
#
|
|
|
|
check_build_depends_pkg()
|
|
|
|
{
|
|
|
|
[ -z "$pkgname" ] && return 2
|
|
|
|
|
|
|
|
if [ -n "$build_depends" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|