Debian Codegraph @

tools/boot/bullseye/boot-x86

raw
1 # This script gets sourced from boot-i386 and boot-amd64.
2 #
3 # Do install stuff for x86, including making bootable CDs
4 # Works with debian-installer
5 #
6 # $1 is the CD number
7 # $2 is the temporary CD build dir
8
9 . $BASEDIR/tools/boot/$DI_CODENAME/common.sh
10 . $BASEDIR/tools/boot/$DI_CODENAME/x86-desktop.sh
11
12 set -e
13 #set -x
14
15 # Workaround for #823881:
16 export MTOOLS_SKIP_CHECK=1
17
18 # Have we been told to use just one boot method? If none listed,
19 # assume all are desired. Order also matters. Possible values are
20 # "BIOS", "EFI" and "BIOS EFI". We'll also accept "EFI BIOS" for
21 # completeness, but we will switch the order.
22 if [ "$BOOT_METHODS"x = ""x ] \
23 || [ "$BOOT_METHODS"x = "BIOS EFI"x ] \
24 || [ "$BOOT_METHODS"x = "EFI BIOS"x ] ; then
25 BOOT_BIOS=1
26 BOOT_EFI=2
27 elif [ "$BOOT_METHODS"x = "BIOS"x ] ; then
28 BOOT_BIOS=1
29 BOOT_EFI=0
30 elif [ "$BOOT_METHODS"x = "EFI"x ] ; then
31 BOOT_EFI=1
32 BOOT_BIOS=0
33 else
34 echo "ERROR: Unrecognized boot method choice $BOOT_METHODS"
35 exit 1
36 fi
37
38 N=$1
39 CDDIR=$2
40 BOOTDIR=
41 if [ "$DI_WWW_HOME" = "default" ]; then
42 # Tempting as it might be to merge these two definitions using $ARCH,
43 # do *not* do that - these defs are parsed out by other scripts that
44 # won't cope with that
45 if [ "$ARCH" = amd64 ]; then
46 DI_WWW_HOME="https://d-i.debian.org/daily-images/amd64/daily"
47 else
48 DI_WWW_HOME="https://d-i.debian.org/daily-images/i386/daily"
49 fi
50 try_di_image_cache
51 else
52 DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,")
53 fi
54
55 case "$MKISOFS" in
56 *xorriso*)
57 XORRISO_VER=$(xorriso_version)
58 ;;
59 *)
60 echo "ERROR: debian-cd now depends on xorriso for making x86 bootable CDs."
61 exit 1;
62 ;;
63 esac
64
65 cd $CDDIR/..
66
67 # This script is called with $1 (now $N) as the CD to make bootable.
68 # Exit if this is not a boot disk
69 if [ $N != 1 ] ; then exit 0; fi
70
71 INSTALLDIR_amd64="install.amd"
72 INSTALLDIR_i386="install.386"
73
74 if [ "$ARCH" = amd64 ]; then
75 INSTALLDIR="$INSTALLDIR_amd64"
76 else
77 INSTALLDIR="$INSTALLDIR_i386"
78 fi
79
80 BOOT_IMAGES="cdrom/initrd.gz cdrom/vmlinuz cdrom/debian-cd_info.tar.gz"
81
82 # Download boot images.
83 for image in $BOOT_IMAGES; do
84 if [ ! -e "$image" ]; then
85 dir=$(dirname $image)
86 mkdir -p $dir
87 if [ -n "$LOCAL" -a -f "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" ]; then
88 cp "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" "$image"
89 elif [ ! "$DI_WWW_HOME" ];then
90 if [ ! "$DI_DIR" ];then
91 DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images"
92 fi
93 # echo "Copying images from $DI_DIR"
94 cp "$DI_DIR/$image" "$image"
95 else
96 $WGET "$DI_WWW_HOME/$image" -O "$image"
97 fi
98 fi
99 done
100
101 # Images that are not really required or may be unavailable.
102 for image in $DISK_IMAGES $EXTRA_DISK_IMAGES; do
103 if [ ! -e "$image" ]; then
104 dir=$(dirname $image)
105 mkdir -p $dir
106 if [ -n "$LOCAL" -a -f "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" ]; then
107 cp "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" "$image"
108 elif [ ! "$DI_WWW_HOME" ];then
109 if [ ! "$DI_DIR" ];then
110 DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images"
111 fi
112 cp "$DI_DIR/$image" "$image" || true
113 else
114 $WGET "$DI_WWW_HOME/$image" -O "$image" || rm -f "$image"
115 fi
116 fi
117 done
118
119 # Only disk one gets the extra files installed
120 if [ "$N" = "1" ]; then
121 # populate the install directory as well
122 for disk in $DISK_IMAGES $EXTRA_DISK_IMAGES; do
123 if [ -e "$disk" ]; then
124 dir=$(dirname $disk)
125 mkdir -p $CDDIR/$INSTALLDIR/$dir
126 cp -lf $disk $CDDIR/$INSTALLDIR/$dir
127 fi
128 done
129
130 if [ -e "$MIRROR/tools" ] && \
131 [ ! -e $CDDIR/tools ] && \
132 [ "$OMIT_DOC_TOOLS" != "1" ] ; then
133 echo " Adding tools to CD1"
134 $BASEDIR/tools/add_files $CDDIR $MIRROR tools
135 # Remove the win32-loader/ subdirectory from tools, as d-i already installs setup.exe
136 rm -Rf $CDDIR/tools/win32-loader
137 fi
138 fi
139
140 case "$DESKTOP" in
141 $UNSPEC_DESKTOP_DEFAULT)
142 # default from tasksel
143 DESKTOP=
144 ;;
145 all)
146 # default from tasksel
147 DESKTOP=
148 ;;
149 light)
150 DESKTOP=xfce
151 ;;
152 esac
153 # desktop boot parameter gets set separately through DESKTOP variable
154 KERNEL_PARAMS="$(echo "$KERNEL_PARAMS" | sed -r "s/desktop=[^ ]* ?//")"
155
156 mkdir -p $CDDIR/$INSTALLDIR
157 cp -lf cdrom/vmlinuz $CDDIR/$INSTALLDIR/
158 cp -lf cdrom/initrd.gz $CDDIR/$INSTALLDIR/
159 if [ -e $CDDIR/tools/loadlin.exe ]; then
160 echo "\\tools\\loadlin.exe vmlinuz initrd=initrd.gz" | todos > $CDDIR/$INSTALLDIR/install.bat
161 fi
162
163 # In case of a multi-arch CD the script will be called two times. The
164 # first time the isolinux dir gets set up for single arch; if it is
165 # called a second time the isolinux dir already exists and we know it
166 # will be multi-arch. We then throw away the first version and just
167 # configure things from scratch for multi-arch.
168
169 MULTIARCH=
170 if [ -e boot$N/isolinux/isolinux.cfg ]; then
171 MULTIARCH=1
172 rm -r boot$N/isolinux
173 fi
174
175 mkdir -p boot$N/isolinux
176 # Isolinux setup including config and help files comes from d-i.
177 cat cdrom/debian-cd_info.tar.gz | (cd boot$N/isolinux/; tar zx)
178
179 # Not everything in the tarball is isolinux stuff
180 if [ -e boot$N/isolinux/win32-loader.ini ] ; then
181 echo " Moving extra loader files into place:"
182 for file in boot$N/isolinux/g2ldr* boot$N/isolinux/setup.exe boot$N/isolinux/win32-loader.ini; do
183 if [ -e $file ] ; then
184 printf " "
185 mv -v $file CD$N/
186 fi
187 done
188 # Modify win32-loader.ini for the "current" arch
189 sed -i "s|install/|$INSTALLDIR/|" CD$N/win32-loader.ini
190 if [ "${DESKTOP}" ] ; then
191 sed -i "s|^\(default_desktop\)=.*|\1=${DESKTOP}|" CD$N/win32-loader.ini
192 fi
193 fi
194
195 # Add autorun
196 if [ -f CD$N/setup.exe ]; then
197 # when win32-loader is present, use that (it already checks for README.html)
198 todos > $CDDIR/autorun.inf <<EOF
199 [autorun]
200 open=setup.exe
201 icon=setup.exe,0
202 label=Install Debian GNU/Linux
203
204 [Content]
205 MusicFiles=false
206 PictureFiles=false
207 VideoFiles=false
208 EOF
209 elif [ -f $CDDIR/README.html ]; then
210 todos > $CDDIR/autorun.inf <<EOF
211 [autorun]
212 open=autorun.bat
213 label=Install Debian GNU/Linux
214
215 [Content]
216 MusicFiles=false
217 PictureFiles=false
218 VideoFiles=false
219 EOF
220 todos > $CDDIR/autorun.bat <<EOF
221 @echo Starting "README.html"...
222 @start README.html
223 @exit
224 EOF
225 fi
226
227 # Common mkisofs options when creating CDs
228 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long"
229 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes"
230
231 # BIOS-boot specific stuff. Even when we're *not* doing BIOS boot, we
232 # still create all the isolinux config files as they're parsed and
233 # used later. We just don't grab all the syslinux files, then make
234 # sure that we *don't* set up BIOS boot on the xorriso command line.
235 if [ "$BOOT_BIOS" = 1 ] ; then
236 echo " Adding BIOS boot code for $ARCH on CD$N"
237 mkdir -p $CDDIR/../syslinux
238 SYSLINUXDEB=$(find_pkg_file syslinux)
239 if [ -z "$SYSLINUXDEB" ]; then
240 echo "ERROR: syslinux package is required" >&2
241 exit 1
242 fi
243 (dpkg --fsys-tarfile "$MIRROR/$SYSLINUXDEB" | \
244 tar xf - -C $CDDIR/../syslinux ./usr/lib)
245
246 if [ -n "$ARCHIVE_EXTRACTED_SOURCES" ]; then
247 echo $SYSLINUXDEB >> $CDDIR/../$N.pkgs_extracted
248 find_pkg_file syslinux source >> $CDDIR/../$N.pkgs_extracted
249 fi
250
251 ISOLINUXDEB=$(find_pkg_file isolinux)
252 if [ -z "$ISOLINUXDEB" ]; then
253 echo "ERROR: isolinux package is required" >&2
254 exit 1
255 fi
256 (dpkg --fsys-tarfile "$MIRROR/$ISOLINUXDEB" | \
257 tar xf - -C $CDDIR/../syslinux ./usr/lib)
258
259 if [ -n "$ARCHIVE_EXTRACTED_SOURCES" ]; then
260 echo $ISOLINUXDEB >> $CDDIR/../$N.pkgs_extracted
261 find_pkg_file isolinux source >> $CDDIR/../$N.pkgs_extracted
262 fi
263 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-isohybrid-mbr syslinux/usr/lib/ISOLINUX/isohdpfx.bin"
264
265 cp -f $CDDIR/../syslinux/usr/lib/ISOLINUX/isolinux.bin boot$N/isolinux/
266 cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/vesamenu.c32 boot$N/isolinux/
267 cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/ldlinux.c32 boot$N/isolinux/
268 cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/libcom32.c32 boot$N/isolinux/
269 cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/libutil.c32 boot$N/isolinux/
270
271 if [ ! -z "$MULTIARCH" ]; then
272 # Mandatory for 64bits capability detection
273 if [ -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/ifcpu64.c32 ] ; then
274 cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/ifcpu64.c32 boot$N/isolinux/
275 else
276 cp -f $CDDIR/../syslinux/usr/lib/syslinux/ifcpu64.c32 boot$N/isolinux/
277 fi
278 fi
279
280 # If we don't have grub stuff from d-i, tell xorriso to add a
281 # partition offset for the isohybrid code
282 if [ ! -d boot$N/isolinux/grub ] || [ $BOOT_EFI = 0 ] ; then
283 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_offset 16"
284 fi
285
286 # Add the normal options to make an ElTorito bootable CD/DVD using isolinux
287 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-b isolinux/isolinux.bin"
288 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-c isolinux/boot.cat"
289 bls=4 # Specify 4 for BIOS boot, don't calculate it
290 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-boot-load-size $bls"
291 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-boot-info-table"
292 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-no-emul-boot"
293
294 # We explicitly put the boot bits in boot$N (as opposed to CD$N)
295 # and list it first on the eventual mkisofs command line. That
296 # means they'll be placed nearer the front of the eventual image;
297 # some older BIOSes apparently have a limitation on what they'll
298 # boot here.
299 add_mkisofs_opt $CDDIR/../$N.mkisofs_dirs "boot$N"
300 else
301 echo " No BIOS boot code for $ARCH on CD$N"
302 fi
303
304 di_syslinux_ver="$(di_syslinux_version)"
305 case "$di_syslinux_ver" in
306 2.0)
307 : ;;
308 1.*)
309 echo "Error: syslinux config versions before 2.0 are not supported"
310 exit 1 ;;
311 *)
312 echo "Error: unrecognized syslinux config version '$di_syslinux_ver'"
313 exit 1 ;;
314 esac
315
316 if [ -e boot$N/isolinux/f3.txt.withgtk ]; then
317 extra_image gtk/vmlinuz "../vmlinuz"
318 extra_image gtk/initrd.gz "../initrd.gz"
319 mv boot$N/isolinux/f3.txt.withgtk boot$N/isolinux/f3.txt
320 mv boot$N/isolinux/f4.txt.withgtk boot$N/isolinux/f4.txt
321 if [ -e boot$N/isolinux/isolinux.cfg.withgtk ]; then
322 mv boot$N/isolinux/isolinux.cfg.withgtk boot$N/isolinux/isolinux.cfg
323 fi
324 if [ -e $CDDIR/tools/loadlin.exe ]; then
325 echo "\\tools\\loadlin.exe \\$INSTALLDIR\\vmlinuz initrd=initrd.gz vga=788" | todos > $CDDIR/$INSTALLDIR/gtk/install.bat
326 fi
327 fi
328 rm -f boot$N/isolinux/isolinux.cfg.with*
329
330 if variant_enabled "xen" ; then
331 extra_image xen/vmlinuz "../vmlinuz ../gtk/vmlinuz"
332 extra_image xen/initrd.gz "../initrd.gz ../gtk/initrd.gz"
333 extra_image xen/debian.cfg || extra_image xen/xm-debian.cfg
334 fi
335
336 if [ -z "$MULTIARCH" ]; then
337 # Set up isolinux dir for only the current arch
338 grep -lr '%install%' boot$N/isolinux/* | xargs -r sed -i "s|%install%|$INSTALLDIR|"
339
340 # Remove the x86*.cfg files to avoid them being loaded on a disc
341 # that does not have both amd64 and i386 dirs.
342 find boot$N/isolinux/ -name "x86*.cfg" -delete
343 else
344 # Use the syslinux.cfg with architecture detection
345 mv boot$N/isolinux/x86syslinux.cfg boot$N/isolinux/isolinux.cfg
346
347 # Set up isolinux dir for multi-arch
348 grep -lr '%install[-x86]*%' boot$N/isolinux/* | \
349 xargs -r sed -i -e "s|%install%|$INSTALLDIR_amd64|" \
350 -e "s|%install-x86%|$INSTALLDIR_i386|"
351
352 for file in boot$N/isolinux/f3.txt* boot$N/isolinux/f4.txt*; do
353 sed -i "4 s/^$/(note: amd64 is default; prepend 'x86-' to use an i386 kernel instead)/" $file
354 done
355
356 if [ -e CD$N/win32-loader.ini ]; then
357 # Modify win32-loader.ini to also cover the "other" arch
358 if [ "$ARCH" = amd64 ]; then
359 sed -i -e "/^arch=/d
360 /^amd64\//p; s/^amd64/i386/; s/=$INSTALLDIR_amd64/=$INSTALLDIR_i386/g" \
361 CD$N/win32-loader.ini
362 else
363 sed -i -e "/^arch=/d
364 /^i386\//p; s/^i386/amd64/; s/=$INSTALLDIR_i386/=$INSTALLDIR_amd64/g" \
365 CD$N/win32-loader.ini
366 fi
367 fi
368
369 if [ "$BOOT_BIOS" = 1 ] ; then
370 # Add another ifcpu64.c32 launch to let the 'enter' in help menus work correctly
371 sed -i "/^include menu.cfg/ a\include instsel.cfg" \
372 boot$N/isolinux/prompt.cfg
373 cat >boot$N/isolinux/instsel.cfg <<EOF
374 default install-select
375 label install-select
376 kernel ifcpu64.c32
377 append installgui -- x86-installgui
378 EOF
379 fi
380 fi
381
382 if [ "$SPLASHPNG" ] ; then
383 cp $SPLASHPNG boot$N/isolinux/splash.png
384 fi
385
386 # used by Debian Edu
387 if [ "$LOGOPNG" ] ; then
388 # Add custom logo to the initrd.gz file, replacing old image
389 GTKINITRD=$CDDIR/$INSTALLDIR/gtk/initrd
390 GTKINITRDGZ=$GTKINITRD.gz
391 echo "info: Adding $LOGOPNG to $GTKINITRD"
392 INITRDDIR=$TDIR/initrd-$$
393 # Repack initrd with new image
394 mkdir -p $INITRDDIR
395 (
396 cd $INITRDDIR
397 # There may be multiple hardlinks to the initrd.gz, so
398 # explicitly break the links here
399 zcat $GTKINITRDGZ > $GTKINITRD
400 rm -f $GTKINITRDGZ
401 mkdir -p $INITRDDIR/usr/share/graphics
402 cp $LOGOPNG $INITRDDIR/usr/share/graphics/logo_debian.png
403 echo usr/share/graphics/logo_debian.png | \
404 cpio -oA -H newc -F $GTKINITRD
405 pigz -9nm $GTKINITRD
406 )
407 rm -rf $INITRDDIR
408 fi
409
410 sed -i "s|built on|built $BUILD_DATE; d-i|" boot$N/isolinux/f1.txt
411
412 if [ -n "$KERNEL_PARAMS" ]; then
413 # Substitute custom kernel params into the isolinux config file(s)
414 for file in boot$N/isolinux/*.cfg; do
415 case "$(basename $file)" in
416 instsel.cfg)
417 continue ;;
418 esac
419 sed -i "/^[[:space:]]\+append .*---/ s|append|append $KERNEL_PARAMS|" \
420 $file
421 done
422 fi
423
424 set_default_desktop
425 rm -rf cdrom
426
427 if [ -d boot$N/isolinux/grub ] && [ $BOOT_EFI -ne 0 ] ; then
428 echo " Adding EFI boot code for $ARCH on CD$N"
429
430 # Move GRUB files to the right place.
431 mkdir -p $CDDIR/EFI/boot
432 mcopy -n -s -i boot$N/isolinux/grub/efi.img '::efi/*' $CDDIR/EFI
433 mkdir -p $CDDIR/boot/grub
434 mv boot$N/isolinux/grub/* $CDDIR/boot/grub/
435 rmdir boot$N/isolinux/grub
436
437 # If we're only doing EFI, copy the splash file from the BIOS boot dir
438 if [ $BOOT_EFI = 1 ] ; then
439 mkdir -p $CDDIR/isolinux
440 cp boot$N/isolinux/splash.png $CDDIR/isolinux
441 fi
442
443 # Create grub menu entries to match the isolinux ones
444 sed -i '/^menuentry/Q' $CDDIR/boot/grub/grub.cfg;
445 $BASEDIR/tools/boot/$DI_CODENAME/parse_isolinux \
446 boot$N/isolinux $CDDIR $BASEDIR/data/$DI_CODENAME/grub-theme.in "$DISKINFO_DISTRO" "$DEBIAN_KERNEL" "$DEBVERSION" \
447 >> $CDDIR/boot/grub/grub.cfg
448 cp -v $BASEDIR/data/$DI_CODENAME/hl*png $CDDIR/boot/grub/theme
449 NUM_ENTRIES=$(grep menuentry $CDDIR/boot/grub/grub.cfg | wc -l)
450 echo " CD$N/boot/grub/grub.cfg has $NUM_ENTRIES boot entries defined"
451
452 # Stuff the EFI boot files into a FAT filesystem, making it as
453 # small as possible. We end up re-packing like this in case we're
454 # making a multi-arch image
455
456 change_grub_cfg_uuid $CDDIR
457
458 # First, work out how many blocks we need
459 blocks=$(calculate_efi_image_size $CDDIR)
460
461 # Now make a new image to contain the files
462 rm -f $CDDIR/boot/grub/efi.img
463 mkfs.msdos -v -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null
464
465 # And copy them into place
466 mmd -i "$CDDIR/boot/grub/efi.img" ::efi
467 mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \
468 "::efi"
469
470 if [ $BOOT_EFI = 2 ] ; then
471 # We're being added alongside (after) a BIOS boot record. Tell
472 # xorriso to create a (secondary) ElTorito boot record for the
473 # EFI bootloader. Otherwise, xorriso will create it as the
474 # primary.
475 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-eltorito-alt-boot"
476 fi
477
478 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot"
479 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
480 else
481 echo " No EFI boot code for $ARCH on CD$N"
482 fi
483
484 # th,th, thats all
485