summaryrefslogtreecommitdiff
blob: 492acd39905baa7f0afaf6b768846b261eabf0c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
Index: util-vserver-0.30.210/configure.ac
===================================================================
--- util-vserver-0.30.210.orig/configure.ac
+++ util-vserver-0.30.210/configure.ac
@@ -56,6 +56,11 @@ ENSC_PATHPROG(NOHUP,     nohup)
 ENSC_PATHPROG(RMMOD,     rmmod)
 ENSC_PATHPROG(VCONFIG,   vconfig,, [See http://www.candelatech.com/~greear/vlan.html; usually this tool is shipped in the 'vconfig' or 'vlan' package of your distribution])
 ENSC_PATHPROG(WGET,      wget)
+ENSC_PATHPROG(FILE,      file,    [file])
+ENSC_PATHPROG(GZIP,      gzip,    [gzip])
+ENSC_PATHPROG(BZIP2,     bzip2,   [bzip2])
+ENSC_PATHPROG(CPIO,      cpio,    [cpio])
+ENSC_PATHPROG(RESTORE,   restore, [restore])
 
 ENSC_PATHPROG(DOXYGEN,   doxygen,  [:])
 ENSC_PATHPROG(XSLTP,     xsltp,    [:])
Index: util-vserver-0.30.210/contrib/manifest.dat.pathsubst
===================================================================
--- util-vserver-0.30.210.orig/contrib/manifest.dat.pathsubst
+++ util-vserver-0.30.210/contrib/manifest.dat.pathsubst
@@ -8,6 +8,7 @@ build  @PKGLIBDIR@/vserver-build.deboots
 build  @PKGLIBDIR@/vserver-build.yum
 build  @PKGLIBDIR@/vserver-build.rpm
 build  @PKGLIBDIR@/vserver-build.clone
+build  @PKGLIBDIR@/vserver-build.template
 build  @PKGLIBDIR@/vserver-build.functions
 build  @PKGLIBDIR@/vserver-build.functions.apt
 build  @PKGLIBDIR@/vserver-build.functions.rpm
Index: util-vserver-0.30.210/scripts/Makefile-files
===================================================================
--- util-vserver-0.30.210.orig/scripts/Makefile-files
+++ util-vserver-0.30.210/scripts/Makefile-files
@@ -39,6 +39,7 @@ AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += \
 
 scripts_pkglib_src_DTA =	scripts/functions \
 				scripts/gentoo-functions.sh \
+				scripts/magic.mime \
 				scripts/vserver-build.apt-rpm \
 				scripts/vserver-build.skeleton \
 				scripts/vserver-build.debootstrap \
@@ -50,6 +51,7 @@ scripts_pkglib_src_DTA =	scripts/functio
 				scripts/vserver-build.functions.rpm \
 				scripts/vserver-build.functions.pkgmgmt \
 				scripts/vserver-build.functions.yum \
+				scripts/vserver-build.template \
 				scripts/vserver-setup.functions \
 				scripts/vserver.functions \
 				scripts/vserver.start \
Index: util-vserver-0.30.210/scripts/magic.mime
===================================================================
--- /dev/null
+++ util-vserver-0.30.210/scripts/magic.mime
@@ -0,0 +1,19 @@
+# Borrowed from file(1)
+# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
+0	string		\037\213		application/x-gzip
+# tar posix
+257	string		ustar\0			application/x-tar
+# tar gnu
+257	string		ustar\040\040\0		application/x-tar
+# cpio
+0	short		070707			application/x-cpio
+# cpio swapped
+0	short		0143561			application/x-cpio
+# bzip2
+0	string		BZh			application/x-bzip2
+# dump/restore new-fs big and little endian
+24	belong		60012			application/x-dump
+24	lelong		60012			application/x-dump
+# dump/restore old-fs big and little endian
+24	belong		60011			application/x-dump
+24	lelong		60011			application/x-dump
Index: util-vserver-0.30.210/scripts/util-vserver-vars.pathsubst
===================================================================
--- util-vserver-0.30.210.orig/scripts/util-vserver-vars.pathsubst
+++ util-vserver-0.30.210/scripts/util-vserver-vars.pathsubst
@@ -43,6 +43,7 @@ _IFSPEC="$__LEGACYDIR/ifspec"
 _INITSYNC_MINIT_START=:
 _KEEP_CTX_ALIVE="$__PKGLIBDIR/keep-ctx-alive"
 _LIB_FUNCTIONS="$__PKGLIBDIR/functions"
+_LIB_MAGIC="$__PKGLIBDIR/magic"
 _LIB_GENTOO_FUNCTIONS="$__PKGLIBDIR/gentoo-functions.sh"
 _LIB_VSERVER_SETUP_FUNCTIONS="$__PKGLIBDIR/vserver-setup.functions"
 _LIB_VSERVER_BUILD_FUNCTIONS="$__PKGLIBDIR/vserver-build.functions"
@@ -103,14 +104,18 @@ _VYUM="$__SBINDIR/vyum"
 _VYUM_WORKER="$__PKGLIBDIR/vyum-worker"
 
 _AWK="@AWK@"
+_BZIP2="@BZIP2@"
 _CAT="@CAT@"
 _CHOWN="@CHOWN@"
 _CMP="@CMP@"
 _CP="@CP@"
+_CPIO="@CPIO@"
 _DIRNAME="@DIRNAME@"
 _EGREP="@EGREP@"
 _ENV="@ENV@"
+_FILE="@FILE@"
 _GREP="@GREP@"
+_GZIP="@GZIP@"
 _IP="@IP@"
 _IPTABLES="@IPTABLES@"
 _LN="@LN@"
@@ -125,6 +130,7 @@ _MV="@MV@"
 _NAMEIF="@NAMEIF@"
 _NICE="@NICE@"
 _NOHUP="@NOHUP@"
+_RESTORE="@RESTORE@"
 _RM="@RM@"
 _RMDIR="@RMDIR@"
 _RMMOD="@RMMOD@"
Index: util-vserver-0.30.210/scripts/vserver-build
===================================================================
--- util-vserver-0.30.210.orig/scripts/vserver-build
+++ util-vserver-0.30.210/scripts/vserver-build
@@ -66,6 +66,8 @@ Possible methods are:
 		     configuration file and calls an optional command then
     debootstrap ... -- -d <distribution> [-m <mirror>] [-s <script> ] [-- <debootstrap-options>*]
                      bootstraps the vserver with Debian's 'debootstrap' package
+    template ... -- (-t <tarball>)+
+                ...  installs a guest using tarball(s)
 
 Please report bugs to $PACKAGE_BUGREPORT"
     exit 0
@@ -126,7 +128,7 @@ setup_setDefaults "$VSERVER_NAME"
 
 case x"$method" in
     (xlegacy)	exec $_VSERVER_LEGACY "$VSERVER_NAME" build "$@" ;;
-    (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm|xclone)
+    (xapt-rpm|xcopy|xskeleton|xdebootstrap|xyum|xrpm|xclone|xtemplate)
 		. $__PKGLIBDIR/vserver-build.$method
 		;;
     (x)		panic $"No build-method specified";;
Index: util-vserver-0.30.210/scripts/vserver-build.template
===================================================================
--- /dev/null
+++ util-vserver-0.30.210/scripts/vserver-build.template
@@ -0,0 +1,92 @@
+# $Id:$	--*- sh -*--
+
+# Copyright (C) 2006 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:t:' --long debug,pkgmgmt,template: -n "vserver-build.template" -- "$@") || exit 1
+eval set -- "$tmp"
+
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
+
+DISTRIBUTION=:
+use_pkgmgmt=
+declare -a TEMPLATE=()
+while true; do
+    case "$1" in
+	-d)		DISTRIBUTION=$2; shift;;
+	--debug)	set -x;;
+	--pkgmgmt)	use_pkgmgmt=1;;
+	-t|--template)
+			case "$2" in
+			     /*)	f="$2";;
+			     *)		f=`pwd`/"$2";;
+			esac
+			TEMPLATE=( "${TEMPLATE[@]}" "$f" )
+			shift
+			;;
+	--)		shift; break ;;
+	*)		echo "vserver-build.template: internal error: unrecognized option '$1'" >&2
+			exit 1
+			;;
+    esac
+    shift
+done
+
+getDistribution '' 1
+
+base.init
+test -z "$use_pkgmgmt" || pkgmgmt.initVariables
+
+base.initFilesystem "$OPTION_FORCE"
+test -z "$use_pkgmgmt" || pkgmgmt.initFilesystem "$OPTION_FORCE"
+
+
+setup_writeOption "$VSERVER_NAME"
+setup_writeInitialFstab
+
+test -z "$BUILD_INITPRE"  || "$BUILD_INITPRE" "$SETUP_CONFDIR"  "$UTIL_VSERVER_VARS"
+
+pushd "$SETUP_CONFDIR/vdir" >& /dev/null
+for t in "${TEMPLATE[@]}"; do
+    mime=$($_FILE -Nbiz -m "$_LIB_MAGIC" "$t")
+    compression=$(echo "$mime" | $_GREP '(' | $_SED 's!.*(\(.*\))$!\1!')
+
+    case "$compression" in
+	application/x-bzip2)	DECOMPRESS="$_BZIP2 -d -c";;
+	application/x-gzip)	DECOMPRESS="$_GZIP -d -c";;
+	"")			DECOMPRESS=$_CAT;;
+	*)
+	    echo "Unsupported compression method: $compression"
+	    exit 1
+	    ;;
+    esac
+
+    case "$mime" in
+	application/x-tar*)	EXTRACT="$_TAR -x";;
+	application/x-cpio*)	EXTRACT="$_CPIO -i";;
+	application/x-dump*)	EXTRACT="$_RESTORE -rf -";;
+	*)
+	    echo "Unsupported packaging method: $mime"
+	    exit 1
+	    ;;
+    esac
+
+    $DECOMPRESS "$t" | $EXTRACT
+done
+popd >& /dev/null
+
+test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
+
+base.setSuccess