diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-09-13 12:50:11 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-09-13 12:50:11 +0000 |
commit | b933ff44933ffc6d418d212aa5881476ce30cd90 (patch) | |
tree | d654a0c335c1d2875a1be5daa45c57f288be79ad /packages | |
parent | d280a89ab955b86a58854032b338535828af4522 (diff) | |
download | vyos-build-b933ff44933ffc6d418d212aa5881476ce30cd90.tar.gz vyos-build-b933ff44933ffc6d418d212aa5881476ce30cd90.zip |
T5261: Improve build for aws-gwlbtun package
Diffstat (limited to 'packages')
3 files changed, 40 insertions, 73 deletions
diff --git a/packages/aws-gateway-load-balancer-tunnel-handler/Jenkinsfile b/packages/aws-gateway-load-balancer-tunnel-handler/Jenkinsfile index e8ee142f..cbf5a407 100644 --- a/packages/aws-gateway-load-balancer-tunnel-handler/Jenkinsfile +++ b/packages/aws-gateway-load-balancer-tunnel-handler/Jenkinsfile @@ -19,14 +19,14 @@ // @Library annotation is not an import statement! @Library('vyos-build@current')_ +def timestamp = new Date().format('yyyyMMddhhmmss') +def commit_id = 'f78058a' + def pkgList = [ - [ - 'name': 'aws-gateway-load-balancer-tunnel-handler', - 'scmCommit': 'f78058a', - 'scmUrl': 'https://github.com/aws-samples/aws-gateway-load-balancer-tunnel-handler', - 'buildCmd': "cd ..; ./build.py", - 'architecture': ['amd64', 'arm64'], - ], + ['name': "aws-gwlbtun-${timestamp}-${commit_id}", + 'scmCommit': commit_id, + 'scmUrl': 'https://github.com/aws-samples/aws-gateway-load-balancer-tunnel-handler', + 'buildCmd': "../build.py --package aws-gwlbtun --version ${timestamp}-${commit_id}"], ] // Start package build using library function from https://github.com/vyos/vyos-build diff --git a/packages/aws-gateway-load-balancer-tunnel-handler/build.py b/packages/aws-gateway-load-balancer-tunnel-handler/build.py index 46778059..dd3a7b82 100755 --- a/packages/aws-gateway-load-balancer-tunnel-handler/build.py +++ b/packages/aws-gateway-load-balancer-tunnel-handler/build.py @@ -1,72 +1,45 @@ #!/usr/bin/env python3 -# -# Copyright (C) 2023 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -import os -import subprocess -import toml +from argparse import ArgumentParser +from subprocess import run -def build_package(arch, version, source_dir): - package_dir = f"aws-gwlbtun-{arch}" - deb_name = f"aws-gwlbtun_{version}_{arch}.deb" - # Navigate to the repository directory - os.chdir(source_dir) +def build_package(package_name: str, package_ver: str) -> bool: + """Build a package using commands from external file - # Build the binary - subprocess.run(["cmake", f"-DARCH={arch}"]) - subprocess.run(["make"]) + Args: + package_name (str): package name + package_ver (str): package version - # Create the Debian package directory structure - os.makedirs(f"{package_dir}/DEBIAN", exist_ok=True) - os.makedirs(f"{package_dir}/usr/bin", exist_ok=True) + Returns: + bool: build status + """ + # prepare sources + debmake_cmd = [ + 'debmake', '-e', 'support@vyos.io', '-f', 'VyOS Support', '-p', + package_name, '-u', package_ver, '-t' + ] + run(debmake_cmd) - # Move the binary to the package directory - subprocess.run(["cp", "gwlbtun", f"{package_dir}/usr/bin"]) + # build a package + run('debuild') - # Create the control file - control_file = f"""Package: aws-gwlbtun -Version: {version} -Architecture: {arch} -Maintainer: VyOS Maintainers <autobuild@vyos.net> -Description: AWS Gateway Load Balancer Tunnel Handler -""" - with open(f"{package_dir}/DEBIAN/control", "w") as f: - f.write(control_file) + return True - # Build the Debian package - subprocess.run(["dpkg-deb", "--build", package_dir]) - # Move the generated package to the original working directory with the correct name - subprocess.run(["mv", f"{package_dir}.deb", f"../{deb_name}"]) +# build a package +if __name__ == '__main__': + # prepare argument parser + arg_parser = ArgumentParser() + arg_parser.add_argument('--package', + required=True, + help='Package name to build') + arg_parser.add_argument('--version', + required=True, + help='Version for the package') + args = arg_parser.parse_args() - # Clean up - subprocess.run(["make", "clean"]) + if not build_package(args.package, args.version): + exit(1) - # Go back to the initial directory - os.chdir("..") - -def main(): - # Load configuration from TOML file - config = toml.load("build_config.toml") - version = config["version"] - architectures = config["architectures"] - source_dir = config.get("sourceDir", "aws-gateway-load-balancer-tunnel-handler") - - for arch in architectures: - build_package(arch, version, source_dir) - -if __name__ == "__main__": - main() + exit() diff --git a/packages/aws-gateway-load-balancer-tunnel-handler/build_config.toml b/packages/aws-gateway-load-balancer-tunnel-handler/build_config.toml deleted file mode 100644 index 08921d41..00000000 --- a/packages/aws-gateway-load-balancer-tunnel-handler/build_config.toml +++ /dev/null @@ -1,6 +0,0 @@ - -architectures = ["amd64", "arm64"] -packageName = "aws-gwlbtun" -scmUrl = "https://github.com/aws-samples/aws-gateway-load-balancer-tunnel-handler" -scmCommit = "f78058a" -version = "1-f78058a" |