summaryrefslogtreecommitdiff
path: root/helpers/lh_binary_syslinux
blob: d80d66eba7a1858b3ffd721a9999839d25cc09d7 (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 .stage/bootstrap

# Checking lock file
Check_lockfile .lock

# Creating lock file
Create_lockfile .lock

# Checking stage file
Check_stagefile .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 chroot/usr/bin/syslinux ]
	then
		PACKAGES="${PACKAGES} syslinux"
	fi

	if [ -n "${PACKAGES}" ]
	then
		# Installing symlinks
		case "${LH_APT}" in
			apt|apt-get)
				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 binary/isolinux
			cp chroot/usr/lib/syslinux/isolinux.bin binary/isolinux
			cp -r "${LIVE_TEMPLATES}"/syslinux/* binary/isolinux

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

			# Configure syslinux templates
			sed -i -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" binary/isolinux/isolinux.cfg
			sed -i -e "s/LIVE_DATE/`date +%Y%m%d`/" binary/isolinux/f1.txt
			sed -i -e "s/LIVE_VERSION/${VERSION}/" binary/isolinux/f10.txt

			# Remove unused files
			rm -f binary/isolinux/pxelinux.cfg
			;;

		net)
			# Copying syslinux
			mkdir -p tftpboot
			cp chroot/usr/lib/syslinux/pxelinux.0 tftpboot

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

			# Copying splash screen
			if [ -n "${LIVE_SYSLINUX_SPLASH}" ]
			then
				cp "${LIVE_SYSLINUX_SPLASH}" ftpboot/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}#" tftpboot/pxelinux.cfg/default
			sed -i -e "s/LIVE_DATE/`date +%Y%m%d`/" tftpboot/pxelinux.cfg/f1.txt
			sed -i -e "s/LIVE_VERSION/${VERSION}/" tftpboot/pxelinux.cfg/f10.txt

			# Remove unused files
			rm -f tftpboot/pxelinux.cfg/isolinux.cfg
			;;

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

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

			# Configure syslinux templates
			sed -i -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" binary/syslinux.cfg
			sed -i -e "s/LIVE_DATE/`date +%Y%m%d`/" binary/f1.txt
			sed -i -e "s/LIVE_VERSION/${VERSION}/" binary/f10.txt

			# Remove unused files
			rm -f binary/pxelinux.cfg
			;;
	esac

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

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

	# Creating stage file
	Create_stagefile .stage/binary_syslinux
fi