#! /bin/bash
# $Id$
-# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+# Copyright (C) 2003,2004,2005 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
yum ... -- -d <distribution>
... installs the base-packages of the given distribution with
help of 'vyum'
+ rpm ... -- [-d <distribution>] ([--force] [--nodeps] <manifest>)*
+ ... installs lists of rpm-packages
skeleton ... -- [<cmd> <args>*]
... installs a minimal skeleton filesystem, creates the
configuration file and calls an optional command then
$"vserver-build $PACKAGE_VERSION -- initializes a vserver
This program is part of $PACKAGE_STRING
-Copyright (C) 2003 Enrico Scholz
+Copyright (C) 2003,2004,2005 Enrico Scholz
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty."
exit 0
case x"$method" in
(xlegacy) exec $_VSERVER_LEGACY "$VSERVER_NAME" build "$@" ;;
- (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum)
+ (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm)
. $PKGLIBDIR/vserver-build.$method
;;
(x) panic $"No build-method specified";;
--- /dev/null
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2005 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:b: --long debug -n "$0" -- "$@") || exit 1
+eval set -- "$tmp"
+
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_RPM"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
+
+set -e
+
+
+## Usage: installPackages <vserver> <rpm-options>*
+## it expects a list of packages on stdin
+function installPackages()
+{
+ local cfgdir=$1
+ shift
+
+ while read; do
+ case x"$REPLY" in
+ (x|\#*) continue;;
+ esac
+
+ echo "$BASEDIR/$REPLY"
+ done >>"$manifest"
+
+ cat "$manifest"
+ test ! -s "$manifest" || $_VRPM "$cfgdir" -- -Uv "$@" "$manifest"
+}
+
+BASEDIR=$(pwd)
+DISTRIBUTION=
+
+echo "$@"
+
+while true; do
+ case "$1" in
+ (-d) DISTRIBUTION=$2; shift;;
+ (-b) BASEDIR=$2; shift;;
+ (--debug) set -x;;
+ (--) shift; break ;;
+ (*) echo "vserver-build.rpm: internal error: unrecognized option '$1'" >&2
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+getDistribution "template"
+
+base.initVariables
+pkgmgmt.initVariables
+rpm.initVariables
+
+base.initFilesystem "$OPTION_FORCE"
+pkgmgmt.initFilesystem "$OPTION_FORCE"
+rpm.initFilesystem
+
+setup_writeOption "$VSERVER_NAME"
+setup_writeInitialFstab
+
+# when basedir is a non-local location, rpm will download it into the
+# current directory. Therefore, create and go into a temporay directory
+# before doing the operations.
+tmpdir=$($_MKTEMPDIR /var/tmp/vserver-build.rpm.XXXXXX)
+manifest=$($_MKTEMP /tmp/vserver-build.rpm.manifest.XXXXXX)
+trap "rm -rf $tmpdir $manifest" EXIT
+cd "$tmpdir"
+
+test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+rpm.importGPGPubKeys "$SETUP_CONFDIR" "$CONFDIR/.distributions/$DISTRIBUTION/pubkeys" "$DISTRIBDIR/$DISTRIBUTION/pubkeys"
+rpm.initDB "$SETUP_CONFDIR"
+
+for i; do
+ case "$i" in
+ (--force|--nodeps) opts=( "${opts[@]}" "$i" ); continue;;
+ esac
+
+ installPackages "$VSERVER_NAME" "${opts[@]}" <"$i"
+ opts=
+done
+
+test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"