aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
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 /bootstrap
parenta22c237897a5fee1e32b52251d5a324248dc41f8 (diff)
Add support for aarch64
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap66
1 files changed, 53 insertions, 13 deletions
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