Fix binary_syslinux to properly detect the presence of the bootloader.
Sophie Brun
9 years ago
1 | 1 | |
2 | 2 | [ Sophie Brun ] |
3 | 3 | * Update EFI patch. |
4 | * Fix binary_syslinux to properly detect the presence of the bootloader. | |
4 | 5 | |
5 | 6 | [ Raphaël Hertzog ] |
6 | 7 | * Improve package list parsing code in multiple ways: |
0 | From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <[email protected]> | |
1 | Date: Fri, 5 Dec 2014 09:36:27 +0100 | |
2 | Subject: Add support for EFI boot with syslinux-efi. | |
3 | ||
4 | Bug-Debian: http://bugs.debian.org/731709 | |
5 | Bug-Kali: https://bugs.kali.org/view.php?id=680 | |
6 | --- | |
7 | scripts/build/binary | 3 + | |
8 | scripts/build/binary_efi | 278 +++++++++++++++++++++++++++++++++++++++++++++++ | |
9 | scripts/build/binary_iso | 37 +++++++ | |
10 | 3 files changed, 318 insertions(+) | |
11 | create mode 100644 scripts/build/binary_efi | |
12 | ||
13 | diff --git a/scripts/build/binary b/scripts/build/binary | |
14 | index c1f9ec6..b893988 100755 | |
15 | --- a/scripts/build/binary | |
16 | +++ b/scripts/build/binary | |
17 | @@ -69,6 +69,9 @@ lb binary_loadlin ${@} | |
18 | lb binary_win32-loader ${@} | |
19 | lb binary_includes ${@} | |
20 | lb binary_hooks ${@} | |
21 | +lb binary_efi ${@} # After includes/hooks because it copies in efi.img | |
22 | + # files that can be overriden by binary_includes and | |
23 | + # modified by binary_hooks | |
24 | lb binary_checksums ${@} | |
25 | ||
26 | if [ "${LB_BUILD_WITH_CHROOT}" != "true" ] | |
27 | diff --git a/scripts/build/binary_efi b/scripts/build/binary_efi | |
28 | new file mode 100644 | |
29 | index 0000000..f98a5bf | |
30 | --- /dev/null | |
31 | +++ b/scripts/build/binary_efi | |
32 | @@ -0,0 +1,278 @@ | |
33 | +#!/bin/sh | |
34 | + | |
35 | +## live-build(7) - System Build Scripts | |
36 | +## Copyright (C) 2014 Raphaël Hertzog <[email protected]> | |
37 | +## | |
38 | +## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. | |
39 | +## This is free software, and you are welcome to redistribute it | |
40 | +## under certain conditions; see COPYING for details. | |
41 | + | |
42 | + | |
43 | +set -e | |
44 | + | |
45 | +# Including common functions | |
46 | +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh | |
47 | + | |
48 | +# Setting static variables | |
49 | +DESCRIPTION="$(Echo 'prepares and installs EFI support into binary')" | |
50 | +HELP="" | |
51 | +USAGE="${PROGRAM} [--force]" | |
52 | + | |
53 | +Arguments "${@}" | |
54 | + | |
55 | +# Reading configuration files | |
56 | +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source | |
57 | +Set_defaults | |
58 | + | |
59 | +if [ "${LB_BOOTLOADER}" != "syslinux" ] | |
60 | +then | |
61 | + exit 0 | |
62 | +fi | |
63 | + | |
64 | +Echo_message "Begin preparing EFI support..." | |
65 | + | |
66 | +# Requiring stage file | |
67 | +Require_stagefile .build/config .build/bootstrap | |
68 | + | |
69 | +# Checking stage file | |
70 | +Check_stagefile .build/binary_efi | |
71 | + | |
72 | +# Checking lock file | |
73 | +Check_lockfile .lock | |
74 | + | |
75 | +# Creating lock file | |
76 | +Create_lockfile .lock | |
77 | + | |
78 | +# Check architecture | |
79 | +Check_architectures amd64 i386 | |
80 | +Check_crossarchitectures | |
81 | + | |
82 | +case "$LIVE_IMAGE_ARCHITECTURE" in | |
83 | + amd64) | |
84 | + _EFI_TYPE=efi64 | |
85 | + ;; | |
86 | + i386) | |
87 | + _EFI_TYPE=efi32 | |
88 | + ;; | |
89 | + *) | |
90 | + echo "ERROR: can't provide EFI boot support to architecture $LIVE_IMAGE_ARCHITECTURE" >&2 | |
91 | + exit 1 | |
92 | + ;; | |
93 | +esac | |
94 | + | |
95 | +# Assembling image specifics | |
96 | +case "${LIVE_IMAGE_TYPE}" in | |
97 | + iso*) | |
98 | + _BOOTLOADER="isolinux" | |
99 | + | |
100 | + case "${LB_MODE}" in | |
101 | + progress-linux) | |
102 | + _CONFDIR="binary/boot" | |
103 | + ;; | |
104 | + | |
105 | + *) | |
106 | + _CONFDIR="binary/isolinux" | |
107 | + ;; | |
108 | + esac | |
109 | + ;; | |
110 | + | |
111 | + netboot) | |
112 | + _BOOTLOADER="pxelinux" | |
113 | + _CONFDIR="tftpboot" | |
114 | + ;; | |
115 | + | |
116 | + hdd*|*) | |
117 | + case ${LB_BINARY_FILESYSTEM} in | |
118 | + fat*|ntfs) | |
119 | + _BOOTLOADER=syslinux | |
120 | + | |
121 | + case "${LB_MODE}" in | |
122 | + progress-linux) | |
123 | + _CONFDIR="binary/boot" | |
124 | + ;; | |
125 | + | |
126 | + *) | |
127 | + _CONFDIR="binary/syslinux" | |
128 | + ;; | |
129 | + esac | |
130 | + ;; | |
131 | + | |
132 | + ext[234]|btrfs) | |
133 | + _BOOTLOADER=extlinux | |
134 | + _CONFDIR="binary/boot/extlinux" | |
135 | + ;; | |
136 | + | |
137 | + *) | |
138 | + Echo_error "syslinux/extlinux doesn't support ${LB_BINARY_FILESYSTEM}" | |
139 | + exit 1 | |
140 | + ;; | |
141 | + esac | |
142 | + ;; | |
143 | +esac | |
144 | + | |
145 | +# Checking depends | |
146 | +case "${LB_BUILD_WITH_CHROOT}" in | |
147 | + true) | |
148 | + _CHROOT_DIR="" | |
149 | + _SYSLINUX_EFI_DIR="chroot/usr/lib/SYSLINUX.EFI/$_EFI_TYPE" | |
150 | + | |
151 | + Check_package chroot/usr/bin/syslinux syslinux | |
152 | + Check_package chroot/usr/lib/syslinux syslinux-common | |
153 | + Check_package chroot/usr/lib/SYSLINUX.EFI syslinux-efi | |
154 | + Check_package chroot/usr/bin/mcopy mtools | |
155 | + Check_package chroot/sbin/mkfs.msdos dosfstools | |
156 | + ;; | |
157 | + | |
158 | + false) | |
159 | + _CHROOT_DIR="chroot" | |
160 | + _SYSLINUX_EFI_DIR="/usr/lib/syslinux/$_EFI_TYPE" | |
161 | + | |
162 | + if [ ! -e /usr/bin/syslinux ] | |
163 | + then | |
164 | + # syslinux | |
165 | + Echo_error "/usr/bin/syslinux - no such file." | |
166 | + exit 1 | |
167 | + fi | |
168 | + | |
169 | + if [ ! -e /usr/lib/syslinux ] | |
170 | + then | |
171 | + # syslinux-common | |
172 | + Echo_error "/usr/lib/syslinux - no such directory" | |
173 | + exit 1 | |
174 | + fi | |
175 | + | |
176 | + if [ ! -e /usr/lib/SYSLINUX.EFI ] | |
177 | + then | |
178 | + # syslinux-efi | |
179 | + Echo_error "/usr/lib/SYSLINUX.EFI - no such directory" | |
180 | + exit 1 | |
181 | + fi | |
182 | + | |
183 | + if [ ! -e /usr/bin/mcopy ] | |
184 | + then | |
185 | + # mtools | |
186 | + Echo_error "/usr/bin/mcopy - no such file." | |
187 | + exit 1 | |
188 | + fi | |
189 | + | |
190 | + if [ ! -e /sbin/mkfs.msdos ] | |
191 | + then | |
192 | + # dosfstools | |
193 | + Echo_error "/sbin/mkfs.msdos - no such file." | |
194 | + exit 1 | |
195 | + fi | |
196 | + ;; | |
197 | +esac | |
198 | + | |
199 | +# Restoring cache | |
200 | +Restore_cache cache/packages.binary | |
201 | + | |
202 | +# Installing depends | |
203 | +Install_package | |
204 | + | |
205 | +# Abort if we don't have the required EFI files | |
206 | +if [ ! -e $_SYSLINUX_EFI_DIR/syslinux.efi ]; then | |
207 | + Echo_warning "$_SYSLINUX_EFI_DIR/syslinux.efi missing, no EFI support included." | |
208 | + case "${LB_BUILD_WITH_CHROOT}" in | |
209 | + true) | |
210 | + # Saving cache | |
211 | + Save_cache cache/packages.binary | |
212 | + | |
213 | + # Removing depends | |
214 | + Remove_package | |
215 | + ;; | |
216 | + esac | |
217 | + exit 0 | |
218 | +fi | |
219 | + | |
220 | +# Cleanup files that we generate | |
221 | +rm -rf chroot/efi-temp chroot/efi.img binary/boot/efi.img | |
222 | + | |
223 | +# Copy syslinux and its config files in the temporary EFI image | |
224 | +mkdir -p chroot/efi-temp/live | |
225 | +mkdir -p chroot/efi-temp/EFI/BOOT | |
226 | +for _F in $_CONFDIR/*.cfg $_CONFDIR/*.png $_SYSLINUX_EFI_DIR/*.*32 $_SYSLINUX_EFI_DIR/*.*64; do | |
227 | + if [ -e $_F ]; then | |
228 | + cp $_F chroot/efi-temp/EFI/BOOT/ | |
229 | + fi | |
230 | +done | |
231 | +cp $_SYSLINUX_EFI_DIR/syslinux.efi chroot/efi-temp/EFI/BOOT/BOOTX64.efi | |
232 | +cp $_SYSLINUX_EFI_DIR/syslinux.efi chroot/efi-temp/EFI/BOOT/syslinux.efi | |
233 | + | |
234 | +# Copy the various kernel images | |
235 | +cp binary/live/vmlinuz* binary/live/initrd.img* chroot/efi-temp/live/ | |
236 | +if [ -d binary/install ]; then | |
237 | + cp -r binary/install chroot/efi-temp/ | |
238 | +fi | |
239 | + | |
240 | +# Edit the menu to differentiate the EFI version | |
241 | +if [ -e chroot/efi-temp/EFI/BOOT/menu.cfg ]; then | |
242 | + sed -i -e "s/^menu title/menu title EFI/" chroot/efi-temp/EFI/BOOT/menu.cfg | |
243 | +else | |
244 | + Echo "No menu.cfg file that can be edited to indicate that we boot on EFI!" | |
245 | +fi | |
246 | + | |
247 | +# Ensure we have a syslinux.cfg | |
248 | +if [ ! -e chroot/efi-temp/EFI/BOOT/syslinux.cfg ]; then | |
249 | + for _F in isolinux.cfg pxelinux.cfg/default extlinux.conf; do | |
250 | + if [ -f chroot/efi-temp/EFI/BOOT/$_F ]; then | |
251 | + cp chroot/efi-temp/EFI/BOOT/$_F chroot/efi-temp/EFI/BOOT/syslinux.cfg | |
252 | + break | |
253 | + fi | |
254 | + done | |
255 | +fi | |
256 | + | |
257 | +# Define the EFI filesystem size | |
258 | +_TOTALSIZE=$(du -sk chroot/efi-temp/ | awk '{print $1}') | |
259 | +# Add 5% safety margin | |
260 | +_TOTALSIZE=$(( $_TOTALSIZE * 21 / 20 )) | |
261 | +# Required size rounded to upper 32kb | |
262 | +_BLOCKS=$(( ($_TOTALSIZE + 31) / 32 * 32 )) | |
263 | +Echo "EFI boot image needs $_TOTALSIZE Kb, thus allocating $_BLOCKS blocks." | |
264 | + | |
265 | +# Script to generate the EFI boot image | |
266 | +cat >binary.sh <<END | |
267 | +#!/bin/sh | |
268 | + | |
269 | +set -e | |
270 | + | |
271 | +mkfs.msdos -C $_CHROOT_DIR/efi.img $_BLOCKS | |
272 | +mcopy -s -v -i $_CHROOT_DIR/efi.img $_CHROOT_DIR/efi-temp/* :: | |
273 | +END | |
274 | + | |
275 | +# Copying files | |
276 | +case "${LB_BUILD_WITH_CHROOT}" in | |
277 | + true) | |
278 | + mv binary.sh chroot/ | |
279 | + Chroot chroot "sh binary.sh" | |
280 | + rm -f chroot/binary.sh | |
281 | + | |
282 | + # Saving cache | |
283 | + Save_cache cache/packages.binary | |
284 | + | |
285 | + # Removing depends | |
286 | + Remove_package | |
287 | + ;; | |
288 | + | |
289 | + false) | |
290 | + sh binary.sh | |
291 | + rm -f binary.sh | |
292 | + ;; | |
293 | +esac | |
294 | + | |
295 | +mkdir -p binary/boot | |
296 | +mv chroot/efi.img binary/boot/ | |
297 | +rm -rf chroot/efi-temp | |
298 | + | |
299 | +case "${LB_BUILD_WITH_CHROOT}" in | |
300 | + true) | |
301 | + # Saving cache | |
302 | + Save_cache cache/packages.binary | |
303 | + | |
304 | + # Removing depends | |
305 | + Remove_package | |
306 | + ;; | |
307 | +esac | |
308 | + | |
309 | +# Creating stage file | |
310 | +Create_stagefile .build/binary_efi | |
311 | diff --git a/scripts/build/binary_iso b/scripts/build/binary_iso | |
312 | index 7abfc69..62fcf9c 100755 | |
313 | --- a/scripts/build/binary_iso | |
314 | +++ b/scripts/build/binary_iso | |
315 | @@ -82,6 +82,23 @@ fi | |
316 | # Handle xorriso generic options | |
317 | XORRISO_OPTIONS="-R -r -J -joliet-long -l -cache-inodes" | |
318 | ||
319 | +case "${LB_BUILD_WITH_CHROOT}" in | |
320 | + true) | |
321 | + XORRISO_VER=$(Chroot chroot xorriso --version 2>&1 | awk ' | |
322 | + /^xorriso version/ { | |
323 | + split($4, ver, ".") | |
324 | + print ver[1]*10000+ver[2]*100+ver[3] | |
325 | + }') | |
326 | + ;; | |
327 | + false) | |
328 | + XORRISO_VER=$(xorriso --version 2>&1 | awk ' | |
329 | + /^xorriso version/ { | |
330 | + split($4, ver, ".") | |
331 | + print ver[1]*10000+ver[2]*100+ver[3] | |
332 | + }') | |
333 | + ;; | |
334 | +esac | |
335 | + | |
336 | # Handle xorriso live-build specific options | |
337 | if [ "${LIVE_IMAGE_TYPE}" = "iso-hybrid" ] | |
338 | then | |
339 | @@ -155,6 +172,26 @@ case "${LB_BOOTLOADER}" in | |
340 | ;; | |
341 | esac | |
342 | ||
343 | +if [ -e binary/boot/efi.img ]; then | |
344 | + #if [ "$XORRISO_VER" -le 10202 ]; then | |
345 | + # 1.2.2 shipping in wheezy | |
346 | + Echo "Using older EFI command line for xorriso $XORRISO_VER" | |
347 | + # Tell xorriso to create a secondary ElTorito boot record for the | |
348 | + # EFI bootloader | |
349 | + XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot --efi-boot boot/efi.img" | |
350 | + # Add the efi image as a FAT partition too, so our CD image will | |
351 | + # also boot on a USB key (like isohybrid, just implemented | |
352 | + # differently) | |
353 | + XORRISO_OPTIONS="${XORRISO_OPTIONS} -append_partition 2 0x01 binary/boot/efi.img" | |
354 | + #else | |
355 | + # Echo "Using newer EFI support in xorriso $XORRISO_VER" | |
356 | + # XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot -e boot/efi.img -no-emul-boot" | |
357 | + # XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat" | |
358 | + #fi | |
359 | +else | |
360 | + Echo "No EFI boot code to include in the ISO" | |
361 | +fi | |
362 | + | |
363 | #if [ "${LB_DEBIAN_INSTALLER}" != "live" ] | |
364 | #then | |
365 | # XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}" |
0 | From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <[email protected]> | |
1 | Date: Fri, 5 Dec 2014 09:36:27 +0100 | |
2 | Subject: Add support for EFI boot | |
3 | ||
4 | Bug-Debian: http://bugs.debian.org/731709 | |
5 | Bug-Kali: https://bugs.kali.org/view.php?id=680 | |
6 | --- | |
7 | scripts/build/binary | 3 + | |
8 | scripts/build/binary_efi | 256 +++++++++++++++++++++++++++++++++++++++++++++++ | |
9 | scripts/build/binary_iso | 37 +++++++ | |
10 | 3 files changed, 296 insertions(+) | |
11 | create mode 100644 scripts/build/binary_efi | |
12 | ||
13 | diff --git a/scripts/build/binary b/scripts/build/binary | |
14 | index c1f9ec6..b893988 100755 | |
15 | --- a/scripts/build/binary | |
16 | +++ b/scripts/build/binary | |
17 | @@ -69,6 +69,9 @@ lb binary_loadlin ${@} | |
18 | lb binary_win32-loader ${@} | |
19 | lb binary_includes ${@} | |
20 | lb binary_hooks ${@} | |
21 | +lb binary_efi ${@} # After includes/hooks because it copies in efi.img | |
22 | + # files that can be overriden by binary_includes and | |
23 | + # modified by binary_hooks | |
24 | lb binary_checksums ${@} | |
25 | ||
26 | if [ "${LB_BUILD_WITH_CHROOT}" != "true" ] | |
27 | diff --git a/scripts/build/binary_efi b/scripts/build/binary_efi | |
28 | new file mode 100644 | |
29 | index 0000000..4e711e1 | |
30 | --- /dev/null | |
31 | +++ b/scripts/build/binary_efi | |
32 | @@ -0,0 +1,256 @@ | |
33 | +#!/bin/sh | |
34 | + | |
35 | +## live-build(7) - System Build Scripts | |
36 | +## Copyright (C) 2014 Raphaël Hertzog <[email protected]> | |
37 | +## | |
38 | +## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. | |
39 | +## This is free software, and you are welcome to redistribute it | |
40 | +## under certain conditions; see COPYING for details. | |
41 | + | |
42 | + | |
43 | +set -e | |
44 | + | |
45 | +# Including common functions | |
46 | +[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh | |
47 | + | |
48 | +# Setting static variables | |
49 | +DESCRIPTION="$(Echo 'prepares and installs EFI support into binary')" | |
50 | +HELP="" | |
51 | +USAGE="${PROGRAM} [--force]" | |
52 | + | |
53 | +Arguments "${@}" | |
54 | + | |
55 | +# Reading configuration files | |
56 | +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source | |
57 | +Set_defaults | |
58 | + | |
59 | +if [ "${LB_BOOTLOADER}" != "syslinux" ] | |
60 | +then | |
61 | + exit 0 | |
62 | +fi | |
63 | + | |
64 | +Echo_message "Begin preparing EFI support..." | |
65 | + | |
66 | +# Requiring stage file | |
67 | +Require_stagefile .build/config .build/bootstrap | |
68 | + | |
69 | +# Checking stage file | |
70 | +Check_stagefile .build/binary_efi | |
71 | + | |
72 | +# Checking lock file | |
73 | +Check_lockfile .lock | |
74 | + | |
75 | +# Creating lock file | |
76 | +Create_lockfile .lock | |
77 | + | |
78 | +# Check architecture | |
79 | +Check_architectures amd64 i386 | |
80 | +Check_crossarchitectures | |
81 | + | |
82 | +case "$LIVE_IMAGE_ARCHITECTURE" in | |
83 | + amd64) | |
84 | + _EFI_TYPE=efi64 | |
85 | + ;; | |
86 | + i386) | |
87 | + _EFI_TYPE=efi32 | |
88 | + ;; | |
89 | + *) | |
90 | + echo "ERROR: can't provide EFI boot support to architecture $LIVE_IMAGE_ARCHITECTURE" >&2 | |
91 | + exit 1 | |
92 | + ;; | |
93 | +esac | |
94 | + | |
95 | +# Assembling image specifics | |
96 | +case "${LB_BINARY_IMAGES}" in | |
97 | + iso*) | |
98 | + _BOOTLOADER="isolinux" | |
99 | + | |
100 | + case "${LB_MODE}" in | |
101 | + progress-linux) | |
102 | + _CONFDIR="binary/boot" | |
103 | + ;; | |
104 | + | |
105 | + *) | |
106 | + _CONFDIR="binary/isolinux" | |
107 | + ;; | |
108 | + esac | |
109 | + ;; | |
110 | + | |
111 | + netboot) | |
112 | + _BOOTLOADER="pxelinux" | |
113 | + _CONFDIR="tftpboot" | |
114 | + ;; | |
115 | + | |
116 | + hdd*|*) | |
117 | + _BOOTLOADER="syslinux" | |
118 | + | |
119 | + case "${LB_MODE}" in | |
120 | + progress-linux) | |
121 | + _CONFDIR="binary/boot" | |
122 | + ;; | |
123 | + | |
124 | + *) | |
125 | + _CONFDIR="binary/syslinux" | |
126 | + ;; | |
127 | + esac | |
128 | + ;; | |
129 | +esac | |
130 | + | |
131 | +# Checking depends | |
132 | +case "${LB_BUILD_WITH_CHROOT}" in | |
133 | + true) | |
134 | + _CHROOT_DIR="" | |
135 | + _SYSLINUX_EFI_DIR="chroot/usr/lib/syslinux/$_EFI_TYPE" | |
136 | + | |
137 | + Check_package chroot/usr/bin/syslinux syslinux | |
138 | + Check_package chroot/usr/lib/syslinux syslinux-common | |
139 | + Check_package chroot/usr/bin/mcopy mtools | |
140 | + Check_package chroot/sbin/mkfs.msdos dosfstools | |
141 | + ;; | |
142 | + | |
143 | + false) | |
144 | + _CHROOT_DIR="chroot" | |
145 | + _SYSLINUX_EFI_DIR="/usr/lib/syslinux/$_EFI_TYPE" | |
146 | + | |
147 | + if [ ! -e /usr/bin/syslinux ] | |
148 | + then | |
149 | + # syslinux | |
150 | + Echo_error "/usr/bin/syslinux - no such file." | |
151 | + exit 1 | |
152 | + fi | |
153 | + | |
154 | + if [ ! -e /usr/lib/syslinux ] | |
155 | + then | |
156 | + # syslinux-common | |
157 | + Echo_error "/usr/lib/syslinux - no such directory" | |
158 | + exit 1 | |
159 | + fi | |
160 | + | |
161 | + if [ ! -e /usr/bin/mcopy ] | |
162 | + then | |
163 | + # mtools | |
164 | + Echo_error "/usr/bin/mcopy - no such file." | |
165 | + exit 1 | |
166 | + fi | |
167 | + | |
168 | + if [ ! -e /sbin/mkfs.msdos ] | |
169 | + then | |
170 | + # dosfstools | |
171 | + Echo_error "/sbin/mkfs.msdos - no such file." | |
172 | + exit 1 | |
173 | + fi | |
174 | + ;; | |
175 | +esac | |
176 | + | |
177 | +# Restoring cache | |
178 | +Restore_cache cache/packages.binary | |
179 | + | |
180 | +# Installing depends | |
181 | +Install_package | |
182 | + | |
183 | +# Abort if we don't have the required EFI files | |
184 | +if [ ! -e $_SYSLINUX_EFI_DIR/syslinux.efi ]; then | |
185 | + Echo_warning "$_SYSLINUX_EFI_DIR/syslinux.efi missing, no EFI support included." | |
186 | + case "${LB_BUILD_WITH_CHROOT}" in | |
187 | + true) | |
188 | + # Saving cache | |
189 | + Save_cache cache/packages.binary | |
190 | + | |
191 | + # Removing depends | |
192 | + Remove_package | |
193 | + ;; | |
194 | + esac | |
195 | + exit 0 | |
196 | +fi | |
197 | + | |
198 | +# Cleanup files that we generate | |
199 | +rm -rf chroot/efi-temp chroot/efi.img binary/boot/efi.img | |
200 | + | |
201 | +# Copy syslinux and its config files in the temporary EFI image | |
202 | +mkdir -p chroot/efi-temp/live | |
203 | +mkdir -p chroot/efi-temp/EFI/BOOT | |
204 | +for _F in $_CONFDIR/*.cfg $_CONFDIR/*.png $_SYSLINUX_EFI_DIR/*.*32 $_SYSLINUX_EFI_DIR/*.*64; do | |
205 | + if [ -e $_F ]; then | |
206 | + cp $_F chroot/efi-temp/EFI/BOOT/ | |
207 | + fi | |
208 | +done | |
209 | +cp $_SYSLINUX_EFI_DIR/syslinux.efi chroot/efi-temp/EFI/BOOT/BOOTX64.efi | |
210 | +cp $_SYSLINUX_EFI_DIR/syslinux.efi chroot/efi-temp/EFI/BOOT/syslinux.efi | |
211 | + | |
212 | +# Copy the various kernel images | |
213 | +cp binary/live/vmlinuz* binary/live/initrd.img* chroot/efi-temp/live/ | |
214 | +if [ -d binary/install ]; then | |
215 | + cp -r binary/install chroot/efi-temp/ | |
216 | +fi | |
217 | + | |
218 | +# Edit the menu to differentiate the EFI version | |
219 | +if [ -e chroot/efi-temp/EFI/BOOT/menu.cfg ]; then | |
220 | + sed -i -e "s/^menu title/menu title EFI/" chroot/efi-temp/EFI/BOOT/menu.cfg | |
221 | +else | |
222 | + Echo "No menu.cfg file that can be edited to indicate that we boot on EFI!" | |
223 | +fi | |
224 | + | |
225 | +# Ensure we have a syslinux.cfg | |
226 | +if [ ! -e chroot/efi-temp/EFI/BOOT/syslinux.cfg ]; then | |
227 | + for _F in isolinux.cfg pxelinux.cfg/default extlinux.conf; do | |
228 | + if [ -f chroot/efi-temp/EFI/BOOT/$_F ]; then | |
229 | + cp chroot/efi-temp/EFI/BOOT/$_F chroot/efi-temp/EFI/BOOT/syslinux.cfg | |
230 | + break | |
231 | + fi | |
232 | + done | |
233 | +fi | |
234 | + | |
235 | +# Define the EFI filesystem size | |
236 | +_TOTALSIZE=$(du -sk chroot/efi-temp/ | awk '{print $1}') | |
237 | +# Add 5% safety margin | |
238 | +_TOTALSIZE=$(( $_TOTALSIZE * 21 / 20 )) | |
239 | +# Required size rounded to upper 32kb | |
240 | +_BLOCKS=$(( ($_TOTALSIZE + 31) / 32 * 32 )) | |
241 | +Echo "EFI boot image needs $_TOTALSIZE Kb, thus allocating $_BLOCKS blocks." | |
242 | + | |
243 | +# Script to generate the EFI boot image | |
244 | +cat >binary.sh <<END | |
245 | +#!/bin/sh | |
246 | + | |
247 | +set -e | |
248 | + | |
249 | +mkfs.msdos -C $_CHROOT_DIR/efi.img $_BLOCKS | |
250 | +mcopy -s -v -i $_CHROOT_DIR/efi.img $_CHROOT_DIR/efi-temp/* :: | |
251 | +END | |
252 | + | |
253 | +# Copying files | |
254 | +case "${LB_BUILD_WITH_CHROOT}" in | |
255 | + true) | |
256 | + mv binary.sh chroot/ | |
257 | + Chroot chroot "sh binary.sh" | |
258 | + rm -f chroot/binary.sh | |
259 | + | |
260 | + # Saving cache | |
261 | + Save_cache cache/packages.binary | |
262 | + | |
263 | + # Removing depends | |
264 | + Remove_package | |
265 | + ;; | |
266 | + | |
267 | + false) | |
268 | + sh binary.sh | |
269 | + rm -f binary.sh | |
270 | + ;; | |
271 | +esac | |
272 | + | |
273 | +mkdir -p binary/boot | |
274 | +mv chroot/efi.img binary/boot/ | |
275 | +rm -rf chroot/efi-temp | |
276 | + | |
277 | +case "${LB_BUILD_WITH_CHROOT}" in | |
278 | + true) | |
279 | + # Saving cache | |
280 | + Save_cache cache/packages.binary | |
281 | + | |
282 | + # Removing depends | |
283 | + Remove_package | |
284 | + ;; | |
285 | +esac | |
286 | + | |
287 | +# Creating stage file | |
288 | +Create_stagefile .build/binary_efi | |
289 | diff --git a/scripts/build/binary_iso b/scripts/build/binary_iso | |
290 | index 7abfc69..62fcf9c 100755 | |
291 | --- a/scripts/build/binary_iso | |
292 | +++ b/scripts/build/binary_iso | |
293 | @@ -82,6 +82,23 @@ fi | |
294 | # Handle xorriso generic options | |
295 | XORRISO_OPTIONS="-R -r -J -joliet-long -l -cache-inodes" | |
296 | ||
297 | +case "${LB_BUILD_WITH_CHROOT}" in | |
298 | + true) | |
299 | + XORRISO_VER=$(Chroot chroot xorriso --version 2>&1 | awk ' | |
300 | + /^xorriso version/ { | |
301 | + split($4, ver, ".") | |
302 | + print ver[1]*10000+ver[2]*100+ver[3] | |
303 | + }') | |
304 | + ;; | |
305 | + false) | |
306 | + XORRISO_VER=$(xorriso --version 2>&1 | awk ' | |
307 | + /^xorriso version/ { | |
308 | + split($4, ver, ".") | |
309 | + print ver[1]*10000+ver[2]*100+ver[3] | |
310 | + }') | |
311 | + ;; | |
312 | +esac | |
313 | + | |
314 | # Handle xorriso live-build specific options | |
315 | if [ "${LIVE_IMAGE_TYPE}" = "iso-hybrid" ] | |
316 | then | |
317 | @@ -155,6 +172,26 @@ case "${LB_BOOTLOADER}" in | |
318 | ;; | |
319 | esac | |
320 | ||
321 | +if [ -e binary/boot/efi.img ]; then | |
322 | + #if [ "$XORRISO_VER" -le 10202 ]; then | |
323 | + # 1.2.2 shipping in wheezy | |
324 | + Echo "Using older EFI command line for xorriso $XORRISO_VER" | |
325 | + # Tell xorriso to create a secondary ElTorito boot record for the | |
326 | + # EFI bootloader | |
327 | + XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot --efi-boot boot/efi.img" | |
328 | + # Add the efi image as a FAT partition too, so our CD image will | |
329 | + # also boot on a USB key (like isohybrid, just implemented | |
330 | + # differently) | |
331 | + XORRISO_OPTIONS="${XORRISO_OPTIONS} -append_partition 2 0x01 binary/boot/efi.img" | |
332 | + #else | |
333 | + # Echo "Using newer EFI support in xorriso $XORRISO_VER" | |
334 | + # XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot -e boot/efi.img -no-emul-boot" | |
335 | + # XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat" | |
336 | + #fi | |
337 | +else | |
338 | + Echo "No EFI boot code to include in the ISO" | |
339 | +fi | |
340 | + | |
341 | #if [ "${LB_DEBIAN_INSTALLER}" != "live" ] | |
342 | #then | |
343 | # XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}" |
0 | From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <[email protected]> | |
1 | Date: Tue, 9 Dec 2014 16:48:00 +0100 | |
2 | Subject: binary_syslinux: correct the path used to check if the bootloader is | |
3 | available | |
4 | ||
5 | The {iso,pxe,ext,sys}linux packages use /usr/lib/{ISO,PXE,EXT,SYS}LINUX/ | |
6 | directories and not /share/{ISO,PXE,EXT,SYS}LINUX/. | |
7 | --- | |
8 | scripts/build/binary_syslinux | 2 +- | |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
10 | ||
11 | diff --git a/scripts/build/binary_syslinux b/scripts/build/binary_syslinux | |
12 | index abd900a..f0dba0e 100755 | |
13 | --- a/scripts/build/binary_syslinux | |
14 | +++ b/scripts/build/binary_syslinux | |
15 | @@ -143,7 +143,7 @@ case "${LB_BUILD_WITH_CHROOT}" in | |
16 | ;; | |
17 | ||
18 | *) | |
19 | - Check_package chroot/share/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z]) ${_BOOTLOADER} | |
20 | + Check_package chroot/usr/lib/$(echo ${_BOOTLOADER} | tr [a-z] [A-Z]) ${_BOOTLOADER} | |
21 | Check_package chroot/usr/lib/syslinux syslinux-common | |
22 | ;; | |
23 | esac |
0 | 0 | 0001-Update-linux-flavours-for-armhf-armel.patch |
1 | 0002-Add-support-for-EFI-boot.patch | |
1 | 0002-Add-support-for-EFI-boot-with-syslinux-efi.patch | |
2 | 2 | 0003-Lookup-LIVE_IMAGE_-foo-and-LB_-foo-for-if-tests-in-p.patch |
3 | 3 | 0004-Skip-comments-in-package-lists.patch |
4 | 4 | 0005-Properly-support-empty-package-lists.patch |
5 | 0006-binary_syslinux-correct-the-path-used-to-check-if-th.patch |