]> git.zerfleddert.de Git - m1-debian/blob - m1n1_uboot_kernel.sh
9ae38efc6b0e3df8f314a73c79828e7c5ff620b9
[m1-debian] / m1n1_uboot_kernel.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 export CARGO_HOME="$(pwd)/build/cargo"
13 export RUSTUP_HOME="$(pwd)/build/rust"
14 source "$(pwd)/build/cargo/env"
15
16 unset LC_CTYPE
17 unset LANG
18
19 export M1N1_VERSION=1.4.6
20 export KERNEL_VERSION=asahi-6.5-26
21
22 build_linux()
23 {
24 (
25 test -d linux || git clone https://github.com/AsahiLinux/linux
26 cd linux
27 git fetch -a -t
28 git reset --hard $KERNEL_VERSION
29 git clean -f -x -d > /dev/null
30 cat ../../config.txt > .config
31 make LLVM=-15 rustavailable
32 make LLVM=-15 olddefconfig
33 make -j `nproc` LLVM=-15 V=0 bindeb-pkg > /dev/null
34 )
35 }
36
37 build_m1n1()
38 {
39 (
40 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
41 cd m1n1
42 git fetch -a -t
43 git reset --hard v${M1N1_VERSION};
44 git clean -f -x -d > /dev/null
45 make -j `nproc`
46 )
47 }
48
49 build_uboot()
50 {
51 (
52 test -d u-boot || git clone https://github.com/AsahiLinux/u-boot
53 cd u-boot
54 git fetch -a -t
55 git reset --hard asahi-v2023.07.02-3
56 git clean -f -x -d > /dev/null
57
58 make apple_m1_defconfig
59 make -j `nproc`
60 )
61 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
62 }
63
64 package_boot_bin()
65 {
66 (
67 rm -rf m1n1_${M1N1_VERSION}_arm64
68 mkdir -p m1n1_${M1N1_VERSION}_arm64/DEBIAN m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/
69 cp u-boot.bin m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/boot.bin
70 cat <<EOF > m1n1_${M1N1_VERSION}_arm64/DEBIAN/control
71 Package: m1n1
72 Version: $M1N1_VERSION
73 Section: base
74 Priority: optional
75 Architecture: arm64
76 Maintainer: Thomas Glanzmann <thomas@glanzmann.de>
77 Description: Apple silicon boot loader
78 Next to m1n1 this also contains the device trees and u-boot.
79 EOF
80
81 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF'
82 #!/bin/bash
83
84 export PATH=/bin
85 if [ -f /boot/efi/m1n1/boot.bin ]; then
86 cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin
87 fi
88 mkdir -p /boot/efi/m1n1/
89 cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
90 EOF
91
92 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
93 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
94 )
95 }
96
97 mkdir -p build
98 cd build
99
100 build_linux
101 build_m1n1
102 build_uboot
103 package_boot_bin
Impressum, Datenschutz