]> git.zerfleddert.de Git - m1-debian/blame_incremental - m1n1_uboot_kernel.sh
no longer necessary because I no longer ship crosscompiled kernels
[m1-debian] / m1n1_uboot_kernel.sh
... / ...
CommitLineData
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
12export CARGO_HOME="$(pwd)/build/cargo"
13export RUSTUP_HOME="$(pwd)/build/rust"
14source "$(pwd)/build/cargo/env"
15
16unset LC_CTYPE
17unset LANG
18
19build_linux()
20{
21(
22 test -d linux || git clone https://github.com/AsahiLinux/linux
23 cd linux
24 git fetch -a -t
25 git reset --hard asahi-6.4-6;
26 curl https://tg.st/u/0001-remove-debug-spam.patch | git am -
27 cat ../../config.txt > .config
28 make LLVM=${CLANG_VERSION} rustavailable
29 make LLVM=${CLANG_VERSION} olddefconfig
30 make -j `nproc` LLVM=${CLANG_VERSION} V=0 bindeb-pkg > /dev/null
31)
32}
33
34build_m1n1()
35{
36(
37 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
38 cd m1n1
39 git fetch -a -t
40 git reset --hard v1.3.2;
41 make -j `nproc`
42)
43}
44
45build_uboot()
46{
47(
48 test -d u-boot || git clone https://github.com/AsahiLinux/u-boot
49 cd u-boot
50 git fetch -a -t
51 git reset --hard asahi-v2023.07.02-2;
52
53 make apple_m1_defconfig
54 make -j `nproc`
55)
56 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
57}
58
59package_boot_bin()
60{
61(
62 export M1N1_VERSION=1.3.2
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
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
77 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF'
78#!/bin/bash
79
80export PATH=/bin
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/
85cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
86EOF
87
88 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
89 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
90)
91}
92
93if type clang-15; then
94 export CLANG_VERSION=-15
95elif type clang-11; then
96 export CLANG_VERSION=-11
97fi
98
99mkdir -p build
100cd build
101
102build_linux
103build_m1n1
104build_uboot
105package_boot_bin
Impressum, Datenschutz