--- /dev/null
+<!ELEMENT cfgdirdoc (topleveldir+)>
+
+<!ELEMENT topleveldir (description?,(dir|file|script)+)>
+<!ATTLIST topleveldir
+ path CDATA #REQUIRED>
+<!ELEMENT dir (description?,(dir|file|symlink|script)*)>
+<!ATTLIST dir
+ name CDATA #REQUIRED
+ type (fixed,symbolic) #REQUIRED
+ optional (yes,no) #IMPLIED>
+<!ELEMENT file (description)>
+<!ATTLIST file
+ name CDATA #REQUIRED
+ type (fixed,symbolic) #IMPLIED
+ optional (yes,no) #IMPLIED
+>
+
+<!ELEMENT script (description,params)>
+<!ATTLIST script
+ name CDATA #REQUIRED
+>
+
+<!ELEMENT description ANY>
+
+
+<!ELEMENT symlink (description,default?)>
+<!ATTLIST symlink
+ name CDATA #REQUIRED>
+
+<!ELEMENT params (param*)>
+<!ELEMENT param (description)>
+<!ATTLIST param
+ id CDATA #REQUIRED>
+
+<!ELEMENT default ANY>
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE cfgdirdoc SYSTEM "cfgdirdoc.dtd" [
+<!ENTITY init-scriptlet-params
+ "<params>
+ <param id='vserver-dir'>
+ <description>The configuration directory of the current vserver</description>
+ </param>
+ <param id='vserver-name'>
+ <description>The name of the current vserver</description>
+ </param>
+ <param id='action'>
+ <description>The fixed value of the current action (e.g. 'prepre-start', 'post-stop', ...).</description>
+ </param>
+ </params>">
+<!ENTITY init-script-text "The scriptlet">
+<!ENTITY init-dir-text "A directory with scriptlets">
+<!ENTITY init-dir-script-text "A scriptlet">
+
+<!ENTITY init-prepre-start "which will be executed before the network-interfaces are enabled
+ and the directories are mounted.">
+<!ENTITY init-pre-start "which will be executed after network-interfaces were enabled and
+ the directories mounted, but before the vserver itself has been
+ started.">
+<!ENTITY init-post-start "which will be executed after the vserver has been started.">
+<!ENTITY init-pre-stop "which will be executed before the vserver will be stopped.">
+<!ENTITY init-post-stop "which will be executed after the vserver has been stopped, but
+ before the directories will be umounted and the the interfaces
+ disabled.">
+<!ENTITY init-postpost-stop "which will be executed after the vserver has been stopped
+ completely.">
+]>
+
+
+<cfgdirdoc>
+ <topleveldir path="@CONFDIR@">
+ <description>The base configuration directory.</description>
+
+ <dir name=".defaults" type="fixed" optional="yes">
+ <dir name="init" type="fixed">
+ <file name="mtab">
+ <description>Default mtab-file</description>
+ </file>
+ </dir>
+
+ <symlink name="vdirbase">
+ <description></description>
+ <default>/vservers</default>
+ </symlink>
+
+ <dir name="apps" type="fixed">
+ <dir name="pkgmgmt" type="fixed">
+ <symlink name="base">
+ <description></description>
+ <default>/vservers/.pkg</default>
+ </symlink>
+ </dir>
+ </dir>
+ </dir>
+
+ <dir name=".distributions" type="fixed" optional="yes">
+ <dir name="dist" type="symbolic">
+ <file name="dev">
+ <description></description>
+ </file>
+
+ <script name="initpre">
+ <description>Script which will be executed before packages will be installed.</description>
+ <params>
+ <param id="confdir">
+ <description>The configuration directory of the vserver which is going to be set
+ up.</description>
+ </param>
+
+ <param id="vserver">
+ <description>The pathname of the vserver binary.</description>
+ </param>
+ </params>
+ </script>
+
+ <script name="initpost">
+ <description>Script which will be executed after packages are installed.</description>
+ <params>
+ <param id="confdir">
+ <description>The configuration directory of the vserver which is going to be set
+ up.</description>
+ </param>
+
+ <param id="vserver">
+ <description>The pathname of the vserver binary.</description>
+ </param>
+ </params>
+ </script>
+
+ <dir name="pkgs" type="fixed">
+ <description>Contains files with packages.</description>
+ <file name="list" type="symbolic">
+ <description>File which contains the name of packages. On top of file the special
+ keywords '--reinstall' and '--can-fail' are possible.</description>
+ </file>
+ </dir>
+
+ <dir name="pubkeys" type="fixed">
+ <description>Directory with GPG pubkeys which are used to sign the packages of this
+ distribution.</description>
+ </dir>
+
+ <dir name="apt" type="fixed">
+ <description>Default content of the /etc/apt/ directory.</description>
+ </dir>
+
+ <dir name="rpm" type="fixed">
+ <description>Default content of the /etc/rpm directory.</description>
+ </dir>
+
+ <symlink name="rpmlib">
+ <description>Directory which overrides /usr/lib/rpm.</description>
+ </symlink>
+
+ <symlink name="execdir">
+ <description>Directory with all executables and libraries which are required for this
+ distribution.</description>
+ </symlink>
+ </dir>
+ </dir> <!-- .distributions -->
+
+ <dir name="vserver-name" type="symbolic">
+ <description>The configuration directory for the vserver vserver-name.</description>
+
+ <file name="hostname">
+ <description>Contains the hostname of the vserver.</description>
+ </file>
+
+ <file name="name">
+ <description>Contains the name of the vserver. When not given, the basename of the directory
+ will be assumed as this name.</description>
+ </file>
+
+ <file name="domainname">
+ <description>The domainname of the vserver.</description>
+ </file>
+
+ <file name="nice">
+ <description>The nice-level on which the vserver will be started.</description>
+ </file>
+
+ <file name="capabilities">
+ <description>Contains per line a capability.</description>
+ </file>
+
+ <file name="shell">
+ <description>Contains the pathname of the shell which will be used by the "vserver ... enter"
+ command.</description>
+ </file>
+
+ <file name="flags">
+ <description>Contains per line a flag.</description>
+ </file>
+
+ <file name="context">
+ <description>Contains the context which shall be used for the vserver.</description>
+ </file>
+
+ <file name="fstab">
+ <description>The fstab file for the vserver.</description>
+ </file>
+
+ <dir name="apps" type="fixed">
+ <dir name="init" type="fixed">
+ <file name="mtab">
+ <description>The initial-mtab which will be used for the vserver.</description>
+ </file>
+
+ <file name="style">
+ <description>Contains the init-style; possible values are 'sysv', 'plain' and
+ 'minit'.</description>
+ </file>
+
+ <file name="runlevel">
+ <description>The start runlevel.</description>
+ </file>
+
+ <file name="runlevel.start">
+ <description>The start runlevel.</description>
+ </file>
+
+ <file name="runlevel.stop">
+ <description>The stop runlevel.</description>
+ </file>
+
+ <file name="killseq">
+ <description>Contains the 'signal [wait signal]*' sequence which is used to stop the
+ vserver.</description>
+ </file>
+
+ <file name="cmd.start">
+ <description>The command which is used to start the vserver. Each option must be on a
+ separate line.</description>
+ </file>
+
+ <file name="cmd.start-sync">
+ <description>The command which is used to wait on the vserver after it has been
+ started. Each option must be on a separate line. This file will be ignored when the
+ 'sync' does not exist and the '--sync' option was not used.</description>
+ </file>
+
+ <file name="cmd.stop">
+ <description>The command which is used to stop the vserver. Each option must be on a
+ separate line.</description>
+ </file>
+
+ <file name="cmd.stop-sync">
+ <description>The command which is used to wait on the vserver after it has been
+ stopped. Each option must be on a separate line. This file will be ignored when the
+ 'sync' does not exist and the '--sync' option was not used.</description>
+ </file>
+
+ <file name="cmd.prepare">
+ <description>The command which is used to setup the init-system (e.g. to set the runlevel
+ in the utmp-file). Each option must be on a separate line.</description>
+ </file>
+
+ <file name="sync">
+ <description>Without this file, the 'cmd.*-sync' files will be ignored.</description>
+ </file>
+ </dir>
+ </dir>
+
+ <dir name="scripts" type="fixed">
+ <script name="prepre-start">
+ <description>&init-script-text; &init-prepre-start;</description>
+ &init-scriptlet-params;
+ </script>
+ <dir name="prepre-start.d" type="fixed">
+ <description>&init-dir-text; &init-prepre-start;</description>
+
+ <script name="script">
+ <description>&init-dir-script-text; &init-prepre-start;</description>
+ &init-scriptlet-params;
+ </script>
+ </dir>
+
+ <script name="pre-start">
+ <description>&init-script-text; &init-pre-start;</description>
+ &init-scriptlet-params;
+ </script>
+
+ <dir name="pre-start.d">
+ <description>&init-dir-text; &init-pre-start;</description>
+
+ <script name="script">
+ <description>&init-dir-script-text; &init-pre-start;</description>
+ &init-scriptlet-params;
+ </script>
+
+ </dir>
+
+ <script name="post-start">
+ <description>&init-script-text; &init-post-start;</description>
+ &init-scriptlet-params;
+ </script>
+
+ <dir name="post-start.d">
+ <description>&init-dir-text; &init-post-start;</description>
+
+ <script name="script">
+ <description>&init-dir-script-text; &init-post-start;</description>
+ &init-scriptlet-params;
+ </script>
+ </dir>
+
+ <script name="pre-stop">
+ <description>&init-script-text; &init-pre-stop;</description>
+ &init-scriptlet-params;
+ </script>
+
+ <dir name="pre-stop.d" type="fixed">
+ <description>&init-dir-text; &init-pre-stop;</description>
+ <script name="script">
+ <description>&init-dir-script-text; &init-pre-stop;</description>
+ &init-scriptlet-params;
+ </script>
+ </dir>
+
+ <script name="post-stop">
+ <description>&init-script-text; &init-post-stop;</description>
+ &init-scriptlet-params;
+ </script>
+
+ <dir name="post-stop.d" type="fixed">
+ <description>&init-dir-text; &init-post-stop;</description>
+ <script name="script">
+ <description>&init-dir-script-text; &init-post-stop;</description>
+ &init-scriptlet-params;
+ </script>
+ </dir>
+
+ <script name="postpost-stop">
+ <description>&init-script-text; &init-postpost-stop;</description>
+ &init-scriptlet-params;
+ </script>
+
+ <dir name="postpost-stop.d" type="fixed">
+ <description>&init-dir-text; &init-postpost-stop;</description>
+ <script name="script">
+ <description>&init-dir-script-text; &init-postpost-stop;</description>
+ &init-scriptlet-params;
+ </script>
+ </dir>
+ </dir>
+
+
+
+ <dir name="interfaces" type="fixed">
+ <file name="bcast">
+ <description>The deafult broadcast address.</description>
+ </file>
+ <file name="dev">
+ <description>The default network-device.</description>
+ </file>
+ <file name="prefix">
+ <description>The default network-prefix.</description>
+ </file>
+ <file name="mask">
+ <description>The default network-mask.</description>
+ </file>
+ <file name="scope">
+ <description>The default scope of the network interfaces.</description>
+ </file>
+
+ <dir name="iface" type="symbolic">
+ <file name="disabled">
+ <description>When this file exists, this interface will be ignored.</description>
+ </file>
+
+ <file name="ip">
+ <description>The ip which will be assigned to this interface.</description>
+ </file>
+ <file name="bcast">
+ <description>The broadcast address.</description>
+ </file>
+ <file name="dev">
+ <description>The network-device.</description>
+ </file>
+ <file name="prefix">
+ <description>The network-prefix.</description>
+ </file>
+ <file name="mask">
+ <description>The network-mask.</description>
+ </file>
+ <file name="scope">
+ <description>The scope of the network interfaces.</description>
+ </file>
+ <file name="name">
+ <description>When this file exists, the interface will be named.</description>
+ </file>
+ </dir>
+ </dir>
+ </dir>
+ </topleveldir>
+</cfgdirdoc>
+
+
+<!--
+!! Local Variables:
+!! fill-column: 100
+!! End:
+-->
--- /dev/null
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+tmp=$(getopt -o +d: -n "$0" -- "$@") || exit 1
+eval set -- "$tmp"
+
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_RPM"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_APT"
+
+while true; do
+ case "$1" in
+ -d) DISTRIBUTION=$2; shift;;
+ --) shift; break ;;
+ *) echo "vserver-build.apt-rpm: internal error: unrecognized option '$1'"
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+getDistribution
+
+initVariables
+initVariablesRPM
+initVariablesApt
+
+initFilesystem "$OPTION_FORCE"
+initFilesystemRPM
+initFilesystemApt
+
+setup_writeOption "$VSERVER_NAME"
+setup_writeInitialFstab
+
+test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$_VSERVER"
+importGPGPubKeys "$VSERVER_NAME" "$CONFDIR/.distributions/$DISTRIBUTION/pubkeys" "$DISTRIBDIR/$DISTRIBUTION/pubkeys"
+"$_VAPT_GET" "$SETUP_CONFDIR" -- update
+installBasePackages "$SETUP_CONFDIR" "$PKGDIR"
+"$_VAPT_GET" "$SETUP_CONFDIR" -- dist-upgrade -y
+test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$_VSERVER"
--- /dev/null
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Expected environment:
+# $VSERVER_NAME ... name of vserver
+
+ROOTDIR=
+ROOTDIR_REL=
+PKGCFGBASE=
+PKGCFGBASE_REL=
+VSERVERDIRNAME=
+
+VDIR=
+
+_DEV_FILE=
+_EXEC_DIR=
+
+BUILD_INITPRE=
+BUILD_INITPOST=
+
+function makeDevEntry
+{
+ local dst=$1/$2
+ case "$3" in
+ c|b) mknod -m$6 "$dst" $3 $4 $5;;
+ d) mkdir -p -m$4 "$dst";;
+ f) touch "$dst"
+ chmod $4 "$dst"
+ ;;
+ *) echo "Unknown dev-entry mode '$3'" >&2
+ false
+ ;;
+ esac
+}
+
+function populateDirectory
+{
+ local dst=$1
+ local i
+
+ shift
+ for i; do
+ local file=
+
+ for file in "$i"/*; do
+ test -e "$file" || continue
+ case "$file" in
+ */CVS) test ! -d "$file" || continue;;
+ *.rpmsave|*.rpmnew|*.rpmorig)
+ continue;;
+ esac
+
+ cp -a "$file" "$dst/"
+ done
+ done
+}
+
+function _setRootDir
+{
+ test -z "$ROOTDIR" || return 0
+
+ for item in "\"$CONFDIR/.defaults/vdirbase\" 1" "/vservers"; do
+ eval set -- "$item"
+ ROOTDIR=$1
+ ROOTDIR_REL=$2
+ test ! -d "$ROOTDIR" || break
+ done
+
+ test -d "$ROOTDIR" || {
+ echo "Root-directory '$ROOTDIR' does not exist or is invalid"
+ exit 1
+ }
+}
+
+function _setPkgCfgBase
+{
+ test -z "$PKGCFGBASE" || return 0
+
+ for item in "\"$CONFDIR/.defaults/apps/pkgmgmt/base\" 1" "$ROOTDIR/.pkg"; do
+ eval set -- "$item"
+ PKGCFGBASE=$1
+ PKGCFGBASE_REL=$2
+ test ! -d "$PKGCFGBASE" || break
+ done
+
+ test -d "$PKGCFGBASE" || {
+ echo "pkgcfgbase-dir '$PKGCFGBASE' does not exists or is invalid"
+ exit 1
+ }
+}
+
+function _setPkgCfg
+{
+ _setPkgCfgBase
+
+ test -z "$PKGCFGDIR" || return 0
+ PKGCFGDIR="$PKGCFGBASE/$VSERVERDIRNAME"
+}
+
+function _setVserverDir
+{
+ test -z "$VSERVERDIRNAME" || return 0
+ VSERVERDIRNAME="$VSERVER_NAME"
+}
+
+function _setVdir
+{
+ VDIR="$ROOTDIR/$VSERVERDIRNAME"
+}
+
+function say
+{
+ test -z "$OPTION_SILENT" || return 0
+ echo "$@"
+}
+
+function _renameVserverCfg
+{
+ local suffix=.~$(date +'%s')~
+ local i
+
+ for i in "$VDIR" "$SETUP_CONFDIR"; do
+ test ! -e "$i" || {
+ mv "$i" "$i$suffix"
+ say "Renamed '$i' to '$i$suffix'"
+ }
+ done
+}
+
+function getDistribution
+{
+ test -z "$DISTRIBUTION" || return 0
+
+ if test -e /etc/fedora-release; then
+ set -- $(cat /etc/fedora-release)
+ DISTRIBUTION=fdr$4
+ elif test -e /etc/redhat-release; then
+ set -- $(cat /etc/redhat-release)
+ DISTRIBUTION=rh$5
+ elif test -e /etc/debian_version; then
+ set -- $(cat /etc/debian_version)
+ DISTRIBUTION=deb$1
+ else
+ echo "Can not determine distribution; please specify it manually"
+ echo "with the '-d' option"
+ exit 1
+ fi >&2
+}
+
+## Usage: initFilesystem [force]
+function initFilesystem
+{
+ test -z "$1" || _renameVserverCfg
+ test ! -d "$VDIR" -a ! -d "$SETUP_CONFDIR" || {
+ echo "vserver-topdirectory and/or configuration exist already; "
+ echo "please try to use '--force', or remove them manually"
+ exit 1
+ } >&2
+
+ mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt "$VDIR"/{dev/pts,etc} "$SETUP_LOCKREVDIR"
+
+ ln -s "$VDIR" "$SETUP_CONFDIR/vdir"
+
+ test -z "$PKGCFGDIR" || {
+ ln -s "$PKGCFGDIR" "$SETUP_CONFDIR/apps/pkgmgmt/base"
+
+ test "$_EXECDIR" = / || ln -s "$_EXECDIR" "$confdir/apps/pkgmgmt/execdir"
+ }
+
+ local spec
+ while read spec; do
+ makeDevEntry "$VDIR"/dev $spec
+ done <$_DEV_FILE
+}
+
+function initVariables
+{
+ _setRootDir
+ _setVserverDir
+ _setPkgCfg
+ _setVdir
+
+ findFile _DEV_FILE "$CONFDIR/.distributions/$DISTRIBUTION/devs" "$DISTRIBDIR/$DISTRIBUTION/devs" "$DISTRIBDIR/defaults/devs"
+ findDir _EXECDIR "$CONFDIR/.distributions/$DISTRIBUTION/execdir" "$DISTRIBDIR/$DISTRIBUTION/execdir" /
+ findFile BUILD_INITPRE "$CONFDIR/.distributions/$DISTRIBUTION/initpre" "$DISTRIBDIR/$DISTRIBUTION/initpre" ""
+ findFile BUILD_INITPOST "$CONFDIR/.distributions/$DISTRIBUTION/initpost" "$DISTRIBDIR/$DISTRIBUTION/initpost" ""
+ findDir PKGDIR "$CONFDIR/.distributions/$DISTRIBUTION/pkgs" "$DISTRIBDIR/$DISTRIBUTION/pkgs" /
+}
--- /dev/null
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+function installBasePackages
+{
+ local name="$1"
+ local dir="$2"
+
+ test "$dir" != / || return 0
+ for filelist in "$dir"/*; do
+ test -f "$filelist" || continue
+ local idx=0
+ local can_fail=false
+ local flags=
+
+ set -- $(<$filelist)
+ while test "$#" -gt 0; do
+ case "$1" in
+ --reinstall) flags='--reinstall';;
+ --can-fail) can_fail=true;;
+ *) break;;
+ esac
+ shift
+ done
+ "$_VAPT_GET" "$name" -- install -y $flags $* || $can_fail
+ done
+}
+
+function initVariablesApt
+{
+ :
+}
+
+function initFilesystemApt
+{
+ mkdir -p "$PKGCFGDIR"/apt/{etc,archives/partial,cache,state/lists/partial}
+
+ populateDirectory "$PKGCFGDIR/apt/etc" \
+ "$DISTRIBDIR/$DISTRIBUTION/apt" \
+ "$CONFDIR/.distributions/$DISTRIBUTION/apt"
+}
--- /dev/null
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+RPMDB_PATH=
+RPMLIBDIR=
+
+function importGPGPubKeys
+{
+ local dst=$1
+ local pkgs
+ declare -a pkgs
+ local i
+
+ shift
+ for i; do
+ local file=
+ for file in "$i"/*; do
+ test -f "$file" || continue
+
+ pkgs=( "${pkgs[@]}" "$file" )
+ done
+ done
+
+ test "$pkgs" || return 0
+ "$_VRPM" "$dst" -- --import "${pkgs[@]}"
+}
+
+function initVariablesRPM
+{
+ test "$WORKAROUND_106057" && \
+ RPMDB_PATH=/.rpmdb || \
+ RPMDB_PATH=/dev
+
+ findDir RPMLIBDIR "$CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$DISTRIBDIR/$DISTRIBUTION/rpmlib" /
+}
+
+function initFilesystemRPM
+{
+ test -z "$WORKAROUND_106057" || mkdir -p "$RPMDB_PATH"
+ mkdir -p "$VDIR$RPMDB_PATH"
+
+ test -z "$WORKAROUND_APT_DBPATH" || {
+ mkdir -p "$VDIR/var/lib"
+ ln -s "$RPMDB_PATH" "$VDIR/var/lib/rpm"
+ }
+
+ mkdir -p "$PKGCFGDIR"/rpm/{etc,state}
+ populateDirectory "$PKGCFGDIR/rpm/etc" \
+ "$DISTRIBDIR/defaults/rpm" \
+ "$DISTRIBDIR/$DISTRIBUTION/rpm" \
+ "$CONFDIR/.distributions/$DISTRIBUTION/rpm"
+
+ echo "%_dbpath $RPMDB_PATH" >>"$pkgcfg/etc/macros"
+
+ test "$RPMLIBDIR" = / || ln -s "$RPMLIB" "$confdir/apps/pkgmgmt/rpmlib"
+}
--- /dev/null
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+SETUP_HOSTNAME=
+SETUP_NETDEV=
+SETUP_NETMASK=
+SETUP_NETPREFIX=
+SETUP_BCAST=
+SETUP_LOCKFILE=
+SETUP_LOCKREVDIR=
+SETUP_CONFDIR=
+
+declare -a SETUP_INTERFACES=()
+declare -a SETUP_FLAGS=()
+
+declare -r SETUP_OPTIONS="confdir:lockfile:lockrevdir:hostname:,netdev:,netmask:,netprefix:,netbcast:,interface:,flags:"
+declare -r SETUP_HELPMSG=$"
+ --confdir ... [default: $CONFDIR/<name>]
+ --lockfile <filename>
+ ... [default: $RUNDIR/<name>]
+ --lockrevdir <dirname>
+ ... [default: $RUNDIR/rev/]
+ --hostname <hostname>
+ --netdev <device>
+ --netmask <netmask>|--netprefix <prefix>
+ ... sets the default netmask (a.b.c.d quadruple) or prefix
+ (length of the interface)
+ --interface [<name-suffix>=][<device>:]<ip>[/<mask|prefix>]
+ ... declares an network-interface; this option can be specified
+ multiple times
+ --flags <flags>+
+ ... sets comma-separated list of flags; possible flags are
+ lock: Prevent the vserver from setting new security context
+ sched: Merge scheduler priority of all processes in the
+ vserver so that it acts a like a single one.
+ nproc: Limit the number of processes in the vserver
+ according to ulimit (instead of a per user limit,
+ this becomes a per vserver limit)
+ private: No other process can join this security context.
+ Even root
+"
+
+function setup_setOption2
+{
+ case "$1" in
+ --confdir) SETUP_CONFDIR=$2;;
+ --lockfile) SETUP_LOCKFILE=$2;;
+ --lockrevdir) SEUTP_LOCKREVDIR=$2;;
+ --hostname) SETUP_HOSTNAME=$2;;
+ --netdev) SETUP_NETDEV=$2;;
+ --netmask) SETUP_NETMASK=$2;;
+ --netprefix) SETUP_NETPREFIX=$2;;
+ --netbcast) SETUP_BCAST=$2;;
+ --interface) SETUP_INTERFACES=( "${SETUP_INTERFACES[@]}" "$2" );;
+ --flags) old_IFS=$IFS
+ IFS=,
+ set -- $2
+ SETUP_FLAGS=( "${SETUP_FLAGS[@]}" "$@" )
+ IFS=$old_IFS
+ ;;
+ *) return 1;;
+ esac
+
+ return 0
+}
+
+function _setup_writeSingleOption
+{
+ test -z "$1" || echo "$1" >"$2"
+}
+
+function _setup_writeInterface
+{
+ local vdir=$1
+ local idx=$2
+ local tmp=$3
+
+ local name=${tmp%%=*}
+ test "$name" != "$tmp" || name=
+
+ tmp=${tmp##${name}=}
+ local dev=${tmp%%:*}
+ test "$dev" != "$tmp" || dev=
+
+ tmp=${tmp##${dev}:}
+ local mask=${tmp##*/}
+ test "$mask" != "$tmp" || mask=
+
+ local ip=${tmp%%/${mask}}
+
+ local prefix=
+ test "${mask%%.*}" != "$mask" || {
+ prefix=$mask
+ mask=
+ }
+
+ d=$vdir/interfaces/$idx
+ mkdir "$d"
+
+ _setup_writeSingleOption "$name" $d/name
+ _setup_writeSingleOption "$dev" $d/dev
+ _setup_writeSingleOption "$ip" $d/ip
+ _setup_writeSingleOption "$mask" $d/mask
+ _setup_writeSingleOption "$prefix" $d/prefix
+}
+
+function setup_setDefaults
+{
+ : ${SETUP_CONFDIR:=$CONFDIR/$1}
+ : ${SETUP_LOCKFILE:=$RUNDIR/$1}
+ : ${SETUP_LOCKREVDIR:=$RUNDIR/rev}
+}
+
+function setup_writeOption
+{
+ local name=$1
+ local cfgdir=$SETUP_CONFDIR
+ local i
+
+ mkdir -p "$cfgdir/interfaces"
+
+ _setup_writeSingleOption "$name" "$cfgdir"/name
+ _setup_writeSingleOption "$SETUP_HOSTNAME" "$cfgdir"/hostname
+ _setup_writeSingleOption "$SETUP_NETDEV" "$cfgdir"/interfaces/dev
+ _setup_writeSingleOption "$SETUP_NETMASK" "$cfgdir"/interfaces/mask
+ _setup_writeSingleOption "$SETUP_NETPREFIX" "$cfgdir"/interfaces/prefix
+
+ local idx=0
+ for i in "${SETUP_INTERFACES[@]}"; do
+ _setup_writeInterface "$cfgdir" $idx "$i"
+ let ++idx
+ done
+
+ test -z "$SETUP_FLAGS" || for i in "${SETUP_FLAGS[@]}"; do
+ echo "$i"
+ done >"$cfgdir"/flags
+
+ ln -s "$SETUP_LOCKFILE" "$cfgdir/run"
+ ln -s "$SETUP_LOCKREVDIR" "$cfgdir/run.rev"
+}
+
+function setup_writeInitialFstab
+{
+ cat <<EOF >$SETUP_CONFDIR/fstab
+none /proc proc defaults 0 0
+none /tmp tmpfs size=16m,mode=1777 0 0
+none /dev/pts devpts gid=5,mode=620 0 0
+EOF
+}
+
+function setup_test
+{
+ SETUP_INTERFACES=()
+
+ setup_setOption2 --interface foo0=eth0:1.2.3.4/1
+ setup_setOption2 --interface foo1=eth0:1.2.3.4/255.255.248.0
+ setup_setOption2 --interface foo2=eth0:1.2.3.4
+ setup_setOption2 --interface foo3=1.2.3.4
+ setup_setOption2 --interface foo4=1.2.3.4/1
+ setup_setOption2 --interface eth0:1.2.3.4
+ setup_setOption2 --interface eth0:1.2.3.4/1
+ setup_setOption2 --interface 1.2.3.4
+ setup_setOption2 --interface 1.2.3.4/1
+
+ setup_writeOption xx
+}