shutils: use xbps-pkgdb getpkg{name,version}, remove item from TODO.

--HG--
extra : convert_revision : 69927380509b3bc6b3f80ee3cbc44953bdd2b729
This commit is contained in:
Juan RP 2009-02-17 13:58:34 +01:00
parent 3d308188b7
commit 0bb1780f8e
4 changed files with 47 additions and 37 deletions

View file

@ -3,8 +3,6 @@ xbps-src:
* Multiple URLs to download source distribution files, aliases, etc. * Multiple URLs to download source distribution files, aliases, etc.
Something like ${sourceforge} to pick up any specified mirror on the list. Something like ${sourceforge} to pick up any specified mirror on the list.
* More robust and fast dependency checking. * More robust and fast dependency checking.
* $version needs to have a dot to be found by xbps.sh.
Some packages do not have a dot on its version, like udev-130.
* Add support to run the prepost-* scripts, so that the same actions are * Add support to run the prepost-* scripts, so that the same actions are
performed in source/bin packages. Use current postinstall_helpers to performed in source/bin packages. Use current postinstall_helpers to
automatically add triggers, shared by src/bin pkgs. [IN PROGRESS] automatically add triggers, shared by src/bin pkgs. [IN PROGRESS]

View file

@ -1,5 +1,5 @@
#- #-
# Copyright (c) 2008 Juan Romero Pardines. # Copyright (c) 2008-2009 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -25,6 +25,15 @@
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
run_template()
{
local pkg="$1"
if [ "$pkgname" != "$pkg" ]; then
reset_tmpl_vars
. $XBPS_TEMPLATESDIR/$pkg/template
fi
}
# #
# Recursive function that founds dependencies in all required # Recursive function that founds dependencies in all required
# packages. # packages.
@ -32,27 +41,28 @@
add_dependency_tolist() add_dependency_tolist()
{ {
local curpkg="$1" local curpkg="$1"
local curpkgname=
local j= local j=
local jver=
local jname=
[ -z "$curpkg" ] && return 1 [ -z "$curpkg" ] && return 1
[ -n "$prev_pkg" ] && curpkg=$prev_pkg [ -n "$prev_pkg" ] && curpkg=$prev_pkg
if [ "$pkgname" != "${curpkg%-[0-9]*.*}" ]; then curpkgname=$(xbps-pkgdb getpkgname ${curpkg})
reset_tmpl_vars run_template $curpkgname
. $XBPS_TEMPLATESDIR/${curpkg%-[0-9]*.*}/template
fi
for j in ${build_depends}; do for j in ${build_depends}; do
# #
# Check if dep already installed. # Check if dep already installed.
# #
check_installed_pkg $j ${j##[aA-zZ]*-} check_installed_pkg $j
# #
# If dep is already installed, check one more time # If dep is already installed, check one more time
# if all its deps are there and continue. # if all its deps are there and continue.
# #
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
install_builddeps_required_pkg $j #install_builddeps_required_pkg $j
installed_deps_list="$j $installed_deps_list" installed_deps_list="$j $installed_deps_list"
continue continue
fi fi
@ -62,7 +72,7 @@ add_dependency_tolist()
# #
# Check if dependency needs more deps. # Check if dependency needs more deps.
# #
check_build_depends_pkg ${j%-[0-9]*.*} check_build_depends_pkg $j
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
add_dependency_tolist $j add_dependency_tolist $j
prev_pkg="$j" prev_pkg="$j"
@ -127,8 +137,10 @@ install_dependencies_pkg()
{ {
local pkg="$1" local pkg="$1"
local i= local i=
local ipkg= local ipkgname=
local iversion= local iversion=
local reqname=
local reqvers=
deps_list= deps_list=
installed_deps_list= installed_deps_list=
@ -145,22 +157,26 @@ install_dependencies_pkg()
msg_normal "Required minimal deps for $(basename $pkg):" msg_normal "Required minimal deps for $(basename $pkg):"
for i in ${installed_deps_list}; do for i in ${installed_deps_list}; do
ipkg=${i%-[0-9]*.*} ipkgname=$(xbps-pkgdb getpkgname ${i})
iversion="$($XBPS_REGPKGDB_CMD version $ipkg)" iversion=$($XBPS_REGPKGDB_CMD version $ipkgname)
echo " $ipkg >= ${i##[aA-zZ]*-}: found $ipkg-$iversion." reqvers=$(xbps-pkgdb getpkgversion ${i})
echo " $ipkgname >= $reqvers: found $ipkgname-$iversion."
done done
for i in ${deps_list}; do for i in ${deps_list}; do
echo " ${i%-[0-9]*.*} >= ${i##[aA-zZ]*-}: not found." reqname=$(xbps-pkgdb getpkgname ${i})
reqvers=$(xbps-pkgdb getpkgversion ${i})
echo " $reqname >= $reqvers: not found."
done done
for i in ${deps_list}; do for i in ${deps_list}; do
# skip dup deps # skip dup deps
check_installed_pkg $i ${i##[aA-zZ]*-} check_installed_pkg $i
[ $? -eq 0 ] && continue [ $? -eq 0 ] && continue
# continue installing deps # continue installing deps
msg_normal "Installing $pkg dependency: $i." msg_normal "Installing $pkg dependency: $i."
install_pkg ${i%-[0-9]*.*} ipkgname=$(xbps-pkgdb getpkgname ${i})
install_pkg $ipkgname
done done
unset installed_deps_list unset installed_deps_list
@ -170,19 +186,20 @@ install_dependencies_pkg()
install_builddeps_required_pkg() install_builddeps_required_pkg()
{ {
local pkg="$1" local pkg="$1"
local pkgname=$(xbps-pkgdb getpkgname ${pkg})
local dep= local dep=
local depname=
[ -z "$pkg" ] && return 1 [ -z "$pkg" ] && return 1
if [ "$pkgname" != "${pkg%-[0-9]*.*}" ]; then run_template $pkgname
. $XBPS_TEMPLATESDIR/${pkg%-[0-9]*.*}/template
fi
for dep in ${build_depends}; do for dep in ${build_depends}; do
check_installed_pkg $dep ${dep##[aA-zZ]*-} check_installed_pkg $dep
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_normal "Installing $pkg dependency: $dep." msg_normal "Installing $pkg dependency: $dep."
install_pkg ${dep%-[0-9]*.*} depname=$(xbps-pkgdb getpkgname ${dep})
install_pkg $depname
fi fi
done done
} }
@ -194,15 +211,15 @@ install_builddeps_required_pkg()
check_installed_pkg() check_installed_pkg()
{ {
local pkg="$1" local pkg="$1"
local reqver="$2" local pkgname=
local reqver=
local iver= local iver=
[ -z "$pkg" -o -z "$reqver" ] && return 1 [ -z "$pkg" ] && return 1
if [ "$pkgname" != "${pkg%-[0-9]*.*}" ]; then pkgname=$(xbps-pkgdb getpkgname $pkg)
reset_tmpl_vars reqver=$(xbps-pkgdb getpkgversion $pkg)
. $XBPS_TEMPLATESDIR/${pkg%-[0-9]*.*}/template run_template $pkgname
fi
iver="$($XBPS_REGPKGDB_CMD version $pkgname)" iver="$($XBPS_REGPKGDB_CMD version $pkgname)"
if [ -n "$iver" ]; then if [ -n "$iver" ]; then
@ -220,13 +237,11 @@ check_installed_pkg()
check_build_depends_pkg() check_build_depends_pkg()
{ {
local pkg="$1" local pkg="$1"
local pkgname=$(xbps-pkgdb getpkgname ${pkg})
[ -z $pkg ] && return 1 [ -z $pkg ] && return 1
if [ "$pkgname" != "${pkg%-[0-9]*.*}" ]; then run_template $pkgname
reset_tmpl_vars
. $XBPS_TEMPLATESDIR/${pkg%-[0-9]*.*}/template
fi
if [ -n "$build_depends" ]; then if [ -n "$build_depends" ]; then
return 0 return 0

View file

@ -237,7 +237,7 @@ umount_chroot_fs()
[ -n "$base_chroot" ] && return 0 [ -n "$base_chroot" ] && return 0
. $XBPS_SHUTILSDIR/builddep_funcs.sh . $XBPS_SHUTILSDIR/builddep_funcs.sh
check_installed_pkg xbps-base-chroot 0.1 check_installed_pkg xbps-base-chroot-0.1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "The '$pkgname' package requires to be installed in a chroot." echo "The '$pkgname' package requires to be installed in a chroot."
echo "Please install the 'xbps-base-chroot' package and try again." echo "Please install the 'xbps-base-chroot' package and try again."

View file

@ -65,10 +65,7 @@ stow_pkg()
# #
# Run template postinstall helpers if requested. # Run template postinstall helpers if requested.
# #
if [ "$pkgname" != "${pkg%%-$version}" ]; then run_template $pkgname
. $XBPS_TEMPLATESDIR/${pkg%%-$version}/template
fi
for i in ${postinstall_helpers}; do for i in ${postinstall_helpers}; do
local pihf="$XBPS_HELPERSDIR/$i" local pihf="$XBPS_HELPERSDIR/$i"
[ -f "$pihf" ] && . $pihf [ -f "$pihf" ] && . $pihf