Debian Codegraph @

tools/boot/buster/boot-arm64

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