Skip to content

Non-interactive install options: -y/--yes-to-all #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ script:
ln -fs "$(which gcc-5)" "$HOME/bin/gcc"
ln -fs "$(which g++-5)" "$HOME/bin/g++"
export PATH="$PATH:$HOME/bin"
yes | ./install.sh -i "$HOME/opt/opencoarrays" -j 4 -f "$HOME/bin/gfortran" -c "$HOME/bin/gcc" -C "$HOME/bin/g++"
./install.sh --yes-to-all -i "$HOME/opt/opencoarrays" -j 4 -f "$HOME/bin/gfortran" -c "$HOME/bin/gcc" -C "$HOME/bin/g++"
else
mkdir cmake-build
cd cmake-build
Expand Down
7 changes: 4 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ info "-P (--print-path): ${arg_P}"
info "-U (--print-url): ${arg_U}"
info "-v (--version): ${arg_v}"
info "-V (--print-version): ${arg_V}"
info "-y (--yes-to-all): ${arg_y}"
}
# This file is organized into three sections:
# 1. Command-line argument and environment variable processing.
Expand Down Expand Up @@ -239,7 +240,7 @@ source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh
if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then

# Print script copyright if invoked with -v, -V, or --version argument
cmake_project_line=$(grep project ${opencoarrays_src_dir}/CMakeLists.txt | grep VERSION)
cmake_project_line="$(grep project "${opencoarrays_src_dir}/CMakeLists.txt" | grep VERSION)"
text_after_version_keyword="${cmake_project_line##*VERSION}"
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
opencoarrays_version=$text_before_language_keyword
Expand Down Expand Up @@ -309,8 +310,8 @@ elif [[ "${arg_p:-}" == "ofp" ]]; then
elif [[ ! -z "${arg_p:-}" ]]; then

info "Invoking build script with the following command:"
info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${@:-}"
"${opencoarrays_src_dir}"/prerequisites/build.sh ${@:-}
info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${*:-}"
"${opencoarrays_src_dir}"/prerequisites/build.sh "${@:-}"

fi
# ____________________________________ End of Main Body ____________________________________________
1 change: 1 addition & 0 deletions install.sh-usage
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
-U --print-url [arg] Print download location for specified package.
-v --version Print OpenCoarrays version number.
-V --print-version [arg] Print version number for specified package.
-y --yes-to-all Build non-interactively by assuming affirmative user responses.
26 changes: 16 additions & 10 deletions prerequisites/build-functions/download_if_necessary.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash disable=SC2148
# shellcheck source=./ftp-url.sh
source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp-url.sh"
# shellcheck source=./set_SUDO_if_needed_to_write_to_directory.sh
Expand All @@ -12,14 +13,18 @@ download_if_necessary()
if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail}" ]] ; then
info "Found '${url_tail}' in ${download_path}."
info "If it resulted from an incomplete download, building ${package_name} could fail."
info "Would you like to proceed anyway? (Y/n)"
read -r proceed
if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
info "n"
info "Please remove $url_tail and restart the installation to to ensure a fresh download." 1>&2
emergency "Aborting. [exit 80]"
if [[ "${arg_y}" == "${__flag_present}" ]]; then
info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
else
info "y"
info "Would you like to proceed anyway? (Y/n)"
read -r proceed
if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
info "n"
info "Please remove $url_tail and restart the installation to to ensure a fresh download." 1>&2
emergency "Aborting. [exit 80]"
else
info "y"
fi
fi
elif ! type "${fetch}" &> /dev/null; then
# The download mechanism is missing
Expand All @@ -45,9 +50,9 @@ download_if_necessary()
args="clone"
elif [[ "${fetch}" == "curl" ]]; then
first_three_characters=$(echo "${package_url}" | cut -c1-3)
if [[ "${first_three_characters}" == "ftp" ]]; then
if [[ "${first_three_characters}" == "ftp" ]]; then
args="-LO -u anonymous:"
elif [[ "${first_three_characters}" == "htt" ]]; then
elif [[ "${first_three_characters}" == "htt" ]]; then
args="-LO"
else
emergency "download_if_necessary.sh: Unrecognized URL."
Expand All @@ -64,7 +69,8 @@ download_if_necessary()
info "Download command: \"${fetch}\" ${args:-} ${package_url}"
info "Depending on the file size and network bandwidth, this could take several minutes or longer."
pushd "${download_path}"
"${fetch}" ${args:-} ${package_url}
# args should be an array. Then "${args[@]:-}" will prevent shellcheck from complaining
"${fetch}" ${args:-} "${package_url}"
popd
if [[ ! -z "${arg_B:-}" ]]; then
return
Expand Down
7 changes: 4 additions & 3 deletions prerequisites/build-functions/set_or_print_default_version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash disable=SC2148
# If -p, -D, -P, or -U specifies a package, set default_version
# If -V specifies a package, print the default_version and exit with normal status
# If -l is present, list all packages and versions and exit with normal status
Expand All @@ -15,11 +16,11 @@ set_or_print_default_version()
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" # not needed for -l

if [[ "${package_name}" == "ofp" ]]; then
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
"${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
exit 0
fi
fi

[ "${package_name}" == "opencoarrays" ] &&
[ "${package_name}" == "opencoarrays" ] &&
emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays "
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
Expand Down
25 changes: 13 additions & 12 deletions prerequisites/build-functions/set_or_print_downloader.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash disable=SC2148
# If -p, -P, -U, or -V specifies a package, set fetch variable
# If -D specifies a package, print "${fetch}" and exit with normal status
# If -l is present, list all packages and versions and exit with normal status
Expand All @@ -11,20 +12,20 @@ set_or_print_downloader()
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}"

if [[ "${package_name}" == "ofp" ]]; then
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
"${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
exit 0
fi
fi

# Choose the first available download mechanism, prioritizing first any absolute requirement
# Choose the first available download mechanism, prioritizing first any absolute requirement
# (svn for gcc development branches) and second robustness:
info "Checking available download mechanisms: ftp, wget, and curl."
info "\${package_name}=${package_name} \${arg_b:-\${arg_B:-}}=${arg_b:-${arg_B:-}}"

if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then

if type svn &> /dev/null; then
fetch=svn
else
fetch=svn
else
tried="svn"
fi

Expand All @@ -39,19 +40,19 @@ set_or_print_downloader()
fi
else
tried="curl, wget, and ftp"
fi
fi

if [[ -z "${fetch:-}" ]]; then
if [[ -z "${arg_B:-}" ]]; then
warning "No available download mechanism. Options tried: ${tried}"
else
emergency "No available download mechanism. Option tried: ${tried}"
warning "No available download mechanism. Options tried: ${tried}"
else
emergency "No available download mechanism. Option tried: ${tried}"
fi
fi

# If a printout of the download mechanism was requested, then print it and exit with normal status
if [[ ! -z "${arg_D}" ]]; then
printf "%s\n" "${fetch}"
if [[ ! -z "${arg_D}" ]]; then
printf "%s\n" "${fetch}"
exit 0
fi
}
11 changes: 7 additions & 4 deletions prerequisites/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, S
export __flag_present=1

# shellcheck disable=SC2154
if [[ "${arg_l}" != "${__flag_present}" &&
"${arg_v}" != "${__flag_present}" &&
if [[ "${arg_l}" != "${__flag_present}" &&
"${arg_v}" != "${__flag_present}" &&
"${arg_h}" != "${__flag_present}" &&
-z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}" ]]; then
help "${__base}: Insufficient arguments. Please pass either -B, -D, -h, -l, -L, -p, -P, -U, -v, -V, or a longer equivalent."
Expand Down Expand Up @@ -110,17 +110,20 @@ info "-t (--with-tau): ${arg_t} "
info "-U (--print-url): ${arg_U} "
info "-v (--version): ${arg_v} "
info "-V (--print-version): ${arg_V} "
info "-y (--yes-to-all): ${arg_y} "
}

if [[ -z "${arg_B}" ]]; then
# shellcheck source=./build-functions/set_or_print_default_version.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
# shellcheck disable=SC2119
set_or_print_default_version
export version_to_build="${arg_I:-${arg_b:-${default_version}}}"
fi

# shellcheck source=./build-functions/set_or_print_downloader.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh"
# shellcheck disable=SC2119
set_or_print_downloader

# shellcheck source=./build-functions/set_or_print_url.sh
Expand All @@ -142,11 +145,11 @@ if [[ -z "${arg_B}" ]]; then
# shellcheck source=./build-functions/unpack_if_necessary.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/unpack_if_necessary.sh"
unpack_if_necessary

# shellcheck source=./build-functions/set_compilers.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_compilers.sh"
set_compilers

# shellcheck source=./build-functions/build_and_install.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/build_and_install.sh"
build_and_install
Expand Down
1 change: 1 addition & 0 deletions prerequisites/build.sh-usage
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
-U --print-url [arg] Print URL for package specified in argument.
-v --version Print OpenCoarrays version number.
-V --print-version [arg] Print installation version for package specified in argument.
-y --yes-to-all Build non-interactively by assuming affirmative user responses.
2 changes: 1 addition & 1 deletion prerequisites/install-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
exit 2
else
# shellcheck source=./prerequisites/use-case/bootstrap.sh
# shellcheck source=./use-case/bootstrap.sh
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
fi
### End of boilerplate -- start user edits below #########################
Expand Down
Loading