summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-03-02 12:44:33 +0100
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-03-02 12:44:33 +0100
commitd824e1e651835014ce7c5d9b0c21f7bc403d5646 (patch)
treecab5a84dbd39e4c50f6190f67661d26af2c29edf
parent0fdea6e043b65b79add983ab6b196b479c768e3d (diff)
downloadmidipix_build-d824e1e651835014ce7c5d9b0c21f7bc403d5646.tar.bz2
midipix_build-d824e1e651835014ce7c5d9b0c21f7bc403d5646.tar.xz
- Emit warnings whenever a potentially dangerous operation is invoked by the build scripts.
Currently, this only includes rm_if_exists(). - Adds pedantic mode (-pt,) which additionally adds manual confirmation of each potentially dangerous operation.
-rw-r--r--.gitignore1
-rwxr-xr-xbuild.sh1
-rw-r--r--build.subr19
-rw-r--r--build.usage6
-rw-r--r--build.vars1
5 files changed, 25 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 5953a191..00b28afd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
build.log
*.sw[op]
+TODO
diff --git a/build.sh b/build.sh
index 26879b1f..db7c9cd0 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 48560774..30a45fa8 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 ea09ad17..c4d33da5 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 a534d031..04f99c7b 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"};