]> cvs.zerfleddert.de Git - m1-debian/blame_incremental - m1n1_uboot_kernel.sh
Line in the wrong section spotted by Jostein Kjønigsen
[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.11
20export KERNEL_VERSION=asahi-6.6-14
21export UBOOT_VERSION=asahi-v2023.07.02-4
22
23build_linux()
24{
25(
26 test -d linux || git clone https://github.com/AsahiLinux/linux
27 cd linux
28 git fetch -a -t
29 git reset --hard $KERNEL_VERSION
30 git clean -f -x -d > /dev/null
31 cat ../../config.txt > .config
32 make LLVM=-15 rustavailable
33 make LLVM=-15 olddefconfig
34 make -j `nproc` LLVM=-15 V=0 bindeb-pkg > /dev/null
35)
36}
37
38build_m1n1()
39{
40(
41 test -d m1n1 || git clone --recursive https://github.com/AsahiLinux/m1n1
42 cd m1n1
43 git fetch -a -t
44 git reset --hard v${M1N1_VERSION};
45 git clean -f -x -d > /dev/null
46 make -j `nproc`
47)
48}
49
50build_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
56 git reset --hard $UBOOT_VERSION
57 git clean -f -x -d > /dev/null
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
63}
64
65package_boot_bin()
66{
67(
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
72Package: m1n1
73Version: $M1N1_VERSION
74Section: base
75Priority: optional
76Architecture: arm64
77Maintainer: Thomas Glanzmann <thomas@glanzmann.de>
78Description: Apple silicon boot loader
79 Next to m1n1 this also contains the device trees and u-boot.
80EOF
81
82 cat > m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst <<'EOF'
83#!/bin/bash
84
85export PATH=/bin
86if [ -f /boot/efi/m1n1/boot.bin ]; then
87 cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin
88fi
89mkdir -p /boot/efi/m1n1/
90cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/
91EOF
92
93 chmod 755 m1n1_${M1N1_VERSION}_arm64/DEBIAN/postinst
94 dpkg-deb --build m1n1_${M1N1_VERSION}_arm64
95)
96}
97
98mkdir -p build
99cd build
100
101build_linux
102build_m1n1
103build_uboot
104package_boot_bin
Impressum, Datenschutz