added the '-m rpm' method
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 31 Jan 2005 22:45:42 +0000 (22:45 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 31 Jan 2005 22:45:42 +0000 (22:45 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1833 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/Makefile-files
util-vserver/scripts/vserver-build
util-vserver/scripts/vserver-build.rpm [new file with mode: 0644]

index 46e5b42..1ce5c48 100644 (file)
@@ -40,6 +40,7 @@ scripts_pkglib_src_DTA =      scripts/functions \
                                scripts/vserver-build.apt-rpm \
                                scripts/vserver-build.skeleton \
                                scripts/vserver-build.debootstrap \
+                               scripts/vserver-build.rpm \
                                scripts/vserver-build.yum \
                                scripts/vserver-build.functions \
                                scripts/vserver-build.functions.apt \
index d64c98e..d01c521 100755 (executable)
@@ -1,7 +1,7 @@
 #! /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
@@ -56,6 +56,8 @@ Possible methods are:
     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
@@ -72,7 +74,7 @@ function showVersion()
 $"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
@@ -118,7 +120,7 @@ setup_setDefaults "$VSERVER_NAME"
 
 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";;
diff --git a/util-vserver/scripts/vserver-build.rpm b/util-vserver/scripts/vserver-build.rpm
new file mode 100644 (file)
index 0000000..6f3d240
--- /dev/null
@@ -0,0 +1,98 @@
+# $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"