Debian Codegraph @

tools/boot/trixie/boot-armhf

raw
1 #!/bin/bash
2 # Do install stuff for armhf
3 # Sets up a grub-efi installer
4 #
5 # $1 is the CD number
6 # $2 is the temporary CD build dir
7
8 . $BASEDIR/tools/boot/$DI_CODENAME/common.sh
9
10 set -e
11
12 N=$1
13 CDDIR=$2
14 INSTALLDIR="install.ahf"
15
16 # Workaround for #823881:
17 export MTOOLS_SKIP_CHECK=1
18
19 # Common options for all disks
20 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long"
21 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes"
22 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-l"
23
24 # Exit if this is not CD#1/DVD#1
25 if [ $N != "1" ]; then
26 exit 0
27 fi
28
29 if [ "$DI_WWW_HOME" = "default" ]; then
30 DI_WWW_HOME="https://d-i.debian.org/daily-images/armhf/daily"
31 try_di_image_cache
32 else
33 DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,")
34 fi
35
36 # armhf is not bootable directly from CD/DVD/USB for all plaforms. For
37 # those that are not, add the needed files in the right place so that
38 # users can find them, at least
39 copy_arch_images
40
41 # Now for the more clever stuff - for U-Boot EFI support or a direct
42 # qemu etc. we can boot using EFI!
43 case "$MKISOFS" in
44 *xorriso*)
45 XORRISO_VER=$(xorriso_version)
46 ;;
47 *)
48 echo "ERROR: debian-cd depends on xorriso for making $ARCH bootable CDs."
49 exit 1;
50 ;;
51 esac
52
53 cd $CDDIR/..
54
55 BOOT_IMAGES="cdrom/initrd.gz cdrom/vmlinuz cdrom/debian-cd_info.tar.gz"
56
57 # Download boot images.
58 for image in $BOOT_IMAGES; do
59 if [ ! -e "$image" ]; then
60 dir=$(dirname $image)
61 mkdir -p $dir
62 if [ -n "$LOCAL" -a -f "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" ]; then
63 cp "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" "$image"
64 elif [ ! "$DI_WWW_HOME" ];then
65 if [ ! "$DI_DIR" ];then
66 DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images"
67 fi
68 cp "$DI_DIR/$image" "$image"
69 else
70 $WGET "$DI_WWW_HOME/$image" -O "$image"
71 fi
72 fi
73 done
74
75 mkdir -p $CDDIR/$INSTALLDIR
76 cp -lf cdrom/vmlinuz $CDDIR/$INSTALLDIR/
77 cp -lf cdrom/initrd.gz $CDDIR/$INSTALLDIR/
78
79 # Boot setup including config and help files comes from d-i.
80 mkdir -pv $PWD/boot$N
81 cat cdrom/debian-cd_info.tar.gz | (cd boot$N/; tar zx)
82
83 if [ -d boot$N/grub ] ; then
84 echo " Adding EFI boot code for $ARCH on CD$N"
85
86 # Move GRUB files to the right place.
87 mkdir -p $CDDIR/EFI/boot
88 mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI
89 mkdir -p $CDDIR/boot/grub
90 mv boot$N/grub/* $CDDIR/boot/grub/
91 rmdir boot$N/grub
92
93 change_grub_cfg_uuid $CDDIR
94
95 # Stuff the EFI boot files into a FAT filesystem, making it as
96 # small as possible. We end up re-packing like this in case we're
97 # making a multi-arch image
98
99 # First, work out how many blocks we need
100 blocks=$(calculate_efi_image_size $CDDIR)
101
102 # Now make a new image to contain the files
103 rm -f $CDDIR/boot/grub/efi.img
104 mkfs.msdos --invariant -v -i deb00001 -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null
105
106 # And copy them into place
107 mmd -i "$CDDIR/boot/grub/efi.img" ::efi
108 mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \
109 "::efi"
110
111 # Ugh - different code here depending on the version of xorriso we've got
112 if [ $XORRISO_VER -le 10202 ] ; then
113 echo "ERROR: debian-cd depends on xorriso > 1.2.2 for making $ARCH bootable CDs."
114 exit 1;
115 elif [ $XORRISO_VER -gt 10202 ] ; then
116 echo " Using newer EFI support in xorriso $XORRISO_VER"
117
118 # Location of the EFI boot image, and don't emulate a floppy or HD
119 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot"
120
121 # Add an *extra* partition on the end for the EFI bits
122 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-append_partition 2 0xef $CDDIR/boot/grub/efi.img"
123
124 # And force alignment
125 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_cyl_align all"
126 fi
127
128 # Finally, belt and braces - fix up the %install% entries in grub
129 # in case they're still there
130 sed -i "s|\%install\%|$INSTALLDIR|g" $CDDIR/boot/grub/grub.cfg
131
132 # Substitute custom KERNEL_PARAMS into grub.cfg
133 sed -i "s|/vmlinuz |/vmlinuz $KERNEL_PARAMS |g" $CDDIR/boot/grub/grub.cfg
134
135 else
136 echo " No EFI boot code for $ARCH on CD$N"
137 fi
138
139 # th,th, thats all