From 81bd9bf6ec23f8853338cba508fc23d358744c43 Mon Sep 17 00:00:00 2001 From: dandan zhang Date: Wed, 25 Sep 2024 10:46:15 +0000 Subject: [PATCH] Add basic support for loongarch64 --- CONF.sh | 3 + Makefile | 2 +- data/trixie/loong64_businesscard_udeb_include | 3 + data/trixie/loong64_netinst_udeb_include | 2 + data/trixie/loong64_udeb_include | 3 + tools/boot/trixie/boot-loong64 | 140 ++++++++++++++++++ tools/generate_di+k_list | 11 ++ update-cd | 2 +- 8 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 data/trixie/loong64_businesscard_udeb_include create mode 100644 data/trixie/loong64_netinst_udeb_include create mode 100644 data/trixie/loong64_udeb_include create mode 100755 tools/boot/trixie/boot-loong64 diff --git a/CONF.sh b/CONF.sh index 8837989a..5c4a8265 100644 --- a/CONF.sh +++ b/CONF.sh @@ -222,6 +222,9 @@ export JIGDO_CHECKSUM="md5" #export amd64_MKISOFS="xorriso" #export amd64_MKISOFS_OPTS="-as mkisofs -r -checksum_algorithm_iso sha256,sha512" +export loong64_MKISOFS="xorriso" +export loong64_MKISOFS_OPTS="-as mkisofs -r -checksum_algorithm_iso sha256,sha512" + # amd64 builds will also include 32-bit UEFI files by default, to # allow for booting on weird machines with 64-bit CPUs but 32-bit # firmware like Baytrail or some models of Apple iMac. To disable diff --git a/Makefile b/Makefile index 9c3ba3a0..744b1e5b 100755 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ DEBOOTSTRAP_OPTS=--no-check-gpg endif ## Additional packages required for Debian Ports -DEBIAN_PORTS_ARCHES=alpha hppa ia64 hurd-amd64 hurd-i386 m68k powerpc powerpcspe ppc64 sh4 sparc sparc64 x32 +DEBIAN_PORTS_ARCHES=alpha hppa ia64 hurd-amd64 hurd-i386 loong64 m68k powerpc powerpcspe ppc64 sh4 sparc sparc64 x32 ifneq (,$(filter $(DEBIAN_PORTS_ARCHES),$(ARCHES))) export BASE_INCLUDE := $(BASEDIR)/data/debian_ports $(BASE_INCLUDE) endif diff --git a/data/trixie/loong64_businesscard_udeb_include b/data/trixie/loong64_businesscard_udeb_include new file mode 100644 index 00000000..6326d6c5 --- /dev/null +++ b/data/trixie/loong64_businesscard_udeb_include @@ -0,0 +1,3 @@ +choose-mirror +netcfg +ethdetect diff --git a/data/trixie/loong64_netinst_udeb_include b/data/trixie/loong64_netinst_udeb_include new file mode 100644 index 00000000..6f1c801c --- /dev/null +++ b/data/trixie/loong64_netinst_udeb_include @@ -0,0 +1,2 @@ +netcfg +ethdetect diff --git a/data/trixie/loong64_udeb_include b/data/trixie/loong64_udeb_include new file mode 100644 index 00000000..15532776 --- /dev/null +++ b/data/trixie/loong64_udeb_include @@ -0,0 +1,3 @@ +netcfg +ethdetect +pcmciautils-udeb diff --git a/tools/boot/trixie/boot-loong64 b/tools/boot/trixie/boot-loong64 new file mode 100755 index 00000000..03e90126 --- /dev/null +++ b/tools/boot/trixie/boot-loong64 @@ -0,0 +1,140 @@ +#!/bin/bash + +# Based on boot-x86 +# +# Do install stuff for loong64, including making bootable CDs +# Works with debian-installer +# +# $1 is the CD number +# $2 is the temporary CD build dir + +. $BASEDIR/tools/boot/$DI_CODENAME/common.sh + +set -e +#set -x + +# Workaround for #823881: +export MTOOLS_SKIP_CHECK=1 + +N=$1 +CDDIR=$2 +INSTALLDIR="install" + +# Common options for all disks +add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long" +add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes" +add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-l" + +# Exit if this is not CD#1/DVD#1 +if [ $N != "1" ]; then + exit 0 +fi + +if [ "$DI_WWW_HOME" = "default" ]; then + DI_WWW_HOME="https://d-i.debian.org/daily-images/loong64/daily" + try_di_image_cache +else + DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,") +fi + +case "$MKISOFS" in + *xorriso*) + XORRISO_VER=$(xorriso_version) + ;; + *) + echo "ERROR: debian-cd depends on xorriso for making $ARCH bootable CDs." + exit 1; + ;; +esac + +cd $CDDIR/.. + +BOOT_IMAGES="cdrom/initrd.gz cdrom/vmlinuz cdrom/debian-cd_info.tar.gz" + +# Download boot images. +for image in $BOOT_IMAGES; do + if [ ! -e "$image" ]; then + dir=$(dirname $image) + mkdir -p $dir + if [ -n "$LOCAL" -a -f "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" ]; then + cp "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" "$image" + elif [ ! "$DI_WWW_HOME" ];then + if [ ! "$DI_DIR" ];then + DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images" + fi + cp "$DI_DIR/$image" "$image" + else + $WGET "$DI_WWW_HOME/$image" -O "$image" + fi + fi +done + +mkdir -p $CDDIR/$INSTALLDIR +cp -lf cdrom/vmlinuz $CDDIR/$INSTALLDIR/ +cp -lf cdrom/initrd.gz $CDDIR/$INSTALLDIR/ + +# Try to add graphical installer build too +extra_image gtk/vmlinuz "../vmlinuz" || true +extra_image gtk/initrd.gz "../initrd.gz" || true + +# Boot setup including config and help files comes from d-i. +mkdir -pv $PWD/boot$N +cat cdrom/debian-cd_info.tar.gz | (cd boot$N/; tar zx) + +if [ -d boot$N/grub ] ; then + echo " Adding EFI boot code for $ARCH on CD$N" + + # Move GRUB files to the right place. + mkdir -p $CDDIR/EFI/boot + mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI + mkdir -p $CDDIR/boot/grub + mv boot$N/grub/* $CDDIR/boot/grub/ + rmdir boot$N/grub + + change_grub_cfg_uuid $CDDIR + + # Stuff the EFI boot files into a FAT filesystem, making it as + # small as possible. We end up re-packing like this in case we're + # making a multi-arch image + + # First, work out how many blocks we need + blocks=$(calculate_efi_image_size $CDDIR) + + # Now make a new image to contain the files + rm -f $CDDIR/boot/grub/efi.img + mkfs.msdos --invariant -v -i deb00001 -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null + + # And copy them into place + mmd -i "$CDDIR/boot/grub/efi.img" ::efi + mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \ + "::efi" + + # Ugh - different code here depending on the version of xorriso we've got + if [ $XORRISO_VER -le 10202 ] ; then + echo "ERROR: debian-cd depends on xorriso > 1.2.2 for making $ARCH bootable CDs." + exit 1; + elif [ $XORRISO_VER -gt 10202 ] ; then + echo " Using newer EFI support in xorriso $XORRISO_VER" + + # Location of the EFI boot image, and don't emulate a floppy or HD + add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot" + + # Add an *extra* partition on the end for the EFI bits + add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-append_partition 2 0xef $CDDIR/boot/grub/efi.img" + + # And force alignment + add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_cyl_align all" + fi + + # Finally, belt and braces - fix up the %install% entries in grub + # in case they're still there + sed -i "s|\%install\%|$INSTALLDIR|g" $CDDIR/boot/grub/grub.cfg + + # Substitute custom KERNEL_PARAMS into grub.cfg + sed -i "s|/vmlinuz |/vmlinuz $KERNEL_PARAMS |g" $CDDIR/boot/grub/grub.cfg + +else + echo " No EFI boot code for $ARCH on CD$N" +fi + +# th,th, thats all diff --git a/tools/generate_di+k_list b/tools/generate_di+k_list index 04e7118c..baae7ccc 100755 --- a/tools/generate_di+k_list +++ b/tools/generate_di+k_list @@ -379,4 +379,15 @@ grub-pc s390-tools sysconfig-hardware #endif + +#ifdef ARCH_loong64 +initramfs-tools +busybox +zstd +linux-image-loong64 +linux-headers-loong64 +grub-efi +grub-efi-loong64 +grub-efi-loong64-bin +#endif EOF diff --git a/update-cd b/update-cd index 82ade53a..060d3293 100755 --- a/update-cd +++ b/update-cd @@ -89,7 +89,7 @@ CAPCODE=`perl -e "print ucfirst("$CODENAME")"` export FIRSTVER CAPCODE if [ "$ARCHLIST"x = ""x ] ; then - ARCHLIST="arm64 armel armhf amd64 i386 mips mipsel mips64el ppc64el s390x source" # amd64 # -all dealt with specially + ARCHLIST="arm64 armel armhf amd64 i386 loong64 mips mipsel mips64el ppc64el s390x source" # amd64 # -all dealt with specially fi export TDIR NONFREE NONFREE_FIRMWARE VER MIRROR CODENAME OUT BASEDIR