summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKyrylo Yatsenko <hedrok@gmail.com>2026-04-29 22:40:53 +0300
committerKyrylo Yatsenko <hedrok@gmail.com>2026-06-18 22:49:58 +0300
commit3e3a8e0611f35dd905f92afc13b19933d8b8ac48 (patch)
treeddcb5d6a43d541a10e4ae4f5c6c84d0f3f2ef31e /scripts
parentbd827e7b8d12c82ed6a9455c22d8f9cc0c280f33 (diff)
downloadvyos-build-3e3a8e0611f35dd905f92afc13b19933d8b8ac48.tar.gz
vyos-build-3e3a8e0611f35dd905f92afc13b19933d8b8ac48.zip
T8599: Make source packages required and fix them
A lot of packages failed to build source package. Stop ignoring source package build errors and fix it. To fix source packages: * Use <source_package>_<upstream_version>.orig.tar.gz naming for source archive. * Get `source_package` and `upstream_version` from changelog using dpkg-parsechangelog utility * Clean build-deps after usage or dpkg-source sees these files as changes relative to upstream. * Add '.github' to --diff-ignore source option
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/package-build/build.py38
1 files changed, 28 insertions, 10 deletions
diff --git a/scripts/package-build/build.py b/scripts/package-build/build.py
index 9f3233f9..535a3d45 100755
--- a/scripts/package-build/build.py
+++ b/scripts/package-build/build.py
@@ -136,9 +136,26 @@ def build_package(package: list, patch_dir: Path) -> None:
if (repo_dir / 'patches'):
apply_patches(repo_dir, patch_dir / repo_name)
- # Sanitize the commit ID and build a tarball for the package
- commit_id_sanitized = package['commit_id'].replace('/', '_')
- tarball_name = f"{repo_name}_{commit_id_sanitized}.tar.gz"
+ # Create original tarball for dpkg-source to be happy
+ package_version = run(['dpkg-parsechangelog', '--show-field', 'Version', '--file', repo_dir / 'debian/changelog'], capture_output=True, check=False)
+ if package_version.stdout:
+ package_version = package_version.stdout.decode().strip()
+ package_version = package_version.rsplit('-', maxsplit=1)[0]
+ if ':' in package_version:
+ package_version = package_version.split(':', maxsplit=1)[1]
+ else:
+ # On failure fallback to sanitized commit ID
+ package_version = package['commit_id'].replace('/', '_')
+
+ package_name = run(['dpkg-parsechangelog', '--show-field', 'Source', '--file', repo_dir / 'debian/changelog'], capture_output=True, check=False)
+ if package_name.stdout:
+ package_name = package_name.stdout.decode().strip()
+ else:
+ # On failure fallback to repo name
+ package_name = repo_name
+
+ # Build a tarball for the package
+ tarball_name = f'{package_name}_{package_version}.orig.tar.gz'
run(['tar', '--exclude=.git', '--exclude=.github', '-czf', tarball_name, '-C', str(repo_dir.parent), repo_name], check=True)
print(f"I: Tarball created: {tarball_name}")
@@ -151,18 +168,18 @@ def build_package(package: list, patch_dir: Path) -> None:
try:
run('sudo mk-build-deps --install --tool "apt-get --yes --no-install-recommends"', cwd=repo_dir, check=True, shell=True)
run('sudo dpkg -i *build-deps*.deb', cwd=repo_dir, check=True, shell=True)
+ # Clean up or dpkg-source will see this as changes to binary files
+ cleanup_build_deps(repo_dir)
except CalledProcessError as e:
print(f"Failed to build package {repo_name}: {e}")
# Build the package, check if we have build_cmd in the package.toml
try:
- build_cmd = package.get('build_cmd', 'dpkg-buildpackage -uc -us -tc -F --source-option=--tar-ignore=.git --source-option=--tar-ignore=.github')
+ build_cmd = package.get('build_cmd', r'dpkg-buildpackage -uc -us -tc -F --source-option=--tar-ignore=.git --source-option=--tar-ignore=.github --source-option=--extend-diff-ignore="^\.github(?:/.*)?$"')
run(build_cmd, cwd=repo_dir, check=True, shell=True)
except CalledProcessError as e:
- print(e)
- print("I: Source packages build failed, ignoring - building binaries only")
- build_cmd = package.get('build_cmd', 'dpkg-buildpackage -uc -us -tc -b')
- run(build_cmd, cwd=repo_dir, check=True, shell=True)
+ print(f"E: Package build failed for package '{repo_name}': {e}")
+ sys.exit(1)
except CalledProcessError as e:
print(f"Failed to build package {repo_name}: {e}")
@@ -176,8 +193,9 @@ def cleanup_build_deps(repo_dir: Path) -> None:
"""Clean up build dependency packages"""
try:
if repo_dir.exists():
- for file in glob.glob(str(repo_dir / '*build-deps*.deb')):
- os.remove(file)
+ for suffix in ('deb', 'buildinfo', 'changes'):
+ for file in glob.glob(str(repo_dir / f'*build-deps*.{suffix}')):
+ os.remove(file)
print("I: Cleaned up build dependency packages")
except Exception as e:
print(f"Error cleaning up build dependencies: {e}")