summaryrefslogtreecommitdiff
path: root/helpers/lh_binary_syslinux
blob: 5384232d6313623da675c2e175e54059073eed61 (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
#!/bin/sh

# lh_binary_syslinux(1) - installs syslinux

set -e

# Source common functions
for FUNCTION in /usr/share/live-helper/functions/*.sh
do
	. ${FUNCTION}
done

# Reading configuration files
Read_conffile config/common
Read_conffile config/bootstrap
Read_conffile config/image
Set_defaults

# Requiring stage file
Require_stagefile "${LIVE_ROOT}"/.stage/bootstrap

# Checking lock file
Check_lockfile "${LIVE_ROOT}"/.lock

# Creating lock file
Create_lockfile "${LIVE_ROOT}"/.lock

# Checking stage file
Check_stagefile "${LIVE_ROOT}"/.stage/binary_syslinux

if [ "${LIVE_ARCHITECTURE}" != "amd64" ] && [ "${LIVE_ARCHITECTURE}" != "i386" ]
then
	echo "W: skipping binary_syslinux, foreign architecture."
	exit 0
fi

if [ "${LIVE_SYSLINUX}" = "enabled" ]
then
	if [ ! -f "${LIVE_CHROOT}"/usr/bin/syslinux ]
	then
		PACKAGES="${PACKAGES} syslinux"
	fi

	if [ -n "${PACKAGES}" ]
	then
		# Installing symlinks
		case "${LH_APT}" in
			apt)
				Chroot "apt-get install --yes ${PACKAGES}"
				;;

			aptitude)
				Chroot "aptitude install --assume-yes ${PACKAGES}"
				;;
		esac
	fi

	if [ -n "${LIVE_ENCRYPTION}" ]
	then
		LIVE_BOOTAPPEND="${LIVE_BOOTAPPEND} encryption=${LIVE_ENCRYPTION}"
	fi

	case "${LIVE_BINARY_IMAGE}" in
		iso)
			# Copying syslinux
			mkdir -p "${LIVE_ROOT}"/binary/isolinux
			cp "${LIVE_CHROOT}"/usr/lib/syslinux/isolinux.bin "${LIVE_ROOT}"/binary/isolinux
			cp -r "${LIVE_TEMPLATES}"/syslinux/* "${LIVE_ROOT}"/binary/isolinux

			# Copying splash screen
			if [ -n "${LIVE_SYSLINUX_SPLASH}" ]
			then
				cp "${LIVE_SYSLINUX_SPLASH}" "${LIVE_ROOT}/binary/isolinux/splash.rle"
			fi

			# Configure syslinux templates
			sed -i -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" "${LIVE_ROOT}"/binary/isolinux/isolinux.cfg
			sed -i -e "s/LIVE_DATE/${DATE}/" "${LIVE_ROOT}"/binary/isolinux/f1.txt
			sed -i -e "s/LIVE_VERSION/${VERSION}/" "${LIVE_ROOT}"/binary/isolinux/f10.txt

			# Remove unused files
			rm -f "${LIVE_ROOT}"/binary/isolinux/pxelinux.cfg
			;;

		net)
			# Copying syslinux
			mkdir -p "${LIVE_ROOT}"/tftpboot
			cp "${LIVE_CHROOT}"/usr/lib/syslinux/pxelinux.0 "${LIVE_ROOT}"/tftpboot

			# Install syslinux templates
			mkdir -p "${LIVE_ROOT}"/tftpboot/pxelinux.cfg
			cp -r "${LIVE_TEMPLATES}"/syslinux/* "${LIVE_ROOT}"/tftpboot/pxelinux.cfg
			mv "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/pxelinux.cfg "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/default
			sed -i -e 's#splash.rle#pxelinux.cfg/splash.rle#' "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/isolinux.txt

			# Copying splash screen
			if [ -n "${LIVE_SYSLINUX_SPLASH}" ]
			then
				cp "${LIVE_SYSLINUX_SPLASH}" "${LIVE_ROOT}/tftpboot/pxelinux.cfg/splash.rle"
			fi

			# Configure syslinux templates
			sed -i -e "s/LIVE_SERVER_ADDRESS/${LIVE_SERVER_ADDRESS}/" -e "s#LIVE_SERVER_PATH#${LIVE_SERVER_PATH}#" -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/default
			sed -i -e "s/LIVE_DATE/${DATE}/" "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/f1.txt
			sed -i -e "s/LIVE_VERSION/${VERSION}/" "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/f10.txt

			# Remove unused files
			rm -f "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/isolinux.cfg
			;;

		usb)
			# Copying syslinux
			mkdir -p "${LIVE_ROOT}"/binary
			cp "${LIVE_CHROOT}"/usr/lib/syslinux/isolinux.bin "${LIVE_ROOT}"/binary/syslinux.bin
			cp -r "${LIVE_TEMPLATES}"/syslinux/* "${LIVE_ROOT}"/binary
			mv "${LIVE_ROOT}"/binary/isolinux.cfg "${LIVE_ROOT}"/binary/syslinux.cfg
			mv "${LIVE_ROOT}"/binary/isolinux.txt "${LIVE_ROOT}"/binary/syslinux.txt
			sed -i -e "s/isolinux.txt/syslinux.txt/" "${LIVE_ROOT}"/binary/syslinux.cfg

			# Copying splash screen
			if [ -n "${LIVE_SYSLINUX_SPLASH}" ]
			then
				cp "${LIVE_SYSLINUX_SPLASH}" "${LIVE_ROOT}/binary/splash.rle"
			fi

			# Configure syslinux templates
			sed -i -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" "${LIVE_ROOT}"/binary/syslinux.cfg
			sed -i -e "s/LIVE_DATE/${DATE}/" "${LIVE_ROOT}"/binary/f1.txt
			sed -i -e "s/LIVE_VERSION/${VERSION}/" "${LIVE_ROOT}"/binary/f10.txt

			# Remove unused files
			rm -f "${LIVE_ROOT}"/binary/pxelinux.cfg
			;;
	esac

	if [ -n "${PACKAGES}" ]
	then
		# Removing syslinux
		case "${LH_APT}" in
			apt)
				Chroot "apt-get remove --purge --yes ${PACKAGES}"
				;;

			aptitude)
				Chroot "aptitude purge --assume-yes ${PACKAGES}"
				;;
		esac
	fi

	# Creating stage file
	Create_stagefile "${LIVE_ROOT}"/.stage/binary_syslinux
fi