]> git.zerfleddert.de Git - m1-debian/blob - bootstrap.sh
b019d4f2d21f2ec5d51745b7ef413b4ca45eee9a
[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 handle_crosscompile
21 sudo rm -rf testing
22 mkdir -p cache
23 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
24
25 export KERNEL=`ls -1rt linux-image*.deb | grep -v dbg | tail -1`
26
27 cd testing
28
29 sudo mkdir -p boot/efi
30
31 sudo bash -c 'echo debian > etc/hostname'
32
33 sudo bash -c 'echo > etc/motd'
34
35 sudo cp ../../files/sources.list etc/apt/sources.list
36 sudo cp ../../files/hosts etc/hosts
37 sudo cp ../../files/resolv.conf etc/resolv.conf
38 sudo cp ../../files/quickstart.txt root/
39 sudo cp ../../files/interfaces etc/network/interfaces
40 sudo cp ../../files/wpa.conf etc/wpa_supplicant/wpa_supplicant.conf
41 sudo cp ../../files/rc.local etc/rc.local
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 cp ../${KERNEL} .
51 sudo chroot . dpkg -i ${KERNEL}
52 sudo rm ${KERNEL}
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_efi()
73 {
74 (
75 rm -rf EFI
76 mkdir -p EFI/boot EFI/debian
77 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi EFI/boot/bootaa64.efi
78
79 export INITRD=`ls -1 testing/boot/ | grep initrd`
80 export VMLINUZ=`ls -1 testing/boot/ | grep vmlinuz`
81 export UUID=`blkid -s UUID -o value media`
82 cat > EFI/debian/grub.cfg <<EOF
83 search.fs_uuid ${UUID} root
84 linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw
85 initrd (\$root)/boot/${INITRD}
86 boot
87 EOF
88 tar czf efi.tgz EFI
89 )
90 }
91
92 build_asahi_installer_image()
93 {
94 (
95 rm -rf aii
96 mkdir -p aii/esp/m1n1
97 cp -a EFI aii/esp/
98 cp u-boot.bin aii/esp/m1n1/boot.bin
99 ln media aii/media
100 cd aii
101 zip -r9 ../debian-base.zip esp media
102 )
103 }
104
105 publish_artefacts()
106 {
107 export KERNEL=`ls -1rt linux-image*.deb | grep -v dbg | tail -1`
108 cp ${KERNEL} k.deb
109 sudo cp efi.tgz asahi-debian-live.tar debian-base.zip /u/
110 }
111
112 mkdir -p build
113 cd build
114
115 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
116
117 build_linux
118 build_m1n1
119 build_uboot
120 build_rootfs
121 build_efi
122 build_asahi_installer_image
123 build_live_stick
124 publish_artefacts
Impressum, Datenschutz