]> git.zerfleddert.de Git - m1-debian/blame - bootstrap.sh
build m1n1 and linux-image-asahi package correctly; working on bootstrap.sh
[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(
0bffa1b0 20 handle_crosscompile
350079f4 21 sudo rm -rf testing
ae43a6ec 22 mkdir -p cache
8b2a692f 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
ce8ebd75 24
08045305
TG
25 export KERNEL=`ls -1rt linux-image*.deb | grep -v dbg | tail -1`
26
ce8ebd75
TG
27 cd testing
28
a6fc4794 29 sudo mkdir -p boot/efi
60b2ebc1 30
16cad30f 31 sudo bash -c 'echo debian > etc/hostname'
f325b48f 32
350079f4 33 sudo bash -c 'echo > etc/motd'
ce8ebd75 34
08045305
TG
35 sudo cp ../../files/sources.list etc/apt/sources.list
36 sudo cp ../../files/hosts etc/hosts
8d82f6b0 37 sudo cp ../../files/resolv.conf etc/resolv.conf
08045305 38 sudo cp ../../files/quickstart.txt root/
da7dd4b8 39 sudo cp ../../files/interfaces etc/network/interfaces
7a54df2e 40 sudo cp ../../files/wpa.conf etc/wpa_supplicant/wpa_supplicant.conf
b96f460f 41 sudo cp ../../files/rc.local etc/rc.local
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
08045305
TG
50 sudo cp ../${KERNEL} .
51 sudo chroot . dpkg -i ${KERNEL}
52 sudo rm ${KERNEL}
ce8ebd75 53
60cb512a 54 sudo bash -c 'chroot . apt-get clean'
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
0ffed154
TG
72build_efi()
73{
74(
7da211a3 75 rm -rf EFI
60b2ebc1 76 mkdir -p EFI/boot EFI/debian
0ffed154
TG
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`
eb57d280 81 export UUID=`blkid -s UUID -o value media`
60b2ebc1 82 cat > EFI/debian/grub.cfg <<EOF
0ffed154 83search.fs_uuid ${UUID} root
60b2ebc1
TG
84linux (\$root)/boot/${VMLINUZ} root=UUID=${UUID} rw
85initrd (\$root)/boot/${INITRD}
0ffed154
TG
86boot
87EOF
88 tar czf efi.tgz EFI
89)
90}
91
5d41b6d6
TG
92build_asahi_installer_image()
93{
304bd206
TG
94(
95 rm -rf aii
1cf0f22b 96 mkdir -p aii/esp/m1n1
304bd206 97 cp -a EFI aii/esp/
1cf0f22b 98 cp u-boot.bin aii/esp/m1n1/boot.bin
304bd206
TG
99 ln media aii/media
100 cd aii
1cf0f22b 101 zip -r9 ../debian-base.zip esp media
304bd206 102)
5d41b6d6
TG
103}
104
3b4d866f 105publish_artefacts()
bb14d862
TG
106{
107 export KERNEL=`ls -1rt linux-image*.deb | grep -v dbg | tail -1`
108 cp ${KERNEL} k.deb
59b40e06 109 sudo cp efi.tgz asahi-debian-live.tar debian-base.zip /u/
bb14d862
TG
110}
111
08045305
TG
112mkdir -p build
113cd build
114
56d14923 115sudo 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 116
bc45a4cc 117build_linux
6859a054
TG
118build_m1n1
119build_uboot
120build_rootfs
6859a054
TG
121build_efi
122build_asahi_installer_image
123build_live_stick
f77f8aca 124publish_artefacts
Impressum, Datenschutz