From a0e0c80f11c611088f7d8fe4643e26d0ba73baab Mon Sep 17 00:00:00 2001 From: Marcus Geiger Date: Tue, 9 Feb 2016 16:47:51 +0000 Subject: [PATCH] Add --pkgarch option to build.py to specify the packaging architecture which can be different to GOARCH. Example: build for debian on raspberry pi. GOARCH will be arm but the packaging architecture on debian will be armhf (arm hard float). The --pkgarch option is passed to fpm to specify the required architecture which is reflected in the package manifest and also in the result filename. --- build.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build.py b/build.py index 8efc1e22d..53c3e84e0 100755 --- a/build.py +++ b/build.py @@ -412,7 +412,7 @@ def generate_md5_from_file(path): m.update(data) return m.hexdigest() -def build_packages(build_output, version, nightly=False, rc=None, iteration=1): +def build_packages(build_output, version, pkg_arch, nightly=False, rc=None, iteration=1): outfiles = [] tmp_build_dir = create_temp_dir() if debug: @@ -461,6 +461,9 @@ def build_packages(build_output, version, nightly=False, rc=None, iteration=1): current_location = os.path.join(current_location, name + '.tar.gz') if rc is not None: package_iteration = "0.rc{}".format(rc) + saved_a = a + if pkg_arch is not None: + a = pkg_arch if a == '386': a = 'i386' fpm_command = "fpm {} --name {} -a {} -t {} --version {} --iteration {} -C {} -p {} ".format( @@ -472,6 +475,8 @@ def build_packages(build_output, version, nightly=False, rc=None, iteration=1): package_iteration, build_root, current_location) + if pkg_arch is not None: + a = saved_a if package_type == "rpm": fpm_command += "--depends coreutils " fpm_command += "--depends lsof" @@ -506,6 +511,7 @@ def print_usage(): print("\t --goarm= \n\t\t- Build for specified ARM version (when building for ARM). Default value is: 6") print("\t --platform= \n\t\t- Build for specified platform. Acceptable values: linux, windows, darwin, or all") print("\t --version= \n\t\t- Version information to apply to build metadata. If not specified, will be pulled from repo tag.") + print("\t --pkgarch= \n\t\t- Package architecture if different from ") print("\t --commit= \n\t\t- Use specific commit for build (currently a NOOP).") print("\t --branch= \n\t\t- Build from a specific branch (currently a NOOP).") print("\t --rc= \n\t\t- Whether or not the build is a release candidate (affects version information).") @@ -532,6 +538,7 @@ def main(): commit = None target_platform = None target_arch = None + package_arch = None nightly = False race = False branch = None @@ -570,6 +577,9 @@ def main(): elif '--version' in arg: # Version to assign to this build (0.9.5, etc) version = arg.split("=")[1] + elif '--pkgarch' in arg: + # Package architecture if different from (armhf, etc) + package_arch = arg.split("=")[1] elif '--rc' in arg: # Signifies that this is a release candidate build. rc = arg.split("=")[1] @@ -703,7 +713,7 @@ def main(): if not check_path_for("fpm"): print("!! Cannot package without command 'fpm'. Stopping.") return 1 - packages = build_packages(build_output, version, nightly=nightly, rc=rc, iteration=iteration) + packages = build_packages(build_output, version, package_arch, nightly=nightly, rc=rc, iteration=iteration) # Optionally upload to S3 if upload: upload_packages(packages, bucket_name=upload_bucket, nightly=nightly)