Skip to content

Commit 4f605b8

Browse files
carlonlucaazubieta
authored andcommitted
Handle diversions when returned from dpk-query
The parser of the dpkg-query output should also handle diversions. When dpkg-query is run on Ubuntu, this is a possible output: diversion by libc6 from: /lib64/ld-linux-x86-64.so.2 diversion by libc6 to: /lib64/ld-linux-x86-64.so.2.usr-is-merged This commit parses the output, assumes libc6 is a dependency and adds it to the list.
1 parent 61c8ddd commit 4f605b8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

appimagebuilder/modules/generate/package_managers/apt/file_package_resolver.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# all copies or substantial portions of the Software.
1212
import logging
1313
import subprocess
14+
import re
15+
import os
1416

1517
from appimagebuilder.utils import shell
1618

@@ -38,11 +40,19 @@ def _run_dpkg_query_s(self, files):
3840
stdout_data = _proc.stdout.decode()
3941
return stdout_data
4042

43+
def _extract_package_names(self, pkg_names):
44+
match = re.match(r"diversion by (.+?) (to|from)", pkg_names)
45+
if match:
46+
extracted_names = match.group(1).strip()
47+
return extracted_names
48+
else:
49+
return pkg_names.strip()
50+
4151
def _parse_dpkg_query_s_output(self, stdout_data):
4252
results = {}
4353
for line in stdout_data.splitlines():
4454
line_parts = line.split(sep=": ", maxsplit=1)
45-
pkg_names = line_parts[0]
55+
pkg_names = self._extract_package_names(line_parts[0])
4656
file_path = line_parts[1]
4757
for pkg_name in pkg_names.split(","):
4858
pkg_name = pkg_name.strip()

0 commit comments

Comments
 (0)