]> cvs.zerfleddert.de Git - m1-debian/blame - bootstrap.sh
rename gpu script
[m1-debian] / bootstrap.sh
CommitLineData
aae6cdc3 1#!/usr/bin/env bash
2df410ee 2
605f3b2d
TG
3# SPDX-License-Identifier: MIT
4
aae6cdc3
TG
5set -o errexit
6set -o nounset
7set -o pipefail
8set -o xtrace
9
10cd "$(dirname "$0")"
2df410ee
TG
11
12unset LC_CTYPE
13unset LANG
14
0bffa1b0
TG
15export DEBOOTSTRAP=debootstrap
16
f325b48f 17build_rootfs()
ce8ebd75
TG
18{
19(
350079f4 20 sudo rm -rf testing
ae43a6ec 21 mkdir -p cache
8b2a692f 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
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
f325b48f 44 sudo bash -c 'chroot . apt update'
0bffa1b0 45 sudo bash -c 'chroot . apt install -y firmware-linux'
ce8ebd75
TG
46
47 sudo -- perl -p -i -e 's/root:x:/root::/' etc/passwd
48
f325b48f 49 sudo -- ln -s lib/systemd/systemd init
ce8ebd75 50
62ba1d23
TG
51 sudo chroot . apt update
52 sudo chroot . apt install -y m1n1 linux-image-asahi
adfb7d3e 53 sudo chroot . apt clean
cccfe6d5 54 sudo rm var/lib/apt/lists/* || true
ce8ebd75
TG
55)
56}
5920ad39 57
bca3e283 58build_live_stick()
f325b48f
TG
59{
60(
bca3e283
TG
61 rm -rf live-stick
62 mkdir -p live-stick/efi/boot live-stick/efi/debian/
f493aec2
TG
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'
bca3e283
TG
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
7a54df2e 68 (cd live-stick; tar cf ../asahi-debian-live.tar .)
f325b48f
TG
69)
70}
5920ad39 71
adfb7d3e
TG
72build_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
0ffed154
TG
88build_efi()
89{
90(
7da211a3 91 rm -rf EFI
60b2ebc1 92 mkdir -p EFI/boot EFI/debian
0ffed154
TG
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`
eb57d280 97 export UUID=`blkid -s UUID -o value media`
60b2ebc1 98 cat > EFI/debian/grub.cfg <<EOF
0ffed154 99search.fs_uuid ${UUID} root
60b2ebc1
TG
100linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw
101initrd (\$root)/boot/${INITRD}
0ffed154
TG
102boot
103EOF
104 tar czf efi.tgz EFI
105)
106}
107
5d41b6d6
TG
108build_asahi_installer_image()
109{
304bd206
TG
110(
111 rm -rf aii
1cf0f22b 112 mkdir -p aii/esp/m1n1
304bd206 113 cp -a EFI aii/esp/
adfb7d3e 114 cp testing/usr/lib/m1n1/boot.bin aii/esp/m1n1/boot.bin
304bd206
TG
115 ln media aii/media
116 cd aii
1cf0f22b 117 zip -r9 ../debian-base.zip esp media
304bd206 118)
5d41b6d6
TG
119}
120
3b4d866f 121publish_artefacts()
bb14d862 122{
59b40e06 123 sudo cp efi.tgz asahi-debian-live.tar debian-base.zip /u/
bb14d862
TG
124}
125
08045305
TG
126mkdir -p build
127cd build
128
56d14923 129sudo 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
0bffa1b0 130
6859a054 131build_rootfs
adfb7d3e 132build_dd
6859a054
TG
133build_efi
134build_asahi_installer_image
135build_live_stick
f77f8aca 136publish_artefacts
Impressum, Datenschutz