From 1865f68bd82e97a586f73b1946b5649825270227 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Mon, 7 Oct 2024 20:10:35 +1100 Subject: [PATCH] Side show to build minimal arm64 on multiarch amd64 --- run-arm64.sh | 26 +++++++++ trial-arm64-upgrade.sh | 129 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100755 run-arm64.sh create mode 100755 trial-arm64-upgrade.sh diff --git a/run-arm64.sh b/run-arm64.sh new file mode 100755 index 0000000..6dd6ec2 --- /dev/null +++ b/run-arm64.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +ARCH=arm64 + +IMG=disk-$ARCH.raw + +APPEND="ima_appraise=off security=none" +QEMU=qemu-system-aarch64 +ARGS=( + -M virt -cpu cortex-a53 -m 4G + -kernel arm64/vmlinuz -initrd arm64/initrd.gz + -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4 $APPEND" + -serial mon:stdio -echr 0x1c + -display gtk,gl=on -device virtio-gpu-pci + -device qemu-xhci -device usb-kbd + #-nographic + #-chardev socket,id=QEMU,server=on,wait=off,path=QEMU-arm64 + #-serial stdio -mon chardev=QEMU,mode=readline + -device virtio-blk-device,drive=hd + -drive if=none,id=hd,file=$IMG,format=raw + -device virtio-net-device,netdev=unet + -netdev vde,sock=/run/vde.ctl,id=unet +) + +echo $QEMU "${ARGS[@]}" | sed 's/ -/\n -/g' >&2 +exec $QEMU "${ARGS[@]}" diff --git a/trial-arm64-upgrade.sh b/trial-arm64-upgrade.sh new file mode 100755 index 0000000..77c79a3 --- /dev/null +++ b/trial-arm64-upgrade.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# This is the boot system build script. +: ${REPO_URL:=http://deb.devuan.org/merged} +: ${ARCH:=arm64} +: ${CODENAME:=daedalus} +: ${BUILD:=$ARCH/build} +: ${SOURCES:=$ARCH/sources} +: ${INITRD:=$ARCH/build/initrd} +: ${MEDIA:=$ARCH/build/media} +: ${POOL:=$ARCH/build/media/pool} +: ${http_proxy:=http://10.10.10.100:3142} + +export http_proxy + +note() { + echo "$*" >&2 +} + +die() { # message... + note "**ERROR: $*" + exit 1 +} + +get_source() { # section + local E + local P="$SOURCES/${S//\//_}-Packages" + local URL=$REPO_URL/dists/$CODENAME/$S/binary-$ARCH/Packages + note "$P" + mkdir -p $(dirname "$P") + for E in .xz:unxz .gz:gunzip :cat ; do + wget -q -O- $URL${E%:*} | ${E#*:} > "$P" && return 0 + rm "$P" + done + die "$URL" +} + +debattr() { # package-expr tag + sed -e '/Package: '$1'$/,/^$/!d;/^'$2':/!d;s|^[^ ]* ||' \ + $SOURCES/main{,_debian-installer}-Packages +} + +heredoc() { # pathname + mkdir -p $(dirname "$1") + cat > "$1" +} + +herescript() { # pathname + heredoc "$1" + chmod a+x "$1" +} + +do_depends() { # package depend-tag directory + local D + debattr "$1" "$2" | tr , '\012' | sed 's/|.*//;s/([^)]*)//g' | \ + while read D ; do [ -z "$D" ] || unpack $D $3 || exit 1 ; done +} + +unpack() { # package directory + local F="$(debattr $1 Filename)" + local URL="${REPO_URL%/*}/$F" + local DST="$MEDIA/$F" + [ -z "$F" ] && die "Unknown package $1" + [ -f "$DST" ] && return 0 + local URL="${REPO_URL}/$F" + mkdir -p "${DST%/*}" + note "${INDENT}Get $1" + if ! wget -q -O $DST $URL ; then rm "$DST" ; exit 1 ; fi + mkdir -p "$2" + ar p $DST data.tar.xz | tar -xJf - -C $2 + INDENT="$INDENT " do_depends "$1" Pre-Depends "$2" || exit 1 + INDENT="$INDENT " do_depends "$1" Depends "$2" || exit 1 +} + +#================================================================= +SECTIONS="main main/debian-installer" +for S in $SECTIONS ; do get_source $S || die $S ; done +LINUX="$(debattr linux-image-$ARCH Depends | sed 's| .*||' )" +VERSION="${LINUX#linux-image-}" +KERNEL="kernel-image-$VERSION-di" + +for M in $(cat) ; do unpack $M $INITRD || exit 1 ; done < $ARCH/initrd.gz + -- 2.39.2