diff options
author | Lucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de> | 2016-07-21 11:22:46 +0000 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de> | 2016-07-21 11:22:46 +0000 |
commit | ec813227662caaa5434a528768f7c1467172be89 (patch) | |
tree | 604531d5215ba21e435a0418527a47e46ca6153e | |
parent | 8d03b33b9eeeb087dc28e939f76dcedf7fed17e8 (diff) | |
download | midipix_build-ec813227662caaa5434a528768f7c1467172be89.tar.bz2 midipix_build-ec813227662caaa5434a528768f7c1467172be89.tar.xz |
Adds -pi (old -i, insert build script) and -pr (remove build script.)
-rwxr-xr-x | build.sh | 3 | ||||
-rw-r--r-- | build.subr | 39 | ||||
-rw-r--r-- | build.usage | 10 |
3 files changed, 40 insertions, 12 deletions
@@ -15,7 +15,8 @@ case ${1} in -x) ARG_XTRACE=1; set -o xtrace; ;; -a) [ -z "${2}" ] && exec cat build.usage || ARCH="${2}"; shift; ;; -b) [ -z "${2}" ] && exec cat build.usage || BUILD="${2}"; shift; ;; --i) [ -z "${2}" ] && exec cat build.usage || insert_build_script_link "${2}"; exit; ;; +-pi) [ -z "${2}" ] && exec cat build.usage || insert_build_script_link "${2}"; exit; ;; +-pr) [ -z "${2}" ] && exec cat build.usage || remove_build_script_link "${2}"; exit; ;; -r) [ -n "${ARG_RESTART_SCRIPT}" ] && exec cat build.usage; if [ "${2#*:*}" != "${2}" ]; then ARG_RESTART_SCRIPT="${2%%:*}"; ARG_RESTART_SCRIPT_AT="${2##*:}"; @@ -64,9 +64,9 @@ insert_build_script_link() { _ibsl_fname=${1}; _ibsl_level=${_ibsl_fname%%.*}; _ibsl_name=${_ibsl_fname#*.}; _ibsl_name=${_ibsl_name%.build}; - if [ -z "${_ibsl_fname}" -o -z "${_ibsl_level}" \ - -o -z "${_ibsl_name}" ] \ - || ! isnumber ${_ibsl_level} \ + if [ -z "${_ibsl_fname}" -o -z "${_ibsl_level}" \ + -o -z "${_ibsl_name}" ] \ + || ! isnumber ${_ibsl_level} \ || [ ${#_ibsl_level} != 3 ]; then log_msg failexit "Error: invalid or empty build script filename/level/name."; elif [ -e ${_ibsl_fname} ]; then @@ -77,8 +77,8 @@ insert_build_script_link() { unset _ibsl_fname _ibsl_level _ibsl_name; return 0; else - _ibsl_levels="$(find -maxdepth 1 -name \ - ${_ibsl_level%[0-9][0-9]}\[0-9\]\[0-9\].\* \ + _ibsl_levels="$(find -maxdepth 1 -name \ + ${_ibsl_level%[0-9][0-9]}\[0-9\]\[0-9\].\* \ -printf '%P\n' | sort -nk1)"; fi; for _ibsl_fname_cur in ${_ibsl_levels}; do @@ -89,13 +89,14 @@ insert_build_script_link() { _ibsl_changed=1; fi; if [ ${_ibsl_changed:=0} -eq 1 ]; then - if [ -z "$(find -maxdepth 1 -name $((${_ibsl_fname_cur%%.*}+1)).\* \ + if [ -z "$(find -maxdepth 1 \ + -name $((${_ibsl_fname_cur%%.*}+1)).\* \ -printf '%P\n' -quit)" ]; then _ibsl_last=1; fi; - echo mv -- ${_ibsl_fname_cur} \ + echo mv -- ${_ibsl_fname_cur} \ $((${_ibsl_fname_cur%%.*}+1)).${_ibsl_fname_cur#*.}; - mv -- ${_ibsl_fname_cur} \ + mv -- ${_ibsl_fname_cur} \ $((${_ibsl_fname_cur%%.*}+1)).${_ibsl_fname_cur#*.}; if [ ${_ibsl_last:-0} -eq 1 ]; then break; @@ -119,6 +120,28 @@ isnumber() { fi; done; unset _i_num; return 0; }; +remove_build_script_link() { + _rbsl_fname=${1}; + _rbsl_level=${_rbsl_fname%%.*}; + _rbsl_name=${_rbsl_fname#*.}; _rbsl_name=${_rbsl_name%.build}; + if [ -z "${_rbsl_fname}" -o -z "${_rbsl_level}" \ + -o -z "${_rbsl_name}" ] \ + || ! isnumber ${_rbsl_level} \ + || [ ${#_rbsl_level} != 3 ]; then + log_msg failexit "Error: invalid or empty build script filename/level/name."; + elif [ ! -e ${_rbsl_fname} ]; then + log_msg failexit "Error: build script \`${_rbsl_fname}' doesn't exist."; + else for _rbsl_fname_cur in $(find -maxdepth 1 \ + -name ${_rbsl_level%[0-9][0-9]}\[0-9\]\[0-9\].\* \ + -printf '%P\n' | sort -nk1); do + _rbsl_fname_cur_level=${_rbsl_fname_cur%%.*}; + if [ ${_rbsl_fname_cur_level} -gt ${_rbsl_level} ]; then + echo mv ${_rbsl_fname_cur} \ + $(printf "%03u" \ + $((${_rbsl_fname_cur_level#00}-1))).${_rbsl_fname_cur#*.}; + fi; + done; fi; +}; is_build_script_done() { if [ -n "${ARG_RESTART_SCRIPT_AT}" ]; then diff --git a/build.usage b/build.usage index 59677ed6..5a105c00 100644 --- a/build.usage +++ b/build.usage @@ -1,13 +1,17 @@ -usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-c] [-h] [-i level.name.build] - [-r ALL|level.name.build[:diff|:step[,...]]] [-t[.gz|.bz2|.xz] [-x] +usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-c] [-h] [-pi level.name.build] + [-pr level.name.build] [-r ALL|level.name.build[:diff|:step[,...]]] + [-t[.gz|.bz2|.xz] [-x] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build; defaults to debug. This currently only controls CFLAGS. -c Clean ${PREFIX} before processing build scripts. -h Show this screen. - -i level.name.build Insert link to pkg.build for the specified build script. + -pi level.name.build Insert link to pkg.build for the specified build script. All consecutive scripts with higher build levels will be renamed automatically. + -pr level.name.build Remove the specified build script. As with -pi, all con- + secutive scripts with higher build levels will be renamed + automatically. -r ALL|level.name.build[:step[,...]] Restart all or the specified build script(s) completely or at the optionally specified build step. Currently defined |