gentoo: use /var/run for new /run compatibility
[util-vserver.git] / scripts / pkgmgmt
index 04ddd42..2da1b1e 100755 (executable)
@@ -23,6 +23,7 @@ test -e "$UTIL_VSERVER_VARS" || {
 }
 . "$UTIL_VSERVER_VARS"
 . "$_LIB_FUNCTIONS"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS"
 . "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
 . "$__PKGLIBDIR/vserver.functions"
 
@@ -54,7 +55,6 @@ function init()
     else
        rpmdb_mntpoint=/.rpmdb
     fi
-    pkgmgmt.initVariables
 }
 
 function _createDirs()
@@ -160,8 +160,9 @@ function _mountFilesystems()
     }
     test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
     
-    _mountFilesystemsInternal "$cfgdir"/fstab       $_CHBIND "${CHBIND_OPTS[@]}" || return 1
-    _mountFilesystemsInternal "$cfgdir"/fstab.local $_CHBIND "${CHBIND_OPTS[@]}" || return 1
+    _mountFilesystemsInternal "$cfgdir"/fstab                           || return 1
+    _mountFilesystemsInternal "$cfgdir"/fstab.local                     || return 1
+    _mountFilesystemsInternal "$cfgdir"/fstab.remote "${CHBIND_CMD[@]}" || return 1
 }
 
 function _umountFilesystems()
@@ -176,8 +177,9 @@ function _umountFilesystems()
     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=
+       _umountVserverInternal  "$cfgdir"/fstab.remote "${CHBIND_CMD[@]}" || is_ok=
+       _umountVserverInternal  "$cfgdir"/fstab.local                     || is_ok=
+       _umountVserverInternal  "$cfgdir"/fstab                           || is_ok=
     popd >/dev/null           || return 1
     
     test -n "$is_ok"
@@ -193,7 +195,7 @@ packagemanagement:
 "
     
     case $2 in
-       (RH)    pkgs=$(vrpm "$1" -- -q --qf '---%{NAME}---\n' rpm apt yum "${YUM_RELEASEPKGS[@]}")
+       (RH)    pkgs=$(vrpm "$1" -- -q --qf '---%{NAME}---\n' rpm apt yum urpmi "${YUM_RELEASEPKGS[@]}")
                hasSubstring "$pkgs" ---rpm--- || {
                    warning "$ERR
 * The vserver does not seem to have the 'rpm' package which is required
@@ -203,7 +205,7 @@ packagemanagement:
                    ERR=
                }
                
-               hasSubstring "$pkgs"  ---apt--- ---yum--- || {
+               hasSubstring "$pkgs"  ---apt--- ---yum--- ---urpmi--- || {
                    warning "$ERR
 * The vserver does not seem to have a depsolver like 'apt' or 'yum'
   installed. It is suggested to install such a program before setting
@@ -212,7 +214,8 @@ packagemanagement:
                    ERR=
                }
 
-               test -n "$have_apt" || test -z "$have_yum"   || \
+               test -n "$have_apt" || test -n "$have_urpmi" ||
+               test -z "$have_yum" || \
                hasSubstring "$pkgs" "${YUM_RELEASEPKGS[@]}" || {
                    warning "$ERR
 * yum requires a special package which describes the version of the
@@ -233,6 +236,8 @@ function processVserver_RH()
     local vserver=$1
     local is_internalize=$2
     local have_apt
+    local have_yum
+    local have_urpmi
     local cfgdir
     local i
 
@@ -242,8 +247,10 @@ function processVserver_RH()
     ## Figure out the environment....
     have_apt=1
     have_yum=1
+    have_urpmi=1
     pkgmgmt.isAptAvailable "$cfgdir" "$vdir" "$is_internalize" || have_apt=
     pkgmgmt.isYumAvailable "$cfgdir" "$vdir" "$is_internalize" || have_yum=
+    pkgmgmt.isUrpmiAvailable "$cfgdir" "$vdir" "$is_internalize" || have_urpmi=
 
     local APTETCDIR=
     local APTSTATEDIR=
@@ -278,11 +285,16 @@ Can not continue; use '--force' to override this check"
        popd >/dev/null
        
        if test -n "$have_apt"; then
-           findDir APTETCDIR    "$cfgdir"/aptetc "$cfgdir"/base/apt/etc /etc/apt /
+           findDir APTETCDIR     "$cfgdir"/aptetc "$cfgdir"/base/apt/etc /etc/apt /
+       elif test -n "$have_urpmi"; then
+           findDir URPMISTATEDIR "$cfgdir"/base/var/lib/urpmi
+           findDir URPMIETCDIR   "$cfgdir"/base/etc/urpmi
        fi
 
-       findDir RPMETCDIR   "$cfgdir"/rpmetc   "$cfgdir"/base/rpm/etc    /etc/rpm /
-       findDir RPMSTATEDIR "$cfgdir"/rpmstate "$cfgdir"/base/rpm/state
+       findDir RPMETCDIR   "$cfgdir"/rpmetc   "$cfgdir"/base/rpm/etc    \
+                           "$cfgdir"/base/etc/rpm /etc/rpm /
+       findDir RPMSTATEDIR "$cfgdir"/rpmstate "$cfgdir"/base/rpm/state  \
+                           "$cfgdir"/base/var/lib/rpm
     else
        mkdir -m755 -p "$cfgdir"
        local need_base=
@@ -325,6 +337,9 @@ Can not continue; use '--force' to override this check"
            pushd "$vdir" >/dev/null
                _hashAuto /etc/apt/apt.conf '/'
            popd >/dev/null
+       elif test -n "$have_urpmi"; then
+           _copySecure "$vdir" "$URPMISTATEDIR" /var/lib/urpmi
+           _copySecure "$vdir" "$URPMIETCDIR" /etc/urpmi
        fi
 
        _copySecure "$vdir" "$RPMETCDIR"   /etc/rpm
@@ -396,6 +411,11 @@ function processVserver()
        echo $"Vserver '$vserver' does not seem to exist; skipping it..."
        return 1
     } >&2
+
+    _setVserverDir "$vserver"
+    _setVserverName
+    _setVserverDirName
+    pkgmgmt.initVariables
     
     pkgmgmt.isInternal "$vserver" || is_external=1