4 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; version 2 of the License.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
22 test -e "$UTIL_VSERVER_VARS" || {
23 echo "Can not find util-vserver installation; aborting..."
26 . "$UTIL_VSERVER_VARS"
27 . "$PKGLIBDIR/functions"
29 tmp=$(getopt -o d:r: --long force,dir:,pkgcfg:,hostname:,iproot:,iprootmask:,iprootbcast:,iprootdev:,help,version \
30 -n "$0" -- "$@") || exit 1
51 c|b) mknod -m$6 "$dst" $3 $4 $5;;
52 d) mkdir -p -m$4 "$dst";;
56 *) echo "Unknown dev-entry mode '$3'" >&2
62 function installBasePackages
67 test "$dir" != / || return
68 for filelist in "$dir"/*; do
69 test -f "$filelist" || continue
75 while test "$#" -gt 0; do
77 --reinstall) flags='--reinstall';;
78 --can-fail) can_fail=true;;
83 "$_VAPT_GET" "$name" -- install -y $flags $* || $can_fail
87 function populateDirectory
96 for file in "$i"/*; do
97 test -e "$file" || continue
103 function prepareRPMDb
106 test -z "$WORKAROUND_106057" || {
108 mkdir -p "$rpmdb_path"
110 mkdir -p "$vdir$rpmdb_path"
115 -d) distrib="$2"; shift 2;;
116 -r) root="$2"; shift 2;;
117 --pkgcfg) pkgcfg="$2"; shift 2;;
118 --force) force=1; shift;;
119 --dir) dir="$2"; shift 2;;
120 --hostname) hostname="$2"; shift 2;;
121 --iproot) iproot="$2"; shift 2;;
122 --iprootmask) iprootmask="$2"; shift 2;;
123 --iprootbcast) iprootbcast="$2"; shift 2;;
124 --iprootdev) iprootdev="$2"; shift 2;;
125 --help) showHelp; exit 0;;
126 --version) showVersion; exit 0;;
128 *) echo "Internal error!"; exit 1;;
133 echo "No vserver name given" >&2
138 echo "Too much parameters" >&2
143 test "$dir" || dir=$name
144 test "$pkgcfg" || pkgcfg=$root/.pkg/$name
147 test ! -d "$vdir" || {
148 test "$force" && mv "$vdir" "$vdir".bak
151 confdir="$CONFDIR/$name"
152 test ! -d "$confdir" || {
153 test "$force" && mv "$confdir" "$confdir".bak
156 test ! -d "$vdir" -a ! -d "$confdir" || {
157 echo "vserver-topdirectory and/or configuration exist already; "
158 echo "please try to use '--force', or remove them manually"
163 if test -e /etc/redhat-release; then
164 set -- $(cat /etc/redhat-release)
167 echo "Can not determine distribution; please specify it manually"
168 echo "with the '-d' option"
173 findFile INITPRE $CONFDIR/.distributions/$distrib/initpre $DISTRIBDIR/$distrib/initpre ""
174 findFile INITPOST $CONFDIR/.distributions/$distrib/initpost $DISTRIBDIR/$distrib/initpost ""
175 findFile DEVDESCR $CONFDIR/.distributions/$distrib/devs $DISTRIBDIR/$distrib/devs $DISTRIBDIR/defaults/devs
176 findDir EXECDIR $CONFDIR/.distributions/$distrib/execdir $DISTRIBDIR/$distrib/execdir /
177 findDir RPMLIB $CONFDIR/.distributions/$distrib/rpmlib $DISTRIBDIR/$distrib/rpmlib /
178 findDir PKGDIR $CONFDIR/.distributions/$distrib/pkgs $DISTRIBDIR/$distrib/pkgs /
180 mkdir -p "$confdir"/apps/pkgmgmt "$vdir"/{dev,etc} \
181 "$pkgcfg"/{rpm/{etc,state},apt/{etc,archives/partial,cache,state/lists/partial}}
185 ## HACK AND SECURITY ALERT!
186 ## /var/lib/rpm is hardcoded into apt-get which does not honor the
187 ## %_dbpath variable therefore
188 #mkdir -p "$vdir"/var/lib
189 #ln -s ../../dev "$vdir"/var/lib/rpm
193 makeDevEntry "$vdir"/dev $spec
196 ln -s "$vdir" "$confdir"/vdir
197 for i in hostname iproot iprootmask iprootbcast iprootdev; do
200 test -z "$v" || echo $v >"$confdir/$i"
203 ln -s "$pkgcfg" "$confdir/apps/pkgmgmt/base"
204 test "$EXECDIR" = / || ln -s "$EXECDIR" "$confdir/apps/pkgmgmt/execdir"
205 test "$RPMLIB" = / || ln -s "$RPMLIB" "$confdir/apps/pkgmgmt/rpmlib"
207 populateDirectory "$pkgcfg/apt/etc" "$DISTRIBDIR/$distrib/apt" "$CONFDIR/.distributions/$distrib/apt"
208 populateDirectory "$pkgcfg/rpm/etc" "$DISTRIBDIR/defaults/rpm" "$DISTRIBDIR/$distrib/rpm" \
209 "$CONFDIR/.distributions/$distrib/rpm"
211 echo "%_dbpath $rpmdb_path" >>"$pkgcfg/rpm/etc/macros"
213 test -z "$INITPRE" || "$INITPRE" "$name"
214 "$_VAPT_GET" "$name" -- update
215 installBasePackages "$name" "$PKGDIR"
216 "$_VAPT_GET" "$name" -- dist-upgrade -y
217 test -z "$INITPOST" || "$INITPOST" "$name"