]> git.zerfleddert.de Git - m1-debian/blob - bootstrap.sh
make m1n1 package compatible with new way to package things
[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 cd testing
26
27 sudo mkdir -p boot/efi
28
29 sudo bash -c 'echo debian > etc/hostname'
30
31 sudo bash -c 'echo > etc/motd'
32
33 sudo cp ../../files/sources.list etc/apt/sources.list
34 sudo cp ../../files/hosts etc/hosts
35 sudo cp ../../files/resolv.conf etc/resolv.conf
36 sudo cp ../../files/quickstart.txt root/
37 sudo cp ../../files/interfaces etc/network/interfaces
38 sudo cp ../../files/wpa.conf etc/wpa_supplicant/wpa_supplicant.conf
39 sudo cp ../../files/rc.local etc/rc.local
40
41 sudo bash -c 'chroot . apt update'
42 sudo bash -c 'chroot . apt install -y firmware-linux'
43
44 sudo -- perl -p -i -e 's/root:x:/root::/' etc/passwd
45
46 sudo -- ln -s lib/systemd/systemd init
47
48 sudo cp ../${KERNEL} .
49 sudo chroot . dpkg -i ${KERNEL}
50 sudo rm ${KERNEL}
51
52 sudo bash -c 'chroot . apt-get clean'
53 )
54 }
55
56 build_live_stick()
57 {
58 (
59 rm -rf live-stick
60 mkdir -p live-stick/efi/boot live-stick/efi/debian/
61 sudo cp ../files/wifi.pl testing/etc/rc.local
62 sudo bash -c 'cd testing; find . | cpio --quiet -H newc -o | pigz -9 > ../live-stick/initrd.gz'
63 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi live-stick/efi/boot/bootaa64.efi
64 cp testing/boot/vmlinuz* live-stick/vmlinuz
65 cp ../files/grub.cfg live-stick/efi/debian/grub.cfg
66 (cd live-stick; tar cf ../asahi-debian-live.tar .)
67 )
68 }
69
70 build_efi()
71 {
72 (
73 rm -rf EFI
74 mkdir -p EFI/boot EFI/debian
75 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi EFI/boot/bootaa64.efi
76
77 export INITRD=`ls -1 testing/boot/ | grep initrd`
78 export VMLINUZ=`ls -1 testing/boot/ | grep vmlinuz`
79 export UUID=`blkid -s UUID -o value media`
80 cat > EFI/debian/grub.cfg <<EOF
81 search.fs_uuid ${UUID} root
82 linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw
83 initrd (\$root)/boot/${INITRD}
84 boot
85 EOF
86 tar czf efi.tgz EFI
87 )
88 }
89
90 build_asahi_installer_image()
91 {
92 (
93 rm -rf aii
94 mkdir -p aii/esp/m1n1
95 cp -a EFI aii/esp/
96 cp u-boot.bin aii/esp/m1n1/boot.bin
97 ln media aii/media
98 cd aii
99 zip -r9 ../debian-base.zip esp media
100 )
101 }
102
103 publish_artefacts()
104 {
105 sudo cp efi.tgz asahi-debian-live.tar debian-base.zip /u/
106 }
107
108 mkdir -p build
109 cd build
110
111 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
112
113 build_linux
114 build_m1n1
115 build_uboot
116 build_rootfs
117 build_efi
118 build_asahi_installer_image
119 build_live_stick
120 publish_artefacts
Impressum, Datenschutz