]> cvs.zerfleddert.de Git - m1-debian/blob - bootstrap.sh
1cd86340d468ff60ace4767c4588f6a1269ba9cc
[m1-debian] / bootstrap.sh
1 #!/usr/bin/env bash
2
3 # SPDX-License-Identifier: MIT
4
5 set -o errexit
6 set -o nounset
7 set -o pipefail
8 set -o xtrace
9
10 cd "$(dirname "$0")"
11
12 unset LC_CTYPE
13 unset LANG
14
15 export DEBOOTSTRAP=debootstrap
16
17 build_rootfs()
18 {
19 (
20 sudo rm -rf testing
21 mkdir -p cache
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 testing testing http://deb.debian.org/debian
23
24 cd testing
25
26 sudo mkdir -p boot/efi/m1n1 etc/X11/xorg.conf.d
27
28 sudo bash -c 'echo debian > etc/hostname'
29
30 sudo bash -c 'echo > etc/motd'
31
32 sudo cp ../../files/sources.list etc/apt/sources.list
33 sudo cp ../../files/glanzmann.list etc/apt/sources.list.d/
34 sudo cp ../../files/thomas-glanzmann.gpg etc/apt/trusted.gpg.d/
35 sudo cp ../../files/hosts etc/hosts
36 sudo cp ../../files/resolv.conf etc/resolv.conf
37 sudo cp ../../files/quickstart.txt root/
38 sudo cp ../../files/interfaces etc/network/interfaces
39 sudo cp ../../files/wpa.conf etc/wpa_supplicant/wpa_supplicant.conf
40 sudo cp ../../files/rc.local etc/rc.local
41 sudo cp ../../files/30-modeset.conf etc/X11/xorg.conf.d/30-modeset.conf
42
43 sudo bash -c 'chroot . apt update'
44 sudo bash -c 'chroot . apt install -y firmware-linux'
45
46 sudo -- perl -p -i -e 's/root:x:/root::/' etc/passwd
47
48 sudo -- ln -s lib/systemd/systemd init
49
50 sudo chroot . apt update
51 sudo chroot . apt install -y m1n1 linux-image-asahi
52 sudo chroot . apt clean
53
54 sudo bash -c 'chroot . apt-get clean'
55 )
56 }
57
58 build_live_stick()
59 {
60 (
61 rm -rf live-stick
62 mkdir -p live-stick/efi/boot live-stick/efi/debian/
63 sudo cp ../files/wifi.pl testing/etc/rc.local
64 sudo bash -c 'cd testing; find . | cpio --quiet -H newc -o | pigz -9 > ../live-stick/initrd.gz'
65 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi live-stick/efi/boot/bootaa64.efi
66 cp testing/boot/vmlinuz* live-stick/vmlinuz
67 cp ../files/grub.cfg live-stick/efi/debian/grub.cfg
68 (cd live-stick; tar cf ../asahi-debian-live.tar .)
69 )
70 }
71
72 build_dd()
73 {
74 (
75 rm -f media
76 dd if=/dev/zero of=media bs=1 count=0 seek=2G
77 mkdir -p mnt
78 mkfs.ext4 media
79 tune2fs -O extents,uninit_bg,dir_index -m 0 -c 0 -i 0 media
80 sudo mount -o loop media mnt
81 sudo cp -a testing/* mnt/
82 sudo rm -rf mnt/init mnt/boot/efi/m1n1
83 sudo umount mnt
84 tar cf - media | pigz -9 > m1.tgz
85 )
86 }
87
88 build_efi()
89 {
90 (
91 rm -rf EFI
92 mkdir -p EFI/boot EFI/debian
93 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi EFI/boot/bootaa64.efi
94
95 export INITRD=`ls -1 testing/boot/ | grep initrd`
96 export VMLINUZ=`ls -1 testing/boot/ | grep vmlinuz`
97 export UUID=`blkid -s UUID -o value media`
98 cat > EFI/debian/grub.cfg <<EOF
99 search.fs_uuid ${UUID} root
100 linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw
101 initrd (\$root)/boot/${INITRD}
102 boot
103 EOF
104 tar czf efi.tgz EFI
105 )
106 }
107
108 build_asahi_installer_image()
109 {
110 (
111 rm -rf aii
112 mkdir -p aii/esp/m1n1
113 cp -a EFI aii/esp/
114 cp testing/usr/lib/m1n1/boot.bin aii/esp/m1n1/boot.bin
115 ln media aii/media
116 cd aii
117 zip -r9 ../debian-base.zip esp media
118 )
119 }
120
121 publish_artefacts()
122 {
123 sudo cp efi.tgz asahi-debian-live.tar debian-base.zip /u/
124 }
125
126 mkdir -p build
127 cd build
128
129 sudo apt-get install -y build-essential bash git locales gcc-aarch64-linux-gnu libc6-dev device-tree-compiler imagemagick ccache eatmydata debootstrap pigz libncurses-dev qemu-user-static binfmt-support rsync git flex bison bc kmod cpio libncurses5-dev libelf-dev:native libssl-dev dwarves
130
131 build_rootfs
132 build_dd
133 build_efi
134 build_asahi_installer_image
135 build_live_stick
136 publish_artefacts
Impressum, Datenschutz