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