summaryrefslogtreecommitdiff
path: root/src/main.sh
blob: 3403d44aa4bd66ed4af2d95ada52e56223227c0a (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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
#!/bin/sh

# make-live - utility to build Debian Live systems
#
# Copyright (C) 2006 Daniel Baumann <daniel@debian.org>
# Copyright (C) 2006 Marco Amadori <marco.amadori@gmail.com>
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# On Debian systems, the complete text of the GNU General Public License
# can be found in /usr/share/common-licenses/GPL file.

set -e

# Set static variables
BASE=${LIVE_BASE:-"/usr/share/make-live"}
CONFIG="/etc/make-live.conf"
PROGRAM="`basename ${0}`"
VERSION="0.99.23"

export VERSION

CODENAME_OLDSTABLE="woody"
CODENAME_STABLE="sarge"
CODENAME_TESTING="etch"
CODENAME_UNSTABLE="sid"

# Source sub scripts
for SCRIPT in `find ${BASE}/scripts/ -not -name '*~' -not -wholename "${BASE}/scripts/.*" -and -type f`
do
	. "${SCRIPT}"
done

USAGE="Usage: ${PROGRAM} [-a|--architecture ARCHITECTURE] [-b|--bootappend KERNEL_PARAMETER|\"KERNEL_PARAMETERS\"] [--clone DIRECTORY] [--config FILE] [-c|--chroot DIRECTORY] [-d|--distribution DISTRIBUTION] [-e|--encryption ALGORITHM] [--with-generic-indices] [--without-generic-indices] [--with-recommends] [--without-recommends] [--with-daemons] [--without-daemons] [--filesystem FILESYSTEM] [-f|--flavour BOOTSTRAP_FLAVOUR] [--hook COMMAND|\"COMMANDS\"] [--include-chroot FILE|DIRECTORY] [--include-image FILE|DIRECTORY] [-k|--kernel KERNEL_FLAVOUR] [--manifest PACKAGE] [-m|--mirror URL] [-k|--keyring] [--mirror-security URL] [--packages PACKAGE|\"PACKAGES\"] [-p|--package-list LIST|FILE] [--preseed FILE] [--proxy-ftp URL] [--proxy-http URL] [--repositories NAME] [-r|--root DIRECTORY] [-s|--section SECTION|\"SECTIONS\"] [--server-address HOSTNAME|IP] [--server-path DIRECTORY] [--templates DIRECTORY] [-t|--type TYPE] [--tasks TASK]"

Help ()
{
	echo "${PROGRAM} - utility to build Debian Live systems"
	echo
	echo "${USAGE}"
	echo "Usage: ${PROGRAM} [-h|--help]"
	echo "Usage: ${PROGRAM} [-u|--usage]"
	echo "Usage: ${PROGRAM} [-v|--version]"
	echo
	echo "Lists: gnome, gnome-core, gnome-full, kde, kde-core, kde-core-i18n, kde-extra, kde-extra-i18n, kde-full, kde-full-i18n, kde-i18n, standard, standard-i18n, x11, x11-core, xfce."
	echo
	echo "Values:"
	echo "  Architectures: alpha, amd64, arm, hppa, i386, ia64, m68k, powerpc, s390, sparc."
	echo "  Distributions: testing, unstable, experimental or etch, sid".
	echo "  Filesystems: ext2, plain, squashfs."
	echo "  Boostrap flavours: minimal, standard."
	echo "  Kernel flavours: Debian Kernel flavour of your architecture."
	echo "  Types: iso, net, usb."
	echo
	echo "Options:"
	echo "  -a, --architecture: specifies the bootstrap architecture."
	echo "  -b, --bootappend: specifies the kernel parameter(s)."
	echo "  --config: specifies an alternate configuration file."
	echo "  -c, --chroot: specifies the chroot directory."
	echo "  --clone: specifies a chroot directory to clone."
	echo "  -d, --distribution: specifies the debian distribution."
	echo "  -e, --encryption: specifies the filesystem encryption algorithm."
	echo "  --filesystem: specifies the chroot filesystem."
	echo "  -f, --flavour: specifies the bootstrap flavour."
	echo "  --bootstrap-config: specifies the suite configuration to be used for bootstraping."
	echo "  --hook: specifies extra command(s)."
	echo "  --include-chroot: specifies file or directory for chroot inclusion."
	echo "  --include-image: specifies file or directory for image inclusion."
	echo "  -k, --kernel: specifies debian kernel flavour."
	echo "  --manifest: specifies the pivot package to create filesystem.manifest-desktop upon (mostly \"ubuntu-live\")."
	echo "  -m, --mirror: specifies debian mirror."
	echo "  --mirror-security: specifies debian security mirror."
	echo "  --keyring: specifies keyring package."
	echo "  --packages: specifies aditional packages."
	echo "  -p, --package-list: specifies additonal package list."
	echo "  --repositories: specifies custom repositories."
	echo "  -r, --root: specifies build root."
	echo "  --preseed: specifies a debconf preseeding file."
	echo "  --proxy-ftp: specifies \${ftp_proxy}."
	echo "  --proxy-http: specifies \${http_proxy}."
	echo "  -s, --section: specifies the debian sections."
	echo "  --server-address: specifies the netboot server address."
	echo "  --server-path: specifies the netboot server path for chroot."
	echo "  --templates: specifies location of the templates."
	echo "  -t, --type: specifies live system type."
	echo "  --tasks: specifies one or more aptitude tasks."
	echo "  --with-generic-indices: enables generic debian package indices (default)."
	echo "  --without-generic-indices: disables generic debian package indices."
	echo "  --with-recommends: installes recommended packages too."
	echo "  --without-recommends: does not install recommended packages (default)."
	echo "  --with-daemons: don't touch daemons."
	echo "  --without-daemons: disable all non-essential daemons."
	echo
	echo "Environment:"
	echo "  All settings can be also specified trough environment variables. Please see make-live.conf(5) for more information."
	echo
	echo "Report bugs to Debian Live project <http://live.debian.net>."
	exit 0
}

Usage ()
{
	echo "${PROGRAM} - utility to build Debian Live systems"
	echo
	echo "${USAGE}"
	echo "Usage: ${PROGRAM} [-h|--help]"
	echo "Usage: ${PROGRAM} [-u|--usage]"
	echo "Usage: ${PROGRAM} [-v|--version]"
	echo
	echo "Try \"${PROGRAM} --help\" for more information."
	exit ${1}
}

Version ()
{
	echo "${PROGRAM}, version ${VERSION}"
	echo
	echo "Copyright (C) 2006 Daniel Baumann <daniel@debian.org>"
	echo "Copyright (C) 2006 Marco Amadori <marco.amadori@gmail.com>"
	echo
	echo "This program is free software; you can redistribute it and/or modify"
	echo "it under the terms of the GNU General Public License as published by"
	echo "the Free Software Foundation; either version 2 of the License, or"
	echo "(at your option) any later version."
	echo
	echo "This program is distributed in the hope that it will be useful,"
	echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
	echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
	echo "GNU General Public License for more details."
	echo
	echo "You should have received a copy of the GNU General Public License"
	echo "along with this program; if not, write to the Free Software"
	echo "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA"
	echo
	echo "On Debian systems, the complete text of the GNU General Public License"
	echo "can be found in /usr/share/common-licenses/GPL file."
	echo
	echo "Homepage: <http://live.debian.net/>"
	exit 0
}

Configuration ()
{
	# Source default configuration
	if [ -r "${CONFIG}" ]
	then
		. "${CONFIG}"
	fi

	# Source alternate configuration
	if [ -n "${LIVE_CONFIG}" ]
	then
		if [ -r "${LIVE_CONFIG}" ]
		then
			. "${LIVE_CONFIG}"
		fi
	fi
}

Main ()
{
	ARGUMENTS="`getopt --longoptions root:,tasks:,type:,architecture:,bootappend:,clone:,config:,chroot:,distribution:,encryption:,filesystem:,flavour:,bootstrap-config:,hook:,include-chroot:,include-image:,kernel:,manifest:,mirror:,keyring:,mirror-security:,output:,packages:,package-list:,proxy-ftp:,preseed:,proxy-http:,repositories:,section:,server-address:,server-path:,templates:,with-generic-indices,without-generic-indices,with-recommends,without-recommends,with-daemons,without-daemons,with-source,without-source,help,usage,version --name=${PROGRAM} --options r:t:a:b:c:d:e:f:k:m:o:p:s:huv --shell sh -- "${@}"`"

	if [ "${?}" != "0" ]
	then
		echo "Terminating." >&2
		exit 1
	fi

	eval set -- "${ARGUMENTS}"

	while true
	do
		case "${1}" in
			-r|--root)
				LIVE_ROOT="${2}"; shift 2
				export LIVE_ROOT
				;;

			-t|--type)
				LIVE_TYPE="${2}"; shift 2
				export LIVE_TYPE
				;;

			--tasks)
				LIVE_TASKS="${2}"; shift 2
				export LIVE_TASKS
				;;

			-a|--architecture)
				LIVE_ARCHITECTURE="${2}"; shift 2
				export LIVE_ARCHITECTURE
				;;

			-b|--bootappend)
				LIVE_BOOTAPPEND="${2}"; shift 2
				export LIVE_BOOTAPPEND
				;;

			--clone)
				LIVE_CLONE="${2}"; shift 2
				export LIVE_CLONE
				;;

			--config)
				LIVE_CONFIG="${2}"; shift 2
				export LIVE_CONFIG
				;;

			-c|--chroot)
				LIVE_CHROOT="${2}"; shift 2
				export LIVE_CHROOT
				;;

			-d|--distribution)
				LIVE_DISTRIBUTION="${2}"; shift 2
				export LIVE_DISTRIBUTION
				;;

			-e|--encryption)
				LIVE_ENCRYPTION="${2}"; shift 2
				export LIVE_ENCRYPTION
				;;

			--filesystem)
				LIVE_FILESYSTEM="${2}"; shift 2
				export LIVE_FILESYSTEM
				;;

			-f|--flavour)
				LIVE_FLAVOUR="${2}"; shift 2
				export LIVE_FLAVOUR
				;;
			--bootstrap-config)
				LIVE_BOOTSTRAP_CONFIG="${2}"; shift 2
				export LIVE_BOOTSTRAP_CONFIG
				;;
			--hook)
				LIVE_HOOK="${2}"; shift 2
				export LIVE_HOOK
				;;

			--include-chroot)
				LIVE_INCLUDE_CHROOT="${2}"; shift 2
				export LIVE_INCLUDE_CHROOT
				;;

			--include-image)
				LIVE_INCLUDE_IMAGE="${2}"; shift 2
				export LIVE_INCLUDE_IMAGE
				;;

			-k|--kernel)
				LIVE_KERNEL="${2}"; shift 2
				export LIVE_KERNEL
				;;

			--manifest)
				LIVE_MANIFEST="${2}"; shift 2
				export LIVE_MANIFEST
				;;

			-m|--mirror)
				LIVE_MIRROR="${2}"; shift 2
				export LIVE_MIRROR
				;;

			--keyring)
				LIVE_REPOSITORY_KEYRING="${2}"; shift 2
				export LIVE_REPOSITORY_KEYRING
				;;

			--mirror-security)
				LIVE_MIRROR_SECURITY="${2}"; shift 2
				export LIVE_MIRROR_SECURITY
				;;

			-o|--output)
				LIVE_IMAGE="${2}"; shift 2
				export LIVE_IMAGE
				;;

			--packages)
				LIVE_PACKAGES="${2}"; shift 2
				export LIVE_PACKAGES
				;;

			-p|--package-list)
				LIVE_PACKAGE_LIST="${2}"; shift 2
				export LIVE_PACKAGE_LIST
				;;

			--preseed)
				LIVE_PRESEED="${2}"; shift 2
				export LIVE_PRESEED
				;;

			--proxy-ftp)
				LIVE_PROXY_FTP="${2}"; shift 2
				export LIVE_PROXY_FTP
				;;

			--proxy-http)
				LIVE_PROXY_HTTP="${2}"; shift 2
				export LIVE_PROXY_HTTP
				;;

			--repositories)
				LIVE_REPOSITORIES="${2}"; shift 2
				export LIVE_REPOSITORIES
				;;

			-s|--section)
				LIVE_SECTION="${2}"; shift 2
				export LIVE_SECTION
				;;

			--server-address)
				LIVE_SERVER_ADDRESS="${2}"; shift 2
				export LIVE_SERVER_ADDRESS
				;;

			--server-path)
				LIVE_SERVER_PATH="${2}"; shift 2
				export LIVE_SERVER_PATH
				;;

			--templates)
				LIVE_TEMPLATES="${2}"; shift 2
				export LIVE_TEMPLATES
				;;

			--with-generic-indices)
				LIVE_GENERIC_INDICES="yes"; shift
				export LIVE_GENERIC_INDICES
				;;

			--without-generic-indices)
				LIVE_GENERIC_INDICES="no"; shift
				export LIVE_GENERIC_INDIDCES
				;;

			--with-recommends)
				LIVE_RECOMMENDS="yes"; shift
				export LIVE_RECOMMENDS
				;;

			--without-recommends)
				LIVE_RECOMMENDS="no"; shift
				export LIVE_RECOMMENDS
				;;

			--with-daemons)
				LIVE_DAEMONS="yes"; shift
				export LIVE_DAEMONS
				;;

			--without-daemons)
				LIVE_DAEMONS="no"; shift
				export LIVE_DEAMONS
				;;

			--with-source)
				LIVE_SOURCE="yes"; shift
				export LIVE_SOURCE
				;;

			--without-source)
				LIVE_SOURCE="no"; shift
				export LIVE_SOURCE
				;;

			-h|--help)
				Help; shift
				;;

			-u|--usage)
				Usage 0; shift
				;;

			-v|--version)
				Version; shift
				;;

			--)
				shift; break
				;;

			*)
				echo "Internal error."
				exit 1
				;;
		esac
	done

	# Initialising
	lh_testroot
	Configuration
	Defaults

	# Building live system
	lh_cdebootstrap
	Chroot

	# Building live image
	lh_buildbinary
	lh_buildsource
}

Main "${@}"