From ec813227662caaa5434a528768f7c1467172be89 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Jul 21 2016 11:22:46 +0000 Subject: Adds -pi (old -i, insert build script) and -pr (remove build script.) --- diff --git a/build.sh b/build.sh index a09f1b3..a6977fa 100755 --- a/build.sh +++ b/build.sh @@ -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##*:}"; diff --git a/build.subr b/build.subr index fc3ab1d..237f48c 100644 --- a/build.subr +++ b/build.subr @@ -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 59677ed..5a105c0 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