summaryrefslogtreecommitdiff
path: root/make-live.sh
blob: b0a9585180369e9bc29f7fd6e77d34b0785e4ce1 (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
#!/bin/sh

# make-live - An utility for building 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

set -e

PROGRAM="`basename ${0}`"
VERSION="0.99"

# Source default configuration
if [ -r /etc/make-live.conf ]
then
	. /etc/make-live.conf
fi

# Source alternate configuration
if [ ! -z "${LIVE_CONFFILE}" ]
then
	if [ -r "${LIVE_CONFFILE}" ]
	then
		. "${LIVE_CONFFILE}"
	else
		echo "W: could not read ${LIVE_CONFFILE}, using defaults."
	fi
fi

# Source scriptlets
for SCRIPT in /usr/share/make-live/scripts/*.sh
do
	. "${SCRIPT}"
done

Help ()
{
	echo "make-live - An utility for building Debian Live systems."
	echo
	echo "Usage: ${PROGRAM} [-a ARCHITECTURE] [-c FILE] [--clone DIRECTORY] [-d DISTRIBUTION] [--debug] [-f FILESYSTEM] [--flavour FLAVOUR] [--hook \"COMMAND...\"] [--include-image FILE|DIRECTORY] [--include-rootfs FILE|DIRECTORY] [--linux-image FLAVOUR] [--logfile FILE] [-p|--package-list FILE] [--preseed FILE] [--rootfs DIRECTORY] [-s|--section \"SECTION...\"] [--splashy [THEME]] [-t|--type TYPE] [--templates DIRECTORY] [--verbose] [LIST]"
	echo
	echo "Values:"
	echo "  Architectures: alpha, amd64, arm, hppa, i386, ia64, m68k, powerpc, s390, sparc."
	echo "  Distributions: oldstable, stable, testing, unstable."
	echo "  Filesystems: ext2, squashfs, xfs."
	echo "  Flavours: bootable, build, minimal, standard."
	echo "  Linux Images: alpha-generic, alpha-smp, alpha-legacy, amd64-k8, amd64-k8-smp, em64t-p4, em64t-p4-smp, footbridge, ixp4xx, nslu2, rpc, s3c2410, parisc, parisc-smp, parisc64, parisc64-smp, 486, 686, k7, itanium, itanium-smp, mckinley, mckinley-smp, amiga, mac, r4k-ip22, r5k-ip32, sb1-bcm91250a, sb1a-bcm91480b, r5k-cobalt, r3k-kn02, r4k-kn04, powerpc, powerpc-smp, powerpc-miboot, powerpc64, s390, s390x, sparc32, sparc64, sparc64-smp."
	echo "  Sections: main, contrib, non-free."
	echo "  Types: iso, net."
	echo "  Lists: gnome, gnome-core, gnome-full, kde, kde-core, kde-core-i18n, kde-extra, kde-extra-i18n, kde-full, kde-full-i18n, kde-18n, standard-i18n, x11, x11-core, xfce."
	echo
	echo "Options:"
	echo "  -h, --help:    display this help and exit."
	echo "  -u, --usage:   show usage and exit."
	echo "  -v, --version: output version information and exit."
	echo
	echo "Environment:"
	echo "  All settings can also be done through environment variables. Please see make-live.conf(8) for more information."
	echo
	echo "Report bugs to Debian Live project <http://live.debian.net>."
	exit 1
}

Usage ()
{
	echo "make-live - An utility for building Debian Live systems."
	echo
	echo "Usage: ${PROGRAM} [-a ARCHITECTURE] [-c FILE] [--clone DIRECTORY] [-d DISTRIBUTION] [--debug] [-f FILESYSTEM] [--flavour FLAVOUR] [--hook "COMMAND..."] [--include-image FILE|DIRECTORY] [--include-rootfs FILE|DIRECTORY] [--linux-image FLAVOUR] [--logfile FILE] [-p|--package-list FILE] [--preseed FILE] [--rootfs DIRECTORY] [-s|--section "SECTION..."] [--splashy [THEME]] [-t|--type TYPE] [--templates DIRECTORY] [--verbose] [LIST]"
	echo
	echo "Try \"${PROGRAM} --help\" for more information."
	exit 1
}

Version ()
{
	echo "make-live, 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 "Homepage: Debian Live project <http://live.debian.net/>"
	exit 1
}

Main ()
{
	ARGUMENTS=`getopt --shell=sh --name="${PROGRAM}" \
		--options="a:c:d:f:p:s:t:huv" \
		--longoptions="architecture:,conffile:,clone:,distribution:,debug,filesystem:,flavour:,hook:,include-image:,include-rootfs:,linux-image:,logfile:,package-list:,preseed:,rootfs:,section:,splashy::,type:,templates:,verbose" \
		-- "${@}"`

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

	eval set -- "${ARGUMENTS}"

	while true
	do
		case "${1}" in
			-a|--architecture)
				LIVE_ARCHITECTURE="${2}"; shift 2
				;;

			-c|--conffile)
				LIVE_CONFIG="${2}"; shift 2
				;;

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

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

			--debug)
				LIVE_DEBUG="1"
				LIVE_VERBOSE="1"; shift
				;;

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

			--flavour)
				LIVE_FLAVOUR="${2}"; shift 2
				;;

			--hook)
				LIVE_HOOK="${2}"; shift 2
				;;

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

			--include-rootfs)
				LIVE_INCLUDE_ROOTFS="${2}"; shift 2
				;;

			--linux-image)
				LIVE_LINUX="${2}"; shift 2
				;;

			--logfile)
				LIVE_LOGFILE="${2}"; shift 2
				;;

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

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

			--rootfs)
				LIVE_ROOTFS="${2}"; shift 2
				;;

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

			--splashy)
				LIVE_SPLASHY="1" 
				case "${2}" in
					"") 
						shift 2;
						;;
					*)
						LIVE_SPLASHY_THEME=${2} ; shift 2
						;;
				esac
				;;

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

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

			--verbose)
				LIVE_VERBOSE="1"; shift
				;;

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

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

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

			--)
				shift; break
				;;

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

	LIVE_LIST="${1}"

	# Enabling debug
	if [ "${LIVE_DEBUG}" ]
	then
		set +x
	fi

	# Setting defaults
	Defaults

	# Initial checks
	Init

	# Bootstrap chroot
	Bootstrap

	# Customize chroot
	Chroot

	# Create type
	if [ "${LIVE_TYPE}" ]
	then
		case ${LIVE_TYPE} in
			iso)
				LIVE_TYPE="Iso"
				;;

			net)
				LIVE_TYPE="Net"
				;;

			*)
				echo "You specified a wrong image type"
				Help
				;;
		esac

		${LIVE_TYPE}
	else
		Iso
	fi
}

Main "${@}"