Skip to content

Commit f3786d8

Browse files
committed
fix: support uncompressed control.tar archives
1 parent f534a09 commit f3786d8

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pydpkg/dpkg.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def _extract_message(self, ctar: tarfile.TarFile) -> Message[str, str]:
271271
self._log.debug("got control message: %s", message)
272272
return message
273273

274-
def _read_archive(self, dpkg_archive: Archive) -> tuple[ArchiveFileData, Literal["gz", "xz", "zst"]]:
274+
def _read_archive(self, dpkg_archive: Archive) -> tuple[ArchiveFileData, Literal["gz", "xz", "zst", "none"]]:
275275
"""Search an opened archive for a compressed control file and return it plus the compression"""
276276
dpkg_archive.read_all_headers()
277277

@@ -287,6 +287,10 @@ def _read_archive(self, dpkg_archive: Archive) -> tuple[ArchiveFileData, Literal
287287
control_archive = dpkg_archive.archived_files[b"control.tar.zst"]
288288
return control_archive, "zst"
289289

290+
if b"control.tar" in dpkg_archive.archived_files:
291+
control_archive = dpkg_archive.archived_files[b"control.tar"]
292+
return control_archive, "none"
293+
290294
raise DpkgMissingControlGzipFile("Corrupt dpkg file: no control.tar.gz/xz/zst file in ar archive.")
291295

292296
def _extract_message_from_tar(self, fd: SupportsRead[bytes], archive_name: str = "undefined") -> Message[str, str]:
@@ -298,7 +302,7 @@ def _extract_message_from_tar(self, fd: SupportsRead[bytes], archive_name: str =
298302
return message
299303

300304
def _extract_message_from_archive(
301-
self, control_archive: IO[bytes], control_archive_type: Literal["gz", "xz", "zst"]
305+
self, control_archive: IO[bytes], control_archive_type: Literal["gz", "xz", "zst", "none"]
302306
) -> Message[str, str]:
303307
"""Extract the control file from a compressed archive fileobj"""
304308
if control_archive_type == "gz":
@@ -314,6 +318,9 @@ def _extract_message_from_archive(
314318
with zst.stream_reader(control_archive) as reader:
315319
return self._extract_message_from_tar(reader, "zst")
316320

321+
if control_archive_type == "none":
322+
return self._extract_message_from_tar(control_archive, "none")
323+
317324
raise DpkgError(f"Unknown control archive type: {control_archive_type}")
318325

319326
def _process_dpkg_file(self, filename: str) -> Message[str, str]:

0 commit comments

Comments
 (0)