2008-12-13 05:23:16 +01:00
|
|
|
#-
|
2009-02-17 13:58:34 +01:00
|
|
|
# Copyright (c) 2008-2009 Juan Romero Pardines.
|
2008-12-13 05:23:16 +01: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
|
|
|
|
|
|
|
|
#
|
2009-02-17 17:15:12 +01:00
|
|
|
# Recursive function that installs all direct and indirect
|
|
|
|
# dependencies of a package.
|
2008-12-13 05:23:16 +01:00
|
|
|
#
|
2009-02-17 17:15:12 +01:00
|
|
|
install_pkg_deps()
|
2008-12-13 05:23:16 +01:00
|
|
|
{
|
|
|
|
local curpkg="$1"
|
2009-03-11 06:31:56 +01:00
|
|
|
local curpkgname=$(xbps-pkgdb getpkgname $1)
|
|
|
|
local saved_prevpkg=$(xbps-pkgdb getpkgname $2)
|
|
|
|
local j jver jname reqver
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2009-03-10 14:01:02 +01:00
|
|
|
[ -z "$curpkg" ] && return 1
|
2009-02-17 17:15:12 +01:00
|
|
|
|
2009-03-11 06:31:56 +01:00
|
|
|
if [ -n "$prev_pkg" ]; then
|
|
|
|
curpkg=$prev_pkg
|
|
|
|
curpkgname=$(xbps-pkgdb getpkgname ${curpkg})
|
|
|
|
fi
|
2009-02-17 17:15:12 +01:00
|
|
|
|
2009-03-11 06:31:56 +01:00
|
|
|
echo "==> Installing $saved_prevpkg dependency: $curpkgname."
|
2009-02-17 17:40:44 +01:00
|
|
|
|
2009-03-11 06:31:56 +01:00
|
|
|
run_template $curpkgname
|
|
|
|
check_build_depends_pkg
|
2009-02-17 17:15:12 +01:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "==> Dependency $curpkgname requires:"
|
|
|
|
for j in ${build_depends}; do
|
|
|
|
jname=$(xbps-pkgdb getpkgname ${j})
|
|
|
|
jver=$($XBPS_REGPKGDB_CMD version ${jname})
|
|
|
|
reqver=$(xbps-pkgdb getpkgversion ${j})
|
|
|
|
check_installed_pkg $j
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo " $jname >= $reqver: found $jname-$jver."
|
|
|
|
else
|
|
|
|
echo " $jname >= $reqver: not found."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2009-02-17 17:15:12 +01:00
|
|
|
for j in ${build_depends}; do
|
|
|
|
#
|
|
|
|
# Check if dep already installed.
|
|
|
|
#
|
|
|
|
check_installed_pkg $j
|
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
|
|
|
|
[ -n "$prev_pkg" ] && unset prev_pkg
|
|
|
|
#
|
2009-02-18 20:10:11 +01:00
|
|
|
# Iterate again, this will check if there are more
|
|
|
|
# required deps for current pkg.
|
2009-02-17 17:15:12 +01:00
|
|
|
#
|
2009-02-18 20:10:11 +01:00
|
|
|
install_pkg_deps $j $curpkg
|
|
|
|
prev_pkg="$j"
|
2009-02-17 17:15:12 +01:00
|
|
|
done
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2009-02-18 00:28:35 +01:00
|
|
|
install_pkg $curpkgname auto
|
2009-03-11 06:31:56 +01:00
|
|
|
[ -n "$prev_pkg" ] && unset prev_pkg
|
2008-12-13 05:23:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Installs all dependencies required by a package.
|
|
|
|
#
|
|
|
|
install_dependencies_pkg()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2009-02-17 17:15:12 +01:00
|
|
|
local lpkgname=$(xbps-pkgdb getpkgname ${pkg})
|
2009-03-28 08:27:29 +01:00
|
|
|
local i ipkgname iversion reqvers notinstalled_deps lver
|
2008-12-13 05:23:16 +01:00
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 1
|
|
|
|
|
|
|
|
doing_deps=true
|
|
|
|
|
2009-03-28 08:27:29 +01:00
|
|
|
if [ -n "$revision" ]; then
|
|
|
|
lver="${version}_${revision}"
|
|
|
|
else
|
|
|
|
lver="${version}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "==> Required build dependencies for $pkgname-$lver... "
|
2009-02-17 17:15:12 +01:00
|
|
|
for i in ${build_depends}; do
|
|
|
|
ipkgname=$(xbps-pkgdb getpkgname ${i})
|
|
|
|
iversion=$($XBPS_REGPKGDB_CMD version $ipkgname)
|
|
|
|
reqvers=$(xbps-pkgdb getpkgversion ${i})
|
|
|
|
check_installed_pkg $i
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo " $ipkgname >= $reqvers: found $ipkgname-$iversion."
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
echo " $ipkgname >= $reqvers: not found."
|
|
|
|
notinstalled_deps="$notinstalled_deps $i"
|
|
|
|
fi
|
2008-12-13 05:23:16 +01:00
|
|
|
done
|
|
|
|
|
2009-03-11 06:31:56 +01:00
|
|
|
[ -z "$notinstalled_deps" ] && return 0
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2009-02-17 17:15:12 +01:00
|
|
|
for i in ${notinstalled_deps}; do
|
2009-02-17 13:58:34 +01:00
|
|
|
check_installed_pkg $i
|
2008-12-13 05:23:16 +01:00
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
|
2009-03-11 06:31:56 +01:00
|
|
|
ipkgname=$(xbps-pkgdb getpkgname ${i})
|
|
|
|
run_template $ipkgname
|
|
|
|
check_build_depends_pkg
|
2009-02-17 17:15:12 +01:00
|
|
|
if [ $? -eq 1 ]; then
|
2009-03-11 06:31:56 +01:00
|
|
|
msg_normal "Installing $lpkgname dependency: $ipkgname."
|
2009-02-18 00:28:35 +01:00
|
|
|
install_pkg $ipkgname auto
|
2009-02-17 17:15:12 +01:00
|
|
|
else
|
|
|
|
install_pkg_deps $i $pkg
|
|
|
|
fi
|
|
|
|
done
|
2008-12-13 05:23:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
install_builddeps_required_pkg()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2009-02-17 13:58:34 +01:00
|
|
|
local pkgname=$(xbps-pkgdb getpkgname ${pkg})
|
2009-03-11 06:31:56 +01:00
|
|
|
local dep depname
|
2008-12-13 05:23:16 +01:00
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 1
|
|
|
|
|
2009-02-17 13:58:34 +01:00
|
|
|
run_template $pkgname
|
2008-12-13 05:23:16 +01:00
|
|
|
|
|
|
|
for dep in ${build_depends}; do
|
2009-02-17 13:58:34 +01:00
|
|
|
check_installed_pkg $dep
|
2008-12-13 05:23:16 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
2009-02-17 17:15:12 +01:00
|
|
|
msg_normal "Installing $pkgname dependency: $dep."
|
2009-02-17 13:58:34 +01:00
|
|
|
depname=$(xbps-pkgdb getpkgname ${dep})
|
2009-02-18 00:28:35 +01:00
|
|
|
install_pkg $depname auto
|
2008-12-13 05:23:16 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Checks the registered pkgs db file and returns 0 if a pkg that satisfies
|
|
|
|
# the minimal required version is there, or 1 otherwise.
|
|
|
|
#
|
|
|
|
check_installed_pkg()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2009-03-11 06:31:56 +01:00
|
|
|
local pkgname reqver iver
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2009-03-11 06:31:56 +01:00
|
|
|
[ -z "$pkg" ] && return 2
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2009-02-17 13:58:34 +01:00
|
|
|
pkgname=$(xbps-pkgdb getpkgname $pkg)
|
|
|
|
reqver=$(xbps-pkgdb getpkgversion $pkg)
|
|
|
|
run_template $pkgname
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2008-12-19 04:18:49 +01:00
|
|
|
iver="$($XBPS_REGPKGDB_CMD version $pkgname)"
|
2008-12-13 05:23:16 +01:00
|
|
|
if [ -n "$iver" ]; then
|
2008-12-22 02:14:40 +01:00
|
|
|
xbps-cmpver $pkgname-$iver $pkgname-$reqver
|
2009-03-19 00:30:44 +01:00
|
|
|
[ $? -eq 0 -o $? -eq 1 ] && return 0
|
2008-12-13 05:23:16 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Checks the build depends db file and returns 0 if pkg has dependencies,
|
|
|
|
# otherwise returns 1.
|
|
|
|
#
|
|
|
|
check_build_depends_pkg()
|
|
|
|
{
|
2009-03-11 06:31:56 +01:00
|
|
|
[ -z "$pkgname" ] && return 2
|
2008-12-13 05:23:16 +01:00
|
|
|
|
|
|
|
if [ -n "$build_depends" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|