diff --git a/.gitignore b/.gitignore index 5953a19..00b28af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build.log *.sw[op] +TODO diff --git a/build.sh b/build.sh index 26879b1..db7c9cd 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,7 @@ while [ ${#} -gt 0 ]; do case ${1} in -c) ARG_CLEAN=1; ;; -nd) ARG_NO_DOWNLOAD=1; ;; +-pt) ARG_PEDANTIC=1; ;; -r) [ -n "${ARG_RESTART_SCRIPT}" ] && exec cat build.usage; match_any "${2}" : \ && { ARG_RESTART_SCRIPT="${2%%:*}"; ARG_RESTART_SCRIPT_AT="${2##*:}"; } \ diff --git a/build.subr b/build.subr index 4856077..30a45fa 100644 --- a/build.subr +++ b/build.subr @@ -75,8 +75,22 @@ find_with_no_paths() { rm_if_exists() { [ -z "${1#-m}" ] && { _rie_arg_m=1; shift; }; [ -z "${1#-c}" ] && { _rie_arg_c=1; shift; }; - [ -d ${1} -o -f ${1} ] && rm -rf ${1}; - [ ${_rie_arg_m:-0} -eq 1 ] && { mkdir ${1}; unset _rie_arg_m; }; + if [ -d ${1} -o -f ${1} ]; then + log_msg warn "Removing directory or file \`${1}'."; + if [ ${ARG_PEDANTIC:-0} -eq 1 ]; then + printf "Confirm deletion (y|N) "; + read _rie_prompt; case "${_rie_prompt}" in + [yY]) rm -rf ${1}; ;; + *) log_msg warn "Skipping removal of \`${1}'."; + _rie_arg_m=0; ;; + esac; + else + rm -rf ${1}; + fi; + fi; + [ ${_rie_arg_m:-0} -eq 1 ] && { + log_msg warn "Making directory \`${1}'."; + mkdir ${1}; unset _rie_arg_m; }; [ ${_rie_arg_c:-0} -eq 1 ] && { cd ${1}; unset _rie_arg_c; }; return 0; }; @@ -231,6 +245,7 @@ log_msg() { fail) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;; info) printf "\033[${LOG_MSG_INFO_COLOUR}m"; ;; succ) printf "\033[${LOG_MSG_SUCC_COLOUR}m"; ;; + warn) printf "\033[${LOG_MSG_WARN_COLOUR}m"; ;; esac; if [ $# -gt 1 ]; then printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*"; diff --git a/build.usage b/build.usage index ea09ad1..c4d33da 100644 --- a/build.usage +++ b/build.usage @@ -1,11 +1,15 @@ usage: ./build.sh [-c] [-nd] [-r ALL|name[:step]] [-h] [-t] -c Clean $PREFIX before processing build scripts. -nd Don't rm(1) and re-download tarballs when not required. + -h Show this screen. + -pt Enable pedantic mode. In addition to the warnings emitted + whenever a potentially dangerous operation is invoked by + the build scripts, manual confirmation will be required. + This currently only includes rm_if_exists(). -r ALL|name[:step] Restart all or the specified build script(s) completely or at the optionally specified build step. Currently defined build steps are: fetch extract patch configure clean build install configure1 configure2 build1 build2 install1 install2. - -h Show this screen. -t Produce a distribution tarball containing $PREFIX sans $WORKDIR and $PREFIX/src/midipix_build at the end of a build with zero failures. diff --git a/build.vars b/build.vars index a534d03..04f99c7 100644 --- a/build.vars +++ b/build.vars @@ -24,6 +24,7 @@ : ${LOG_MSG_FAIL_COLOUR:=91}; : ${LOG_MSG_INFO_COLOUR:=93}; : ${LOG_MSG_SUCC_COLOUR:=92}; +: ${LOG_MSG_WARN_COLOUR:=96}; : ${MAKEFLAGS_DEFAULT:=-j8}; : ${TARBALL_FNAME_PREFIX:=midipix.}; : ${TARBALL_EXCLUDE_PATHS:="src tmp"};