binary_syslinux 7.59 KB
Newer Older
1
2
#!/bin/sh

3
## live-build(7) - System Build Scripts
4
## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
5
##
6
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7
8
9
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.

10
11
12

set -e

13
# Including common functions
14
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
15

16
# Setting static variables
17
DESCRIPTION="$(Echo 'installs syslinux into binary')"
18
19
20
21
22
HELP=""
USAGE="${PROGRAM} [--force]"

Arguments "${@}"

23
# Reading configuration files
24
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25
26
Set_defaults

27
if [ "${LB_BOOTLOADER}" != "syslinux" ]
28
29
30
31
then
	exit 0
fi

32
Echo_message "Begin installing syslinux..."
33

34
# Requiring stage file
35
Require_stagefile .build/config .build/bootstrap
36

37
# Checking stage file
38
Check_stagefile .build/binary_syslinux
39

40
# Checking lock file
41
Check_lockfile .lock
42
43

# Creating lock file
44
Create_lockfile .lock
45

46
# Check architecture
47
48
Check_architectures amd64 i386
Check_crossarchitectures
49

50
# Assembling image specifics
51
case "${LIVE_IMAGE_TYPE}" in
52
	iso*)
53
		_BOOTLOADER="isolinux"
54
55

		case "${LB_MODE}" in
56
			progress-linux)
57
58
59
60
61
62
63
				_TARGET="binary/boot"
				;;

			*)
				_TARGET="binary/isolinux"
				;;
		esac
64
65
		;;

66
	netboot)
67
		_BOOTLOADER="pxelinux"
68
		_TARGET="tftpboot"
69
		;;
70

71
	hdd*|*)
72
		_BOOTLOADER="syslinux"
73
74

		case "${LB_MODE}" in
75
			progress-linux)
76
77
78
79
80
81
82
				_TARGET="binary/boot"
				;;

			*)
				_TARGET="binary/syslinux"
				;;
		esac
83
84
85
		;;
esac

86
87
88
89
90
91
92
93
94
95
96
97
98
99
if [ -e "config/bootloaders/${_BOOTLOADER}" ]
then
	# Internal local copy
	_SOURCE="config/bootloaders/${_BOOTLOADER}"
else
	# Internal system copy
	if [ -n "${LIVE_BUILD}" ]
	then
		_SOURCE="${LIVE_BUILD}/share/bootloaders/${_BOOTLOADER}"
	else
		_SOURCE="/usr/share/live/build/bootloaders/${_BOOTLOADER}"
	fi
fi

100
101
102
103
104
105
# Checking depends
case "${LB_BUILD_WITH_CHROOT}" in
	true)
		Check_package chroot/usr/bin/syslinux syslinux
		Check_package chroot/usr/lib/syslinux syslinux-common

106
107
108
109
		if ls "${_SOURCE}"/*.svg* > /dev/null 2>&1
		then
			Check_package chroot/usr/bin/rsvg librsvg2-bin
		fi
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
		;;

	false)
		if [ ! -e /usr/bin/syslinux ]
		then
			# syslinux
			Echo_error "/usr/bin/syslinux - no such file."
			exit 1
		fi

		if [ ! -e /usr/lib/syslinux ]
		then
			# syslinux-common
			Echo_error "/usr/lib/syslinux - no such directory"
			exit 1
		fi

127
128
129
130
131
132
133
134
135
		if ls "${_SOURCE}"/*.svg* > /dev/null 2>&1
		then
			if [ ! -e /usr/bin/rsvg ]
			then
				# librsvg2-bin
				Echo_error "/usr/bin/rsvg - no such file"
				exit 1
			fi
		fi
136
137
138
		;;
esac

139
# Restoring cache
140
Restore_cache cache/packages.binary
141
142
143
144

# Installing depends
Install_package

145
# Copying files
146
147
case "${LB_BUILD_WITH_CHROOT}" in
	true)
148
		mkdir -p ${_TARGET}
149

150
		# Copy in two steps since the theme can have absolute symlinks and would therefore not be dereferenced correctly
151
152
		cp -a ${_SOURCE} chroot/root
		Chroot chroot cp -aL /root/$(basename ${_SOURCE}) /root/$(basename ${_SOURCE}).tmp || true
153
154
		cp -a chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET}
		rm -rf chroot/root/$(basename ${_SOURCE}) chroot/root/$(basename ${_SOURCE}).tmp
155
156
157
		;;

	false)
158
159
		mkdir -p ${_TARGET}

160
		cp -aL ${_SOURCE}/* ${_TARGET} || true
161
162
		;;
esac
163

164
# Configuring files
165
166
167
168
169
170
171
172
173
174
if [ -e "${_TARGET}/live.cfg.in" ]
then
	# This is all rather suboptimal.. needs prettifying at some point
	_FLAVOURS="$(echo ${LB_LINUX_FLAVOURS} | wc -w)"

	case "${_FLAVOURS}" in
		1)
			mv binary/live/vmlinuz-* binary/live/vmlinuz
			mv binary/live/initrd.img-* binary/live/initrd.img

175
			sed -e "s|@FLAVOUR@|${LB_LINUX_FLAVOURS}|g" \
176
			    -e "s|@LINUX@|/live/vmlinuz|g" \
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
			    -e "s|@INITRD@|/live/initrd.img|g" \
			"${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"

			rm -f "${_TARGET}/live.cfg.in"
			;;

		*)
			_NUMBER="0"

			for _FLAVOUR in ${LB_LINUX_FLAVOURS}
			do
				_NUMBER="$((${_NUMBER} + 1))"

				mv binary/live/vmlinuz-*-${_FLAVOUR} binary/live/vmlinuz${_NUMBER}
				mv binary/live/initrd.img-*-${_FLAVOUR} binary/live/initrd${_NUMBER}.img

193
194
				if [ "${_NUMBER}" -gt 1 ]
				then
195
					echo "" >> "${_TARGET}/live.cfg"
196
197
198
199
200
201
202
203
204
					grep -v 'menu default' "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
				else
					cat "${_TARGET}/live.cfg.in" >> "${_TARGET}/live.cfg"
				fi

				sed -i -e "s|@FLAVOUR@|${_FLAVOUR}|g" \
				       -e "s|@LINUX@|/live/vmlinuz${_NUMBER}|g" \
				       -e "s|@INITRD@|/live/initrd${_NUMBER}.img|g" \
				"${_TARGET}/live.cfg"
205
206
207
208
209
			done

			rm -f "${_TARGET}/live.cfg.in"
			;;
	esac
210
fi
211

212
eval _VERSION="$`echo RELEASE_${LB_DISTRIBUTION}`"
213

214
215
_DISTRIBUTION="${LB_DISTRIBUTION}"
_ARCHITECTURE="${LIVE_IMAGE_ARCHITECTURE}"
216

217
218
219
220
221
222
223
_DATE=$(date -R)
_YEAR="$(date +%Y)"
_MONTH="$(date +%m)"
_DAY="$(date +%d)"
_HOUR="$(date +%H)"
_MINUTE="$(date +%M)"
_SECOND="$(date +%S)"
224

225
_LINUX_VERSIONS="$(for _LINUX in chroot/boot/vmlinuz-* ; do chroot chroot apt-cache policy $(basename ${_LINUX} | sed -e 's|vmlinuz-|linux-image-|') | awk '/Installed: / { print $2 }' ; done | sort -Vru | tr "\n" " ")"
226

227
228
229
230
_LIVE_BUILD_VERSION="$(lb --version)"
_LIVE_BOOT_VERSION="$(chroot chroot apt-cache policy live-boot | awk '/Installed: / { print $2 }')"
_LIVE_CONFIG_VERSION="$(chroot chroot apt-cache policy live-config | awk '/Installed: / { print $2 }')"
_LIVE_TOOLS_VERSION="$(chroot chroot apt-cache policy live-tools | awk '/Installed: / { print $2 }')"
231

232
233
234
235
case "${LB_MODE}" in
	progress-linux)
		_PROJECT="Progress Linux"

236
		if ls config/package-lists/desktop-gnome.list*
237
		then
238
			_DESCRIPTION="Desktop GNOME"
239
240
241
242
		elif ls config/package-lists/server-lxc.list* > /dev/null 2>&1
		then
			_DESCRIPTION="Server LXC"
		else
243
			_DESCRIPTION="Base System"
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
		fi
		;;

	*)
		_PROJECT="Debian GNU/Linux"
		_DESCRIPTION=""
		;;
esac

for _FILE in "${_TARGET}"/*.cfg ${_TARGET}/*.svg
do
	if [ -e "${_FILE}" ]
	then
		sed -i  -e "s#@APPEND_LIVE@#${LB_BOOTAPPEND_LIVE}#g" \
			-e "s#@APPEND_LIVE_FAILSAFE@#${LB_BOOTAPPEND_LIVE_FAILSAFE}#g" \
			-e "s#@APPEND_INSTALL@#${LB_BOOTAPPEND_INSTALL}#g" \
			-e "s#@APPEND_INSTALL_FAILSAFE@#${LB_BOOTAPPEND_INSTALL_FAILSAFE}#g" \
			-e "s|@PROJECT@|${_PROJECT}|g" \
			-e "s|@DISTRIBUTION@|${_DISTRIBUTION}|g" \
			-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
			-e "s|@VERSION@|${_VERSION}|g" \
			-e "s|@ARCHITECTURE@|${_ARCHITECTURE}|g" \
			-e "s|@DESCRIPTION@|${_DESCRIPTION}|g" \
			-e "s|@DATE@|${_DATE}|g" \
			-e "s|@YEAR@|${_YEAR}|g" \
			-e "s|@MONTH@|${_MONTH}|g" \
			-e "s|@DAY@|${_DAY}|g" \
			-e "s|@HOUR@|${_HOUR}|g" \
			-e "s|@MINUTE@|${_MINUTE}|g" \
			-e "s|@SECOND@|${_SECOND}|g" \
			-e "s|@LINUX_VERSIONS@|${_LINUX_VERSIONS}|g" \
			-e "s|@LIVE_BUILD_VERSION@|${_LIVE_BUILD_VERSION}|g" \
			-e "s|@LIVE_BOOT_VERSION@|${_LIVE_BOOT_VERSION}|g" \
			-e "s|@LIVE_CONFIG_VERSION@|${_LIVE_CONFIG_VERSION}|g" \
			-e "s|@LIVE_TOOLS_VERSION@|${_LIVE_TOOLS_VERSION}|g" \
		"${_FILE}"
	fi
done
282

283
284
if [ -e "${_TARGET}/splash.svg" ]
then
285
286
287
288
289
290
291
292
293
294
295
296
	case "${LB_BUILD_WITH_CHROOT}" in
		true)
			cp "${_TARGET}/splash.svg" chroot
			Chroot chroot "rsvg --format png --height 480 --width 640 splash.svg splash.png"
			mv chroot/splash.png "${_TARGET}"
			rm -f chroot/splash.svg
			;;

		false)
			rsvg --format png --height 480 --width 640 "${_TARGET}/splash.svg" "${_TARGET}/splash.png"
			;;
	esac
297

298
299
	rm -f "${_TARGET}/splash.svg"
fi
300

301
case "${LB_MODE}" in
302
	progress-linux)
303
304
305
306
		for _FILE in "${_TARGET}/isolinux.bin" "${_TARGET}/isolinux.cfg" "${_TARGET}/syslinux.cfg"
		do
			if [ -e "${_FILE}" ]
			then
307
				mv "${_FILE}" "${_TARGET}/$(echo ${_FILE} | sed -e 's|.*linux|boot|')"
308
309
310
311
312
			fi
		done
		;;
esac

313
314
315
case "${LB_BUILD_WITH_CHROOT}" in
	true)
		# Saving cache
316
		Save_cache cache/packages.binary
317

318
319
		# Removing depends
		Remove_package
320
321
		;;
esac
322

323
# Creating stage file
324
Create_stagefile .build/binary_syslinux