aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-09-12 12:23:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-04 06:10:57 +0200
commit81b23d75d873cbabc086729022a4b9b4f3d22a66 (patch)
treed083968e8555afbee843a834e63de80e4419a076
parenta22c237897a5fee1e32b52251d5a324248dc41f8 (diff)
Add support for aarch64
-rw-r--r--.gitignore6
-rwxr-xr-xbootstrap66
-rw-r--r--bootstrap.txt10
-rwxr-xr-xbuildos6
-rwxr-xr-xupload-os24
5 files changed, 91 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore
index 0158dea..46a102d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
*.cpio.gz
-buildos-buildid
-buildos-initrd
-buildos-image
+buildos-buildid-*
+buildos-initrd-*
+buildos-image-*
bootstrap*.log
diff --git a/bootstrap b/bootstrap
index c202e4c..b32a931 100755
--- a/bootstrap
+++ b/bootstrap
@@ -4,6 +4,8 @@
#
# Assumptions/expectations:
#
+# - Bootstrapping for the host CPU (currently x86_64 or aarch64).
+#
# - Host debootstrap/debian-archive-keyring matching release.
#
# - /btrfs/<user> is a btrfs directory where the current user can create
@@ -32,6 +34,20 @@ id="$(id -un)"
btrfs=/btrfs
root="$btrfs/$id/buildos"
+arch="$(uname -m)"
+
+case "$arch" in
+ x86_64)
+ debian_arch=amd64
+ ;;
+ aarch64)
+ debian_arch=arm64
+ ;;
+ *)
+ error "unsupported architecture: $arch"
+ ;;
+esac
+
# Source distribution and packages. Base packages are installed on stage 1 via
# debootstrap. Extra packages are added on stage 4 via apt-get install. The
# idea is to be able to add extra packages without upgrading the base system.
@@ -42,7 +58,7 @@ root="$btrfs/$id/buildos"
# - some packages (such as CPU microcode updates) are in non-free.
# - systemd-container seems to be required by host systemd-nspawn.
# - must explicitly select between dbus and dbus-broker
-# - not installing linux-image-amd64 since building custom below
+# - not installing linux-image-* since building custom below
#
release="testing"
components="main,contrib,non-free"
@@ -52,8 +68,7 @@ mirror="http://http.us.debian.org/debian/"
base_pkgs="locales,klibc-utils,sudo"
base_pkgs+=",udev,dbus,systemd-timesyncd,systemd-container"
base_pkgs+=",kmod,linux-base,firmware-linux-free,irqbalance"
-base_pkgs+=",intel-microcode" #,amd64-microcode
-base_pkgs+=",pciutils,usbutils,dmidecode,cpuid"
+base_pkgs+=",pciutils,usbutils,dmidecode"
base_pkgs+=",hdparm,btrfs-progs"
base_pkgs+=",lm-sensors,smartmontools,linux-cpupower"
@@ -66,10 +81,20 @@ base_pkgs+=",tftp-hpa,tftpd-hpa"
base_pkgs+=",zstd,xz-utils"
base_pkgs+=",less,nano,time"
+base_pkgs+=",g++,make"
-base_pkgs+=",qemu-system-x86,qemu-utils,socat"
+base_pkgs+=",qemu-utils,socat"
-base_pkgs+=",g++,make"
+case "$arch" in
+ x86_64)
+ base_pkgs+=",cpuid"
+ base_pkgs+=",intel-microcode" #,amd64-microcode
+ base_pkgs+=",qemu-system-x86"
+ ;;
+ aarch64)
+ base_pkgs+=",qemu-system-arm"
+ ;;
+esac
extra_pkgs=""
@@ -212,7 +237,7 @@ if [ "$stage" -eq "1" ]; then
sudo debootstrap \
--foreign \
- --arch=amd64 \
+ --arch="$debian_arch" \
--merged-usr \
--variant=minbase \
--components="$components" \
@@ -256,9 +281,18 @@ rm /etc/localtime
# Both nspawn and debootstrap try to mount /proc /sys (Debian bug#840372).
#
-mkdir /tmp/proc /tmp/sys
-mount --move /proc /tmp/proc
-mount --move /sys /tmp/sys
+# @@ TMP this now causes issues with newer systemd.
+#
+#mkdir /tmp/proc /tmp/sys
+#mount --move /proc /tmp/proc
+#mount --move /sys /tmp/sys
+
+# systemd-nspawn "helpfully" creates a /lib64 symlink that then trips
+# up is-usr-merged package (Debain bug #1019575).
+#
+if [ $arch = aarch64 ]; then
+ rm /lib64
+fi
# Run second stage of debootstrap.
#
@@ -425,7 +459,7 @@ apt-get install -y dwarves
cd /usr/src
tar xf linux-source-*
mv linux-source-*/ linux
-xzcat linux-config-*/config.amd64_none_amd64.xz >linux/.config
+xzcat linux-config-*/config.${debian_arch}_none_${debian_arch}.xz >linux/.config
cd linux
# Adjust configuration.
@@ -449,6 +483,12 @@ scripts/config --disable INIT_STACK_ALL_ZERO
scripts/config --enable DEBUG_INFO_NONE
scripts/config --disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
+# aarch64/5.19 additions:
+#
+scripts/config --disable KCOV
+scripts/config --disable SHADOW_CALL_STACK
+scripts/config --disable VIDEO_ADV7511
+
# Disable sound subsystem/drivers.
#
sed -i -re '/^CONFIG_SND_.+/d' .config
@@ -660,12 +700,12 @@ etc/systemd/system/multi-user.target.wants/buildos.service
EOF
cd "$owd"
- cat buildos-rootfs.cpio.gz buildos-init.cpio.gz >buildos-initrd
+ cat buildos-rootfs.cpio.gz buildos-init.cpio.gz >"buildos-initrd-$arch"
# Copy the kernel image next to the initramfs for convenience.
#
- cp "$root/vmlinuz" buildos-image
- echo "$buildid" >buildos-buildid
+ cp "$root/vmlinuz" "buildos-image-$arch"
+ echo "$buildid" >"buildos-buildid-$arch"
subvol_snapshot -r "$root" "$root-6"
fi
diff --git a/bootstrap.txt b/bootstrap.txt
index 5489a72..e9963fa 100644
--- a/bootstrap.txt
+++ b/bootstrap.txt
@@ -4,7 +4,7 @@
- systemd
- qemu-system-x86
- - linux-image-amd64
+ - linux-image-amd64 & btrfs-progs
- g++
If some of them are very recent (and thus likely to still have issues)
@@ -31,7 +31,10 @@
not to conflate failures.
* Upgrade to latest debootstrap and debian-archive-keyring from unstable
- (or testing).
+ (or testing). Other required host packages:
+
+ uuid-runtime (uuidgen)
+ systemd-container (systemd-nspawn)
* Note: as of latest attempt, bootstrap over https was still broken.
@@ -52,3 +55,6 @@
* Compare sizes to previous version for any abnormalities (if a lot larger,
check if GCC executables are stripped).
+
+* After deployment, test VM upload/removal scripts (there are often issues
+ after upgrading to new btrfs-progs).
diff --git a/buildos b/buildos
index 2d8d043..221e781 100755
--- a/buildos
+++ b/buildos
@@ -29,6 +29,8 @@ function error ()
exit 1
}
+arch="$(uname -m)"
+
# Network timeouts: 60 seconds to connect, 10 minutes to complete, 4 retries
# (5 attempts total). These are similar to bbot timeouts. Note that the
# toolchain archives can be quite sizable.
@@ -122,7 +124,9 @@ function restart ()
sudo systemctl reboot
}
-if [ -z "$buildid_url" ]; then
+if [ -n "$buildid_url" ]; then
+ buildid_url="$buildid_url-$arch"
+else
info "no buildos.buildid_url specified, not monitoring for new os builds"
fi
diff --git a/upload-os b/upload-os
index b573806..dcf295f 100755
--- a/upload-os
+++ b/upload-os
@@ -5,7 +5,7 @@
# If the tftp server host is not specified, then build@build-cache is
# assumed. The images are uploaded to /var/lib/tftpboot/buildos-devel/.
#
-usage="usage: $0 [<user>@<host>]"
+usage="usage: $0 [-a <arch>] [<user>@<host>]"
owd="$(pwd)"
trap "{ cd '$owd'; exit 1; }" ERR
@@ -14,6 +14,26 @@ set -o errtrace # Trap in functions.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }
+arch=
+
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -a)
+ shift
+ arch="$1"
+ shift
+ break
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if [ -z "$arch" ]; then
+ arch="$(uname -m)"
+fi
+
if [ -z "$1" ]; then
host="build@build-cache"
else
@@ -25,5 +45,5 @@ fi
# is a bit more disk space used to temporarily hold copies.
#
rsync -v --progress -lpt -c --copy-unsafe-links --delay-updates \
- buildos-image buildos-initrd buildos-buildid \
+ "buildos-image-$arch" "buildos-initrd-$arch" "buildos-buildid-$arch" \
$host:/var/lib/tftpboot/buildos-devel/