Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pydpkg/dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def _extract_message(self, ctar: tarfile.TarFile) -> Message[str, str]:
self._log.debug("got control message: %s", message)
return message

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

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

if b"control.tar" in dpkg_archive.archived_files:
control_archive = dpkg_archive.archived_files[b"control.tar"]
return control_archive, "none"

raise DpkgMissingControlGzipFile("Corrupt dpkg file: no control.tar.gz/xz/zst file in ar archive.")

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

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

if control_archive_type == "none":
return self._extract_message_from_tar(control_archive, "none")

raise DpkgError(f"Unknown control archive type: {control_archive_type}")

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