Skip to content

Commit 009d2e4

Browse files
committed
updater: add flags to apt conf to auto-resolve conffiles conflicts
fixes QubesOS/qubes-issues/issues/9072
1 parent 528a5d0 commit 009d2e4

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

vmupdate/agent/entrypoint.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def get_package_manager(os_data, log, log_handler, log_level, no_progress):
5656
If appropriate python package is not installed or `no_progress` is `True`
5757
cli based version is returned.
5858
"""
59+
requirements = {}
60+
# plugins MUST be applied before import anything from package managers.
61+
# in case of apt configuration is loaded on `import apt`.
62+
for plugin in plugins.entrypoints:
63+
plugin(os_data, log, requirements=requirements)
64+
5965
if os_data["os_family"] == "Debian":
6066
try:
6167
from source.apt.apt_api import APT as PackageManager
@@ -82,10 +88,6 @@ def get_package_manager(os_data, log, log_handler, log_level, no_progress):
8288
raise NotImplementedError(
8389
"Only Debian, RedHat and ArchLinux based OS is supported.")
8490

85-
requirements = {}
86-
for plugin in plugins.entrypoints:
87-
plugin(os_data, log, requirements=requirements)
88-
8991
pkg_mng = PackageManager(log_handler, log_level)
9092
pkg_mng.requirements = requirements
9193
return pkg_mng
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# coding=utf-8
2+
#
3+
# The Qubes OS Project, http://www.qubes-os.org
4+
#
5+
# Copyright (C) 2024 Piotr Bartman <[email protected]>
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License
9+
# as published by the Free Software Foundation; either version 2
10+
# of the License, or (at your option) any later version.
11+
#
12+
# This program 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
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20+
# USA.
21+
22+
APT_CONF = "/etc/apt/apt.conf.d/01qubes-update"
23+
24+
25+
def apt_keep_old_conffiles(os_data, log, **kwargs):
26+
"""
27+
Always chose default behavior for when conflicts in apt conffiles appears.
28+
"""
29+
if os_data["os_family"] != "Debian":
30+
return
31+
32+
option = '''Dpkg::Options {
33+
"--force-confdef";
34+
"--force-confold";
35+
}'''
36+
with open(APT_CONF, "w") as file:
37+
file.write(f'\n{option}\n')

0 commit comments

Comments
 (0)