]> cvs.zerfleddert.de Git - m1-debian/blame - bootstrap.sh
fedora is obsolete
[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
ce8ebd75 42
f325b48f 43 sudo bash -c 'chroot . apt update'
0bffa1b0 44 sudo bash -c 'chroot . apt install -y firmware-linux'
ce8ebd75
TG
45
46 sudo -- perl -p -i -e 's/root:x:/root::/' etc/passwd
47
f325b48f 48 sudo -- ln -s lib/systemd/systemd init
ce8ebd75 49
62ba1d23
TG
50 sudo chroot . apt update
51 sudo chroot . apt install -y m1n1 linux-image-asahi
adfb7d3e 52 sudo chroot . apt clean
cccfe6d5 53 sudo rm var/lib/apt/lists/* || true
ce8ebd75
TG
54)
55}
5920ad39 56
bca3e283 57build_live_stick()
f325b48f
TG
58{
59(
bca3e283
TG
60 rm -rf live-stick
61 mkdir -p live-stick/efi/boot live-stick/efi/debian/
f493aec2
TG
62 sudo cp ../files/wifi.pl testing/etc/rc.local
63 sudo bash -c 'cd testing; find . | cpio --quiet -H newc -o | pigz -9 > ../live-stick/initrd.gz'
bca3e283
TG
64 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi live-stick/efi/boot/bootaa64.efi
65 cp testing/boot/vmlinuz* live-stick/vmlinuz
66 cp ../files/grub.cfg live-stick/efi/debian/grub.cfg
7a54df2e 67 (cd live-stick; tar cf ../asahi-debian-live.tar .)
f325b48f
TG
68)
69}
5920ad39 70
adfb7d3e
TG
71build_dd()
72{
73(
74 rm -f media
75 dd if=/dev/zero of=media bs=1 count=0 seek=2G
76 mkdir -p mnt
77 mkfs.ext4 media
78 tune2fs -O extents,uninit_bg,dir_index -m 0 -c 0 -i 0 media
79 sudo mount -o loop media mnt
80 sudo cp -a testing/* mnt/
81 sudo rm -rf mnt/init mnt/boot/efi/m1n1
82 sudo umount mnt
83 tar cf - media | pigz -9 > m1.tgz
84)
85}
86
0ffed154
TG
87build_efi()
88{
89(
7da211a3 90 rm -rf EFI
60b2ebc1 91 mkdir -p EFI/boot EFI/debian
0ffed154
TG
92 cp testing/usr/lib/grub/arm64-efi/monolithic/grubaa64.efi EFI/boot/bootaa64.efi
93
94 export INITRD=`ls -1 testing/boot/ | grep initrd`
95 export VMLINUZ=`ls -1 testing/boot/ | grep vmlinuz`
eb57d280 96 export UUID=`blkid -s UUID -o value media`
60b2ebc1 97 cat > EFI/debian/grub.cfg <<EOF
0ffed154 98search.fs_uuid ${UUID} root
60b2ebc1
TG
99linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw
100initrd (\$root)/boot/${INITRD}
0ffed154
TG
101boot
102EOF
103 tar czf efi.tgz EFI
104)
105}
106
5d41b6d6
TG
107build_asahi_installer_image()
108{
304bd206
TG
109(
110 rm -rf aii
1cf0f22b 111 mkdir -p aii/esp/m1n1
304bd206 112 cp -a EFI aii/esp/
adfb7d3e 113 cp testing/usr/lib/m1n1/boot.bin aii/esp/m1n1/boot.bin
304bd206
TG
114 ln media aii/media
115 cd aii
1cf0f22b 116 zip -r9 ../debian-base.zip esp media
304bd206 117)
5d41b6d6
TG
118}
119
3b4d866f 120publish_artefacts()
bb14d862 121{
59b40e06 122 sudo cp efi.tgz asahi-debian-live.tar debian-base.zip /u/
bb14d862
TG
123}
124
08045305
TG
125mkdir -p build
126cd build
127
56d14923 128sudo 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 129
6859a054 130build_rootfs
adfb7d3e 131build_dd
6859a054
TG
132build_efi
133build_asahi_installer_image
134build_live_stick
f77f8aca 135publish_artefacts
Impressum, Datenschutz