New build parameter EXTRA_EXPORT_FILES.

This new parameter allows us to specify additional filename patterns to
be copied to the publication directory, alongside with "outputs/",
"logs/" etc.

Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
Change-Id: Idb56b471e9f0f79b03c7c7bd55ccc8264b290467
This commit is contained in:
Davlet Panech 2022-10-14 11:35:08 -04:00
parent d7a3994d2a
commit d33381b26d
2 changed files with 50 additions and 3 deletions

View File

@ -17,7 +17,7 @@ WORKSPACE_EXPORT_DIR="$WORKSPACE_ROOT/export"
# create the export dir
if ! $DRY_RUN && [[ -d "$WORKSPACE_EXPORT_DIR" ]] ; then
rm -rfv --one-file-system "$WORKSPACE_EXPORT_DIR"
rm -rf --one-file-system "$WORKSPACE_EXPORT_DIR"
fi
mkdir -p "$WORKSPACE_EXPORT_DIR"
@ -34,7 +34,42 @@ if [[ -n "$EXTRA_EXPORT_DIR_CMD" ]] ; then
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"
ls -alR "$WORKSPACE_EXPORT_DIR"
find "$WORKSPACE_EXPORT_DIR" -printf '%P\n'

View File

@ -46,8 +46,20 @@ SIGNING_USER="some_user_id"
# Current directory will be set to $MY_WORKSPACE/export.
# This command must leave any additional files to be published in that
# directory.
#
# $MY_WORKSPACE/export will be copied to the publish area at the end.
EXTRA_EXPORT_DIR_CMD=
# Copy these additional files to $MY_WORKSPACE/export. This must be a
# whitespace or comma-separated list of glob patterns. Relative path names
# will be interpreted relative to the build output directory (ie
# BUILD_OUTPUT_ROOT/TIMESTAMP). Source repo root can be accessed as
# "root/cgcs-root/...". Patterns that begin with "-" refer to optional
# files that won't cause errors when they don't exist.
#
# $MY_WORKSPACE/export will be copied to the publish area at the end.
EXTRA_EXPORT_FILES=
##################################################
# Build outputs
##################################################