| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Based on boot-arm64 |
| 4 |
# |
| 5 |
# Do install stuff for riscv64, 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 |
|
| 12 |
. $BASEDIR/tools/boot/$DI_CODENAME/common.sh |
| 13 |
|
| 14 |
set -e |
| 15 |
#set -x |
| 16 |
|
| 17 |
N=$1 |
| 18 |
CDDIR=$2 |
| 19 |
INSTALLDIR="install" |
| 20 |
|
| 21 |
# Common options for all disks |
| 22 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long" |
| 23 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes" |
| 24 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-l" |
| 25 |
|
| 26 |
# Exit if this is not CD#1/DVD#1 |
| 27 |
if [ $N != "1" ]; then |
| 28 |
exit 0 |
| 29 |
fi |
| 30 |
|
| 31 |
if [ "$DI_WWW_HOME" = "default" ]; then |
| 32 |
DI_WWW_HOME="https://d-i.debian.org/daily-images/riscv64/daily" |
| 33 |
try_di_image_cache |
| 34 |
else |
| 35 |
DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,") |
| 36 |
fi |
| 37 |
|
| 38 |
case "$MKISOFS" in |
| 39 |
*xorriso*) |
| 40 |
XORRISO_VER=$(xorriso_version) |
| 41 |
;; |
| 42 |
*) |
| 43 |
echo "ERROR: debian-cd depends on xorriso for making $ARCH bootable CDs." |
| 44 |
exit 1; |
| 45 |
;; |
| 46 |
esac |
| 47 |
|
| 48 |
cd $CDDIR/.. |
| 49 |
|
| 50 |
BOOT_IMAGES="cdrom/initrd.gz cdrom/vmlinux cdrom/debian-cd_info.tar.gz" |
| 51 |
|
| 52 |
# Download boot images. |
| 53 |
for image in $BOOT_IMAGES; do |
| 54 |
if [ ! -e "$image" ]; then |
| 55 |
dir=$(dirname $image) |
| 56 |
mkdir -p $dir |
| 57 |
if [ -n "$LOCAL" -a -f "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" ]; then |
| 58 |
cp "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" "$image" |
| 59 |
elif [ ! "$DI_WWW_HOME" ];then |
| 60 |
if [ ! "$DI_DIR" ];then |
| 61 |
DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images" |
| 62 |
fi |
| 63 |
cp "$DI_DIR/$image" "$image" |
| 64 |
else |
| 65 |
$WGET "$DI_WWW_HOME/$image" -O "$image" |
| 66 |
fi |
| 67 |
fi |
| 68 |
done |
| 69 |
|
| 70 |
mkdir -p $CDDIR/$INSTALLDIR |
| 71 |
cp -lf cdrom/vmlinux $CDDIR/$INSTALLDIR/ |
| 72 |
cp -lf cdrom/initrd.gz $CDDIR/$INSTALLDIR/ |
| 73 |
|
| 74 |
# Boot setup including config and help files comes from d-i. |
| 75 |
mkdir -pv $PWD/boot$N |
| 76 |
cat cdrom/debian-cd_info.tar.gz | (cd boot$N/; tar zx) |
| 77 |
|
| 78 |
if [ -d boot$N/grub ] ; then |
| 79 |
echo " Adding EFI boot code for $ARCH on CD$N" |
| 80 |
|
| 81 |
# Extract DTB files |
| 82 |
mkdir -p $CDDIR/dtb |
| 83 |
mcopy -n -s -i boot$N/grub/efi.img '::dtb/*' $CDDIR/dtb |
| 84 |
|
| 85 |
# Extract GRUB files |
| 86 |
mkdir -p $CDDIR/EFI/boot |
| 87 |
mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI |
| 88 |
mkdir -p $CDDIR/boot/grub |
| 89 |
mv boot$N/grub/* $CDDIR/boot/grub/ |
| 90 |
rmdir boot$N/grub |
| 91 |
|
| 92 |
# Do not repack efi.img, the version provided by d-i is suitable to create a bootable CD |
| 93 |
|
| 94 |
# Location of the EFI boot image, and don't emulate a floppy or HD |
| 95 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot" |
| 96 |
|
| 97 |
# Add an *extra* partition on the end for the EFI bits |
| 98 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-append_partition 2 0xef $CDDIR/boot/grub/efi.img" |
| 99 |
|
| 100 |
# And force alignment |
| 101 |
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_cyl_align all" |
| 102 |
|
| 103 |
# Finally, belt and braces - fix up the %install% entries in grub |
| 104 |
# in case they're still there |
| 105 |
sed -i "s|\%install\%|$INSTALLDIR|g" $CDDIR/boot/grub/grub.cfg |
| 106 |
|
| 107 |
# Substitute custom KERNEL_PARAMS into grub.cfg |
| 108 |
sed -i "s|/vmlinux |/vmlinux $KERNEL_PARAMS |g" $CDDIR/boot/grub/grub.cfg |
| 109 |
|
| 110 |
else |
| 111 |
echo " No EFI boot code for $ARCH on CD$N" |
| 112 |
fi |
| 113 |
|
| 114 |
# th,th, thats all |