]>
Commit | Line | Data |
---|---|---|
aae6cdc3 | 1 | #!/usr/bin/env bash |
2df410ee | 2 | |
605f3b2d TG |
3 | # SPDX-License-Identifier: MIT |
4 | ||
aae6cdc3 TG |
5 | set -o errexit |
6 | set -o nounset | |
7 | set -o pipefail | |
8 | set -o xtrace | |
9 | ||
10 | cd "$(dirname "$0")" | |
2df410ee TG |
11 | |
12 | unset LC_CTYPE | |
13 | unset LANG | |
14 | ||
0bffa1b0 TG |
15 | export DEBOOTSTRAP=debootstrap |
16 | ||
f325b48f | 17 | build_rootfs() |
ce8ebd75 TG |
18 | { |
19 | ( | |
350079f4 | 20 | sudo rm -rf testing |
ae43a6ec | 21 | mkdir -p cache |
fdb8ca3d | 22 | sudo eatmydata ${DEBOOTSTRAP} --cache-dir=`pwd`/cache --arch=arm64 --include initramfs-tools,pciutils,wpasupplicant,tcpdump,vim,tmux,vlan,ntpdate,parted,curl,wget,grub-efi-arm64,mtr-tiny,dbus,ca-certificates,sudo,openssh-client,mtools,gdisk,cryptsetup,wireless-regdb,zstd testing testing http://deb.debian.org/debian |
ce8ebd75 TG |
23 | |
24 | cd testing | |
25 | ||
adfb7d3e | 26 | sudo mkdir -p boot/efi/m1n1 etc/X11/xorg.conf.d |
60b2ebc1 | 27 | |
16cad30f | 28 | sudo bash -c 'echo debian > etc/hostname' |
f325b48f | 29 | |
350079f4 | 30 | sudo bash -c 'echo > etc/motd' |
ce8ebd75 | 31 | |
08045305 | 32 | sudo cp ../../files/sources.list etc/apt/sources.list |
62ba1d23 TG |
33 | sudo cp ../../files/glanzmann.list etc/apt/sources.list.d/ |
34 | sudo cp ../../files/thomas-glanzmann.gpg etc/apt/trusted.gpg.d/ | |
08045305 | 35 | sudo cp ../../files/hosts etc/hosts |
8d82f6b0 | 36 | sudo cp ../../files/resolv.conf etc/resolv.conf |
08045305 | 37 | sudo cp ../../files/quickstart.txt root/ |
da7dd4b8 | 38 | sudo cp ../../files/interfaces etc/network/interfaces |
7a54df2e | 39 | sudo cp ../../files/wpa.conf etc/wpa_supplicant/wpa_supplicant.conf |
b96f460f | 40 | sudo cp ../../files/rc.local etc/rc.local |
adfb7d3e | 41 | sudo cp ../../files/30-modeset.conf etc/X11/xorg.conf.d/30-modeset.conf |
eeaa52fd | 42 | sudo cp ../../files/blacklist.conf etc/modprobe.d/ |
ce8ebd75 | 43 | |
8895ecac TG |
44 | sudo perl -p -i -e 's/"quiet"/"net.ifnames=0"/ if /^GRUB_CMDLINE_LINUX_DEFAULT=/' etc/default/grub |
45 | ||
f325b48f | 46 | sudo bash -c 'chroot . apt update' |
0bffa1b0 | 47 | sudo bash -c 'chroot . apt install -y firmware-linux' |
ce8ebd75 TG |
48 | |
49 | sudo -- perl -p -i -e 's/root:x:/root::/' etc/passwd | |
50 | ||
f325b48f | 51 | sudo -- ln -s lib/systemd/systemd init |
ce8ebd75 | 52 | |
62ba1d23 TG |
53 | sudo chroot . apt update |
54 | sudo chroot . apt install -y m1n1 linux-image-asahi | |
adfb7d3e | 55 | sudo chroot . apt clean |
cccfe6d5 | 56 | sudo rm var/lib/apt/lists/* || true |
ce8ebd75 TG |
57 | ) |
58 | } | |
5920ad39 | 59 | |
bca3e283 | 60 | build_live_stick() |
f325b48f TG |
61 | { |
62 | ( | |
bca3e283 TG |
63 | rm -rf live-stick |
64 | mkdir -p live-stick/efi/boot live-stick/efi/debian/ | |
f493aec2 | 65 | sudo cp ../files/wifi.pl testing/etc/rc.local |
7803524c | 66 | sudo bash -c 'cd testing; find . | cpio --quiet -H newc -o | zstd -T0 -16 > ../live-stick/initrd.zstd' |
bca3e283 TG |
67 | cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi live-stick/efi/boot/bootaa64.efi |
68 | cp testing/boot/vmlinuz* live-stick/vmlinuz | |
69 | cp ../files/grub.cfg live-stick/efi/debian/grub.cfg | |
7a54df2e | 70 | (cd live-stick; tar cf ../asahi-debian-live.tar .) |
f325b48f TG |
71 | ) |
72 | } | |
5920ad39 | 73 | |
adfb7d3e TG |
74 | build_dd() |
75 | { | |
76 | ( | |
77 | rm -f media | |
78 | dd if=/dev/zero of=media bs=1 count=0 seek=2G | |
79 | mkdir -p mnt | |
80 | mkfs.ext4 media | |
81 | tune2fs -O extents,uninit_bg,dir_index -m 0 -c 0 -i 0 media | |
82 | sudo mount -o loop media mnt | |
83 | sudo cp -a testing/* mnt/ | |
84 | sudo rm -rf mnt/init mnt/boot/efi/m1n1 | |
85 | sudo umount mnt | |
86 | tar cf - media | pigz -9 > m1.tgz | |
87 | ) | |
88 | } | |
89 | ||
615b00f7 TG |
90 | build_efi() |
91 | { | |
92 | ( | |
93 | rm -rf EFI | |
94 | mkdir -p EFI/boot EFI/debian | |
95 | cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi EFI/boot/bootaa64.efi | |
96 | ||
97 | export INITRD=`ls -1 testing/boot/ | grep initrd` | |
98 | export VMLINUZ=`ls -1 testing/boot/ | grep vmlinuz` | |
99 | export UUID=`blkid -s UUID -o value media` | |
100 | cat > EFI/debian/grub.cfg <<EOF | |
101 | search.fs_uuid ${UUID} root | |
4ab93eca | 102 | linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw net.ifnames=0 |
615b00f7 TG |
103 | initrd (\$root)/boot/${INITRD} |
104 | boot | |
105 | EOF | |
106 | ) | |
107 | } | |
108 | ||
5d41b6d6 TG |
109 | build_asahi_installer_image() |
110 | { | |
304bd206 TG |
111 | ( |
112 | rm -rf aii | |
1cf0f22b | 113 | mkdir -p aii/esp/m1n1 |
304bd206 | 114 | cp -a EFI aii/esp/ |
adfb7d3e | 115 | cp testing/usr/lib/m1n1/boot.bin aii/esp/m1n1/boot.bin |
304bd206 TG |
116 | ln media aii/media |
117 | cd aii | |
1cf0f22b | 118 | zip -r9 ../debian-base.zip esp media |
304bd206 | 119 | ) |
5d41b6d6 TG |
120 | } |
121 | ||
3b4d866f | 122 | publish_artefacts() |
bb14d862 | 123 | { |
877db534 | 124 | echo upload build/asahi-debian-live.tar build/debian-base.zip |
bb14d862 TG |
125 | } |
126 | ||
08045305 TG |
127 | mkdir -p build |
128 | cd build | |
129 | ||
6859a054 | 130 | build_rootfs |
adfb7d3e | 131 | build_dd |
615b00f7 | 132 | build_efi |
6859a054 TG |
133 | build_asahi_installer_image |
134 | build_live_stick | |
f77f8aca | 135 | publish_artefacts |