
Partial-Bug: 2081843 Change-Id: If3c975e2fed6376b82badba99631bd851b2e86fb Signed-off-by: Scott Little <scott.little@windriver.com>
98 lines
3.0 KiB
Bash
Executable File
98 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# Copyright (c) 2022 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
set -e
|
|
source $(dirname "$0")/lib/job_utils.sh
|
|
require_job_env BUILD_HOME
|
|
|
|
require_job_env BUILD_PACKAGES
|
|
declare_job_env BUILD_PACKAGES_LIST
|
|
require_job_env BUILD_RT
|
|
require_job_env BUILD_ISO
|
|
declare_job_env BUILD_PACKAGES_PARALLEL_JOBS
|
|
declare_job_env BUILD_PACKAGES_TMPFS_PERCENTAGE
|
|
require_job_env PKG_REUSE
|
|
declare_job_env STX_SHARED_SOURCE
|
|
declare_job_env STX_SHARED_REPO
|
|
declare_job_env PATCH_BUILD
|
|
|
|
load_build_env
|
|
|
|
$BUILD_PACKAGES || bail "BUILD_PACKAGES=false, skipping build"
|
|
|
|
BUILD_PACKAGES_LIST=$(trim $(echo $BUILD_PACKAGES_LIST | sed 's/,/ /g'))
|
|
info "BUILD_PACKAGES_LIST=$BUILD_PACKAGES_LIST"
|
|
|
|
# Always build std, rt only if requested
|
|
build_types="std"
|
|
if $BUILD_RT || $BUILD_ISO; then
|
|
build_types+=",rt"
|
|
fi
|
|
|
|
declare -a parallel_args
|
|
if [[ -n "$BUILD_PACKAGES_PARALLEL_JOBS" && "$BUILD_PACKAGES_PARALLEL_JOBS" -gt 1 ]] ; then
|
|
parallel_args=("--parallel" "$BUILD_PACKAGES_PARALLEL_JOBS")
|
|
if [[ -n "$BUILD_PACKAGES_TMPFS_PERCENTAGE" && "$BUILD_PACKAGES_TMPFS_PERCENTAGE" -ge 0 && "$BUILD_PACKAGES_TMPFS_PERCENTAGE" -le 50 ]] ; then
|
|
parallel_args+=("--tmpfs_percentage" "$BUILD_PACKAGES_TMPFS_PERCENTAGE")
|
|
fi
|
|
fi
|
|
|
|
count=0
|
|
success=0
|
|
# Build all packages a few times
|
|
declare -a extra_args
|
|
while [[ $count -lt $BUILD_PACKAGES_ITERATIONS ]] ; do
|
|
extra_args=()
|
|
environment_args=()
|
|
|
|
# Either build specific or all packages
|
|
if [[ -n $BUILD_PACKAGES_LIST ]] ; then
|
|
extra_args+=("--packages" "$(echo $BUILD_PACKAGES_LIST | sed 's/ /,/g')")
|
|
else
|
|
extra_args+=("--all")
|
|
|
|
if $PKG_REUSE && [[ $count -eq 0 ]] ; then
|
|
extra_args+=("--clean")
|
|
|
|
# When building packages with "--reuse" flag, we re-use almost all packages
|
|
# except the ones in debian-mirror-tools/config/debian/common/never_reuse.lst
|
|
# the packages listed there are built, not re used.
|
|
# When building packages with "--reuse_maximum" flag, we re-use every packages
|
|
# ignoring the debian-mirror-tools/config/debian/common/never_reuse.lst
|
|
# this is useful when building a patch because we don't want to built anything
|
|
# that we didn't update in the patch.
|
|
if $PATCH_BUILD; then
|
|
extra_args+=("--reuse_maximum")
|
|
else
|
|
extra_args+=("--reuse")
|
|
fi
|
|
|
|
if [[ -n $STX_SHARED_SOURCE ]]; then
|
|
environment_args+=("STX_SHARED_SOURCE=$STX_SHARED_SOURCE")
|
|
fi
|
|
|
|
if [[ -n $STX_SHARED_REPO ]]; then
|
|
environment_args+=("STX_SHARED_REPO=$STX_SHARED_REPO")
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# buld'em
|
|
if stx_docker_cmd $DRY_RUN_ARG $VEBOSE_ARG "${environment_args[*]} build-pkgs ${parallel_args[*]} ${extra_args[*]} -b $build_types" ; then
|
|
success=1
|
|
break
|
|
else
|
|
success=0
|
|
fi
|
|
let ++count
|
|
done
|
|
if [[ $success -ne 1 ]] ; then
|
|
notice "Failed to build packages after $BUILD_PACKAGES_ITERATIONS iterations"
|
|
exit 1
|
|
fi
|