--- util-vserver-0.30.216-pre3038/scripts/pkgmgmt~ 2013-05-27 17:13:26.567683113 +0300 +++ util-vserver-0.30.216-pre3038/scripts/pkgmgmt 2013-05-27 17:13:05.566763191 +0300 @@ -185,6 +185,47 @@ test -n "$is_ok" } +## Usage: verifyDBTools +function verifyDBTools +{ + local vdir="$1" + local type="$2" + local host_tool="$3" + local guest_tool="$4" + local res=0 + local hostbdb + local guestbdb + + hostbdb=$(ldd /bin/rpm | awk '/libdb-[0-9\.]+.so/ { sub(/libdb-/, "", $1); sub(/.so/, "", $1); print $1 }') + guestbdb=$(ldd "$vdir"/bin/rpm | awk '/libdb-[0-9\.]+.so/ { sub(/libdb-/, "", $1); sub(/.so/, "", $1); print $1 }') + local i host_path guest_path + for i in /bin /usr/bin /usr/lib/rpm /usr/local/bin; do + test ! -x "$i"/db${hostbdb}_$host_tool || { host_path="$i"/"db${hostbdb}_${host_tool}"; break; } + done + for i in /bin /usr/bin /usr/lib/rpm /usr/local/bin; do + test ! -x "$vdir$i"/db${guestbdb}_$guest_tool || { guest_path="$i"/"db${guestbdb}_${guest_tool}"; break; } + done + + test -n "$host_path" || { + warning " +* The host does not seem to have the 'db${hostbdb}_${host_tool}' program which is required + for $type package management. It is suggested to install it before + continuing." + res=1 + } + test -n "$guest_path" || { + warning " +* The vserver guest does not seem to have the '"db${guestbdb}_${guest_tool}"' program which is required + for $type package management. It is suggested to install it before + continuing." + res=1 + } + + eval db_$host_tool=$host_path + eval db_$guest_tool=$guest_path + return $res +} + # Usage: verifyInternalPackages