Pushing project info

This commit is contained in:
Ivan Bushchik 2023-01-04 12:53:18 +03:00
parent ba128bcbaa
commit e1ac2116e8
No known key found for this signature in database
GPG key ID: 3E4E9C7D66E44BF7
26 changed files with 1115 additions and 17 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
*target* *target*
scripts/build
*.DS_Store*

7
DOCS.md Normal file
View file

@ -0,0 +1,7 @@
# Docs
Build image with kiwi-ng
```
kiwi-ng -profile=<image_profile> --color-output system build --description ./ --target-dir ./outdir
```

View file

@ -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. 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 Look at `dev` branch to see the progress. [TODO](./TODO.md)
- [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)
## Contact me ## Contact me

15
TODO.md Normal file
View file

@ -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.

58
installer/bootstrap.sh Executable file
View file

@ -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

View file

@ -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"
}
]
}
]
}

View file

@ -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"
}
]
}
]
}

0
kiwi/asahi.xml Normal file
View file

0
kiwi/base.xml Normal file
View file

59
kiwi/config.sh Normal file
View file

@ -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

117
kiwi/config.xml Normal file
View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<image schemaversion="7.5" name="asahi-opensuse">
<description type="system">
<author>Ivan Bushchik</author>
<contact>ivabus@ivabus.dev</contact>
<specification>openSUSE for Apple Silicon</specification>
</description>
<preferences>
<version>0.0.1</version>
<packagemanager>zypper</packagemanager>
<bootsplash-theme>openSUSE</bootsplash-theme>
<bootloader-theme>openSUSE</bootloader-theme>
<locale>en_US</locale>
<keytable>us</keytable>
<timezone>UTC</timezone>
<rpm-check-signatures>true</rpm-check-signatures>
<type image="oem" filesystem="btrfs" firmware="uefi" bootpartition="true" bootpartsize="1024" bootfilesystem="ext4" efipartsize="512" target_blocksize="4096">
<bootloader name="grub2" console="gfxterm"/>
<oemconfig>
<oem-resize>false</oem-resize>
</oemconfig>
</type>
</preferences>
<users>
<user password="root" home="/root" name="root" groups="root"/>
</users>
<profiles>
<profile name="Tumbleweed" description="Tumbleweed base"/>
<profile name="Leap" description="Leap base"/>
<profile name="Leap-KDE" description="Leap with KDE desktop">
<requires profile="Tumbleweed"/>
</profile>
<profile name="Leap-GNOME" description="Leap with GNOME desktop">
<requires profile="Tumbleweed"/>
</profile>
<profile name="Leap-XFCE" description="Leap with XFCE desktop">
<requires profile="Tumbleweed"/>
</profile>
<profile name="Tumbleweed-KDE" description="Tumbleweed with KDE desktop">
<requires profile="Tumbleweed"/>
</profile>
<profile name="Tumbleweed-GNOME" description="Tumbleweed with GNOME desktop">
<requires profile="Tumbleweed"/>
</profile>
<profile name="Tumbleweed-XFCE" description="Tumbleweed with XFCE desktop">
<requires profile="Tumbleweed"/>
</profile>
</profiles>
<include from="this://./repos.xml"/>
<!-- Asahi repo -->
<repository type="rpm-md" alias="asahi" sourcetype="baseurl" priority="1" imageinclude="true">
<source path="https://storage.ivabus.dev/asahi-opensuse/repo/">
<signing key="https://ivabus.dev/key.asc"/>
</source>
</repository>
<include from="this://./desktop.xml"/>
<packages type="bootstrap" profiles="Tumbleweed,Leap" patternType="plusRecommended">
<package name="udev"/>
<package name="filesystem"/>
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="openSUSE-release"/>
<package name="zypper"/>
<package name="xz"/>
</packages>
<packages type="image" profiles="Tumbleweed,Leap" patternType="plusRecommended">
<package name="patterns-base-base"/>
<package name="patterns-base-apparmor"/>
<package name="patterns-openSUSE-base"/>
<package name="acl"/>
<package name="btrfsprogs"/>
<package name="btrfsmaintenance"/>
<package name="cron"/>
<package name="chrony"/>
<package name="dracut"/>
<package name="fipscheck"/>
<package name="grub2-branding-openSUSE"/>
<package name="iputils"/>
<package name="zypper-lifecycle-plugin"/>
<package name="vim"/>
<package name="grub2"/>
<package name="grub2-arm64-efi" arch="aarch64"/>
<package name="haveged"/>
<package name="less"/>
<package name="tar"/>
<package name="parted"/>
<package name="rollback-helper"/>
<package name="snapper"/>
<package name="firewalld"/>
<package name="systemd"/>
<package name="timezone"/>
<package name="NetworkManager"/>
<package name="wpa_supplicant"/>
<package name="iproute2"/>
<package name="openssh"/>
<package name="rsync"/>
<package name="salt-minion"/>
<package name="dialog"/>
<package name="grub2-snapper-plugin"/>
<package name="snapper-zypp-plugin"/>
<package name="dracut-kiwi-oem-repart"/>
<package name="ntp"/>
<package name="ruby"/>
<package name="yast2-firstboot"/>
</packages>
<packages type="image">
<package name="kernel"/>
<package name="m1n1"/>
<package name="uboot-asahi"/>
<package name="asahi-scripts"/>
</packages>
</image>

18
kiwi/desktop.xml Normal file
View file

@ -0,0 +1,18 @@
<image>
<packages type="image" profiles="leap-gnome,tumbleweed-gnome">
<package name="patterns-gnome-gnome"/>
<package name="patterns-gnome-gnome_basic"/>
<package name="patterns-gnome-gnome_basis"/>
<package name="patterns-gnome-gnome_internet"/>
<package name="patterns-gnome-gnome_x11"/>
</packages>
<packages type="image" profiles="leap-kde,tumbleweed-kde">
<package name="patterns-kde-kde"/>
<package name="patterns-kde-kde_plasma"/>
</packages>
<packages type="image" profiles="leap-xfce,tumbleweed-xfce">
<package name="patterns-xfce-xfce"/>
<package name="patterns-xfce-xfce_basic"/>
<package name="patterns-xfce-xfce_office"/>
</packages>
</image>

97
kiwi/make-installer.sh Executable file
View file

@ -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 <<EOF
{
"os_list": [
{
"name": "openSUSE Tumbleweed",
"default_os_name": "openSUSE Tumbleweed",
"boot_object": "m1n1.bin",
"next_object": "m1n1/boot.bin",
"package": "${package}.zip",
"supported_fw": ["12.3", "12.3.1", "12.4"],
"partitions": [
{
"name": "EFI",
"type": "EFI",
"size": "${esp_size}B",
"format": "fat",
"volume_id": "${esp_volume_id}",
"copy_firmware": true,
"copy_installer_data": true,
"source": "esp"
},
{
"name": "Boot",
"type": "Linux",
"size": "${boot_size}B",
"image": "boot.img"
},
{
"name": "Root",
"type": "Linux",
"size": "${root_size}B",
"expand": true,
"image": "root.img"
}
]
}
]
}
EOF

5
kiwi/post_bootstrap.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
# Flag file to ensure update-m1n1 doesn't try to autodetect the ESP
touch /boot/.builder
exit 0

23
kiwi/repos.xml Normal file
View file

@ -0,0 +1,23 @@
<image>
<!-- Tumbleweed repositories -->
<repository type="rpm-md" alias="repo-oss" profiles="Tumbleweed" imageinclude="true">
<source path="http://download.opensuse.org/ports/aarch64/tumbleweed/repo/oss/"/>
</repository>
<repository type="rpm-md" alias="repo-debug" profiles="Tumbleweed" imageinclude="true">
<source path="http://download.opensuse.org/ports/aarch64/debug/tumbleweed/repo/oss/"/>
</repository>
<repository type="rpm-md" alias="repo-update" profiles="Tumbleweed" imageinclude="true">
<source path="http://download.opensuse.org/ports/aarch64/update/tumbleweed/"/>
</repository>
<repository type="rpm-md" alias="repo-src-oss" profiles="Tumbleweed" imageinclude="true">
<source path="http://download.opensuse.org/ports/aarch64/source/tumbleweed/repo/oss/"/>
</repository>
<!-- Leap repositories -->
<repository type="rpm-md" alias="repo-oss" profiles="Leap" imageinclude="true">
<source path="http://download.opensuse.org/distribution/leap/15.3/repo/oss"/>
</repository>
<repository type="rpm-md" alias="repo-non-oss" profiles="Leap" imageinclude="true">
<source path="http://download.opensuse.org/distribution/leap/15.3/repo/non-oss/"/>
</repository>
</image>

View file

@ -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

View file

@ -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"
}

8
scripts/00_build_repo.sh Executable file
View file

@ -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

41
scripts/01_build_kernel.sh Executable file
View file

@ -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/

17
scripts/02_build_rpms.sh Executable file
View file

@ -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

29
specs/asahi-dtbs.spec Normal file
View file

@ -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

50
specs/asahi-scripts.spec Normal file
View file

@ -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

153
specs/kernel.sh Executable file
View file

@ -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"

65
specs/m1n1.spec Normal file
View file

@ -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 <ivabus@ivabus.dev> 1.2.4-1
- Update to 1.2.4; Fix installation
* Sun Jan 22 2023 Ivan Bushchik <ivabus@ivabus.dev> 1.2.3-1
- Initial version

47
specs/uboot-asahi.spec Normal file
View file

@ -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 <ivabus@ivabus.dev> 2022.10-2
- Initial version