diff options
author | zsdc <taras@vyos.io> | 2023-09-28 14:58:47 +0300 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-09-28 21:03:36 +0200 |
commit | 4b12762864fb6f4ba06dd8c62d633ab9352c075c (patch) | |
tree | 1dcc7d0c90c58692f426da85e42016c5005f5e9c /packages/pmacct/build.py | |
parent | d40bba0e8a585a6dd0e2ef352f37ab8da79cf2c7 (diff) | |
download | vyos-build-4b12762864fb6f4ba06dd8c62d633ab9352c075c.tar.gz vyos-build-4b12762864fb6f4ba06dd8c62d633ab9352c075c.zip |
pmacct: T5618: Added build rules for custom pmacct package
The current version of pmacct in Debian (`1.7.7-1`) contains the bug which leads
to a crash when IMT is enabled and ICMP traffic is forwarded through a router.
This commit adds our build with an extra patch, which solves the problem:
https://github.com/pmacct/pmacct/commit/73af9545ea33cd87846306f648f634063ac41765
(cherry picked from commit d5f6445381c44a99459f45e74b792e250d727f44)
Diffstat (limited to 'packages/pmacct/build.py')
-rwxr-xr-x | packages/pmacct/build.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/pmacct/build.py b/packages/pmacct/build.py new file mode 100755 index 00000000..2445eb12 --- /dev/null +++ b/packages/pmacct/build.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +from pathlib import Path +from shutil import copy as copy_file +from subprocess import run + + +# copy patches +def apply_deb_patches() -> None: + """Apply patches to sources directory + """ + patches_dir = Path('../patches') + current_dir: str = Path.cwd().as_posix() + if patches_dir.exists(): + patches_list = list(patches_dir.iterdir()) + patches_list.sort() + series_file = Path(f'{current_dir}/debian/patches/series') + series_data = '' + for patch_file in patches_list: + print(f'Applying patch: {patch_file.name}') + copy_file(patch_file, f'{current_dir}/debian/patches/') + if series_file.exists(): + series_data: str = series_file.read_text() + series_data = f'{series_data}\n{patch_file.name}' + series_file.write_text(series_data) + + +def build_package() -> bool: + """Build a package + + Returns: + bool: build status + """ + build_cmd: list[str] = ['dpkg-buildpackage', '-uc', '-us', '-tc', '-b'] + build_status: int = run(build_cmd).returncode + + if not build_status: + return False + return True + + +# build a package +if __name__ == '__main__': + apply_deb_patches() + + if not build_package(): + exit(1) + + exit() |