blob: bf343863525fae987f51f09c75895b636519baea (
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
|
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2016-2020 The Debian Live team
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program 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
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
# Setting static variables
DESCRIPTION="Installs syslinux into binary"
USAGE="${PROGRAM} [--force]"
# Processing arguments and configuration files
Init_config_data "${@}"
Check_Any_Bootloader_Role "syslinux"
Echo_message "Begin installing syslinux..."
# Requiring stage file
Require_stagefile .build/config .build/bootstrap
# Checking stage file
Check_stagefile .build/binary_syslinux
# Acquire lock file
Acquire_lockfile
# Check architecture
Check_architectures amd64 i386
Check_crossarchitectures
case "${LB_INITRAMFS}" in
live-boot)
_INITRAMFS="live"
;;
*)
_INITRAMFS="boot"
;;
esac
# Assembling image specifics
case "${LIVE_IMAGE_TYPE}" in
iso*)
_BOOTLOADER="isolinux"
case "${LB_MODE}" in
progress-linux)
_TARGET="binary/boot"
;;
*)
_TARGET="binary/isolinux"
;;
esac
;;
netboot)
_BOOTLOADER="pxelinux"
_TARGET="tftpboot"
;;
hdd*|*)
case ${LB_BINARY_FILESYSTEM} in
fat*|ntfs)
_BOOTLOADER=syslinux
case "${LB_MODE}" in
progress-linux)
_TARGET="binary/boot"
;;
*)
_TARGET="binary/syslinux"
;;
esac
;;
ext[234]|btrfs)
_BOOTLOADER=extlinux
_TARGET="binary/boot/extlinux"
;;
*)
Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}"
exit 1
;;
esac
;;
esac
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
# Checking depends
Check_package chroot /usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z]) ${_BOOTLOADER}
Check_package chroot /usr/lib/syslinux syslinux-common
if ls "${_SOURCE}"/*.svg* > /dev/null 2>&1
then
Check_package chroot /usr/bin/rsvg-convert librsvg2-bin
fi
# Restoring cache
Restore_package_cache binary
# Installing depends
Install_package
# Copying files
case "${LB_BUILD_WITH_CHROOT}" in
true)
mkdir -p ${_TARGET}
# Copy in two steps since the theme can have absolute symlinks and would therefore not be dereferenced correctly
cp -a ${_SOURCE} chroot/root
Chroot chroot cp -aL /root/$(basename ${_SOURCE}) /root/$(basename ${_SOURCE}).tmp > /dev/null 2>&1 || true
cp -a chroot/root/$(basename ${_SOURCE}).tmp/* ${_TARGET}
rm -rf chroot/root/$(basename ${_SOURCE}) chroot/root/$(basename ${_SOURCE}).tmp
;;
false)
mkdir -p ${_TARGET}
cp -aL ${_SOURCE}/* ${_TARGET} > /dev/null 2>&1 || true
;;
esac
# Use correct install menu set
if [ "${LB_DEBIAN_INSTALLER_GUI}" = "true" ]; then
rm "${_TARGET}"/install_text.cfg
mv "${_TARGET}"/install_gui.cfg "${_TARGET}"/install.cfg
else
rm "${_TARGET}"/install_gui.cfg
mv "${_TARGET}"/install_text.cfg "${_TARGET}"/install.cfg
fi
# Configuring files
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)
# Rename kernel files
# If multiple initrd images are being generated (by DKMS packages, etc),
# we likely only want the latest version.
ln $(ls -r1 --sort=version binary/${_INITRAMFS}/vmlinuz-* | head -n 1) binary/${_INITRAMFS}/vmlinuz
ln $(ls -r1 --sort=version binary/${_INITRAMFS}/initrd.img-* | head -n 1) binary/${_INITRAMFS}/initrd.img
sed -e "s|@FLAVOUR@|${LB_LINUX_FLAVOURS}|g" \
-e "s|@LINUX@|/${_INITRAMFS}/vmlinuz|g" \
-e "s|@INITRD@|/${_INITRAMFS}/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))"
# Rename kernel files
# If multiple initrd images are being generated (by DKMS packages, etc),
# we likely only want the latest version.
ln $(ls -r1 --sort=version binary/${_INITRAMFS}/vmlinuz-*-${_FLAVOUR} | head -n 1) binary/${_INITRAMFS}/vmlinuz${_NUMBER}
ln $(ls -r1 --sort=version binary/${_INITRAMFS}/initrd.img-*-${_FLAVOUR} | head -n 1) binary/${_INITRAMFS}/initrd${_NUMBER}.img
if [ "${_NUMBER}" -gt 1 ]
then
echo "" >> "${_TARGET}/live.cfg"
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@|/${_INITRAMFS}/vmlinuz${_NUMBER}|g" \
-e "s|@INITRD@|/${_INITRAMFS}/initrd${_NUMBER}.img|g" \
"${_TARGET}/live.cfg"
done
rm -f "${_TARGET}/live.cfg.in"
;;
esac
fi
if [ -e chroot/etc/os-release ]
then
_VERSION="$(. chroot/etc/os-release && echo ${VERSION_ID})"
fi
_VERSION="${_VERSION:-none}"
_DISTRIBUTION="${LB_DISTRIBUTION_BINARY}"
_ARCHITECTURE="${LB_ARCHITECTURES}"
_DATE=$(date -R)
_YEAR="$(date +%Y)"
_MONTH="$(date +%m)"
_DAY="$(date +%d)"
_HOUR="$(date +%H)"
_MINUTE="$(date +%M)"
_SECOND="$(date +%S)"
_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" " ")"
_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 }')"
case "${LB_MODE}" in
progress-linux)
_PROJECT="Progress Linux"
;;
*)
_PROJECT="Debian GNU/Linux"
;;
esac
for _FILE in "${_TARGET}"/*.cfg ${_TARGET}/*.svg
do
if [ -e "${_FILE}" ] && [ ! -d "${_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|@PROJECT@|${_PROJECT}|g" \
-e "s|@DISTRIBUTION@|${_DISTRIBUTION}|g" \
-e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION_BINARY}|g" \
-e "s|@VERSION@|${_VERSION}|g" \
-e "s|@ARCHITECTURE@|${_ARCHITECTURE}|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
MEMTEST_PATH="${_INITRAMFS}/memtest"
sed -i -e "s#@MEMTEST_VERSION@#${LB_MEMTEST}#g" -e "s#@MEMTEST@#/${MEMTEST_PATH}#g" "${_TARGET}"/memtest.cfg
# Replace placeholder for optional install menu entries include
if [ "${LB_DEBIAN_INSTALLER}" = "none" ]; then
rm -f "${_TARGET}"/install.cfg
sed -i "#@OPTIONAL_INSTALLER_INCLUDE@#d" "${_TARGET}"/menu.cfg
else
sed -i "s#@OPTIONAL_INSTALLER_INCLUDE@#include install.cfg#g" "${_TARGET}"/menu.cfg
fi
# Replace placeholder for optional memtest menu entry include
if [ ! -f "binary/${MEMTEST_PATH}" ]; then
rm -f "${_TARGET}"/memtest.cfg
sed -i -e "#@OPTIONAL_MEMTEST_INCLUDE@#d" "${_TARGET}"/advanced.cfg
else
sed -i -e "s#@OPTIONAL_MEMTEST_INCLUDE@#include memtest.cfg#g" "${_TARGET}"/advanced.cfg
fi
if [ -e "${_TARGET}/splash.svg" ]
then
case "${LB_BUILD_WITH_CHROOT}" in
true)
cp "${_TARGET}/splash.svg" chroot
Chroot chroot "rsvg-convert --format png --height 480 --width 640 splash.svg -o splash.png"
mv chroot/splash.png "${_TARGET}"
rm -f chroot/splash.svg
;;
false)
rsvg-convert --format png --height 480 --width 640 "${_TARGET}/splash.svg" -o "${_TARGET}/splash.png"
;;
esac
rm -f "${_TARGET}/splash.svg"
fi
# Tweak the grub theme to reuse the syslinux background image
if [ -e binary/boot/grub/live-theme/theme.txt ]; then
sed -i -e 's|^desktop-image:.*|desktop-image: "/isolinux/splash.png"|' \
-e 's|^title-text:.*|title-text: ""|' \
binary/boot/grub/live-theme/theme.txt
fi
case "${LB_MODE}" in
progress-linux)
for _FILE in "${_TARGET}/isolinux.bin" "${_TARGET}/isolinux.cfg" "${_TARGET}/syslinux.cfg"
do
if [ -e "${_FILE}" ]
then
mv "${_FILE}" "${_TARGET}/$(echo ${_FILE} | sed -e 's|.*linux|boot|')"
fi
done
;;
esac
case "${LB_BUILD_WITH_CHROOT}" in
true)
# Saving cache
Save_package_cache binary
# Removing depends
Remove_package
;;
esac
# Creating stage file
Create_stagefile .build/binary_syslinux
|