Skip to content

Commit

Permalink
A new start
Browse files Browse the repository at this point in the history
  • Loading branch information
MastaG committed Jul 12, 2024
0 parents commit 16cbd7e
Show file tree
Hide file tree
Showing 12 changed files with 968 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build_turnip_ppa_2404.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is a basic workflow to help you get started with Actions

name: turnip-ppa-update-24.04

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: '30 2 * * *'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-24-04:
# The type of runner that the job will run on
runs-on: ubuntu-24.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# Runs a set of commands using the runners shell
- name: Run build script for ubuntu 24.04
env:
EMAIL: ${{ secrets.EMAIL }}
PUBKEY: ${{ secrets.PUBKEY }}
PRIVKEY: ${{ secrets.PRIVKEY }}
run: |
cd "$GITHUB_WORKSPACE"
chmod +x ./build_ppa.sh
./build_ppa.sh
36 changes: 36 additions & 0 deletions .github/workflows/build_turnip_ppa_2410.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a basic workflow to help you get started with Actions

name: turnip-ppa-update-24.10

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: '30 2 * * *'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-24-10:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# Runs a set of commands using the runners shell
- name: Run build script inside docker for 24.10
env:
EMAIL: ${{ secrets.EMAIL }}
PUBKEY: ${{ secrets.PUBKEY }}
PRIVKEY: ${{ secrets.PRIVKEY }}
run: |
cd "$GITHUB_WORKSPACE"
sudo apt update
sudo apt install -y podman
podman build -f Dockerfile -t turnip-build --build-arg EMAIL="$EMAIL" --build-arg PRIVKEY="$PRIVKEY" --build-arg PUBKEY="$PUBKEY"
podman run --security-opt seccomp=unconfined turnip-build
57 changes: 57 additions & 0 deletions .github/workflows/turnip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: nightly-turnip-release

on:
workflow_dispatch:
schedule:
- cron: '30 2 * * *'

jobs:
start_building_turnip:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Prepare environment
run: |
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo sed -i 's/^Types: deb$/Types: deb deb-src/g' /etc/apt/sources.list.d/*.sources
sudo apt update
sudo apt build-dep mesa -y
- name: Execute build script
run: bash ./turnip_builder.sh

- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: Upload meson and ninja logs for debugging
path: |
turnip_workdir/ninja_log
turnip_workdir/mesa/build-android-aarch64/meson-logs/meson-log.txt
- id: versions
name: "Get release info"
run: |
echo "name=$(cat turnip_workdir/release)" >> "$GITHUB_OUTPUT"
echo "tag=$(cat turnip_workdir/tag)" >> "$GITHUB_OUTPUT"
echo "filename=$(cat turnip_workdir/filename)" >> "$GITHUB_OUTPUT"
echo "patched=$(cat turnip_workdir/patched)" >> "$GITHUB_OUTPUT"
- name: Release "turnip"
uses: softprops/action-gh-release@v1
with:
body_path: turnip_workdir/description
name: ${{ steps.versions.outputs.name }}
tag_name: ${{ steps.versions.outputs.tag }}
files: |
turnip_workdir/${{ steps.versions.outputs.filename }}.zip
- name: Release "turnip" with patched
if: ${{ contains(steps.versions.outputs.patched, 'true') }}
uses: softprops/action-gh-release@v1
with:
body_path: turnip_workdir/description
name: ${{ steps.versions.outputs.name }}
tag_name: ${{ steps.versions.outputs.tag }}
files: |
turnip_workdir/${{ steps.versions.outputs.filename }}_patched.zip
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:24.10

ARG PUBKEY
ARG PRIVKEY
ARG EMAIL
ENV PUBKEY=$PUBKEY
ENV PRIVKEY=$PRIVKEY
ENV EMAIL=$EMAIL

COPY ./entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "sh", "-c", "/entrypoint.sh" ]
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

![Schermafdruk_2024-07-02_09-42-26](https://github.com/MastaG/mesa-turnip-ppa/assets/15012115/84b6d427-c780-45a2-85bf-cf8b84d6fa56)

This repository takes care of two things:

- Re-building oibaf's graphics-drivers ppa (nightly mesa from git) with extra patches applied.

The patches are meant for running Ubuntu 24.04 (and 24.10 soon) within a proot environment using Termux on your Android device.

This should allow for accelated Vulkan and OpenGL (using Zink).

It will push the patched mesa version to my pesonal ppa: https://launchpad.net/~mastag/+archive/ubuntu/mesa-turnip-kgsl

Quick steps to get this working, assuming you already have Ubuntu 24.04 with xfce4 setup inside your proot env:

1. Use this sample script to enter your proot distribution:
```
#!/bin/sh
export XDG_RUNTIME_DIR=${TMPDIR}
# Kill open X11 processes
kill -9 $(pgrep -f "termux.x11") 2>/dev/null
# Enable PulseAudio over Network
pulseaudio --verbose --start --exit-idle-time=-1 --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1"
# Prepare termux-x11 session
termux-x11 :0 -ac -extension MIT-SHM &
# Wait a bit until termux-x11 gets started.
sleep 2
# Login in PRoot Environment.
proot-distro login ubuntu --shared-tmp --user username
```
2. Once logged into your proot distribution, add the ppa and install the updated drivers:
```
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:mastag/mesa-turnip-kgsl
sudo apt update
sudo apt dist-upgrade
```
2. Add the following variables to ```/etc/environment```:
```
MESA_LOADER_DRIVER_OVERRIDE=zink
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/freedreno_icd.aarch64.json:/usr/share/vulkan/icd.d/freedreno_icd.armv7l.json
TU_DEBUG=noconform
```
3. Use this script to start xfce4:
```
sudo /etc/init.d/dbus start
export DISPLAY=:0
taskset -c 4-7 startxfce4
```
4. Edit your ```~/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml``` file and change: ```vblank_mode``` from ```auto``` to ```off```.
- Building nightly turnip driver releases for use with Android emulators such as Yuzu, Strato, Flycast etc. (big shoutout to @Weab-chan for doing all the work for me).
It basicallly builds a vanilla and patched release.
You can find the patches in the: ```turnip-patches``` directory.
However I also occasionally apply open merge requests, see the following arrays for more information:
For the mesa ppa: https://github.com/MastaG/mesa-turnip-ppa/blob/8e2b333e299acf6d68cc10a2e26969e3bbba7e65/build_ppa.sh#L2
For the turnip nightly releases: https://github.com/MastaG/mesa-turnip-ppa/blob/8e2b333e299acf6d68cc10a2e26969e3bbba7e65/turnip_builder.sh#L14
Feel free to contribute by opening a PR :)
114 changes: 114 additions & 0 deletions build_ppa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash
patches=(
"fix-for-anon-file;../../../turnip-patches/fix-for-anon-file.patch;"
"fix-for-getprogname;../../../turnip-patches/fix-for-getprogname.patch;"
"dri3;../../../turnip-patches/dri3.patch;"
"zink_fixes;../../../turnip-patches/zink_fixes.patch;"
#"descr-prefetching-optimization-a7xx;merge_requests/29873;"
#"make-gmem-work-with-preemption;merge_requests/29871;"
#"VK_EXT_fragment_density_map;merge_requests/29938;"
)
export DEBEMAIL="${EMAIL}"
export DEBFULLNAME="MastaG"
install_dev() {
if [ ! -e .devready ]
then
echo 'install dev packages...'
apt install -y devscripts dpkg-dev build-essential fakeroot dput-ng curl
echo 'done' > .devready
else
echo 'dev packages already installed'
fi
}
sudo apt update
sudo apt install -y software-properties-common git
echo "${PUBKEY}" | base64 --decode | gpg --batch --import
echo "${PRIVKEY}" | base64 --decode | gpg --batch --import
git config --global user.email "${EMAIL}"
git config --global user.name "MastaG"
sudo add-apt-repository -n -y ppa:oibaf/graphics-drivers
sudo add-apt-repository -n -y ppa:mastag/mesa-turnip-kgsl
sudo sed -i 's/^Types: deb$/Types: deb deb-src/g' /etc/apt/sources.list.d/oibaf-*.sources
sudo echo 'APT::Key::Assert-Pubkey-Algo ">=rsa1024";' > /etc/apt/apt.conf.d/99weakkey-warning
sudo apt update
build=()
for i in {libdrm,mesa}
do
if [ "${i}" == "mesa" ]
then
package="mesa-vulkan-drivers"
elif [ "${i}" == "libdrm" ]
then
package="libdrm2"
fi
remotever="$(apt-cache policy ${package} | grep -B1 "oibaf/graphics-drivers/ubuntu" | head -1 | sed -En 's/.* (.*git.*) .*/\1/p')"
ourver="$(apt-cache policy ${package} | grep -B1 "mastag/mesa-turnip-kgsl/ubuntu" | head -1 | sed -En 's/.* (.*git.*) .*/\1/p' | sed 's/-turnip-kgsl//g')"
if [ "${ourver}" == "${remotever}" ]
then
echo "${i} version in our PPA: ${ourver}"
echo "up-to-date with Obiaf's PPA :)"
echo "doing nothing..."
continue
else
echo "${i} version in our PPA: ${ourver}"
echo "${i} version in Obiaf's PPA: ${remotever}"
echo "building new version with turnip patches..."
build+=("${i}")
fi
done
sudo rm -f /etc/apt/sources.list.d/mastag-ubuntu-*
sudo apt update
for i in "${build[@]}"
do
install_dev
sudo apt build-dep -y ${i}
rm -Rf ${i}*
apt-get source ${i}
rm -f ${i}*.dsc
version="$(ls -d ${i}-* | sed "s/^${i}-//g")"
newversion="$(echo "${version}" | sed 's/oibaf/oibaf-turnip-kgsl/g')"
find ./ -maxdepth 1 | grep "${version}" | while read line
do
newfile="$(echo ${line} | sed "s/${version}/${newversion}/g")"
mv -v "${line}" "${newfile}"
done
cd "${i}-${newversion}"
if [ "${i}" == "mesa" ]
then
dch --newversion "${newversion}" "Rebuild mesa-turnip-kgsl with the following patches:"
dch -r -u high "Rebuild mesa-turnip-kgsl with the following patches:"
cd debian/patches
for patch in ${patches[@]}
do
echo "Applying patch ${patch}"
patch_source="$(echo ${patch} | cut -d ";" -f 2 | xargs)"
patch_name="$(echo ${patch} | cut -d ";" -f 1 | xargs)"
dch -a "${patch_name} - ${patch_source}"
if [[ ${patch_source} == *"../../.."* ]]
then
apply="$(echo ${patch_source} | sed 's:.*/::')"
cp -f ${patch_source} .
echo "${apply}" >> series
else
patch_file="${patch_source#*\/}"
patch_args=$(echo ${patch} | cut -d ";" -f 3 | xargs)
curl --output "${patch_file}".patch -k --retry-delay 30 --retry 5 -f --retry-all-errors https://gitlab.freedesktop.org/mesa/mesa/-/"${patch_source}".patch
sleep 1
echo "${patch_file}".patch >> series
fi
done
cd ../..
# Enable kgsl
sed -i 's/GALLIUM_DRIVERS += freedreno$/GALLIUM_DRIVERS += freedreno\n\tconfflags_GALLIUM += -Dfreedreno-kmds=msm,kgsl/g' debian/rules
else
dch --newversion "${newversion}" "Rebuild mesa-turnip-kgsl"
dch -r -u high "Rebuild mesa-turnip-kgsl"
fi
debuild -S -sa -k${EMAIL}
cd ..
done
if ls *.changes 1> /dev/null 2>&1
then
echo "Push to launchpad"
dput --force ppa:mastag/mesa-turnip-kgsl *.changes
fi
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
apt update
apt install -y sudo git
useradd -m -U -s /bin/bash build
echo 'build ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/build_user
su -c 'cd $HOME; git clone https://github.com/MastaG/mesa-turnip-ppa.git; cd mesa-turnip-ppa; ./build_ppa.sh' build
Loading

0 comments on commit 16cbd7e

Please sign in to comment.