Debian Codegraph @

tools/boot/buster/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 # Stuff the EFI boot files into a FAT filesystem, making it as
94 # small as possible. We end up re-packing like this in case we're
95 # making a multi-arch image
96
97 # First, work out how many blocks we need
98 blocks=$(calculate_efi_image_size $CDDIR)
99
100 # Now make a new image to contain the files
101 rm -f $CDDIR/boot/grub/efi.img
102 mkfs.msdos -v -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null
103
104 # And copy them into place
105 mmd -i "$CDDIR/boot/grub/efi.img" ::efi
106 mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \
107 "::efi"
108
109 # Ugh - different code here depending on the version of xorriso we've got
110 if [ $XORRISO_VER -le 10202 ] ; then
111 echo "ERROR: debian-cd depends on xorriso > 1.2.2 for making $ARCH bootable CDs."
112 exit 1;
113 elif [ $XORRISO_VER -gt 10202 ] ; then
114 echo " Using newer EFI support in xorriso $XORRISO_VER"
115
116 # Location of the EFI boot image, and don't emulate a floppy or HD
117 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot"
118
119 # Add an *extra* partition on the end for the EFI bits
120 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-append_partition 2 0xef $CDDIR/boot/grub/efi.img"
121
122 # And force alignment
123 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_cyl_align all"
124 fi
125
126 # Finally, belt and braces - fix up the %install% entries in grub
127 # in case they're still there
128 sed -i "s|\%install\%|$INSTALLDIR|g" $CDDIR/boot/grub/grub.cfg
129
130 # Substitute custom KERNEL_PARAMS into grub.cfg
131 sed -i "s|/vmlinuz |/vmlinuz $KERNEL_PARAMS |g" $CDDIR/boot/grub/grub.cfg
132
133 else
134 echo " No EFI boot code for $ARCH on CD$N"
135 fi
136
137 # th,th, thats all