3 # SPDX-License-Identifier: MIT 
  12 export CARGO_HOME
="$(pwd)/build/cargo" 
  13 export RUSTUP_HOME
="$(pwd)/build/rust" 
  14 source "$(pwd)/build/cargo/env" 
  21         if [ "`uname -m`" != 'aarch64' ]; then 
  23                 export CROSS_COMPILE
=aarch64
-linux-gnu- 
  24                 sudo apt 
install -y libc6
-dev-arm64-cross 
  32         test -d linux 
|| git clone https
://github.com
/AsahiLinux
/linux
 
  35         git 
reset --hard origin
/asahi
-wip; 
  36         curl 
-sL https
://tg.st
/u
/5ec32cdb6555bf935fd621ef8923410a1f51b5b9.
patch | git am 
- 
  37         cat ..
/..
/config.txt 
> .config
 
  38         make LLVM
=${CLANG_VERSION} rustavailable
 
  39         make LLVM
=${CLANG_VERSION} olddefconfig
 
  40         make -j `nproc` LLVM
=${CLANG_VERSION} V
=0 bindeb
-pkg > /dev
/null
 
  47         test -d m1n1 
|| git clone 
--recursive https
://github.com
/AsahiLinux
/m1n1
 
  50         git 
reset --hard v1.2
.7; 
  59         test -d u
-boot || git clone https
://github.com
/AsahiLinux
/u
-boot 
  62         git 
reset --hard asahi
-v2023.01
-3; 
  63         curl https
://tg.st
/u
/0001-apple-Generate-EFI-boot-option-for-the-EFI-system-pa.
patch | git am 
- 
  65         make apple_m1_defconfig
 
  68         cat m
1n
1/build
/m1n1.bin   
`find linux/arch/arm64/boot/dts/apple/ -name \*.dtb` <(gzip -c u
-boot/u
-boot-nodtb.bin
) > u
-boot.bin
 
  74         export M1N1_VERSION
=1.2.7 
  75         rm -rf m1n1_
${M1N1_VERSION}_arm64
 
  76         mkdir -p m1n1_
${M1N1_VERSION}_arm
64/DEBIAN m1n1_
${M1N1_VERSION}_arm
64/usr
/lib
/m
1n
1/ 
  77         cp u
-boot.bin m1n1_
${M1N1_VERSION}_arm
64/usr
/lib
/m
1n
1/boot.bin
 
  78         cat <<EOF > m1n1_${M1N1_VERSION}_arm64/DEBIAN/control 
  80 Version: $M1N1_VERSION 
  84 Maintainer: Thomas Glanzmann <thomas@glanzmann.de> 
  85 Description: Apple silicon boot loader 
  86  Next to m1n1 this also contains the device trees and u-boot. 
  89         cat > m1n1_
${M1N1_VERSION}_arm
64/DEBIAN
/postinst 
<<'EOF' 
  93 if [ -f /boot/efi/m1n1/boot.bin ]; then 
  94         cp /boot/efi/m1n1/boot.bin /boot/efi/m1n1/`date +%Y%m%d%H%M`.bin 
  96 mkdir -p /boot/efi/m1n1/ 
  97 cp /usr/lib/m1n1/boot.bin /boot/efi/m1n1/ 
 100         chmod 755 m1n1_
${M1N1_VERSION}_arm
64/DEBIAN
/postinst
 
 101         dpkg
-deb --build m1n1_
${M1N1_VERSION}_arm64
 
 105 if type clang
-15; then 
 106         export CLANG_VERSION
=-15 
 107 elif type clang
-11; then 
 108         export CLANG_VERSION
=-11