TT#65907 Remove unnecessary subshell calls in helper build_config

It gives ~0.5 second better 'ngcpcfg apply' time.

Change-Id: Ib8d331b9b057708cc34106b82e05128a8019a44e
changes/94/33694/4
Alexander Lutay 7 years ago
parent f4e5c0b645
commit 250cb64e45

@ -46,6 +46,7 @@ if [ -n "${OUTPUT_DIRECTORY:-}" ] ; then
else
export output_file
fi
output_file_dirname="$(dirname "${output_file}")" # like /etc/mysql
# ensure we don't try to generate a file where a directory with same name exists already
if [ -d "${output_file}" ] ; then
@ -57,15 +58,15 @@ fi
if [ -r "${NGCPCTL_MAIN}/templates/${output_file}.prebuild" ] ; then
log_info "Executing prebuild for ${output_file}"
bash "${NGCPCTL_MAIN}/templates/${output_file}.prebuild"
elif [ -r "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.prebuild" ] ; then
elif [ -r "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.prebuild" ] ; then
log_info "Executing prebuild for ${output_file}"
bash "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.prebuild"
bash "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.prebuild"
fi
# if output directory does not exist yet, create it
if ! [ -d "$(dirname "${output_file}")" ] ; then
if ! [ -d "${output_file_dirname}" ] ; then
umask 0022 # directory permissions should be '755'
mkdir -p "$(dirname "${output_file}")"
mkdir -p "${output_file_dirname}"
fi
# assume safe defaults
@ -144,9 +145,9 @@ fi
if [ -r "${NGCPCTL_MAIN}/templates/${output_file}.postbuild" ] ; then
log_info "Executing postbuild for ${output_file}"
bash "${NGCPCTL_MAIN}/templates/${output_file}.postbuild"
elif [ -r "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.postbuild" ] ; then
elif [ -r "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.postbuild" ] ; then
log_info "Executing postbuild for ${output_file}"
bash "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.postbuild"
bash "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.postbuild"
fi
exit $RC

Loading…
Cancel
Save