added playbook

This commit is contained in:
erebion 2024-07-17 01:17:32 +02:00
parent 92fefce0a7
commit d1b6b741a1
12 changed files with 306 additions and 1 deletions

View file

@ -1,3 +1,33 @@
# sargo-temp
Temporary fixes that make Mobian work on sargo
Temporary fixes that make Mobian work on sargo.
Please note that the MIT license does not apply to `qcom-firmware`.
## What to do
### Build Image
Instructions are currently available here: https://pad.dc7ia.eu/hedgedoc/-cHyK2QRQkq9zrkaeys7CA
### Flash image
First flash the image. Boot the phone.
Connect via SSH: `ssh mobian@10.66.0.1`
Accept the host key.
### Roll out workarounds using Ansible
Go to the Ansible folder: `cd ansible`
Roll out workarounds: `./workarounds.sh`
Reboot phone via SSH.
Connect to wifi.
Rolling out the workarounds for audio requires installing packages from the repo, so we need an internet connection.
Roll out audio workarounds: `./audio.sh`

6
ansible/ansible.cfg Normal file
View file

@ -0,0 +1,6 @@
[defaults]
ansible_ssh_user=mobian
become=true
[ssh_connection]
pipelining = True

1
ansible/audio.sh Executable file
View file

@ -0,0 +1 @@
ansible-playbook --ask-become-pass --become -i 10.66.0.1, audio.yml

101
ansible/audio.yml Normal file
View file

@ -0,0 +1,101 @@
---
- hosts: 10.66.0.1
tasks:
### ALSA Config ###
- name: "Download https://gitlab.com/sdm670-mainline/alsa-ucm-conf/-/archive/master/alsa-ucm-conf-master.tar.gz"
ansible.builtin.get_url:
url: "https://gitlab.com/sdm670-mainline/alsa-ucm-conf/-/archive/master/alsa-ucm-conf-master.tar.gz"
dest: /root/alsa-ucm-conf-master.tar.gz
mode: '0440'
- name: "Remove alsa ucm configs"
ansible.builtin.file:
path: "/usr/share/alsa/{{ item }}"
state: absent
loop:
- ucm
- ucm2
- name: "Unpack alsa-ucm-conf-master.tar.gz to /usr/share/alsa"
ansible.builtin.shell: |
tar xvzf /root/alsa-ucm-conf-master.tar.gz -C /usr/share/alsa --strip-components=1 --wildcards "*/ucm" "*/ucm2"
args:
chdir: /usr/share/alsa
### Call Audio ###
- name: "Install gcc, git, libdbus-1-dev, libdbus-cpp-dev and make"
ansible.builtin.apt:
pkg:
- gcc
- git
- libdbus-1-dev
- libdbus-cpp-dev
- make
state: present
update_cache: true
- name: "Clone tinyalsa repo"
ansible.builtin.git:
repo: 'https://github.com/tinyalsa/tinyalsa.git'
dest: /opt/tinyalsa
version: master
- name: "Compile tinyalsa"
community.general.make:
chdir: /opt/tinyalsa
- name: "Install tinyalsa"
community.general.make:
chdir: /opt/tinyalsa
target: install
- name: "Run ldconfig"
ansible.builtin.command: /sbin/ldconfig
args:
chdir: /opt/tinyalsa
- name: "Clone q6voiced repo"
ansible.builtin.git:
repo: 'https://gitlab.com/postmarketOS/q6voiced'
dest: /opt/q6voiced
version: master
- name: "Compile q6voiced"
ansible.builtin.shell:
cmd: "gcc $(pkg-config --cflags dbus-1) q6voiced.c -o q6voiced -ltinyalsa -ldbus-1 -ldl"
args:
chdir: /opt/q6voiced
creates: /opt/q6voiced/q6voiced
- name: "Create /etc/q6voiced.conf"
ansible.builtin.copy:
src: q6voiced.conf
dest: /etc/q6voiced.conf
owner: root
group: root
mode: u+rwx
force: false
- name: "Create q6voiced-temp.service"
ansible.builtin.copy:
src: q6voiced-temp.service
dest: /etc/systemd/system/q6voiced-temp.service
owner: root
group: root
mode: u+rwx
force: true
register: unit
- name: Reload systemd units
ansible.builtin.systemd:
daemon_reload: yes
when: unit.changed
- name: "Enable custom service unit for q6voiced"
ansible.builtin.service:
enabled: true
name: "q6voiced-temp.service"

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -x
rfkill unblock bluetooth
echo $"stdin for btmgmt" | btmgmt -i hci0 public-addr $(hciconfig hci0 | grep -o $"[[:xdigit:]:]\\{11,17\\}")'
# btmgmt requires stdin, so we feed it some garbage...

View file

@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci0", RUN+="/opt/bluetooth-mac.bash"

View file

@ -0,0 +1,15 @@
[Unit]
Description=Android vendor firmware extraction
Wants=sysinit.target make-dynpart-mappings@system_a.service
After=-.mount tmp.mount boot.mount make-dynpart-mappings@system_a.service
Before=plymouth-quit.service display-manager.service
ConditionPathExists=!/var/lib/droid-juicer/status.json
[Service]
Type=oneshot
ExecStartPre=-/usr/bin/plymouth display-message --text="Extracting binary firmware..."
ExecStart=/usr/bin/droid-juicer
ExecStartPost=/usr/sbin/reboot
[Install]
WantedBy=basic.target

View file

@ -0,0 +1,12 @@
[Unit]
Description=q6voiced routes call audio between modem and audio device
After=dbus.service
[Service]
EnvironmentFile=/etc/q6voiced.conf
ExecStart=/opt/q6voiced/q6voiced hw:${q6voice_card},${q6voice_device}
User=nobody
Group=audio
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,2 @@
q6voice_card=0
q6voice_device=4

View file

@ -0,0 +1,64 @@
#!/bin/sh
set -e
PREREQS=""
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
. /usr/share/initramfs-tools/hook-functions
# Fetch the device parameters
for x in $(cat /proc/cmdline); do
case $x in
mobile.qcomsoc=*) QCOMSOC="${x#mobile.qcomsoc=}" ;;
mobile.model=*) MODEL="${x#mobile.model=}" ;;
esac
done
if [ "${QCOMSOC}" ] && [ "${MODEL}" ]; then
# Special case for the OnePlus 6 & 6T: both models use the same
# firmware folder: sdm845/oneplus6
if [ "${MODEL}" = "enchilada" ] || [ "${MODEL}" = "fajita" ]; then
MODEL="oneplus6"
fi
# Special case for the "fp4" (Fairphone 4): this model uses the
# "fairphone4" firmware folder
if [ "${MODEL}" = "fp4" ]; then
MODEL="fairphone4"
fi
# Special case for "bonito" (Pixel 3a XL): this model uses the "sargo" (Pixel 3a) firmware folders
if [ "${MODEL}" = "bonito" ]; then
MODEL="sargo"
fi
FW_LIST="${QCOMSOC}/${MODEL}/adsp.mbn \
${QCOMSOC}/${MODEL}/cdsp.mbn \
${QCOMSOC}/${MODEL}/ipa_fws.mbn"
FW_RADIO="ath10k/WCN3990/hw1.0/board-2.bin \
qca/${MODEL}/crnv21.bin \
qca/crbtfw21.tlv \
qca/crnv21.bin"
if [ "${QCOMSOC}" = "qcom/sdm845" ]; then
FW_LIST="${FW_LIST} \
${QCOMSOC}/${MODEL}/a630_zap.mbn"
elif [ "${QCOMSOC}" = "qcom/sm7225" ] || [ "${QCOMSOC}" = "qcom/sdm670" ]; then
FW_LIST="${FW_LIST} \
${QCOMSOC}/${MODEL}/a615_zap.mbn"
fi
FW_LIST="${FW_LIST} ${FW_RADIO}"
for fwfile in ${FW_LIST}; do
if [ -f "/lib/firmware/updates/${version?}/${fwfile}" ] ||
[ -f "/lib/firmware/updates/${fwfile}" ] ||
[ -f "/lib/firmware/${version}/${fwfile}" ] ||
[ -f "/lib/firmware/${fwfile}" ]; then
add_firmware "${fwfile}"
else
echo "I: Ignoring missing firmware ${fwfile}"
fi
done
fi

1
ansible/workarounds.sh Executable file
View file

@ -0,0 +1 @@
ansible-playbook --ask-become-pass --become -i 10.66.0.1, workarounds.yml

67
ansible/workarounds.yml Normal file
View file

@ -0,0 +1,67 @@
---
- hosts: 10.66.0.1,
tasks:
### Various Small Fixes ###
- name: "Copy /usr/share/initramfs-tools/hooks/qcom-firmware"
ansible.builtin.copy:
src: qcom-firmware
dest: /usr/share/initramfs-tools/hooks/qcom-firmware
owner: root
group: root
mode: u+rwx
force: true
# Has been merged, but package did not have a new release yet
# https://salsa.debian.org/DebianOnMobile-team/qcom-phone-utils/-/merge_requests/2
- name: "Copy custom droid-juicer service unit"
ansible.builtin.copy:
src: droid-juicer-sdm670.service
dest: /etc/systemd/system/droid-juicer-sdm670.service
owner: root
group: root
mode: u+rwx
force: true
register: unit
# Original unit has a hardcoded value, we'll just use our own temporarily
# https://gitlab.com/mobian1/droid-juicer/-/issues/4
- name: Reload systemd units
ansible.builtin.systemd:
daemon_reload: yes
when: unit.changed
- name: "Disable regular service unit for droid-juicer"
ansible.builtin.service:
enabled: false
masked: true
name: "droid-juicer.service"
- name: "Enable custom service unit for droid-juicer"
ansible.builtin.service:
enabled: true
name: "droid-juicer-sdm670.service"
### Bluetooth ###
- name: "Copy /opt/bluetooth-mac.bash"
ansible.builtin.copy:
src: bluetooth-mac.bash
dest: /opt/bluetooth-mac.bash
owner: root
group: root
mode: u+rwx
force: true
- name: "Copy /etc/udev/rules.d/bluetooth.rules"
ansible.builtin.copy:
src: bluetooth-udev.rules
dest: /etc/udev/rules.d/bluetooth.rules
owner: root
group: root
mode: u+rwx
force: true