cleanup Ansible tasks, drop permissions for cloning the repos, use systemd override instead of 2nd unit for droid-juicer

This commit is contained in:
erebion 2024-08-23 01:05:21 +02:00
parent 0e028947ea
commit 81df5538c3
4 changed files with 66 additions and 43 deletions

View file

@ -5,7 +5,7 @@
### ALSA Config ###
- name: "Remove previously downloaded versions of alsa ucm configs"
- name: "Remove previously downloaded version of alsa ucm configs"
ansible.builtin.file:
path: "/root/alsa-ucm-conf-master.tar.gz"
state: absent
@ -16,6 +16,7 @@
dest: /root/alsa-ucm-conf-master.tar.gz
force: true # overwrite if the already have a previous version
mode: '0440'
delay: 2
retries: 20
- name: "Remove alsa ucm configs"
@ -62,7 +63,7 @@
- libdbus-cpp-dev
- make
- devscripts
- doxygen
- doxygen
state: present
update_cache: true
@ -81,6 +82,8 @@
repo: 'https://salsa.debian.org/erebion/tinyalsa.git'
dest: /opt/repos/tinyalsa
version: mobian-git20240621
become_user: nobody
delay: 2
retries: 20
- name: "Clone q6voiced repo"
@ -88,6 +91,8 @@
repo: 'https://salsa.debian.org/erebion/q6voiced.git'
dest: /opt/repos/q6voiced
version: mobian-git20240607
become_user: nobody
delay: 2
retries: 20
- name: "chown repo directories to nobody:nogroup"
@ -97,19 +102,26 @@
owner: nobody
group: nogroup
- name: "Build Debian packages for tinyalsa and q6voiced"
- name: "Build Debian packages for tinyalsa"
ansible.builtin.shell:
cmd: debuild -i -us -uc -b
chdir: "{{ item }}"
chdir: "/opt/repos/tinyalsa/"
become_user: nobody
loop:
- "/opt/repos/tinyalsa/"
- "/opt/repos/q6voiced/"
- name: "Install tinyalsa and q6voiced"
- name: "Install tinyalsa"
ansible.builtin.apt:
deb: "/opt/repos/{{ item }}"
loop:
- "libtinyalsa_2.0.0+git20240621-7f06b2f-2_arm64.deb"
- "tinyalsa_2.0.0+git20240621-7f06b2f-2_arm64.deb"
- "q6voiced_0~0+git20240607-75ae4079-1_arm64.deb"
- "libtinyalsa-dev_2.0.0+git20240621-7f06b2f-3_arm64.deb"
- "libtinyalsa_2.0.0+git20240621-7f06b2f-3_arm64.deb"
- "tinyalsa_2.0.0+git20240621-7f06b2f-3_arm64.deb"
- name: "Build Debian package for q6voiced"
ansible.builtin.shell:
cmd: debuild -i -us -uc -b
chdir: "/opt/repos/q6voiced/"
become_user: nobody
- name: "Install tinyalsa and q6voiced"
ansible.builtin.apt:
deb: "/opt/repos/q6voiced_0~0+git20240607-75ae4079-1_arm64.deb"

View file

@ -1,15 +0,0 @@
[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,4 @@
[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

View file

@ -4,6 +4,26 @@
tasks:
### Remove remnants of previous versions of this playbook ###
- name: "Remove remnants from previous versions of this playbook"
ansible.builtin.service:
enabled: false
masked: true
name: "droid-juicer-sdm670.service"
ignore_errors: true # do not fail if the unit does not exist
register: temp_droid_juicer_unit
- name: "Remove remnants of previous versions of this playbook"
ansible.builtin.file:
path: "/etc/systemd/system/droid-juicer-sdm670.service"
state: absent
- name: Reload systemd units
ansible.builtin.systemd:
daemon_reload: yes
when: temp_droid_juicer_unit.changed
### Various Small Fixes ###
- name: "Copy /usr/share/initramfs-tools/hooks/qcom-firmware"
@ -18,33 +38,35 @@
# 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"
- name: "Create directory for a unit override for droid-juicer.service"
ansible.builtin.file:
path: "/etc/systemd/system/droid-juicer.service.d/"
state: directory
mode: '0644'
- name: "Copy override.conf for droid-juicer.service"
ansible.builtin.copy:
src: droid-juicer-sdm670.service
dest: /etc/systemd/system/droid-juicer-sdm670.service
src: override.conf
dest: /etc/systemd/system/droid-juicer.service.d/override.conf
owner: root
group: root
mode: u+rwx
mode: u+rw
force: true
register: unit
# Original unit has a hardcoded value, we'll just use our own temporarily
register: droid_juicer_unit_override
# Original unit has a hardcoded value, we'll just an override temporarily
# https://gitlab.com/mobian1/droid-juicer/-/issues/4
- name: Reload systemd units
- name: "Reload systemd units"
ansible.builtin.systemd:
daemon_reload: yes
when: unit.changed
when: droid_juicer_unit_override.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:
- name: "Restart droid-juicer.service after adding the override"
ansible.builtin.systemd:
enabled: true
name: "droid-juicer-sdm670.service"
state: restarted
name: "droid-juicer.service"
when: droid_juicer_unit_override.changed
### Bluetooth ###