93f0b873b6
This patch improves safe_copy_dir() and related functions: * clean up & simplify implementation * path sanity checks no longer depend on $PROJECT. * safe_copy_dir(): --chown: resolve user name to UID on host * safe_copy_dir(): interpret dest_dir as in "cp" command, but src_dir as in "rsync" Story: 2010226 Task: 46386 Signed-off-by: Davlet Panech <davlet.panech@windriver.com> Change-Id: I9428d9fceb50f78840fc9fb93e8a6a132425cddc
39 lines
850 B
Bash
Executable File
39 lines
850 B
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
|
|
|
|
load_build_env
|
|
require_job_env BUILD_ISO
|
|
|
|
LAT_SUBDIR="localdisk/deploy"
|
|
|
|
#VERBOSE_ARG="--verbose"
|
|
|
|
$BUILD_ISO || bail "BUILD_ISO=false, bailing out"
|
|
|
|
declare -a chown_files
|
|
mkdir -p "${BUILD_OUTPUT_HOME}/localdisk"
|
|
|
|
src_dir="${BUILD_HOME}/${LAT_SUBDIR}"
|
|
dst_dir="${BUILD_OUTPUT_HOME}/${LAT_SUBDIR}"
|
|
if [[ -d "${src_dir}" ]] ; then
|
|
notice "archving $src_dir"
|
|
mkdir -p "$dst_dir"
|
|
safe_copy_dir $DRY_RUN_ARG $VERBOSE_ARG "${src_dir}/" "${dst_dir}/"
|
|
chown_files+=($(find "${dst_dir}" -mindepth 1 -maxdepth 1 -type f))
|
|
fi
|
|
|
|
if [[ "${#chown_files[@]}" -gt 0 ]] ; then
|
|
notice "changing file ownership to $USER"
|
|
safe_chown $DRY_RUN_ARG $VERBOSE_ARG "$USER:" "${chown_files[@]}"
|
|
fi
|
|
|
|
|