3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 test ! $mod "$i" || { file=$i; break; }
31 test -z "$i" -o "$file" || {
32 echo "Can not find file for '$var'; aborting"
49 function getPhysicalDir
51 ( set -P && cd "$1" && pwd )
54 function _pkgMountBindDir()
56 test "$1" != "$2" || return 0
58 mount -n --bind "$1" "$2"
61 function _pkgSetVarsBase
65 echo "not supported yet"
69 BASEDIR=$CONFDIR/$vserver
70 test -d "$BASEDIR" || {
71 echo "Can not find configuration-directory"
76 test -d "$VDIR" || VDIR=/vservers/$vserver
77 VDIR=$(getPhysicalDir "$VDIR")
79 PKGDIR=$BASEDIR/apps/pkgmgmt
80 test -d "$PKGDIR" || {
81 echo "Can not find configuration-directory for package-managment tools"
85 findDir EXECDIR $PKGDIR/execdir /
91 function _pkgSetVarsRPM
95 echo "not supported yet"
100 findDir RPMETCDIR $PKGDIR/rpmetc $PKGDIR/base/rpm/etc /etc/rpm
101 findDir RPMSTATEDIR $PKGDIR/rpmstate $PKGDIR/base/rpm/state
103 findDir RPMLIBDIR $PKGDIR/rpmlib /
105 RPMSTATEDIR=$(getPhysicalDir "$RPMSTATEDIR")
106 RPMETCDIR=$(getPhysicalDir "$RPMETCDIR")
111 function _pkgSetVarsApt
115 echo "not supported yet"
120 findDir APTETCDIR $PKGDIR/aptetc $PKGDIR/base/apt/etc /etc/apt
121 findDir APTSTATEDIR $PKGDIR/aptstate $PKGDIR/base/apt/state
122 findDir APTCACHEDIR $PKGDIR/aptcache $PKGDIR/base/apt/cache
123 findDir APTARCHIVDIR $PKGDIR/aptarchives $PKGDIR/base/apt/archives /var/cache/apt/archives
128 function _pkgMountBase
133 function _pkgMountApt
138 function _pkgMountRPM
140 _pkgMountBindDir "$RPMETCDIR" /etc/rpm
141 test "$RPMLIBDIR" = "/" || _pkgMountBindDir "$RPMLIBDIR" /usr/lib/rpm
142 "$_SECURE_MOUNT" "$VDIR" "$RPMSTATEDIR" /var/lib/rpm
145 function _pkgSetEnvBase
147 test "$EXECDIR" = "/" || {
149 LD_LIBRARY_PATH=$EXECDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
152 export PATH LD_LIBRARY_PATH
155 function _pkgSetEnvApt
160 function _pkgSetEnvRPM
163 RPM_FAKE_NAMESPACE_MOUNTS=/var/lib/rpm
164 RPM_BINARY=$_VRPM_PRELOAD
166 export CUR_VSERVER RPM_FAKE_NAMESPACE_MOUNTS RPM_BINARY
178 rpm) _pkgSetVarsRPM;;
179 apt) _pkgSetVarsApt;;
180 *) echo "Unknown packaging flavor"; exit 1;;
201 _PKG_VSERVER=$vserver
204 function getAllVservers
209 for i in $CONFDIR/*; do
210 test -d "$i" || continue
211 test ! -e "$i"/disabled || continue
212 test -d "$i"/vdir || continue
214 eval "$var=\"$var ${i##$CONFDIR/}\""