3838# --build-use-local-src Use existing sources in relevant paths.
3939# --prefix=<path> Installation destination.
4040# Default: /usr/local
41+ # --noninteractive Disable any prompt using default.
4142# --verbose Display verbose script output.
4243# --help, -h Display usage, overriding script execution.
4344#
@@ -99,6 +100,7 @@ main()
99100 (--build-parallel=* ) PARALLEL=" ${OPTION#* =} " ;;
100101 (--build-use-local-src) BUILD_USE_LOCAL_SRC=" yes" ;;
101102 (--prefix=* ) PREFIX=" ${OPTION#* =} " ;;
103+ (--noninteractive) NONINTERACTIVE=" yes" ;;
102104 (--verbose) DISPLAY_VERBOSE=" yes" ;;
103105 (--help|-h) DISPLAY_HELP=" yes" ;;
104106 (-DCMAKE_PREFIX_PATH=* ) CMAKE_PREFIX_PATH=" ${OPTION#* =} " ;;
@@ -123,6 +125,7 @@ main()
123125 CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ --build-parallel=*/ } " )
124126 CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ --build-use-local-src/ } " )
125127 CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ --prefix=*/ } " )
128+ CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ --noninteractive/ } " )
126129 CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ --verbose/ } " )
127130 CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ --help/ } " )
128131 CONFIGURE_OPTIONS=(" ${CONFIGURE_OPTIONS[@]/ -h/ } " )
@@ -491,8 +494,19 @@ source_archive()
491494 fi
492495
493496 if [ -d " ${PROJECT} " ]; then
494- msg_warn " Encountered existing '${PROJECT} ' directory, removing..."
495- remove_directory_force " ${PROJECT} "
497+ msg_warn " Encountered existing '${PROJECT} ' directory..."
498+ if [[ " ${NONINTERACTIVE} " == " yes" ]]; then
499+ CONFIRM=" N"
500+ else
501+ read -p " Replace '${PROJECT} ' directory with intended contents? [y/N] " CONFIRM
502+ fi
503+
504+ if [[ " ${CONFIRM,,} " == " y" ]]; then
505+ remove_directory_force " ${PROJECT} "
506+ else
507+ msg_error " Aborted installation."
508+ exit 0
509+ fi
496510 fi
497511
498512 msg " Retrieving ${PROJECT} ..."
@@ -520,6 +534,18 @@ source_archive()
520534 msg_success " Completed download and extraction successfully."
521535}
522536
537+ github_repository_status ()
538+ {
539+ local REPOSITORY=" $1 "
540+
541+ push_directory " ${REPOSITORY} "
542+ local DISCOVERED_COMMIT=$( git rev-parse HEAD)
543+ local DISCOVERED_URL=$( git config --get remote.origin.url)
544+ pop_directory # REPOSITORY
545+ msg_warn " commit : ${DISCOVERED_COMMIT} "
546+ msg_warn " url : ${DISCOVERED_URL} "
547+ }
548+
523549source_github ()
524550{
525551 local OWNER=" $1 "
@@ -541,21 +567,33 @@ source_github()
541567 if [ -d " ${REPOSITORY} " ] &&
542568 [[ " ${BUILD_USE_LOCAL_SRC} " == " yes" ]]; then
543569 msg_warn " Reusing existing '${REPOSITORY} '..."
570+ github_repository_status " ${REPOSITORY} "
544571 pop_directory # BUILD_SRC_DIR
545572 return 0
546573 fi
547574
548575 if [ -d " ${REPOSITORY} " ]; then
549- msg_warn " Encountered existing '${REPOSITORY} ' directory, removing..."
550- remove_directory_force " ${REPOSITORY} "
576+ msg_warn " Encountered existing '${REPOSITORY} ' directory..."
577+ if [[ " ${NONINTERACTIVE} " == " yes" ]]; then
578+ CONFIRM=" N"
579+ else
580+ read -p " Replace '${REPOSITORY} ' directory with intended contents? [y/N] " CONFIRM
581+ fi
582+
583+ if [[ " ${CONFIRM,,} " == " y" ]]; then
584+ remove_directory_force " ${REPOSITORY} "
585+ else
586+ msg_error " Aborted installation."
587+ exit 0
588+ fi
551589 fi
552590
553591 msg " Cloning ${OWNER} /${REPOSITORY} /${TAG} ..."
554592
555593 ${GIT_CLONE} ${CLONE_OPTIONS} --branch " ${TAG} " " https://github.com/${OWNER} /${REPOSITORY} "
556594
557- # pop BUILD_SRC_DIR
558- pop_directory
595+ github_repository_status " ${REPOSITORY} "
596+ pop_directory # pop BUILD_SRC_DIR
559597}
560598
561599install_make ()
@@ -896,6 +934,7 @@ help()
896934 msg " --build-use-local-src Use existing sources in relevant paths."
897935 msg " --prefix=<path> Installation destination."
898936 msg " Default: /usr/local"
937+ msg " --noninteractive Disable any prompt using default."
899938 msg " --verbose Display verbose script output."
900939 msg " --help, -h Display usage, overriding script execution."
901940 msg " "
0 commit comments