From e1ac2116e8366d3a85bf37c34d0ae6750e821348 Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Wed, 4 Jan 2023 12:53:18 +0300 Subject: [PATCH] Pushing project info --- .gitignore | 2 + DOCS.md | 7 + README.md | 22 +- TODO.md | 15 ++ installer/bootstrap.sh | 58 +++++ installer/installer_data-todo.json | 220 ++++++++++++++++++ installer/installer_data.json | 37 +++ kiwi/asahi.xml | 0 kiwi/base.xml | 0 kiwi/config.sh | 59 +++++ kiwi/config.xml | 117 ++++++++++ kiwi/desktop.xml | 18 ++ kiwi/make-installer.sh | 97 ++++++++ kiwi/post_bootstrap.sh | 5 + kiwi/repos.xml | 23 ++ .../root/etc/YaST2}/firstboot.xml | 0 kiwi/root/etc/zypp/repos.d/asahi.repo | 6 + .../99asahi-firmware/module-setup.sh | 36 +++ scripts/00_build_repo.sh | 8 + scripts/01_build_kernel.sh | 41 ++++ scripts/02_build_rpms.sh | 17 ++ specs/asahi-dtbs.spec | 29 +++ specs/asahi-scripts.spec | 50 ++++ specs/kernel.sh | 153 ++++++++++++ specs/m1n1.spec | 65 ++++++ specs/uboot-asahi.spec | 47 ++++ 26 files changed, 1115 insertions(+), 17 deletions(-) create mode 100644 DOCS.md create mode 100644 TODO.md create mode 100755 installer/bootstrap.sh create mode 100644 installer/installer_data-todo.json create mode 100644 installer/installer_data.json create mode 100644 kiwi/asahi.xml create mode 100644 kiwi/base.xml create mode 100644 kiwi/config.sh create mode 100644 kiwi/config.xml create mode 100644 kiwi/desktop.xml create mode 100755 kiwi/make-installer.sh create mode 100644 kiwi/post_bootstrap.sh create mode 100644 kiwi/repos.xml rename {configs => kiwi/root/etc/YaST2}/firstboot.xml (100%) create mode 100644 kiwi/root/etc/zypp/repos.d/asahi.repo create mode 100644 kiwi/root/usr/lib/dracut/modules.d/99asahi-firmware/module-setup.sh create mode 100755 scripts/00_build_repo.sh create mode 100755 scripts/01_build_kernel.sh create mode 100755 scripts/02_build_rpms.sh create mode 100644 specs/asahi-dtbs.spec create mode 100644 specs/asahi-scripts.spec create mode 100755 specs/kernel.sh create mode 100644 specs/m1n1.spec create mode 100644 specs/uboot-asahi.spec diff --git a/.gitignore b/.gitignore index 68e3691..bb8bd82 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *target* +scripts/build +*.DS_Store* \ No newline at end of file diff --git a/DOCS.md b/DOCS.md new file mode 100644 index 0000000..cf0fad4 --- /dev/null +++ b/DOCS.md @@ -0,0 +1,7 @@ +# Docs + +Build image with kiwi-ng + +``` +kiwi-ng -profile= --color-output system build --description ./ --target-dir ./outdir +``` diff --git a/README.md b/README.md index 6908eb2..4cb28ce 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,12 @@ -# Asahi openSUSE port +# asahi-opensuse + +> Port of openSUSE for Apple Silicon Currently I'm working on openSUSE port for Apple Silicon machines. -## TODO list +## Current progress -- [ ] Boot openSUSE from USB device with pre-built (by hands) image - - [x] Build image - - [ ] Test what works or not -- [ ] Prepare installer - - [ ] Prepare OBS repos (or just repos) with necessary packages (kernel, m1n1, u-boot, asahi-scripts, etc.) - - [ ] Prepare basic (cli only, DE) rootfs images (and scripts to build them) - - [ ] Build installer (for use like general Asahi installer, ex. `curl https://ivabus.dev/suse | sh`) - - [ ] Provide all types of openSUSE (Leap, Tumbleweed, Leap Micro, MicroOS) for installation. - - [ ] Test every type of installation - - [ ] Document things - - [ ] First release -- [ ] Integrate with YaST - - [ ] Make some scripts to let openSUSE be installed, using USB drive and on-device U-Boot - - [ ] Somehow tell YaST to not overwrite ESP volume - - [ ] Second release (with YaST installer) +Look at `dev` branch to see the progress. [TODO](./TODO.md) ## Contact me diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..88ab27a --- /dev/null +++ b/TODO.md @@ -0,0 +1,15 @@ + +## TODO list + +- [x] Integrate with yast2-firstboot +- [x] Build Tumbleweed image using kiwi-ng +- [x] Prepare repos with necessary packages (kernel, m1n1, u-boot, asahi-scripts, etc.) +- [x] Provide basic types of openSUSE (Leap, Tumbleweed) for installation. +------ +- [ ] Prepare basic (cli only, DE) rootfs images +- [ ] Build installer (for use like general Asahi installer, ex. `curl https://ivabus.dev/suse | sh`) +- [ ] Test every type of installation +- [ ] Document things +- [ ] First release +------ +- [ ] Provide Leap Micro and MicroOS for installation. \ No newline at end of file diff --git a/installer/bootstrap.sh b/installer/bootstrap.sh new file mode 100755 index 0000000..a65e939 --- /dev/null +++ b/installer/bootstrap.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +set -e + +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 +export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH" + +export VERSION_FLAG=file:///Users/ivabus/storage.ivabus.dev/asahi-opensuse/installer/latest +export INSTALLER_BASE=file:///Users/ivabus/storage.ivabus.dev/asahi-opensuse/installer +export INSTALLER_DATA=file:///Users/ivabus/my/asahi-opensuse/installer/installer_data.json +export INSTALLER_DATA_ALT=https://ivabus.dev/installer_data.json +export REPO_BASE=/Users/ivabus/storage.ivabus.dev/asahi-opensuse + +#TMP="$(mktemp -d)" +TMP=/tmp/asahi-install + +echo +echo "Bootstrapping installer:" + +if [ -e "$TMP" ]; then + mv "$TMP" "$TMP-$(date +%Y%m%d-%H%M%S)" +fi + +mkdir -p "$TMP" +cd "$TMP" + +echo " Checking version..." + +PKG_VER="$(curl --no-progress-meter -L "$VERSION_FLAG")" +echo " Version: $PKG_VER" + +PKG="installer-$PKG_VER.tar.gz" + +echo " Downloading..." + +curl --no-progress-meter -L -o "$PKG" "$INSTALLER_BASE/$PKG" +if ! curl --no-progress-meter -L -O "$INSTALLER_DATA"; then + echo " Error downloading installer_data.json. GitHub might be blocked in your network." + echo " Please consider using a VPN if you experience issues." + echo " Trying workaround..." + curl --no-progress-meter -L -O "$INSTALLER_DATA_ALT" +fi + +echo " Extracting..." +tar xf "$PKG" + +echo " Initializing..." +echo + +if [ "$USER" != "root" ]; then + echo "The installer needs to run as root." + echo "Please enter your sudo password if prompted." + exec caffeinate -dis sudo -E ./install.sh "$@" +else + exec caffeinate -dis ./install.sh "$@" +fi diff --git a/installer/installer_data-todo.json b/installer/installer_data-todo.json new file mode 100644 index 0000000..f3f1a59 --- /dev/null +++ b/installer/installer_data-todo.json @@ -0,0 +1,220 @@ +{ + "os_list": [ + { + "name": "openSUSE Tumbleweed KDE", + "default_os_name": "openSUSE Tumbleweed", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Tumbleweed GNOME", + "default_os_name": "openSUSE Tumbleweed", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Tumbleweed XFCE", + "default_os_name": "openSUSE Tumbleweed", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Tumbleweed base", + "default_os_name": "openSUSE Tumbleweed", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Leap KDE", + "default_os_name": "openSUSE Leap", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Leap GNOME", + "default_os_name": "openSUSE Leap", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Leap XFCE", + "default_os_name": "openSUSE Leap", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + }, + { + "name": "openSUSE Leap base", + "default_os_name": "openSUSE Leap", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "asahi-plasma-20221122-4.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "500MB", + "format": "fat", + "volume_id": "0x2abf9f91", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Root", + "type": "Linux", + "size": "12GB", + "expand": true, + "image": "root.img" + } + ] + } + ] +} \ No newline at end of file diff --git a/installer/installer_data.json b/installer/installer_data.json new file mode 100644 index 0000000..4056152 --- /dev/null +++ b/installer/installer_data.json @@ -0,0 +1,37 @@ +{ + "os_list": [ + { + "name": "openSUSE Tumbleweed", + "default_os_name": "openSUSE Tumbleweed", + "boot_object": "m1n1.bin", + "next_object": "m1n1/boot.bin", + "package": "installer-suse.zip", + "supported_fw": ["12.3", "12.3.1", "12.4"], + "partitions": [ + { + "name": "EFI", + "type": "EFI", + "size": "536870912B", + "format": "fat", + "volume_id": "0xa060cfc3", + "copy_firmware": true, + "copy_installer_data": true, + "source": "esp" + }, + { + "name": "Boot", + "type": "Linux", + "size": "1073741824B", + "image": "boot.img" + }, + { + "name": "Root", + "type": "Linux", + "size": "2970595328B", + "expand": true, + "image": "root.img" + } + ] + } + ] +} \ No newline at end of file diff --git a/kiwi/asahi.xml b/kiwi/asahi.xml new file mode 100644 index 0000000..e69de29 diff --git a/kiwi/base.xml b/kiwi/base.xml new file mode 100644 index 0000000..e69de29 diff --git a/kiwi/config.sh b/kiwi/config.sh new file mode 100644 index 0000000..8df5821 --- /dev/null +++ b/kiwi/config.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -euxo pipefail + +test -f /.kconfig && . /.kconfig +test -f /.profile && . /.profile + +echo "Configure image: [$kiwi_iname]-[$kiwi_profiles]..." + +#====================================== +# Clear machine specific configuration +#-------------------------------------- +## Clear machine-id on pre generated images +rm -f /etc/machine-id +touch /etc/machine-id +## remove random seed, the newly installed instance should make its own +rm -f /var/lib/systemd/random-seed + +#====================================== +# Delete & lock the root user password +#-------------------------------------- +passwd -d root +passwd -l root + +#====================================== +# Setup default services +#-------------------------------------- + +## Enable NetworkManager +systemctl enable NetworkManager.service +## Enable chrony +systemctl enable chronyd.service +## Enable persistent journal +mkdir -p /var/log/journal + +if [[ "$kiwi_profiles" == *"GNOME"* ]] || [[ "$kiwi_profiles" == *"KDE"* ]] || [[ "$kiwi_profiles" == *"XFCE"* ]]; then + systemctl set-default graphical.target +else + systemctl set-default multi-user.target +fi + +#====================================== +# Enable yast2-firstboot +#-------------------------------------- +touch /var/lib/YaST2/reconfig_system + +#====================================== +# Generate boot.bin +#-------------------------------------- +mkdir -p /boot/efi/m1n1 +update-m1n1 /boot/efi/m1n1/boot.bin +rm -rf /boot/.builder +#====================================== +# Regenerate initrds +#-------------------------------------- +mkinitrd +grub2-mkconfig -o /boot/grub2/grub.cfg + +exit 0 diff --git a/kiwi/config.xml b/kiwi/config.xml new file mode 100644 index 0000000..c81cbaf --- /dev/null +++ b/kiwi/config.xml @@ -0,0 +1,117 @@ + + + + + Ivan Bushchik + ivabus@ivabus.dev + openSUSE for Apple Silicon + + + 0.0.1 + zypper + openSUSE + openSUSE + en_US + us + UTC + true + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kiwi/desktop.xml b/kiwi/desktop.xml new file mode 100644 index 0000000..e55f06e --- /dev/null +++ b/kiwi/desktop.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kiwi/make-installer.sh b/kiwi/make-installer.sh new file mode 100755 index 0000000..63085fb --- /dev/null +++ b/kiwi/make-installer.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +set -eu + +fail() { + echo $* >&2 + exit 1 +} + +requireCommands() { + for cmd in $*; do + if ! command -v $cmd &> /dev/null; then + fail "Cannot find required command: $cmd" + fi + done +} + +date=$(date +%Y%m%d) +image="${1:-outdir/asahi-opensuse.aarch64-0.0.1.raw}" +package="installer-suse" + +if [ ! -r "$image" ]; then + fail "$image does not exist or cannot be read!" +fi + +if [ -e "$package" ]; then + fail "$package already exists, aborting" +fi + +requireCommands 7z awk cat cp dd fdisk file mkdir mv stat wget + +workdir="$(mktemp -dp /var/tmp)" + +basedir="$PWD" +imagename="$(basename "$image")" +imagedir="$(dirname "$image")" + +# extract filesystems from disk image +pushd "$imagedir" > /dev/null +eval "$(fdisk -Lnever -lu -b 4096 "$imagename" | awk "/^${imagename}/ { printf \"dd if=${imagename} of=${workdir}/%s skip=%s count=%s bs=4096\\n\", \$1, \$2, \$4 }")" +popd > /dev/null + +# build package +mkdir -p "${workdir}/package/esp" +7z x -o"${workdir}/package/esp" "${workdir}/${imagename}1" +mv "${workdir}/${imagename}2" "${workdir}/package/boot.img" +mv "${workdir}/${imagename}3" "${workdir}/package/root.img" + +esp_volume_id="$(file "${workdir}/${imagename}1" | awk -v 'RS=,' '/serial number/ { print $3 }')" +esp_size="$(stat -c %s "${workdir}/${imagename}1")" +boot_size="$(stat -c %s "${workdir}/package/boot.img")" +root_size="$(stat -c %s "${workdir}/package/root.img")" + +pushd "${workdir}/package" > /dev/null +7z a -tzip -r "${basedir}/${package}" . +popd > /dev/null + + +cat > installer_data.json < + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/configs/firstboot.xml b/kiwi/root/etc/YaST2/firstboot.xml similarity index 100% rename from configs/firstboot.xml rename to kiwi/root/etc/YaST2/firstboot.xml diff --git a/kiwi/root/etc/zypp/repos.d/asahi.repo b/kiwi/root/etc/zypp/repos.d/asahi.repo new file mode 100644 index 0000000..b1778f1 --- /dev/null +++ b/kiwi/root/etc/zypp/repos.d/asahi.repo @@ -0,0 +1,6 @@ +[asahi] +name=asahi +baseurl=https://storage.ivabus.dev/asahi-opensuse/repo +enabled=1 +gpgcheck=1 +gpgkey=https://ivabus.dev/key.asc \ No newline at end of file diff --git a/kiwi/root/usr/lib/dracut/modules.d/99asahi-firmware/module-setup.sh b/kiwi/root/usr/lib/dracut/modules.d/99asahi-firmware/module-setup.sh new file mode 100644 index 0000000..0deabe9 --- /dev/null +++ b/kiwi/root/usr/lib/dracut/modules.d/99asahi-firmware/module-setup.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT + +# called by dracut +check() { + if [ -n "$hostonly" ] && [ ! -e /proc/device-tree/chosen/asahi,efi-system-partition ]; then + return 0 + elif [ -z "$hostonly" ]; then + return 0 + else + return 255 + fi +} + +# called by dracut +depends() { + echo fs-lib + return 0 +} + +# called by dracut +installkernel() { + instmods apple-mailbox nvme-apple +} + +# called by dracut +install() { + inst_dir "/lib/firmware" + ln_r "/vendorfw" "/lib/firmware/vendor" + asahiscriptsdir="/usr/share/asahi-scripts" + inst_dir $asahiscriptsdir + $DRACUT_CP -R -L -t "${initdir}/${asahiscriptsdir}" "${dracutsysrootdir}${asahiscriptsdir}"/* + inst_multiple cpio cut dirname grep modprobe mount seq sleep umount + inst_hook pre-udev 10 "${moddir}/load-asahi-firmware.sh" + inst_hook cleanup 99 "${moddir}/install-asahi-firmware.sh" +} diff --git a/scripts/00_build_repo.sh b/scripts/00_build_repo.sh new file mode 100755 index 0000000..eecfa67 --- /dev/null +++ b/scripts/00_build_repo.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# This script clones & builds all RPMs that are used in repository. + +# Build kernel +sh 01_build_kernel.sh + +# sh 02_build_m1n1.sh diff --git a/scripts/01_build_kernel.sh b/scripts/01_build_kernel.sh new file mode 100755 index 0000000..b820858 --- /dev/null +++ b/scripts/01_build_kernel.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# This script clones & builds all linux-asahi related packages. + +_rcver=6.2 +_rcrel=3 +_asahirel=6 +_commit_id=asahi-${_rcver}${_rcrel+-rc}${_rcrel}-${_asahirel} +makethreads=`nproc` +CC=gcc +CXX=g++ + +if [ ! -d build ]; then + mkdir build +fi +cd build + +if [ ! -f ${_commit_id}.tar.gz ]; then + echo "Downloading linux-asahi sources" + curl -fSLO https://github.com/AsahiLinux/linux/archive/refs/tags/${_commit_id}.tar.gz +fi +if [ ! -d linux-${_commit_id} ]; then + echo "Unpacking linux-asahi" + tar xpf ${_commit_id}.tar.gz +fi +curl -o config -fsSL https://raw.githubusercontent.com/AsahiLinux/PKGBUILDs/main/linux-asahi/config +sed -i -e s/-ARCH/-suse/ config + +cd linux-${_commit_id} +echo "Building main kernel" +cp ../config .config +make olddefconfig prepare +diff -u ../config .config || : +make -j$makethreads CC=$CC CXX=$CXX rpm-pkg + +# Making source package for asahi-dtbs + +make dtbs +make INSTALL_PATH=. dtbs_install +tar cf dtbs-${_rcver}${_rcrel+_rc}${_rcrel}_${_asahirel}.tar dtbs/ +cp dtbs-${_rcver}${_rcrel+_rc}${_rcrel}_${_asahirel}.tar ~/rpmbuild/SOURCES/ diff --git a/scripts/02_build_rpms.sh b/scripts/02_build_rpms.sh new file mode 100755 index 0000000..0598b49 --- /dev/null +++ b/scripts/02_build_rpms.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# This script clones & builds all packages using .spec files. + +SPECTOOL=$(curl https://pagure.io/spectool/raw/master/f/spectool) + +for i in `ls ../specs/*.spec` +do + # Using spectool to download source tarball + python3 -c "$SPECTOOL" -g $i +done +mv *.tar.gz `rpm --eval "%{_sourcedir}"` +for i in `ls ../specs/*.spec` +do + # Building + rpmbuild -ba $i +done diff --git a/specs/asahi-dtbs.spec b/specs/asahi-dtbs.spec new file mode 100644 index 0000000..8202a12 --- /dev/null +++ b/specs/asahi-dtbs.spec @@ -0,0 +1,29 @@ +Name: asahi-dtbs +Version: 6.2_rc3_6 +# From _commit_id in 01_build_kernel.sh +Release: 1 +Summary: Device Trees (dtb) for Apple Silicon machines + +License: GPLv2+ +URL: https://github.com/AsahiLinux/linux +BuildArch: aarch64 + +Source0: dtbs-%{version}.tar +# Generated by 01_build_kernel.sh + +%description +Device Trees (dtb) for Apple Silicon machines + +%prep +%setup -n dtbs + +%install +install -Dpm 755 -t %{buildroot}/lib/modules/$(cat release)-ARCH/dtbs/ $(find . -type f) + +%files +/lib/modules/*-ARCH/dtbs/ + +%posttrans +update-m1n1 + +%changelog \ No newline at end of file diff --git a/specs/asahi-scripts.spec b/specs/asahi-scripts.spec new file mode 100644 index 0000000..65e7643 --- /dev/null +++ b/specs/asahi-scripts.spec @@ -0,0 +1,50 @@ +Name: asahi-scripts +Version: 20221220 +Release: 4 +Summary: Miscellaneous scripts for Asahi Linux + +License: MIT +URL: https://github.com/AsahiLinux/asahi-scripts +Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz + +BuildRequires: systemd-rpm-macros + +Requires: bash +Requires: growpart +Requires: coreutils +Requires: diffutils +Requires: dosfstools +Requires: kernel-firmware-all +Requires: sed +Requires: tar +Requires: asahi-dtbs +Requires: m1n1 +Requires: uboot-asahi + +BuildArch: aarch64 + +%description +This package contains miscellaneous admin scripts for the Asahi Linux reference +distro. + +%prep +%setup -n asahi-scripts-%{version} + +%install +make DESTDIR=%{buildroot} PREFIX=/usr install +make DESTDIR=%{buildroot} PREFIX=/usr DRACUT_CONF_DIR=/etc/dracut.conf.d install-dracut + +%files +%license LICENSE +/etc/m1n1.conf +/etc/dracut.conf.d/10-asahi.conf +/usr/bin/update-m1n1 +/usr/bin/asahi-fwextract +/usr/bin/asahi-diagnose +/usr/share/asahi-scripts/functions.sh +/usr/lib/dracut/modules.d/99asahi-firmware/module-setup.sh +/usr/lib/dracut/modules.d/99asahi-firmware/install-asahi-firmware.sh +/usr/lib/dracut/modules.d/99asahi-firmware/load-asahi-firmware.sh + +#%%changelog +#%%autochangelog diff --git a/specs/kernel.sh b/specs/kernel.sh new file mode 100755 index 0000000..fdb0d77 --- /dev/null +++ b/specs/kernel.sh @@ -0,0 +1,153 @@ +#!/bin/bash +cd=$(pwd) +_rcver=6.2 +_rcrel=3 +_asahirel=7 +_commit_id=asahi-${_rcver}${_rcrel+-rc}${_rcrel}-${_asahirel} + +rpmbuildsources=$(rpm --eval %{_sourcedir}) + +curl -fSLo $rpmbuildsources/${_commit_id}.tar.gz https://github.com/AsahiLinux/linux/archive/refs/tags/${_commit_id}.tar.gz +echo +curl -fSLo $rpmbuildsources/config-${_commit_id} https://raw.githubusercontent.com/AsahiLinux/PKGBUILDs/main/linux-asahi/config +tmpdir=$(mktemp -dp /var/tmp) +cd $tmpdir +tar xpvf $rpmbuildsources/${_commit_id}.tar.gz +cd linux-${_commit_id} +ver=$(make kernelversion) +cd $cd +rm -rf $tmpdir +cat > kernel.spec << EOF +%define _rcver ${_rcver} +%define _rcrel ${_rcrel} +%define _asahirel ${_asahirel} +%define _commit_id asahi-%{_rcver}%(if [ ! %_rcrel == "0" ]; then echo -rc%{_rcrel}; fi)-%{_asahirel} +%define _rpm_ver %{_rcver}%(if [ ! %_rcrel == "0" ]; then echo _rc%{_rcrel}; fi)_%{_asahirel}_asahi_suse +%define ver ${ver}-asahi-suse +Name: kernel +Summary: The Linux Kernel +Version: %{_rpm_ver} +Release: 1 +License: GPL +Group: System Environment/Kernel +Vendor: The Linux Community +URL: https://www.kernel.org +Source0: https://github.com/AsahiLinux/linux/archive/refs/tags/%{_commit_id}.tar.gz +Source1: config-%{_commit_id} +Provides: kernel-drm kernel-%{_rpm_ver} kernel-default kernel kernel-asahi +BuildRequires: bc binutils bison dwarves +BuildRequires: (elfutils-libelf-devel or libelf-devel) flex +BuildRequires: gcc make openssl openssl-devel perl python3 rsync + +# aarch64 as a fallback of _arch in case +# /usr/lib/rpm/platform/*/macros was not included. +%define _arch %{?_arch:aarch64} +%define __spec_install_post /usr/lib/rpm/brp-compress || : +%define debug_package %{nil} + +%description +The Linux Kernel, the operating system core itself + +%package headers +Summary: Header files for the Linux kernel for use by glibc +Group: Development/System +Obsoletes: kernel-headers +Provides: kernel-headers = %{version} +%description headers +Kernel-headers includes the C header files that specify the interface +between the Linux kernel and userspace libraries and programs. The +header files define structures and constants that are needed for +building most standard programs and are also needed for rebuilding the +glibc package. + +%package devel +Summary: Development package for building kernel modules to match the %{_rpm_ver} kernel +Group: System Environment/Kernel +AutoReqProv: no +%description -n kernel-devel +This package provides kernel headers and makefiles sufficient to build modules +against the %{_rpm_ver} kernel package. + +%package dtbs +Summary: Device Tree binaries (dtbs) for Apple Silicon machines +Group: System Environment/Kernel +Provides: asahi-dtbs kernel-asahi-dtbs +%description dtbs +Device Tree binaries (dtbs) for Apple Silicon machines + + +%prep +%setup -n linux-%{_commit_id} -q +sed -i -e s/-ARCH/-suse/ %{_sourcedir}/config-%{_commit_id} +cp %{_sourcedir}/config-%{_commit_id} .config +make olddefconfig prepare +diff -u %{_sourcedir}/config-%{_commit_id} .config || : +rm -f scripts/basic/fixdep scripts/kconfig/conf +rm -f tools/objtool/{fixdep,objtool} + +%build +make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} vmlinux modules dtbs Image + +%install +mkdir -p %{buildroot}/boot +cp arch/arm64/boot/Image %{buildroot}/boot/Image-%{ver} +make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install +make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install +cp System.map %{buildroot}/boot/System.map-%{ver} +cp .config %{buildroot}/boot/config-%{ver} +rm -f %{buildroot}/lib/modules/%{ver}/build +rm -f %{buildroot}/lib/modules/%{ver}/source +mkdir -p %{buildroot}/usr/src/kernels/%{ver} +make INSTALL_PATH=. dtbs_install +install -Dpm 755 -t %{buildroot}/lib/modules/%{ver}-ARCH/dtbs/ \$(find dtbs/ -type f) +tar cf - --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git --exclude=*vmlinux* --exclude=*.mod --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s . | tar xf - -C %{buildroot}/usr/src/kernels/%{ver} +cd %{buildroot}/lib/modules/%{ver} +ln -sf /usr/src/kernels/%{ver} build +ln -sf /usr/src/kernels/%{ver} source + +%clean +rm -rf %{buildroot} + +%post +if [ -x /sbin/installkernel -a -r /boot/Image-%{ver} -a -r /boot/System.map-%{ver} ]; then +cp /boot/Image-%{ver} /boot/.Image-%{ver}-rpm +cp /boot/System.map-%{ver} /boot/.System.map-%{ver}-rpm +rm -f /boot/Image-%{ver} /boot/System.map-%{ver} +/sbin/installkernel %{ver} /boot/.Image-%{ver}-rpm /boot/.System.map-%{ver}-rpm +rm -f /boot/.Image-%{ver}-rpm /boot/.System.map-%{ver}-rpm +fi + +%preun +if [ -x /sbin/new-kernel-pkg ]; then +new-kernel-pkg --remove %{ver} --rminitrd --initrdfile=/boot/initramfs-%{ver}.img +elif [ -x /usr/bin/kernel-install ]; then +kernel-install remove %{ver} +fi + +%postun +if [ -x /sbin/update-bootloader ]; then +/sbin/update-bootloader --remove %{ver} +fi + +%files +%defattr (-, root, root) +/lib/modules/%{ver} +%exclude /lib/modules/%{ver}/build +%exclude /lib/modules/%{ver}/source +/boot/* + +%files headers +%defattr (-, root, root) +/usr/include + +%files devel +%defattr (-, root, root) +/usr/src/kernels/%{ver} +/lib/modules/%{ver}/build +/lib/modules/%{ver}/source + +%files dtbs +%defattr (-, root, root) +/lib/modules/*-ARCH/dtbs/ +EOF +echo "Prepared kernel.spec for $ver" \ No newline at end of file diff --git a/specs/m1n1.spec b/specs/m1n1.spec new file mode 100644 index 0000000..b98877e --- /dev/null +++ b/specs/m1n1.spec @@ -0,0 +1,65 @@ +Name: m1n1 +Version: 1.2.4 +Release: 1 +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 README.md for the breakdown +License: MIT and CC0 and BSD and OFL and zlib +URL: https://github.com/AsahiLinux/m1n1 +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz + +%ifarch aarch64 +# On aarch64 do a native build +BuildRequires: gcc +%global buildflags RELEASE=1 ARCH= +%else +# By default m1n1 does a cross build +BuildRequires: gcc-aarch64-linux-gnu +%global buildflags RELEASE=1 +%endif +BuildRequires: make + +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) + +%description +m1n1 is the bootloader developed by the Asahi Linux project to bridge the Apple +(XNU) boot ecosystem to the Linux boot ecosystem. + +%prep +tar xpvf %{_sourcedir}/%{name}-%{version}.tar.gz + +%build +cd %{name}-%{version} +%make_build %{buildflags} + +%install +install -Dpm0644 -t %{buildroot}/usr/lib/asahi-boot %{name}-%{version}/build/%{name}.bin + +%files +%license %{name}-%{version}/LICENSE %{name}-%{version}/3rdparty_licenses/LICENSE.* +%doc %{name}-%{version}/README.md +/usr/lib/asahi-boot/m1n1.bin + +%posttrans +update-m1n1 + +%changelog +* Tue Jan 24 2023 Ivan Bushchik 1.2.4-1 +- Update to 1.2.4; Fix installation + +* Sun Jan 22 2023 Ivan Bushchik 1.2.3-1 +- Initial version \ No newline at end of file diff --git a/specs/uboot-asahi.spec b/specs/uboot-asahi.spec new file mode 100644 index 0000000..7216111 --- /dev/null +++ b/specs/uboot-asahi.spec @@ -0,0 +1,47 @@ +Name: uboot-asahi +Version: 2022.10 +Release: 2 +Summary: U-Boot for Apple Silicon Macs +License: GPLv3+ +URL: https://github.com/AsahiLinux +BuildArch: aarch64 +%define debug_package %{nil} +%define uboot_commit_id asahi-v%{version}-1 + +# to download the sources +# spectool -g uboot-asahi.spec + +Source0: https://github.com/AsahiLinux/u-boot/archive/%{uboot_commit_id}.tar.gz + +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc +BuildRequires: ImageMagick +BuildRequires: make +BuildRequires: openssl-devel + + +Provides: /usr/lib/asahi-boot/u-boot-nodtb.bin + +%description +U-Boot for Apple Silicon Macs + +%prep +%setup -b 0 -n u-boot-%{uboot_commit_id} +make %{_builddir}/u-boot-%{uboot_commit_id} apple_m1_defconfig + +%build +%make_build HOSTCC="gcc $RPM_OPT_FLAGS" CROSS_COMPILE="" + +%install +install -Dpm0644 -t %{buildroot}/usr/lib/asahi-boot %{_builddir}/u-boot-%{uboot_commit_id}/u-boot-nodtb.bin + +%posttrans +update-m1n1 + +%files +/usr/lib/asahi-boot/u-boot-nodtb.bin + +%changelog +* Tue Jan 24 2023 Ivan Bushchik 2022.10-2 +- Initial version \ No newline at end of file