summaryrefslogtreecommitdiff
path: root/helpers/lh_config
blob: 41c0432503ae0bd0a62dacc15d7e9a2e66095b32 (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
#!/bin/sh

# lh_config(1) - create configuration for live-helper(7)
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.

set -e

# Including common functions
LH_BASE="${LH_BASE:-/usr/share/live-helper}"

for FUNCTION in "${LH_BASE}"/functions/*.sh
do
	. "${FUNCTION}"
done

# Setting static variables
DESCRIPTION="create configuration for live-helper(7)"
HELP=""
USAGE="${PROGRAM} [--force]"

Arguments "${@}"

CONFIG="${1}"

if [ -n "${LH_CONFIG}" ]
then
	if [ -d ${LH_BASE:-/usr/share/live-helper}/configs/"${LH_CONFIG}" ]
	then
		mkdir "${LH_CONFIG}"
		cp -r ${LH_BASE:-/usr/share/live-helper}/configs/"${LH_CONFIG}" "${LH_CONFIG}"/config

		LIVE_ROOT="${LH_CONFIG}"
		CONFIG=""
	else
		Echo_error "Couldn't find config ${LH_CONFIG} in ${LH_BASE:-/usr/share/live-helper}/configs/."
	fi
fi

if [ "${CONFIG}" != "newconfig" ]
then
	# Source existing configuration
	Read_conffile "${LIVE_ROOT}"/config/common
	Read_conffile "${LIVE_ROOT}"/config/bootstrap
	Read_conffile "${LIVE_ROOT}"/config/chroot
	Read_conffile "${LIVE_ROOT}"/config/binary
	Read_conffile "${LIVE_ROOT}"/config/source
fi

# Setting defaults
Set_defaults

# Creating bootstrap configuration
mkdir -p "${LIVE_ROOT}"/config
mkdir -p "${LIVE_ROOT}"/config/includes
mkdir -p "${LIVE_ROOT}"/config/templates

# Creating live-helper configuration
cat > "${LIVE_ROOT}"/config/common << EOF
# config/common - common options for live-helper(7)

# \$LH_APT: set package manager
# (Default: ${LH_APT})
LH_APT="${LH_APT}"

# \$LH_APT_FTPPROXY: set apt/aptitude ftp proxy
# (Default: autodetected or empty)
LH_APT_FTPPROXY="${LH_APT_FTPPROXY}"

# \$LH_APT_HTTPPROXY: set apt/aptitude http proxy
# (Default: autodetected or empty)
LH_APT_HTTPPROXY="${LH_APT_HTTPPROXY}"

# \$LH_APT_PDIFFS: set apt/aptitude pdiff indices
# (Default: ${LH_APT_PDIFFS})
LH_APT_PDIFFS="${LH_APT_PDIFFS}"

# \$LH_APT_PIPELINE: set apt/aptitude pipeline depth
# (Default: ${LH_APT_PIPELINE})
LH_APT_PIPELINE="${LH_APT_PIPELINE}"

# \$LH_APT_RECOMMENDS: set apt/aptitude recommends
# (Default: ${LH_APT_RECOMMENDS})
LH_APT_RECOMMENDS="${LH_APT_RECOMMENDS}"

# \$LH_APT_SECURE: set apt/aptitude security
# (Default: ${LH_APT_SECURE})
LH_APT_SECURE="${LH_APT_SECURE}"

# \$LH_BOOTSTRAP: set bootstrap program
# (Default: ${LH_BOOTSTRAP})
LH_BOOTSTRAP="${LH_BOOTSTRAP}"

# \$LH_CACHE_INDICES: control if downloaded package indices should be cached
# (Default: ${LH_CACHE_INDICES})
LH_CACHE_INDICES="${LH_CACHE_INDICES}"

# \$LH_CACHE_PACKAGES: control if downloaded packages files should be cached
# (Default: ${LH_CACHE_PACKAGES})
LH_CACHE_PACKAGES="${LH_CACHE_PACKAGES}"

# \$LH_CACHE_STAGES: control if completed stages should be cached
# (Default: ${LH_CACHE_STAGES})
LH_CACHE_STAGES="${LH_CACHE_STAGES}"

# \$LH_DEBCONF_FRONTEND: set debconf(1) frontend to use
# (Default: ${LH_DEBCONF_FRONTEND})
LH_DEBCONF_FRONTEND="${LH_DEBCONF_FRONTEND}"

# \$LH_DEBCONF_NOWARNINGS: set debconf(1) warnings
# (Default: ${LH_DEBCONF_NOWARNINGS})
LH_DEBCONF_NOWARNINGS="${LH_DEBCONF_NOWARNINGS}"

# \$LH_DEBCONF_PRIORITY: set debconf(1) priority to use
# (Default: ${LH_DEBCONF_PRIORITY})
LH_DEBCONF_PRIORITY="${LH_DEBCONF_PRIORITY}"

# \$LH_GENISOIMAGE: set genisoimage program
# (Default: ${LH_GENISOIMAGE})
LH_GENISOIMAGE="${LH_GENISOIMAGE}"

# \$LH_INITRAMFS: set initramfs hook
# (Default: ${LH_INITRAMFS})
LH_INITRAMFS="${LH_INITRAMFS}"

# \$LH_LOSETUP: set losetup program
# (Default: autodetected)
LH_LOSETUP="${LH_LOSETUP}"

# \$LH_MODE: set distribution mode
# (Default: ${LH_MODE})
LH_MODE="${LH_MODE}"

# \$LH_ROOT_COMMAND: use sudo or equivalent
# (Default: empty)
#LH_ROOT_COMMAND="sudo"

# \$LH_TASKSEL: set tasksel program
# (Default: ${LH_TASKSEL})
LH_TASKSEL="${LH_TASKSEL}"

# \$LIVE_ROOT: set root directory
# (Default: ${LIVE_ROOT})
LIVE_ROOT="${LIVE_ROOT}"

# \$LIVE_INCLUDES: set includes
# (Default: ${LIVE_INCLUDES})
LIVE_INCLUDES="${LIVE_INCLUDES}"

# \$LIVE_TEMPLATES: set templates
# (Default: ${LIVE_TEMPLATES})
LIVE_TEMPLATES="${LIVE_TEMPLATES}"

# Live-helper options

# \$LH_BREAKPOINTS: enable breakpoints
# (Default: ${LH_BREAKPOINTS})
#LH_BREAKPOINTS="${LH_BREAKPOINTS}"

# \$LH_DEBUG: enable debug
# (Default: ${LH_DEBUG})
#LH_DEBUG="${LH_DEBUG}"

# \$LH_FORCE: enable force
# (Default: ${LH_FORCE})
#LH_FORCE="${LH_FORCE}"

# \$LH_QUIET: enable quiet
# (Default: ${LH_QUIET})
#LH_QUIET="${LH_QUIET}"

# \$LH_VERBOSE: enable verbose
# (Default: ${LH_VERBOSE})
#LH_VERBOSE="${LH_VERBOSE}"
EOF

# Creating lh_bootstrap_* configuration
cat > "${LIVE_ROOT}"/config/bootstrap << EOF
# config/bootstrap - options for live-helper(7), bootstrap stage

# \$LIVE_ARCHITECTURE: select chroot architecture
# (Default: autodetected)
LIVE_ARCHITECTURE="${LIVE_ARCHITECTURE}"

# \$LIVE_BOOTSTRAP_CONFIG: set distribution config directory
# (Default: empty)
LIVE_BOOTSTRAP_CONFIG="${LIVE_BOOTSTRAP_CONFIG}"

# \$LIVE_BOOTSTRAP_FLAVOUR: select flavour to use
# (Default: ${LIVE_BOOTSTRAP_FLAVOUR})
LIVE_BOOTSTRAP_FLAVOUR="${LIVE_BOOTSTRAP_FLAVOUR}"

# \$LIVE_BOOTSTRAP_KEYRING: set distribution keyring
# (Default: empty)
LIVE_BOOTSTRAP_KEYRING="${LIVE_BOOTSTRAP_KEYRING}"

# \$LIVE_DISTRIBUTION: select distribution to use
# (Default: ${LIVE_DISTRIBUTION})
LIVE_DISTRIBUTION="${LIVE_DISTRIBUTION}"

# \$LIVE_MIRROR_BOOTSTRAP: set mirror to fetch packages from
# (Default: ${LIVE_MIRROR_BOOTSTRAP})
LIVE_MIRROR_BOOTSTRAP="${LIVE_MIRROR_BOOTSTRAP}"

# \$LIVE_MIRROR_BOOTSTRAP_SECURITY: set security mirror to fetch packages from
# (Default: ${LIVE_MIRROR_BOOTSTRAP_SECURITY})
LIVE_MIRROR_BOOTSTRAP_SECURITY="${LIVE_MIRROR_BOOTSTRAP_SECURITY}"

# \$LIVE_MIRROR_BINARY: set mirror which ends up in the image
# (Default: ${LIVE_MIRROR_BINARY})
LIVE_MIRROR_BINARY="${LIVE_MIRROR_BINARY}"

# \$LIVE_MIRROR_BINARY_SECURITY: set security mirror which ends up in the image
# (Default: ${LIVE_MIRROR_BINARY_SECURITY})
LIVE_MIRROR_BINARY_SECURITY="${LIVE_MIRROR_BINARY_SECURITY}"

# \$LIVE_SECTIONS: select section(s) to use
# (Default: ${LIVE_SECTIONS})
LIVE_SECTIONS="${LIVE_SECTIONS}"
EOF

# Creating lh_chroot_* configuration
mkdir -p "${LIVE_ROOT}"/config/chroot_local-hooks
mkdir -p "${LIVE_ROOT}"/config/chroot_local-includes
mkdir -p "${LIVE_ROOT}"/config/chroot_local-packages
mkdir -p "${LIVE_ROOT}"/config/chroot_local-packageslists
mkdir -p "${LIVE_ROOT}"/config/chroot_sources

cat > "${LIVE_ROOT}"/config/chroot << EOF
# config/chroot - options for live-helper(7), chroot stage

# \$LIVE_CHROOT_FILESYSTEM: set chroot filesystem
# (Default: ${LIVE_CHROOT_FILESYSTEM})
LIVE_CHROOT_FILESYSTEM="${LIVE_CHROOT_FILESYSTEM}"

# \$LIVE_UNION_FILESYSTEM: set union filesystem
# (Default: ${LIVE_UNION_FILESYSTEM}
LIVE_UNION_FILESYSTEM="${LIVE_UNION_FILESYSTEM}"

# \$LIVE_HOOKS: set hook commands
# (Default: empty)
LIVE_HOOKS="${LIVE_HOOKS}"

# \$LIVE_INTERACTIVE: set interactive build
# (Default: ${LIVE_INTERACTIVE})
LIVE_INTERACTIVE="${LIVE_INTERACTIVE}"

# \$LIVE_KEYRING_PACKAGES: set keyring packages
# (Default: empty)
LIVE_KEYRING_PACKAGES="${LIVE_KEYRING_PACKAGES}"

# \$LIVE_LANGUAGE: set language to use
# (Default: empty)
LIVE_LANGUAGE="${LIVE_LANGUAGE}"

# \$LIVE_LINUX_FLAVOURS: set kernel flavour to use
# (Default: autodetected)
LIVE_LINUX_FLAVOURS="${LIVE_LINUX_FLAVOURS}"

# \$LIVE_LINUX_PACKAGES: set kernel packages to use
# (Default: autodetected)
LIVE_LINUX_PACKAGES="${LIVE_LINUX_PACKAGES}"

# \$LIVE_PACKAGES: set packages to install
# (Default: empty)
LIVE_PACKAGES="${LIVE_PACKAGES}"

# \$LIVE_PACKAGES_LISTS: set package list to install
# (Default: ${LIVE_PACKAGES_LISTS})
LIVE_PACKAGES_LISTS="${LIVE_PACKAGES_LISTS}"

# \$LIVE_TASKS: set tasks to install
# (Default: empty)
LIVE_TASKS="${LIVE_TASKS}"

# \$LIVE_SECURITY: enable security updates
# (Default: ${LIVE_SECURITY})
LIVE_SECURITY="${LIVE_SECURITY}"

# \$LIVE_SYMLINKS: enable symlink convertion
# (Default: ${LIVE_SYMLINKS})
LIVE_SYMLINKS="${LIVE_SYMLINKS}"

# \$LIVE_SYSVINIT: enable sysvinit
# (Default: ${LIVE_SYSVINIT})
LIVE_SYSVINIT="${LIVE_SYSVINIT}"
EOF

# Creating lh_binary_* configuration
mkdir -p "${LIVE_ROOT}"/config/binary_grub
mkdir -p "${LIVE_ROOT}"/config/binary_local-debs
mkdir -p "${LIVE_ROOT}"/config/binary_local-hooks
mkdir -p "${LIVE_ROOT}"/config/binary_local-includes
mkdir -p "${LIVE_ROOT}"/config/binary_local-udebs
mkdir -p "${LIVE_ROOT}"/config/binary_rootfs
mkdir -p "${LIVE_ROOT}"/config/binary_syslinux

cat > "${LIVE_ROOT}"/config/binary << EOF
# config/binary - options for live-helper(7), binary stage

# \$LIVE_BINARY_IMAGES: set image type
# (Default: ${LIVE_BINARY_IMAGES})
LIVE_BINARY_IMAGES="${LIVE_BINARY_IMAGES}"

# \$LIVE_BINARY_INDICES: set apt/aptitude generic indices
# (Default: ${LIVE_BINARY_INDICES})
LIVE_BINARY_INDICES="${LIVE_BINARY_INDICES}"

# \$LIVE_BOOTAPPEND: set boot parameters
# (Default: empty)
LIVE_BOOTAPPEND="${LIVE_BOOTAPPEND}"

# \$LIVE_BOOTLOADER: set bootloader
# (Default: ${LIVE_BOOTLOADER})
LIVE_BOOTLOADER="${LIVE_BOOTLOADER}"

# \${LIVE_CHROOT_BUILD: control if we build binary images chrooted
# (Default: ${LIVE_CHROOT_BUILD})
# DO NEVER, *NEVER*, *N*E*V*E*R* SET THIS OPTION to disabled.
LIVE_CHROOT_BUILD="${LIVE_CHROOT_BUILD}"

# \$LIVE_DEBIAN_INSTALLER: set debian-installer
# (Default: ${LIVE_DEBIAN_INSTALLER})
LIVE_DEBIAN_INSTALLER="${LIVE_DEBIAN_INSTALLER}"

# \$LIVE_ENCRYPTION: set encrytion
# (Default: empty)
LIVE_ENCRYPTION="${LIVE_ENCRYPTION}"

# \$LIVE_GRUB_SPLASH: set custom grub splash
# (Default: empty)
LIVE_GRUB_SPLASH="${LIVE_GRUB_SPLASH}"

# \$LIVE_HOSTNAME: set hostname
# (Default: ${LIVE_HOSTNAME})
LIVE_HOSTNAME="${LIVE_HOSTNAME}"

# \$LIVE_ISO_APPLICATION: set iso author
# (Default: ${LIVE_ISO_APPLICATION})
LIVE_ISO_APPLICATION="${LIVE_ISO_APPLICATION}"

# \$LIVE_ISO_PREPARER: set iso preparer
# (Default: ${LIVE_ISO_PREPARER})
LIVE_ISO_PREPARER="${LIVE_ISO_PREPARER}"

# \$LIVE_ISO_PUBLISHER: set iso preparer
# (Default: ${LIVE_ISO_PUBLISHER})
LIVE_ISO_PUBLISHER="${LIVE_ISO_PUBLISHER}"

# \$LIVE_ISO_VOLUME: set iso volume (max 32 chars)
# (Default: ${LIVE_ISO_VOLUME})
LIVE_ISO_VOLUME="${LIVE_ISO_VOLUME}"

# \$LIVE_MEMTEST: set memtest
# (Default: ${LIVE_MEMTEST})
LIVE_MEMTEST="${LIVE_MEMTEST}"

# \$LIVE_NET_FILESYSTEM: set netboot filesystem
# (Default: ${LIVE_NET_FILESYSTEM})
LIVE_NET_FILESYSTEM="${LIVE_NET_FILESYSTEM}"

# \$LIVE_NET_MOUNTOPTIONS: set nfsopts
# (Default: empty)
LIVE_NET_MOUNTOPTIONS="${LIVE_NET_MOUNTOPTIONS}"

# \$LIVE_NET_PATH: set netboot server directory
# (Default: ${LIVE_NET_PATH})
LIVE_NET_PATH="${LIVE_NET_PATH}"

# \$LIVE_NET_SERVER: set netboot server address
# (Default: ${LIVE_NET_SERVER})
LIVE_NET_SERVER="${LIVE_NET_SERVER}"

# \$LIVE_SYSLINUX_SPLASH: set custom syslinux splash
# (Default: empty)
LIVE_SYSLINUX_SPLASH="${LIVE_SYSLINUX_SPLASH}"

# \$LIVE_USERNAME: set username
# (Default: ${LIVE_USERNAME})
LIVE_USERNAME="${LIVE_USERNAME}"
EOF

# Creating lh_source_* configuration
cat > "${LIVE_ROOT}"/config/source << EOF
# config/source - options for live-helper(7), source stage

# \$LIVE_SOURCE: set source option
# (Default: ${LIVE_SOURCE})
LIVE_SOURCE="${LIVE_SOURCE}"

# \$LIVE_SOURCE_IMAGES: set image type
# (Default: ${LIVE_SOURCE_IMAGES})
LIVE_SOURCE_IMAGES="${LIVE_SOURCE_IMAGES}"
EOF

if [ "${CONFIG}" = "clone" ]
then
	# Read package selection
	echo `dpkg --get-selections | awk '{ print $1 }'` > config/chroot_local-packageslists/local-system

	# Read debconf questions
	if [ ! -f /usr/bin/debconf-get-selections ]
	then
		Echo_warning "Please install 'debconf-utils' in order to use this feature."
	else
		debconf-get-selections | grep -v deinstall | cut -f1 > config/chroot_local-preseed/local-system
	fi
fi