Skip to content

Commit

Permalink
Improve handling of NSIS archives in debloat (#55)
Browse files Browse the repository at this point in the history
* Improve handling of NSIS archives in debloat
  • Loading branch information
nazywam authored Feb 6, 2024
1 parent a6ed9db commit a67bc4b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions karton/archive_extractor/archive_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ def log_message_wrapped(message: str, *args, **kwargs) -> None:

# debloat can sometimes unpack NSIS installer archives but we're interested
# only in the installer script
for f_name in (filename, "Setup.NSIS"):
unpacked_file = Path(tmp_dir) / f_name

if unpacked_file.exists() and unpacked_file.stat().st_size:
return (f_name, unpacked_file.read_bytes())
for unpacked_file in Path(tmp_dir).rglob("*"):
if unpacked_file.is_dir():
continue

if (
unpacked_file.name == filename
or unpacked_file.name.lower() == "setup.nsis"
):
return (unpacked_file.name, unpacked_file.read_bytes())

self.log.warning("Output file is empty - failed to debloat file")
return None
Expand Down

0 comments on commit a67bc4b

Please sign in to comment.