Debian Codegraph @

tools/boot/kali-dev/boot-loong64

raw
1 #!/bin/bash
2
3 # Based on boot-x86
4 #
5 # Do install stuff for loong64, 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"
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/loong64/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 # Try to add graphical installer build too
77 extra_image gtk/vmlinuz "../vmlinuz" || true
78 extra_image gtk/initrd.gz "../initrd.gz" || true
79
80 # Boot setup including config and help files comes from d-i.
81 mkdir -pv $PWD/boot$N
82 cat cdrom/debian-cd_info.tar.gz | (cd boot$N/; tar zx)
83
84 if [ -d boot$N/grub ] ; then
85 echo " Adding EFI boot code for $ARCH on CD$N"
86
87 # Move GRUB files to the right place.
88 mkdir -p $CDDIR/EFI/boot
89 mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI
90 mkdir -p $CDDIR/boot/grub
91 mv boot$N/grub/* $CDDIR/boot/grub/
92 rmdir boot$N/grub
93
94 change_grub_cfg_uuid $CDDIR
95
96 # Stuff the EFI boot files into a FAT filesystem, making it as
97 # small as possible. We end up re-packing like this in case we're
98 # making a multi-arch image
99
100 # First, work out how many blocks we need
101 blocks=$(calculate_efi_image_size $CDDIR)
102
103 # Now make a new image to contain the files
104 rm -f $CDDIR/boot/grub/efi.img
105 mkfs.msdos --invariant -v -i deb00001 -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null
106
107 # And copy them into place
108 mmd -i "$CDDIR/boot/grub/efi.img" ::efi
109 mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \
110 "::efi"
111
112 # Ugh - different code here depending on the version of xorriso we've got
113 if [ $XORRISO_VER -le 10202 ] ; then
114 echo "ERROR: debian-cd depends on xorriso > 1.2.2 for making $ARCH bootable CDs."
115 exit 1;
116 elif [ $XORRISO_VER -gt 10202 ] ; then
117 echo " Using newer EFI support in xorriso $XORRISO_VER"
118
119 # Location of the EFI boot image, and don't emulate a floppy or HD
120 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot"
121
122 # Add an *extra* partition on the end for the EFI bits
123 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-append_partition 2 0xef $CDDIR/boot/grub/efi.img"
124
125 # And force alignment
126 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_cyl_align all"
127 fi
128
129 # Finally, belt and braces - fix up the %install% entries in grub
130 # in case they're still there
131 sed -i "s|\%install\%|$INSTALLDIR|g" $CDDIR/boot/grub/grub.cfg
132
133 # Substitute custom KERNEL_PARAMS into grub.cfg
134 sed -i "s|/vmlinuz |/vmlinuz $KERNEL_PARAMS |g" $CDDIR/boot/grub/grub.cfg
135
136 else
137 echo " No EFI boot code for $ARCH on CD$N"
138 fi
139
140 # th,th, thats all