#!/bin/bash # # Copyright (c) 2022 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # set -e source $(dirname "$0")/lib/job_utils.sh load_build_env declare_job_env EXTRA_EXPORT_DIR_CMD WORKSPACE_EXPORT_DIR="$WORKSPACE_ROOT/export" # create the export dir if ! $DRY_RUN && [[ -d "$WORKSPACE_EXPORT_DIR" ]] ; then rm -rf --one-file-system "$WORKSPACE_EXPORT_DIR" fi mkdir -p "$WORKSPACE_EXPORT_DIR" # if a custom export command is given, run it if [[ -n "$EXTRA_EXPORT_DIR_CMD" ]] ; then cmd="\ cd \$MY_WORKSPACE/export && { $EXTRA_EXPORT_DIR_CMD } " stx_docker_cmd $DRY_RUN_ARG "$cmd" fi # Copy EXTRA_EXPORT_FILES if [[ -n "$EXTRA_EXPORT_FILES" ]] ; then ( cd "$BUILD_OUTPUT_HOME" pattern_list_str="$(echo "$EXTRA_EXPORT_FILES" | sed 's/,/ /g')" # split patterns by whitespace, but leave glob metachars set -o noglob pattern_list=($pattern_list_str) set +o noglob # save files matching each pattern in "flist" array declare -a flist for pattern in "${pattern_list[@]}" ; do # patterns that begin with "-" are optional, ignore files # that do not exist if [[ "$pattern" =~ ^- ]] ; then pattern="${pattern#-}" for f in $pattern ; do if [[ -e "$f" ]] ; then flist+=("$f") fi done continue fi # patterns that do not start with "-" are required flist+=($pattern) done # copy them if [[ "${#flist}" -gt 0 ]] ; then info "copying to export dir: ${flist[*]}" cp -ar -t "${WORKSPACE_EXPORT_DIR}" "${flist[@]}" fi ) fi # print it notice "export dir content follows" find "$WORKSPACE_EXPORT_DIR" -printf '%P\n'