]> git.zerfleddert.de Git - m1-debian/blame - m1n1_uboot_kernel.sh
bump m1n1
[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
6a1d2ed2
TG
19handle_crosscompile()
20{
21 if [ "`uname -m`" != 'aarch64' ]; then
22 export ARCH=arm64
23 export CROSS_COMPILE=aarch64-linux-gnu-
24 sudo apt install -y libc6-dev-arm64-cross
25 fi
26}
27
9ac5deac
TG
28build_linux()
29{
30(
6a1d2ed2 31 handle_crosscompile
9ac5deac
TG
32 test -d linux || git clone https://github.com/AsahiLinux/linux
33 cd linux
34 git fetch -a -t
3d73deff 35 git reset --hard origin/asahi-wip;
8f95ecda 36 curl -sL https://tg.st/u/5ec32cdb6555bf935fd621ef8923410a1f51b5b9.patch | git am -
564fe8c6 37 curl -sL https://tg.st/u/c65f0ecca767f7853bf33f1710d7637f11b70403.patch | git am -
7dcd418b 38 cat ../../config.txt > .config
e7515ac0
TG
39 make LLVM=${CLANG_VERSION} rustavailable
40 make LLVM=${CLANG_VERSION} olddefconfig
41 make -j `nproc` LLVM=${CLANG_VERSION} V=0 bindeb-pkg > /dev/null
9ac5deac
TG
42)
43}
44
45build_m1n1()
46{
47(
48 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
49 cd m1n1
50 git fetch -a -t
457e60ad 51 git reset --hard v1.2.7-7-g076217a;
9ac5deac
TG
52 make -j `nproc`
53)
54}
55
56build_uboot()
57{
58(
6a1d2ed2 59 handle_crosscompile
9ac5deac
TG
60 test -d u-boot || git clone https://github.com/AsahiLinux/u-boot
61 cd u-boot
62 git fetch -a -t
d5659d5f 63 git reset --hard asahi-v2023.01-3;
9ac5deac
TG
64
65 make apple_m1_defconfig
66 make -j `nproc`
67)
68 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
69}
70
ce492006
TG
71package_boot_bin()
72{
73(
457e60ad 74 export M1N1_VERSION=1.2.7-3
59b40e06
TG
75 rm -rf m1n1_${M1N1_VERSION}_arm64
76 mkdir -p m1n1_${M1N1_VERSION}_arm64/DEBIAN m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/
77 cp u-boot.bin m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/boot.bin
78 cat <<EOF > m1n1_${M1N1_VERSION}_arm64/DEBIAN/control
ce492006
TG
79Package: m1n1
80Version: $M1N1_VERSION
81Section: base
82Priority: optional
83Architecture: arm64
84Maintainer: Thomas Glanzmann <thomas@glanzmann.de>
85Description: Apple silicon boot loader
86 Next to m1n1 this also contains the device trees and u-boot.
87EOF
88
d201f029 89 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF'
ce492006
TG
90#!/bin/bash
91
92export PATH=/bin
b5a41dd1
TG
93if [ -f /boot/efi/m1n1/boot.bin ]; then
94 cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin
95fi
96mkdir -p /boot/efi/m1n1/
ce492006
TG
97cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
98EOF
99
59b40e06
TG
100 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
101 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
cd6d1106 102)
ce492006
TG
103}
104
e7515ac0
TG
105if type clang-15; then
106 export CLANG_VERSION=-15
107elif type clang-11; then
108 export CLANG_VERSION=-11
109fi
110
9ac5deac
TG
111mkdir -p build
112cd build
113
5a6d8c66 114build_linux
029bb7dc
TG
115build_m1n1
116build_uboot
117package_boot_bin
Impressum, Datenschutz