Blob Blame History Raw
%global debug_package %{nil}

Name:           m1n1
Version:        1.4.8
Release:        %autorelease
Summary:        Bootloader and experimentation playground for Apple Silicon

# m1n1 proper is MIT licensed, but it relies on a number of vendored projects
# See the "License" section in for the breakdown
License:        MIT AND CC0-1.0 AND OFL-1.1-RFN AND Zlib AND (BSD-2-Clause OR GPL-2.0-or-later) AND (BSD-3-Clause OR GPL-2.0-or-later)
Source:         %{url}/archive/v%{version}/%{name}-%{version}.tar.gz

%ifarch aarch64
# On aarch64 do a native build
BuildRequires:  gcc
%global buildflags RELEASE=1 ARCH=
# By default m1n1 does a cross build
BuildRequires:  gcc-aarch64-linux-gnu
%global buildflags RELEASE=1
BuildRequires:  make

# For the bootloader logos and the framebuffer console
BuildRequires:  adobe-source-code-pro-fonts
BuildRequires:  coreutils
BuildRequires:  fontconfig
BuildRequires:  system-logos
BuildRequires:  ImageMagick
BuildRequires:  zopfli

# For the udev rule
BuildRequires:  systemd-rpm-macros

# These are bundled, modified and statically linked into m1n1
Provides:       bundled(arm-trusted-firmware)
Provides:       bundled(dwc3)
Provides:       bundled(dlmalloc)
Provides:       bundled(PDCLib)
Provides:       bundled(libfdt)
Provides:       bundled(minilzlib)
Provides:       bundled(tinf)

m1n1 is the bootloader developed by the Asahi Linux project to bridge the Apple
(XNU) boot ecosystem to the Linux boot ecosystem.

%package        tools
Summary:        Developer tools for m1n1
Requires:       %{name} = %{version}-%{release}
Requires:       python3
Requires:       python3dist(construct)
Requires:       python3dist(pyserial)
Requires:       systemd-udev
BuildArch:      noarch

%description    tools
This package contains various developer tools for m1n1.

%autosetup -p1

# Use our logos
pushd data
rm bootlogo_{128,256}.{bin,png}
convert -background none -resize 128x128 -gravity center -extent 128x128 \
  %{_datadir}/pixmaps/fedora-logo-sprite.svg bootlogo_128.png
zopflipng -ym bootlogo_128.png bootlogo_128.png
convert -background none -resize 256x256 -gravity center -extent 256x256 \
  %{_datadir}/pixmaps/fedora-logo-sprite.svg bootlogo_256.png
zopflipng -ym bootlogo_256.png bootlogo_256.png

# Use our fonts
font="$(fc-match "Source Code Pro:bold" 'file' | cut -d= -f2)"
if [ ! -e "$font" ]; then
    echo "Failed to find font"
    exit 1

pushd font
rm SourceCodePro-Bold.ttf font.bin font_retina.bin
./ 8 16 12 "$font" font.bin
./ 16 32 25 "$font" font_retina.bin

%make_build %{buildflags}

install -Dpm0644 -t %{buildroot}%{_libdir}/%{name} build/%{name}.{bin,macho}
install -Ddpm0755 %{buildroot}%{_libexecdir}/%{name}
cp -pr proxyclient tools %{buildroot}%{_libexecdir}/%{name}/
install -Dpm0644 -t %{buildroot}%{_udevrulesdir} udev/80-m1n1.rules

%license LICENSE 3rdparty_licenses/LICENSE.*

%files tools