]> git.zerfleddert.de Git - m1-debian/blame_incremental - m1n1_uboot_kernel.sh
default rustup version no longer needs to be specified
[m1-debian] / m1n1_uboot_kernel.sh
... / ...
CommitLineData
1#!/usr/bin/env bash
2
3# SPDX-License-Identifier: MIT
4
5set -o errexit
6set -o nounset
7set -o pipefail
8set -o xtrace
9
10cd "$(dirname "$0")"
11
12export CARGO_HOME="$(pwd)/build/cargo"
13export RUSTUP_HOME="$(pwd)/build/rust"
14source "$(pwd)/build/cargo/env"
15
16unset LC_CTYPE
17unset LANG
18
19export M1N1_VERSION=1.4.6
20export KERNEL_VERSION=asahi-6.5-26
21
22build_linux()
23{
24(
25 test -d linux || git clone https://github.com/AsahiLinux/linux
26 cd linux
27 git fetch -a -t
28 git reset --hard $KERNEL_VERSION
29 git clean -f -x -d > /dev/null
30 cat ../../config.txt > .config
31 make LLVM=-15 rustavailable
32 make LLVM=-15 olddefconfig
33 make -j `nproc` LLVM=-15 V=0 bindeb-pkg > /dev/null
34)
35}
36
37build_m1n1()
38{
39(
40 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
41 cd m1n1
42 git fetch -a -t
43 git reset --hard v${M1N1_VERSION};
44 git clean -f -x -d > /dev/null
45 make -j `nproc`
46)
47}
48
49build_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
55 git reset --hard asahi-v2023.07.02-3
56 git clean -f -x -d > /dev/null
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
62}
63
64package_boot_bin()
65{
66(
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
71Package: m1n1
72Version: $M1N1_VERSION
73Section: base
74Priority: optional
75Architecture: arm64
76Maintainer: Thomas Glanzmann <thomas@glanzmann.de>
77Description: Apple silicon boot loader
78 Next to m1n1 this also contains the device trees and u-boot.
79EOF
80
81 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF'
82#!/bin/bash
83
84export PATH=/bin
85if [ -f /boot/efi/m1n1/boot.bin ]; then
86 cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin
87fi
88mkdir -p /boot/efi/m1n1/
89cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
90EOF
91
92 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
93 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
94)
95}
96
97mkdir -p build
98cd build
99
100build_linux
101build_m1n1
102build_uboot
103package_boot_bin
Impressum, Datenschutz