utils/generate-cyclonedx: remove "support" for bz2 and gzip compressed patches

Buildroot-local patches can only be suffixed by .patch, otherwise they
either need to be downloaded via <PKG>_PATCH or manually applied via
$(APPLY_PATCHES) in a <PKG>_{PRE,POST}_PATCH_HOOKS like in
linux/linux.mk. In the former case, they are then listed in the
show-info output with a full URL (prefixed by '<PKG>_SITE_METHOD+'). In
the latter case, they not listed as patches at the moment, just as
externalReferences.

By removing "support" for those compressed patches, we can avoid the bz2
dependency and can now use Buildroot's host-python3 package without
BR2_PACKAGE_HOST_PYTHON3_BZIP2 to run utils/generate-cyclonedx.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
Quentin Schulz
2026-04-07 19:37:07 +02:00
committed by Arnout Vandecappelle
parent 53bb7eafb2
commit 0b70e16d5a

View File

@@ -9,8 +9,6 @@
import argparse
import bz2
import gzip
import json
import os
from pathlib import Path
@@ -179,7 +177,7 @@ def patch_retrieve_header(content: str) -> str:
def read_patch_file(patch_path: Path) -> str:
"""Read the content of a patch file, handling compression.
"""Read the content of a patch file.
Args:
patch_path (Path): Patch path.
@@ -187,16 +185,8 @@ def read_patch_file(patch_path: Path) -> str:
Returns:
str: Patch content.
"""
if patch_path.suffix == ".gz":
f = gzip.open(patch_path, mode="rt")
elif patch_path.suffix == ".bz":
f = bz2.open(patch_path, mode="rt")
else:
f = open(patch_path)
content = f.read()
f.close()
return content
with open(patch_path) as f:
return f.read()
def cyclonedx_patches(patch_list: list[str]):