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