4 # Copyright (C) 2003,2004,2005 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.
19 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
20 test -e "$UTIL_VSERVER_VARS" || {
21 echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
24 . "$UTIL_VSERVER_VARS"
26 . "$_LIB_VSERVER_SETUP_FUNCTIONS"
27 . "$_LIB_VSERVER_BUILD_FUNCTIONS"
29 ### Some local functions
34 $"Usage: $(basename $0) -m <method> -n <name> --force <cfg-options>*
35 --rootdir <dir> --pkgbase <dir> [--] <method-args>*
38 --force ... remove/rename already existing vservers with the same
40 --keep ... do not delete generated files and directories when
41 build of vserver failed.
42 -m <method> ... use method <method>; see below for possible values
44 ... [default: $__DEFAULT_VSERVERDIR]
46 ... [default: $__DEFAULT_VSERVERPKGDIR]
48 cfg-options are: $SETUP_HELPMSG
51 legacy ... the \"old\" copy-all-from-host method, which requires the
52 old legacy vserver-legacy script; with this method the
53 cfg-options will be ignored
54 apt-rpm ... -- -d <distribution>
55 ... installs the base-packages of the given distribution with
57 yum ... -- -d <distribution> [-- <packages>*]
58 ... installs the base-packages of the given distribution with
60 urpmi ... -- -d <distribution> -m <mirror>
61 rpm ... -- [-d <distribution>] --empty|([--force] [--nodeps] <manifest>)+
62 ... installs lists of rpm-packages
63 skeleton ... -- [<cmd> <args>*]
64 ... installs a minimal skeleton filesystem, creates the
65 configuration file and calls an optional command then
66 debootstrap ... -- -d <distribution> [-m <mirror>] [-s <script> ] [-- <debootstrap-options>*]
67 ... bootstraps the vserver with Debian's 'debootstrap' package
68 template ... -- (-t <tarball>)+ [-d <distribution>]
69 ... installs a guest using tarball(s)
70 fai ... -- [ -f <fai_vserver> ] [-n <nfsroot>] [-d <fai_dir> ] [ -a ]
71 bootstraps the vserver with Debian Fully Automatic Installation
72 -f means use the nfsroot and profile in the vserver <fai_vserver>
73 -n <nfsroot> specifies the 'NFS' root explicitly
74 -d <fai_dir> specifies the location of the FAI profile
75 the -f option implies -n and -d are relative to the <fai_vserver>
76 rsync ... -- [-d <distribution>] --source <source> [-- <rsync options>*]
77 ... installs a guest by rsyncing from <source> to the guest root
78 clone ... -- [-d <distribution>] --source <source> [--exclude-from <exclude-list>]
79 ... clones a guest by linking unified files and copying the rest
81 Please report bugs to $PACKAGE_BUGREPORT"
85 function showVersion()
88 $"vserver-build $PACKAGE_VERSION -- initializes a vserver
89 This program is part of $PACKAGE_STRING
91 Copyright (C) 2003,2004,2005 Enrico Scholz
92 This program is free software; you may redistribute it under the terms of
93 the GNU General Public License. This program has absolutely no warranty."
101 declare -a default_opts=()
102 test -n "$NO_DEFAULT_OPTS" || getFileArray default_opts "$__CONFDIR/.defaults/apps/build/options" || :
104 tmp=$(getopt -o +m:n: --long keep,force,debug,help,version,rootdir:,pkgbase:,$SETUP_OPTIONS -n "$(basename $0)" -- \
105 "${default_opts[@]}" "$@") || exit 1
115 (--help) showHelp $0 ;;
116 (--version) showVersion ;;
117 (--force) OPTION_FORCE=1;;
118 (--keep) OPTION_KEEP=1;;
119 (--debug) let ++OPTION_DEBUG; set -x;;
120 (--rootdir) ROOTDIR=$2; shift;;
121 (--pkgbase) PKGCFGBASE=$2; shift;;
122 (-m) method=$2; shift;;
123 (-n) VSERVER_NAME=$2; shift;;
126 { setup_setOption2 "$1" "$2" && shift; } || \
127 panic $"vserver-build: internal error."
133 test -n "$VSERVER_NAME" ||
134 panic $"Name of vserver not specified"
136 setup_setDefaults "$VSERVER_NAME"
139 (xlegacy) exec $_VSERVER_LEGACY "$VSERVER_NAME" build "$@" ;;
140 (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm|xtemplate|xfai|xrsync|xclone|xurpmi)
141 . $__PKGLIBDIR/vserver-build.$method
143 (x) panic $"No build-method specified";;
144 (*) panic $"Unknown build-method '$method'";;