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