]>
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 | ||
a3103144 TG |
19 | export M1N1_VERSION=1.4.6 |
20 | export KERNEL_VERSION=asahi-6.5-26 | |
c63db8ae | 21 | |
9ac5deac TG |
22 | build_linux() |
23 | { | |
24 | ( | |
25 | test -d linux || git clone https://github.com/AsahiLinux/linux | |
26 | cd linux | |
27 | git fetch -a -t | |
a3103144 | 28 | git reset --hard $KERNEL_VERSION |
e5a3ffbe | 29 | git clean -f -x -d > /dev/null |
7dcd418b | 30 | cat ../../config.txt > .config |
b33d2b4a TG |
31 | make LLVM=-15 rustavailable |
32 | make LLVM=-15 olddefconfig | |
33 | make -j `nproc` LLVM=-15 V=0 bindeb-pkg > /dev/null | |
9ac5deac TG |
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 | |
65ef55f7 | 43 | git reset --hard v${M1N1_VERSION}; |
c8c18241 | 44 | git clean -f -x -d > /dev/null |
9ac5deac TG |
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 | |
e5a3ffbe | 55 | git reset --hard asahi-v2023.07.02-3 |
c8c18241 | 56 | git clean -f -x -d > /dev/null |
9ac5deac TG |
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 | |
9ac5deac TG |
62 | } |
63 | ||
ce492006 TG |
64 | package_boot_bin() |
65 | { | |
66 | ( | |
59b40e06 TG |
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 | |
ce492006 TG |
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 | ||
d201f029 | 81 | cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF' |
ce492006 TG |
82 | #!/bin/bash |
83 | ||
84 | export PATH=/bin | |
b5a41dd1 TG |
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/ | |
ce492006 TG |
89 | cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/ |
90 | EOF | |
91 | ||
59b40e06 TG |
92 | chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst |
93 | dpkg-deb --build m1n1_${M1N1_VERSION}_arm64 | |
cd6d1106 | 94 | ) |
ce492006 TG |
95 | } |
96 | ||
9ac5deac TG |
97 | mkdir -p build |
98 | cd build | |
99 | ||
5a6d8c66 | 100 | build_linux |
029bb7dc TG |
101 | build_m1n1 |
102 | build_uboot | |
103 | package_boot_bin |