From e8705a61dfe56798f03b67dc42d141844438f94a Mon Sep 17 00:00:00 2001 From: Viacheslav Date: Wed, 13 Aug 2025 12:44:17 +0000 Subject: T7714: Exclude auxiliary directories from linux-kernel tarballs Exclude auxiliary directories from linux-kernel and related to linux-kernel tarballs --- scripts/package-build/linux-kernel/build.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'scripts/package-build/linux-kernel') diff --git a/scripts/package-build/linux-kernel/build.py b/scripts/package-build/linux-kernel/build.py index a6323357..1d69b150 100755 --- a/scripts/package-build/linux-kernel/build.py +++ b/scripts/package-build/linux-kernel/build.py @@ -95,11 +95,21 @@ def create_tarball(package_name, source_dir=None): if not os.path.isdir(source_dir): raise FileNotFoundError(f"Directory '{source_dir}' does not exist.") + base_dir = os.path.dirname(source_dir) or '.' + dir_name = os.path.basename(source_dir) + # Create the tarball try: - shutil.make_archive(base_name=output_tarball.replace('.tar.gz', ''), format='gztar', root_dir=source_dir) + subprocess.run([ + 'tar', + f'--exclude={dir_name}/.git', + f'--exclude={dir_name}/.github', + '-czf', output_tarball, + '-C', base_dir, + dir_name + ], check=True) print(f"I: Tarball created: {output_tarball}") - except Exception as e: + except subprocess.CalledProcessError as e: print(f"I: Failed to create tarball for {package_name}: {e}") -- cgit v1.2.3