use $(LIBENSCVECTOR) instead of libensc_vector.a
[util-vserver.git] / util-vserver / scripts / pkgmgmt
index fd14ec8..5e3bb41 100755 (executable)
@@ -24,7 +24,7 @@ test -e "$UTIL_VSERVER_VARS" || {
 . "$UTIL_VSERVER_VARS"
 . "$_LIB_FUNCTIONS"
 . "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
-. "$PKGLIBDIR/vserver.functions"
+. "$__PKGLIBDIR/vserver.functions"
 
 function showHelp()
 {
@@ -60,7 +60,7 @@ function init()
 function _createDirs()
 {
     for i; do
-       test "$i" || continue
+       test -n "$i" || continue
        mkdir -p -m755 "$i"
     done
 }
@@ -94,16 +94,16 @@ function _hashAuto()
 
     $_EXEC_CD "$dir" "$(which test)" "$file" || return 0
     
-    local tmp=$(mktemp /tmp/apt.conf.XXXXXX)
-    trap "rm -f $tmp" EXIT
+    local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
+    trap "$_RM -f $tmp" EXIT
 
-    $_EXEC_CD "$dir" /bin/cat "$file" | \
-       sed -e "s|^\([^$hash].*@autogenerated@\)|$hash$hash\1|" >$tmp
+    $_EXEC_CD "$dir" $_CAT "$file" | \
+       $_SED -e "s|^\([^$hash].*@autogenerated@\)|$hash$hash\1|" >$tmp
 
-    cat $tmp | $_EXEC_CD "$dir" "$(which cmp)" -s - "$file" || \
+    $_CAT $tmp | $_EXEC_CD "$dir" "$(which cmp)" -s - "$file" || \
        $_CHROOT_CAT "$1" <$tmp
 
-    rm -f $tmp
+    $_RM -f $tmp
 }
 
 function _unhashAuto()
@@ -111,14 +111,14 @@ function _unhashAuto()
     test -e "$1" || return 0
 
     local hash=$2
-    local tmp=$(mktemp /tmp/apt.conf.XXXXXX)
-    trap "rm -f $tmp" EXIT
+    local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
+    trap "$_RM -f $tmp" EXIT
 
-    sed -e "s|^$hash$hash\(.*@autogenerated@\)|\1|" "$1" >$tmp
-    cmp -s "$tmp" "$1" || \
-       cat "$tmp" >"$1"
+    $_SED -e "s|^$hash$hash\(.*@autogenerated@\)|\1|" "$1" >$tmp
+    $_CMP -s "$tmp" "$1" || \
+       $_CAT "$tmp" >"$1"
 
-    rm -f $tmp
+    $_RM -f $tmp
 }
 
 function _mountFilesystemsInternal()
@@ -134,11 +134,12 @@ function _mountFilesystemsInternal()
 
 function _mountFilesystems()
 {
-    local cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
+    local cfgdir
+    cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
        echo "Can not determine configuration directory for '$1'; ..." >&2
        return 1
     }
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+    test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
     
     _mountFilesystemsInternal "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || return 1
     _mountFilesystemsInternal "$cfgdir"/fstab.local $_CHBIND "${CHBIND_OPTS[@]}" || return 1
@@ -146,20 +147,21 @@ function _mountFilesystems()
 
 function _umountFilesystems()
 {
-    local cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
+    local cfgdir
+    cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || {
        echo "Can not determine configuration directory for '$1'; ..." >&2
        return 1
     }
     local vdir=$cfgdir/vdir
     local is_ok=1
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+    test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
 
     pushd "$vdir/" >/dev/null || return 1
        _umountVserverInternal  "$cfgdir"/fstab.local                              || is_ok=
        _umountVserverInternal  "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
     popd >/dev/null           || return 1
     
-    test "$is_ok"
+    test -n "$is_ok"
 }
 
 function processVserver_RH()
@@ -186,13 +188,13 @@ function processVserver_RH()
 
     ## Create directories and assign variables where configuration
     ## can/will be found on the host
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        pushd "$vdir" >/dev/null
 
        test ! -L var/lib/rpm || {
-           $_EXEC_CD /var/lib /bin/rm            rpm &&
-           $_EXEC_CD /var/lib /bin/mkdir -m755   rpm &&
-           $_EXEC_CD /var/lib /bin/chown rpm:rpm rpm ||
+           $_EXEC_CD /var/lib $_RM            rpm &&
+           $_EXEC_CD /var/lib $_MKDIR -m755   rpm &&
+           $_EXEC_CD /var/lib $_CHOWN rpm:rpm rpm ||
            :
        } </dev/null 2>/dev/null
 
@@ -200,12 +202,12 @@ function processVserver_RH()
                 var/state/{,apt/{,lists/{,partial}}} \
                 etc/apt etc/rpm; do
            test -d "$i" ||
-               $_EXEC_CD /$(dirname "$i") /bin/mkdir -m755 $(basename "$i") || :
+               $_EXEC_CD /$(dirname "$i") $_MKDIR -m755 $(basename "$i") || :
        done #2>/dev/null
        
        popd >/dev/null
        
-       if test "$have_apt"; then
+       if test -n "$have_apt"; then
            findDir APTETCDIR    "$cfgdir"/aptetc "$cfgdir"/base/apt/etc /etc/apt /
        fi
 
@@ -215,7 +217,7 @@ function processVserver_RH()
        mkdir -m755 -p "$cfgdir"
        local need_base=
 
-       if test "$have_apt"; then
+       if test -n "$have_apt"; then
            findDir APTETCDIR    "$cfgdir"/aptetc      "$cfgdir"/base/apt/etc       /
            findDir APTSTATEDIR  "$cfgdir"/aptstate    "$cfgdir"/base/apt/state     /
            findDir APTCACHEDIR  "$cfgdir"/aptcache    "$cfgdir"/base/apt/cache     /
@@ -247,8 +249,8 @@ function processVserver_RH()
     fi
 
     ## Copy the files...
-    if test "$is_internalize"; then
-       if test "$have_apt"; then
+    if test -n "$is_internalize"; then
+       if test -n "$have_apt"; then
            _copySecure "$vdir" "$APTETCDIR" /etc/apt
            pushd "$vdir" >/dev/null
                _hashAuto /etc/apt/apt.conf '/'
@@ -259,7 +261,7 @@ function processVserver_RH()
        _copySecure "$vdir" "$RPMSTATEDIR" /var/lib/rpm
 
     else
-       if test "$have_apt"; then
+       if test -n "$have_apt"; then
            _copySecureRev "$vdir" /etc/apt "$APTETCDIR"
            _unhashAuto "$APTETCDIR"/apt.conf '/'
        fi
@@ -269,22 +271,22 @@ function processVserver_RH()
     fi
 
     ## Cleanups...
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        :
     else
-       tmpdir=$(mktemp -d /var/tmp/pgmgmt.XXXXXX)
-       trap "rm -rf $tmpdir" EXIT
+       tmpdir=$($_MKTEMPDIR /var/tmp/pgmgmt.XXXXXX)
+       trap "$_RM -rf $tmpdir" EXIT
        pushd "$vdir" >/dev/null
-       $_EXEC_CD /var/lib /bin/mv rpm $tmpdir/
-       $_EXEC_CD /var/lib /bin/ln -s "$rpmdb_mntpoint" rpm
-       rm -rf $tmpdir
+       $_EXEC_CD /var/lib $_MV rpm $tmpdir/
+       $_EXEC_CD /var/lib $_LN_S "$rpmdb_mntpoint" rpm
+       $_RM -rf $tmpdir
     fi
 
     ## Finish it...
-    if test "$is_internalize"; then
-       touch "$cfgdir"/internal
+    if test -n "$is_internalize"; then
+       $_TOUCH "$cfgdir"/internal
     else
-       rm -f "$cfgdir"/internal
+       $_RM -f "$cfgdir"/internal
     fi
 }
 
@@ -293,7 +295,7 @@ function processVserver_Debian()
     local vserver=$1
     local is_internalize=$2
 
-    if test "$is_internalize"; then
+    if test -n "$is_internalize"; then
        echo $"Debian vservers should be internalized everytime; do not know how to handle '$vserver'" >&2
     else
        echo $"External packagemanagement is not supported for Debian vserver" >&2
@@ -367,7 +369,7 @@ while true; do
     shift
 done
 
-test "$1" || {
+test -n "$1" || {
     echo $"No vserver specified; try '--help' for more information"
     exit 1
 } >&2