]>
Commit | Line | Data |
---|---|---|
9ac5deac TG |
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 | ||
9eed8ca6 TG |
12 | export CARGO_HOME="$(pwd)/build/cargo" |
13 | export RUSTUP_HOME="$(pwd)/build/rust" | |
14 | source "$(pwd)/build/cargo/env" | |
15 | ||
9ac5deac TG |
16 | unset LC_CTYPE |
17 | unset LANG | |
18 | ||
d7c644ab | 19 | export M1N1_VERSION=1.4.2 |
c63db8ae | 20 | |
9ac5deac TG |
21 | build_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 | ||
36 | build_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}; |
9ac5deac TG |
43 | make -j `nproc` |
44 | ) | |
45 | } | |
46 | ||
47 | build_uboot() | |
48 | { | |
49 | ( | |
50 | test -d u-boot || git clone https://github.com/AsahiLinux/u-boot | |
51 | cd u-boot | |
52 | git fetch -a -t | |
e5a3ffbe | 53 | git reset --hard asahi-v2023.07.02-3 |
9ac5deac TG |
54 | |
55 | make apple_m1_defconfig | |
56 | make -j `nproc` | |
57 | ) | |
58 | 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 |
59 | } |
60 | ||
ce492006 TG |
61 | package_boot_bin() |
62 | { | |
63 | ( | |
59b40e06 TG |
64 | rm -rf m1n1_${M1N1_VERSION}_arm64 |
65 | mkdir -p m1n1_${M1N1_VERSION}_arm64/DEBIAN m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/ | |
66 | cp u-boot.bin m1n1_${M1N1_VERSION}_arm64/usr/lib/m1n1/boot.bin | |
67 | cat <<EOF > m1n1_${M1N1_VERSION}_arm64/DEBIAN/control | |
ce492006 TG |
68 | Package: m1n1 |
69 | Version: $M1N1_VERSION | |
70 | Section: base | |
71 | Priority: optional | |
72 | Architecture: arm64 | |
73 | Maintainer: Thomas Glanzmann <thomas@glanzmann.de> | |
74 | Description: Apple silicon boot loader | |
75 | Next to m1n1 this also contains the device trees and u-boot. | |
76 | EOF | |
77 | ||
d201f029 | 78 | cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF' |
ce492006 TG |
79 | #!/bin/bash |
80 | ||
81 | export PATH=/bin | |
b5a41dd1 TG |
82 | if [ -f /boot/efi/m1n1/boot.bin ]; then |
83 | cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin | |
84 | fi | |
85 | mkdir -p /boot/efi/m1n1/ | |
ce492006 TG |
86 | cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/ |
87 | EOF | |
88 | ||
59b40e06 TG |
89 | chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst |
90 | dpkg-deb --build m1n1_${M1N1_VERSION}_arm64 | |
cd6d1106 | 91 | ) |
ce492006 TG |
92 | } |
93 | ||
9ac5deac TG |
94 | mkdir -p build |
95 | cd build | |
96 | ||
5a6d8c66 | 97 | build_linux |
029bb7dc TG |
98 | build_m1n1 |
99 | build_uboot | |
100 | package_boot_bin |