|
| 1 | +# |
| 2 | +# The Qubes OS Project, https://www.qubes-os.org/ |
| 3 | +# |
| 4 | +# Copyright (C) 2025 Marek Marczykowski-Górecki |
| 5 | + |
| 6 | +# |
| 7 | +# This library is free software; you can redistribute it and/or |
| 8 | +# modify it under the terms of the GNU General Public |
| 9 | +# License as published by the Free Software Foundation; either |
| 10 | +# version 2 of the License, or (at your option) any later version. |
| 11 | +# |
| 12 | +# This library is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +# Lesser General Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU General Public |
| 18 | +# License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +import subprocess |
| 21 | + |
| 22 | +def pipewire_archlinux(os_data, log, **kwargs): |
| 23 | + """Help with unattended switch from pulseaudio to pipewire-pulse""" |
| 24 | + # pacman proposes to remove pulseaudio when installing pipewire-pulse, |
| 25 | + # but the default answer is "n", so the update with --noconfirm fails |
| 26 | + # workaround it by removing pulseaudio before the update |
| 27 | + if os_data["os_family"] != 'ArchLinux': |
| 28 | + return |
| 29 | + # check if pulseaudio is installed |
| 30 | + p = subprocess.call(["pacman", "-Q", "pulseaudio"], |
| 31 | + stderr=subprocess.DEVNULL, |
| 32 | + stdout=subprocess.DEVNULL, |
| 33 | + ) |
| 34 | + if p != 0: |
| 35 | + return |
| 36 | + # ... and whether pipewire-pulse is going to be installed in the update |
| 37 | + # this will refresh metadata already, before starting progress reporting, |
| 38 | + # but well... |
| 39 | + update_list = subprocess.check_output(["pacman", "-Syup"], |
| 40 | + stderr=subprocess.DEVNULL).decode() |
| 41 | + if not any("/pipewire-pulse-" in line for line in update_list.splitlines()): |
| 42 | + return |
| 43 | + # ... then remove pulseaudio beforehand (temporarily breaking the |
| 44 | + # dependencies) |
| 45 | + log.info("Removing pulseaudio to allow update cleanly migrate to " |
| 46 | + "pipewire-pulse") |
| 47 | + subprocess.check_call(["pacman", "-Rdd", "--noconfirm", "pulseaudio"]) |
0 commit comments