aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/builder/local_apt.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/builder/local_apt.py')
-rw-r--r--src/hydrilla/builder/local_apt.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/hydrilla/builder/local_apt.py b/src/hydrilla/builder/local_apt.py
index 4c93a4d..eee028d 100644
--- a/src/hydrilla/builder/local_apt.py
+++ b/src/hydrilla/builder/local_apt.py
@@ -35,6 +35,7 @@ CP = subprocess.CompletedProcess
from pathlib import Path, PurePosixPath
from tempfile import TemporaryDirectory, NamedTemporaryFile
from hashlib import sha256
+from urllib.parse import unquote
from contextlib import contextmanager
from typing import Optional, Iterable
@@ -296,25 +297,20 @@ def download_apt_packages(list: SourcesList, keys: [str], packages: [str],
Return value is a list of names of all downloaded files.
"""
+ install_line_regex = re.compile(r'^Inst (?P<name>\S+) \((?P<version>\S+) ')
+
with local_apt(list, keys) as apt:
if with_deps:
cp = apt.get('install', '--yes', '--just-print', *packages)
- deps_listing = re.match(
- r'''
- .*
- The\sfollowing\sNEW\spackages\swill\sbe\sinstalled:
- (.*)
- 0\supgraded,
- ''',
- cp.stdout,
- re.MULTILINE | re.DOTALL | re.VERBOSE)
+ lines = cp.stdout.split('\n')
+ matches = [install_line_regex.match(l) for l in lines]
+ packages = [f'{m.group("name")}={m.group("version")}'
+ for m in matches if m]
- if deps_listing is None:
+ if not packages:
raise AptError(_('apt_install_output_not_understood'), cp)
- packages = deps_listing.group(1).split()
-
# Download .debs to indirectly to destination_dir by first placing them
# in a temporary subdirectory.
with TemporaryDirectory(dir=destination_dir) as td:
@@ -343,7 +339,10 @@ def download_apt_packages(list: SourcesList, keys: [str], packages: [str],
.format(deb_file.name)
raise AptError(msg, cp)
- names_vers.append((match.group('name'), match.group('ver')))
+ names_vers.append((
+ unquote(match.group('name')),
+ unquote(match.group('ver'))
+ ))
downloaded.append(deb_file.name)
apt.get('source', '--download-only',