Skip to content

Commit 033949d

Browse files
committed
Update firmware packages from bookworm-backports on Debian 12
Firmware packages in standard Debian repo are too old for recent kernels, and recent hardware in general. This affects all kernel-latest versions, but also soon-to-be-default kernel-6.12. This is at least necessary to support wifi network in NovaCustom laptops, but other modern systems need that too. Fresh template builds have firmware from bookworm-backports already selected, but do that for older versions too. Thanks @aronowski for the hint on apt properties. Fixes QubesOS/qubes-issues#9815
1 parent a415729 commit 033949d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# coding=utf-8
2+
#
3+
# The Qubes OS Project, http://www.qubes-os.org
4+
#
5+
# Copyright (C) 2025 Marek Marczykowski-Górecki
6+
# <marmarek@invisiblethingslab.com>
7+
#
8+
# This program is free software; you can redistribute it and/or
9+
# modify it under the terms of the GNU General Public License
10+
# as published by the Free Software Foundation; either version 2
11+
# of the License, or (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program; if not, write to the Free Software
20+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21+
# USA.
22+
23+
import subprocess
24+
25+
APT_CONF = "/etc/apt/apt.conf.d/01qubes-update"
26+
sources_list = "/etc/apt/sources.list"
27+
backports_line = "deb https://deb.debian.org/debian bookworm-backports main contrib non-free-firmware"
28+
prefs_path = "/etc/apt/preferences.d/firmware_backports"
29+
prefs_data = """\
30+
Package: src:firmware-nonfree
31+
Pin: release n=bookworm-backports
32+
Pin-Priority: 600
33+
"""
34+
35+
36+
def firmware_backports(os_data, log, **kwargs):
37+
"""
38+
Update firmware packages from backports repository.
39+
40+
https://github.com/QubesOS/qubes-issues/issues/9815
41+
"""
42+
if os_data.get("codename", "") == "bookworm":
43+
# do anything only if firmware package is installed already
44+
try:
45+
output = subprocess.check_output(
46+
["dpkg", "-l", "firmware-linux-nonfree"],
47+
stderr=subprocess.DEVNULL,
48+
)
49+
if b"bpo" in output:
50+
# version from backports already installed
51+
return
52+
except subprocess.CalledProcessError:
53+
return
54+
# first, add bookworm-backports if not already there:
55+
with open(sources_list) as sources:
56+
current_sources = sources.read()
57+
if "bookworm-backports" not in current_sources:
58+
with open(sources_list, "a") as sources:
59+
sources.write("\n" + backports_line + "\n")
60+
# then pin firmware packages to backports repo
61+
if not os.path.exists(prefs_path):
62+
with open(prefs_path, "w") as prefs:
63+
prefs.write(prefs_data)

0 commit comments

Comments
 (0)