From 0b70e16d5a7fbcca61553c1b504da3d6f6de4307 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Tue, 7 Apr 2026 19:37:07 +0200 Subject: [PATCH] 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 _PATCH or manually applied via $(APPLY_PATCHES) in a _{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 '_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 Signed-off-by: Arnout Vandecappelle --- utils/generate-cyclonedx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/utils/generate-cyclonedx b/utils/generate-cyclonedx index 4166abd9ff..611a20127d 100755 --- a/utils/generate-cyclonedx +++ b/utils/generate-cyclonedx @@ -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]):