xbps-src: improve builddep code for XBPS_PREFER_BINPKG_DEPS and xbps>=0.11.0.

This commit is contained in:
Juan RP 2011-10-31 04:04:31 +01:00
parent 48913c6c5d
commit ce64a7c5bf
1 changed files with 46 additions and 17 deletions

View File

@ -30,9 +30,25 @@
# #
install_pkg_from_repos() install_pkg_from_repos()
{ {
local cmd rval tmplogf tmpdepf local cmd rval tmplogf tmpdepf xver
msg_normal "$pkgver: installing dependency $1 ...\n" msg_normal "$pkgver: installing '$1'... "
xver=$(xbps-bin.static -V|awk '{print $2}')
case "$xver" in
0.1[1-9].[0-9]*)
_pkgdepname=$($XBPS_PKGDB_CMD getpkgdepname "$1")
_pkgver=$($XBPS_REPO_CMD} -oversion show ${_pkgdepname})
_repoloc=$($XBPS_REPO_CMD} -orepository show ${_pkgdepname})
if [ -n "${_pkgver}" -a -n "${_repoloc}" ]; then
msg_normal_append "found ${_pkgver} (${_repoloc})\n"
else
msg_normal_append "NOT FOUND!\n"
install_pkg_deps "${1}"
fi
;;
*) msg_normal_append "\n";;
esac
cmd="${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} -Ay install" cmd="${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} -Ay install"
tmplogf=$(mktemp) tmplogf=$(mktemp)
@ -107,7 +123,7 @@ install_pkg_deps()
local curpkg="$1" local curpkg="$1"
local curpkgname="$(${XBPS_PKGDB_CMD} getpkgdepname $1)" local curpkgname="$(${XBPS_PKGDB_CMD} getpkgdepname $1)"
local saved_prevpkg="$(${XBPS_PKGDB_CMD} getpkgdepname $2)" local saved_prevpkg="$(${XBPS_PKGDB_CMD} getpkgdepname $2)"
local j jver jname reqver local j jver jname reqver missing_deps
[ -z "$curpkg" -o -z "$curpkgname" ] && return 2 [ -z "$curpkg" -o -z "$curpkgname" ] && return 2
@ -128,7 +144,7 @@ install_pkg_deps()
setup_tmpl "$curpkgname" setup_tmpl "$curpkgname"
check_build_depends_pkg check_build_depends_pkg
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
msg_normal "Package dependency '$curpkgname' requires:\n" msg_normal "Package '$curpkgname' requires:\n"
for j in ${build_depends}; do for j in ${build_depends}; do
jname="$(${XBPS_PKGDB_CMD} getpkgdepname ${j})" jname="$(${XBPS_PKGDB_CMD} getpkgdepname ${j})"
jver="$($XBPS_PKGDB_CMD version ${jname})" jver="$($XBPS_PKGDB_CMD version ${jname})"
@ -137,17 +153,22 @@ install_pkg_deps()
echo " ${j}: found '$jname-$jver'." echo " ${j}: found '$jname-$jver'."
else else
echo " ${j}: not found." echo " ${j}: not found."
if [ -z "$missing_deps" ]; then
missing_deps="${j}"
else
missing_deps="${missing_deps} ${j}"
fi
fi fi
done done
fi fi
for j in ${build_depends}; do for j in ${missing_deps}; do
prev_pkg="$j" prev_pkg="$j"
if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then
install_pkg_from_repos \"${j}\" install_pkg_from_repos "${j}"
if [ $? -eq 255 ]; then if [ $? -eq 255 ]; then
# xbps-bin returned unexpected error # xbps-bin returned unexpected error
msg_red "$saved_prevpkg: failed to install dependency '$j'\n" msg_red "$saved_prevpkg: failed to install '$j'\n"
elif [ $? -eq 0 ]; then elif [ $? -eq 0 ]; then
# package installed successfully. # package installed successfully.
: :
@ -161,9 +182,9 @@ install_pkg_deps()
install_pkg_deps "${j}" "${curpkg}" install_pkg_deps "${j}" "${curpkg}"
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
if [ -n "$saved_prevpkg" ]; then if [ -n "$saved_prevpkg" ]; then
msg_red "$saved_prevpkg: failed to install dependency '$curpkg'\n" msg_red "$saved_prevpkg: failed to install '$curpkg'\n"
else else
msg_red "${_ORIGINPKG}: failed to install dependency '$curpkg'\n" msg_red "${_ORIGINPKG}: failed to install '$curpkg'\n"
fi fi
return 1 return 1
fi fi
@ -171,7 +192,7 @@ install_pkg_deps()
done done
if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then
install_pkg_from_repos \"${curpkg}\" install_pkg_from_repos "${curpkg}"
if [ $? -eq 255 ]; then if [ $? -eq 255 ]; then
# xbps-bin returned unexpected error # xbps-bin returned unexpected error
return $? return $?
@ -179,19 +200,19 @@ install_pkg_deps()
# Package not found, build from source. # Package not found, build from source.
install_pkg "${curpkgname}" install_pkg "${curpkgname}"
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
msg_red "$saved_prevpkg: failed to install dependency '$curpkg'\n" msg_red "$saved_prevpkg: failed to install '$curpkg'\n"
return 1 return 1
fi fi
fi fi
else else
if [ -n "$saved_prevpkg" ]; then if [ -n "$saved_prevpkg" ]; then
msg_normal "$saved_prevpkg: installing dependency '$curpkg'...\n" msg_normal "$saved_prevpkg: installing '$curpkg'...\n"
else else
msg_normal "${_ORIGINPKG}: installing dependency '$curpkg'...\n" msg_normal "${_ORIGINPKG}: installing '$curpkg'...\n"
fi fi
install_pkg "${curpkgname}" install_pkg "${curpkgname}"
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
msg_red "$saved_prevpkg: failed to install dependency '$curpkg'\n" msg_red "$saved_prevpkg: failed to install '$curpkg'\n"
return 1 return 1
fi fi
fi fi
@ -205,6 +226,7 @@ install_dependencies_pkg()
{ {
local pkg="$1" local pkg="$1"
local i pkgn iver missing_deps local i pkgn iver missing_deps
trap "msg_error 'interrupted\n'" INT
[ -z "$pkg" ] && return 2 [ -z "$pkg" ] && return 2
[ -z "$build_depends" ] && return 0 [ -z "$build_depends" ] && return 0
@ -221,7 +243,11 @@ install_dependencies_pkg()
echo " ${i}: found '$pkgn-$iver'." echo " ${i}: found '$pkgn-$iver'."
else else
echo " ${i}: not found." echo " ${i}: not found."
missing_deps=1 if [ -z "$missing_deps" ]; then
missing_deps="${i}"
else
missing_deps="${missing_deps} ${i}"
fi
fi fi
done done
@ -230,15 +256,18 @@ install_dependencies_pkg()
# Install direct build dependencies from binary packages. # Install direct build dependencies from binary packages.
if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then if [ -n "$XBPS_PREFER_BINPKG_DEPS" -a -z "$bootstrap" ]; then
msg_normal "$pkgver: installing dependencies from repositories ...\n" msg_normal "$pkgver: installing dependencies from repositories ...\n"
for i in ${build_depends}; do for i in ${missing_deps}; do
install_pkg_from_repos "${i}" install_pkg_from_repos "${i}"
done done
else else
# Install direct and indirect build dependencies from source. # Install direct and indirect build dependencies from source.
for i in ${build_depends}; do for i in ${missing_deps}; do
install_pkg_deps "${i}" "${pkg}" || return 1 install_pkg_deps "${i}" "${pkg}" || return 1
done done
fi fi
# unregister sighandler.
trap - INT
} }
# #