]> git.zerfleddert.de Git - m1-debian/blame - m1n1_uboot_kernel.sh
simplify build script and get virqfd=y
[m1-debian] / m1n1_uboot_kernel.sh
CommitLineData
9ac5deac
TG
1#!/usr/bin/env bash
2
3# SPDX-License-Identifier: MIT
4
5set -o errexit
6set -o nounset
7set -o pipefail
8set -o xtrace
9
10cd "$(dirname "$0")"
11
9eed8ca6
TG
12export CARGO_HOME="$(pwd)/build/cargo"
13export RUSTUP_HOME="$(pwd)/build/rust"
14source "$(pwd)/build/cargo/env"
15
9ac5deac
TG
16unset LC_CTYPE
17unset LANG
18
d7c644ab 19export M1N1_VERSION=1.4.2
c63db8ae 20
9ac5deac
TG
21build_linux()
22{
23(
24 test -d linux || git clone https://github.com/AsahiLinux/linux
25 cd linux
26 git fetch -a -t
af1fbe8f 27 git reset --hard asahi-6.5-13
7dcd418b 28 cat ../../config.txt > .config
b33d2b4a
TG
29 make LLVM=-15 rustavailable
30 make LLVM=-15 olddefconfig
31 make -j `nproc` LLVM=-15 V=0 bindeb-pkg > /dev/null
9ac5deac
TG
32)
33}
34
35build_m1n1()
36{
37(
38 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
39 cd m1n1
40 git fetch -a -t
c63db8ae 41 git reset --hard v{M1N1_VERSION};
9ac5deac
TG
42 make -j `nproc`
43)
44}
45
46build_uboot()
47{
48(
49 test -d u-boot || git clone https://github.com/AsahiLinux/u-boot
50 cd u-boot
51 git fetch -a -t
983712fb 52 git reset --hard asahi-v2023.07.02-2;
9ac5deac
TG
53
54 make apple_m1_defconfig
55 make -j `nproc`
56)
57 cat m1n1/build/m1n1.bin `find linux/arch/arm64/boot/dts/apple/ -name \*.dtb` <(gzip -c u-boot/u-boot-nodtb.bin) > u-boot.bin
9ac5deac
TG
58}
59
ce492006
TG
60package_boot_bin()
61{
62(
59b40e06
TG
63 rm -rf m1n1_${M1N1_VERSION}_arm64
64 mkdir -p m1n1_${M1N1_VERSION}_arm64/DEBIAN m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/
65 cp u-boot.bin m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/boot.bin
66 cat <<EOF > m1n1_${M1N1_VERSION}_arm64/DEBIAN/control
ce492006
TG
67Package: m1n1
68Version: $M1N1_VERSION
69Section: base
70Priority: optional
71Architecture: arm64
72Maintainer: Thomas Glanzmann <thomas@glanzmann.de>
73Description: Apple silicon boot loader
74 Next to m1n1 this also contains the device trees and u-boot.
75EOF
76
d201f029 77 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF'
ce492006
TG
78#!/bin/bash
79
80export PATH=/bin
b5a41dd1
TG
81if [ -f /boot/efi/m1n1/boot.bin ]; then
82 cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin
83fi
84mkdir -p /boot/efi/m1n1/
ce492006
TG
85cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
86EOF
87
59b40e06
TG
88 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
89 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
cd6d1106 90)
ce492006
TG
91}
92
9ac5deac
TG
93mkdir -p build
94cd build
95
5a6d8c66 96build_linux
029bb7dc
TG
97build_m1n1
98build_uboot
99package_boot_bin
Impressum, Datenschutz