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