diff options
Diffstat (limited to 'subr')
30 files changed, 309 insertions, 322 deletions
diff --git a/subr/build.subr b/subr/build.subr deleted file mode 100644 index 526d9f25..00000000 --- a/subr/build.subr +++ /dev/null @@ -1,181 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -basename() { echo "${1##*/}"; }; -date() { command date "+${1:-${TIMESTAMP_FMT}}"; }; -dirname() { echo "${1%/*}"; }; -get_var_unsafe() { eval echo \${${1}}; }; -set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; }; -pop_IFS() { IFS="${_pI_IFS}"; unset _pI_IFS; }; -push_IFS() { _pI_IFS="${IFS}"; IFS="${1}"; }; -set_build_dir() { PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}"; }; -test_cmd() { command -v "${1}" >/dev/null; }; -toupper() { echo "${1}" | tr a-z A-Z; }; - -build_fileop() { - local _op="${1}"; shift; - if [ "${_op}" = cd ]; then - log_msg varn "Changing working directory to \`${1}'."; - [ \( -n "${1}" \) -a \( -L "${1}" -o -e "${1}" \) ] && cd -- "${1}"; - elif [ "${_op}" = cp ]; then - log_msg varn "Copying \`${1}' to \`${2}' w/ -pPR."; - [ ${#} -ge 2 ] && cp -pPR -- "${@}"; - elif [ "${_op}" = ln_symbolic ]; then - log_msg varn "Linking \`${1}' to \`${2}' w/ -fs"; - [ \( -n "${1}" \) -a \( -n "${2}" \) ] && ln -fs -- "${1}" "${2}"; - elif [ "${_op}" = mv ]; then - log_msg varn "Moving \`${1}' to \`${2}' w/ -fs"; - [ \( -n "${1}" \) -a \( -n "${2}" \) ] && mv -f -- "${1}" "${2}"; - elif [ "${_op}" = mkdir ]\ - || [ "${_op}" = rm ]; then - while [ ${#} -gt 0 ]; do - if [ -z "${1}" ]; then - return 1; - elif [ "${_op}" = mkdir ]\ - && [ ! -e "${1}" ]; then - log_msg varn "Making directory \`${1}'."; - mkdir -p -- "${1}"; - elif [ "${_op}" = rm ]\ - && [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then - log_msg varn "Removing directory or file \`${1}'."; - rm -rf -- "${1}"; - fi; shift; - done; - else - log_msg failexit "Error: build_fileop() called w/ invalid parameter(s) \`${@}'."; - fi; -}; - -is_build_script_done() { - local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${3}"; - if [ -z "${_restart_at}" ]; then - if [ -e "${_done_fname}" ]; then - return 0; # Skip - else - return 1; # Build - fi; - elif [ "${_restart_at}" = "ALL" ]; then - return 1; # Build - elif lmatch "${_restart_at}" , "${2}"; then - return 1; # Build - else - return 0; # Skip - fi; -}; -set_build_script_done() { - local _pkg_fname="${1}"; - local _done_fname_pfx="${WORKDIR}/.${_pkg_fname}"; - shift; while [ ${#} -ge 1 ]; do - if [ "${1#-}" != "${1}" ]; then - build_fileop rm "${_done_fname_pfx}.${1#-}"; - else - touch "${_done_fname_pfx}.${1}"; - log_msg info "Finished build step ${1} of package \`${_pkg_fname}'."; - fi; shift; - done; -}; - -lfilter() { - [ "x${1}" = "x-not" ] && { local _notfl=1; shift; } - local _list="${1}" _filter="${2}" _lnew _litem _lfilter _filterfl; - [ -z "${_filter}" ] && { echo "${_list}"; return 0; }; - for _litem in ${_list}; do - _filterfl=0; - for _lfilter in ${_filter}; do - if [ "${_notfl:-0}" -eq 0 ]\ - && [ "${_lfilter}" = "${_litem}" ]; then - _lnew="${_lnew:+${_lnew} }${_litem}"; break; - elif [ "${_notfl:-0}" -eq 1 ]\ - && [ "${_lfilter}" = "${_litem}" ]; then - _filterfl=1; break; - fi; - done; - if [ "${_notfl:-0}" -eq 1 ]\ - && [ "${_filterfl:-0}" -eq 0 ]; then - _lnew="${_lnew:+${_lnew} }${_litem}"; - fi; - done; - echo "${_lnew}"; -}; - -lmatch() { - local _cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS; - while [ ${#} -gt 0 ]; do - if [ "${1}" = "${_cmp}" ]; then - return 0; - fi; shift; - done; return 1; -}; - -log_env_vars() { - local _nvar=1 _arg _arg_len_max=0; - log_msg info "Variables for this ${1:-build}:"; shift; - while [ ${_nvar} -le ${#} ]; do - _arg="$(eval echo \${${_nvar}})"; - _arg="${_arg%%=*}"; - if [ ${#_arg} -gt ${_arg_len_max} ]; then - _arg_len_max=${#_arg}; - fi; : $((_nvar+=1)); - done; - while [ ${#} -gt 0 ]; do - log_msg info "$(printf \ - "%${_arg_len_max}.${_arg_len_max}s=%s" \ - "${1%%=*}" "$(get_var_unsafe ${1#*=})")"; - shift; - done; -}; - -log_msg() { - local _lvl="${1}"; shift; - if [ "${_lvl#v}" != "${_lvl}" ]\ - && [ ${ARG_VERBOSE:-0} -eq 0 ]; then - return; - fi; - case "${_lvl}" in - failexit) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;; - fail) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;; - info) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;; - vnfo) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;; - succ) printf "\033[0m\033[${LOG_MSG_SUCC_COLOUR}m"; ;; - warn) printf "\033[0m\033[${LOG_MSG_WARN_COLOUR}m"; ;; - varn) printf "\033[0m\033[${LOG_MSG_WARN_COLOUR}m"; ;; - esac; - if [ ${#} -gt 1 ]; then - printf "==> %s %s %s\033[0m\n" "$(date)" "${1}" "$*"; - else - printf "==> %s %s\033[0m\n" "$(date)" "${1}"; - fi; [ ${_lvl} = failexit ] && exit 1 || return 0; -}; - -run_cmd_unsplit() { - local _cmd="${1}" _cmdline _rc; shift; - while [ ${#} -gt 0 ]; do - [ -n "${1}" ] &&\ - _cmdline="${_cmdline:+${_cmdline}:}${1}"; - shift; - done; - push_IFS :; ${_cmd} ${_cmdline}; _rc=$?; pop_IFS; - return ${_rc}; -}; - -set_env_vars_with_sep() { - local _sep="${1}"; shift; push_IFS ${_sep}; set -- ${1}; - while [ ${#} -gt 0 ]; do - export "${1}"; shift; - done; pop_IFS; -}; - -subst_tgts() { - local _pkgs; - while [ ${#} -ge 1 ]; do - _pkgs="$(get_var_unsafe "$(toupper "${1}")_TARGET")"; - if [ -n "${_pkgs}" ]; then - echo "${_pkgs}"; - else - echo "${1}"; - fi; shift; - done; -}; - -# vim:filetype=sh diff --git a/subr/pkg_setup_dispatch.subr b/subr/ex_pkg_dispatch.subr index c4482578..99c9ff8f 100644 --- a/subr/pkg_setup_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -2,7 +2,7 @@ # set -o errexit -o noglob are assumed. # -pkg_setup_dispatch() { +ex_pkg_dispatch() { local _tgt_name="${1}" _pkg_name="${2}" \ _restart="${3}" _restart_at="${4}" \ _pkg_step_cmds _pkg_step_cmd_args; @@ -10,11 +10,14 @@ pkg_setup_dispatch() { PKG_NAME_PARENT="${_pkg_name%_flavour_*}"; fi; (set -o errexit -o noglob; + ex_pkg_vars; ex_pkg_env; + ex_build_fileop mkdir "${PKG_BASE_DIR}"; + ex_build_fileop cd "${PKG_BASE_DIR}"; if [ -n "${_restart}" ]\ || [ "${_tgt_name}" = "INVARIANTS" ]\ - || ! is_build_script_done "${_pkg_name}" finish; then - set -- $(lfilter -not "${BUILD_STEPS}" \ - "$(get_var_unsafe PKG_$(toupper "${_pkg_name}")_BUILD_STEPS_DISABLE)"); + || ! ex_pkg_state_test "${_pkg_name}" finish; then + set -- $(ex_lfilter -not "${BUILD_STEPS}" \ + "$(ex_get_var_unsafe PKG_$(ex_toupper "${_pkg_name}")_BUILD_STEPS_DISABLE)"); while [ ${#} -gt 0 ]; do _pkg_step_cmds=""; _pkg_step_cmd_args=""; case "${1#*:}" in @@ -23,40 +26,41 @@ pkg_setup_dispatch() { _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; elif [ -n "${_restart}" ]; then if [ -z "${_restart_at}" ]\ - || lmatch "${_restart_at}" , "${1%:*}"; then + || ex_lmatch "${_restart_at}" , "${1%:*}"; then _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; fi; - elif ! is_build_script_done "${_pkg_name}" "${1%:*}"; then + elif ! ex_pkg_state_test "${_pkg_name}" "${1%:*}"; then _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; fi; ;; invariant) _pkg_step_cmds="pkg_${1%:*}"; ;; variant) - if lmatch "${_restart_at}" "," "${1%:*}"; then + if ex_lmatch "${_restart_at}" "," "${1%:*}"; then _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; fi; ;; virtual) _pkg_step_cmds="pkg_${_pkg_name}_${1%:*}"; _pkg_step_cmd_args="${_restart_at:-ALL}"; ;; all) - if test_cmd "pkg_${_pkg_name}_${1%:*}"; then + if ex_test_cmd "pkg_${_pkg_name}_${1%:*}"; then "pkg_${_pkg_name}_${1%:*}" "${_restart_at:-ALL}"; break; fi; ;; - *) break; ;; + finish) ex_pkg_state_push "${_pkg_name}" finish; ;; + *) ;; esac; for __ in ${_pkg_step_cmds}; do - if test_cmd "${__}"; then - test_cmd "pkg_${_pkg_name}_${1%:*}_pre" \ + if ex_test_cmd "${__}"; then + ex_test_cmd "pkg_${_pkg_name}_${1%:*}_pre" \ && "pkg_${_pkg_name}_${1%:*}_pre" "${__}" ${_pkg_step_cmd_args}; - test_cmd "pkg_${_pkg_name}_${1%:*}_post" \ + ex_test_cmd "pkg_${_pkg_name}_${1%:*}_post" \ && "pkg_${_pkg_name}_${1%:*}_post" - if [ "${1#*:}" != "always" ]\ + if [ "${1#*:}" != "invariant" ]\ && [ ${#} -ge 2 ]; then - set_build_script_done "${_pkg_name}" "${1%:*}" "-${2#*:}"; + ex_pkg_state_push "${_pkg_name}" "${1%:*}" "-${2#*:}"; else - set_build_script_done "${_pkg_name}" "${1%:*}"; + ex_pkg_state_push "${_pkg_name}" "${1%:*}"; fi; break; fi; done; diff --git a/subr/pkg_setup_env.subr b/subr/ex_pkg_env.subr index f8d720d7..240c6289 100644 --- a/subr/pkg_setup_env.subr +++ b/subr/ex_pkg_env.subr @@ -2,18 +2,18 @@ # set -o errexit -o noglob are assumed. # -pkg_setup_env() { +ex_pkg_env() { + local _vname; if [ -z "${PKG_URL}" ]\ && [ -z "${PKG_URLS_GIT}" ]\ && [ -z "${PKG_VERSION}" ]\ && ! test_cmd "pkg_${PKG_NAME}_all"; then - log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; + ex_log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then - log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'"; + ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'"; exit 0; else [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; - [ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}"; [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; case "${PKG_BASE_DIR}" in @@ -21,7 +21,7 @@ pkg_setup_env() { *) PKG_BASE_DIR="${WORKDIR}/${PKG_NAME}-${PKG_BUILD_TYPE:-native}-${PKG_TARGET}"; if [ -n "${ARG_RESTART}" ]\ && [ -z "${ARG_RESTART_AT}" ]; then - build_fileop rm "${PKG_BASE_DIR}"; + ex_build_fileop rm "${PKG_BASE_DIR}"; fi; ;; esac; PKG_DESTDIR="${PKG_BASE_DIR}/destdir"; @@ -49,11 +49,14 @@ pkg_setup_env() { esac; ;; esac; ;; esac; + for _vname in $(ex_split : ${PKG_ENV_VARS_EXTRA}); do + export "${_vname}"; + done; fi; if [ -n "${PKG_ENV_VARS}" ]\ && [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then PKG_ENV_VARS="$(echo "${PKG_ENV_VARS}" | tr " " "\n" | sort | tr "\n" " ")"; - log_env_vars "build" ${PKG_ENV_VARS}; + ex_log_env_vars "build" ${PKG_ENV_VARS}; fi; }; diff --git a/subr/ex_pkg_state.subr b/subr/ex_pkg_state.subr new file mode 100644 index 00000000..4cc0a8b0 --- /dev/null +++ b/subr/ex_pkg_state.subr @@ -0,0 +1,64 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_pkg_state_build_dir() { + PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}"; +}; + +ex_pkg_state_fini() { + : $((BUILD_TIMES_SECS=$(ex_date %s)-${BUILD_TIMES_SECS})); + : $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600)); + : $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60)); + : $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60)); + if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then + ex_build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME}; + fi; +}; + +ex_pkg_state_init() { + if [ -e ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then + ex_log_msg failexit "Error: another build targeting this architecture and build type is currently in progress."; + else + touch ${BUILD_STATUS_IN_PROGRESS_FNAME}; + fi; + if [ -e ${BUILD_LOG_FNAME} ]; then + mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME}; + fi; + BUILD_DATE_START="$(ex_date %Y-%m-%d-%H-%M-%S)"; + BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}; + BUILD_TIMES_SECS=$(ex_date %s); + BUILD_PKGS_FAILED=""; +}; + +ex_pkg_state_push() { + local _pkg_fname="${1}"; + local _done_fname_pfx="${WORKDIR}/.${_pkg_fname}"; + shift; while [ ${#} -ge 1 ]; do + if [ "${1#-}" != "${1}" ]; then + ex_build_fileop rm "${_done_fname_pfx}.${1#-}"; + else + touch "${_done_fname_pfx}.${1}"; + ex_log_msg info "Finished build step ${1} of package \`${_pkg_fname}'."; + fi; shift; + done; +}; + +ex_pkg_state_test() { + local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${3}"; + if [ -z "${_restart_at}" ]; then + if [ -e "${_done_fname}" ]; then + return 0; # Skip + else + return 1; # Build + fi; + elif [ "${_restart_at}" = "ALL" ]; then + return 1; # Build + elif ex_lmatch "${_restart_at}" , "${2}"; then + return 1; # Build + else + return 0; # Skip + fi; +}; + +# vim:filetype=sh diff --git a/subr/pkg_setup_vars.subr b/subr/ex_pkg_vars.subr index fc9f8537..07c2cacd 100644 --- a/subr/pkg_setup_vars.subr +++ b/subr/ex_pkg_vars.subr @@ -2,19 +2,19 @@ # set -o errexit -o noglob are assumed. # -pkgp_setup_pkg_vars() { +exp_pkg_vars() { local _pkg_name="${1}" _pkg_name_uc _build_uc _vname_dst _vname_src; - _pkg_name_uc="$(toupper "${_pkg_name}")"; - _build_uc="$(toupper "${BUILD}")"; + _pkg_name_uc="$(ex_toupper "${_pkg_name}")"; + _build_uc="$(ex_toupper "${BUILD}")"; for _vname_dst in PREFIX ${PKG_BUILD_VARS}; do for _vname_src in \ "DEFAULT_${_vname_dst}" \ "${BUILD_TARGET}_${_vname_dst}" \ "PKG_${_pkg_name_uc}_${_vname_dst}" \ "PKG_${_pkg_name_uc}_${_vname_dst}_${_build_uc}"; do - if [ -n "$(get_var_unsafe "${_vname_src}")" ]; then - set_var_unsafe "PKG_${_vname_dst}" "$(get_var_unsafe ${_vname_src})"; - if ! lmatch "${PKG_ENV_VARS}" " " "${_vname_src}"; then + if [ -n "$(ex_get_var_unsafe "${_vname_src}")" ]; then + ex_set_var_unsafe "PKG_${_vname_dst}" "$(ex_get_var_unsafe ${_vname_src})"; + if ! ex_lmatch "${PKG_ENV_VARS}" " " "${_vname_src}"; then PKG_ENV_VARS="${PKG_ENV_VARS:+${PKG_ENV_VARS} }${_vname_src}"; fi; fi; @@ -22,7 +22,7 @@ pkgp_setup_pkg_vars() { done; }; -pkg_setup_vars() { +ex_pkg_vars() { local _vars_path; for _vars_path in vars/${PKG_NAME}.vars; do if [ -e "${_vars_path}" ]\ @@ -31,9 +31,9 @@ pkg_setup_vars() { fi; done; if [ -n "${PKG_NAME_PARENT}" ]; then - pkgp_setup_pkg_vars "${PKG_NAME_PARENT}"; + exp_pkg_vars "${PKG_NAME_PARENT}"; fi; - pkgp_setup_pkg_vars "${PKG_NAME}"; + exp_pkg_vars "${PKG_NAME}"; }; # vim:filetype=sh diff --git a/subr/ex_rtl.subr b/subr/ex_rtl.subr new file mode 100644 index 00000000..b014a384 --- /dev/null +++ b/subr/ex_rtl.subr @@ -0,0 +1,60 @@ +# +# set -o errexit -o noglob are assumed. +# + +IFS_NL=" +"; + +ex_basename() { echo "${1##*/}"; }; +ex_date() { command date "+${1:-${TIMESTAMP_FMT}}"; }; +ex_dirname() { echo "${1%/*}"; }; +ex_get_var_unsafe() { eval echo \${${1}}; }; +ex_set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; }; +ex_split() { local IFS="${1}"; set -- $(echo "${2}"); IFS="${IFS_NL}"; echo "${*}"; }; +ex_test_cmd() { command -v "${1}" >/dev/null; }; +ex_toupper() { echo "${1}" | tr a-z A-Z; }; + +ex_lfilter() { + [ "x${1}" = "x-not" ] && { local _notfl=1; shift; } + local _list="${1}" _filter="${2}" _lnew _litem _ex_lfilter _filterfl; + [ -z "${_filter}" ] && { echo "${_list}"; return 0; }; + for _litem in ${_list}; do + _filterfl=0; + for _ex_lfilter in ${_filter}; do + if [ "${_notfl:-0}" -eq 0 ]\ + && [ "${_ex_lfilter}" = "${_litem}" ]; then + _lnew="${_lnew:+${_lnew} }${_litem}"; break; + elif [ "${_notfl:-0}" -eq 1 ]\ + && [ "${_ex_lfilter}" = "${_litem}" ]; then + _filterfl=1; break; + fi; + done; + if [ "${_notfl:-0}" -eq 1 ]\ + && [ "${_filterfl:-0}" -eq 0 ]; then + _lnew="${_lnew:+${_lnew} }${_litem}"; + fi; + done; + echo "${_lnew}"; +}; + +ex_lmatch() { + local _cmp="${3}" IFS="${2}"; set -- ${1}; + while [ ${#} -gt 0 ]; do + if [ "${1}" = "${_cmp}" ]; then + return 0; + fi; shift; + done; return 1; +}; + +ex_run_cmd_unsplit() { + local _cmd="${1}" _cmdline _rc IFS; shift; + while [ ${#} -gt 0 ]; do + [ -n "${1}" ] &&\ + _cmdline="${_cmdline:+${_cmdline}:}${1}"; + shift; + done; + IFS=:; ${_cmd} ${_cmdline}; _rc=$?; + return ${_rc}; +}; + +# vim:filetype=sh diff --git a/subr/ex_rtl_fileop.subr b/subr/ex_rtl_fileop.subr new file mode 100644 index 00000000..3732ab5e --- /dev/null +++ b/subr/ex_rtl_fileop.subr @@ -0,0 +1,39 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_build_fileop() { + local _op="${1}"; shift; + if [ "${_op}" = cd ]; then + ex_log_msg varn "Changing working directory to \`${1}'."; + [ \( -n "${1}" \) -a \( -L "${1}" -o -e "${1}" \) ] && cd -- "${1}"; + elif [ "${_op}" = cp ]; then + ex_log_msg varn "Copying \`${1}' to \`${2}' w/ -pPR."; + [ ${#} -ge 2 ] && cp -pPR -- "${@}"; + elif [ "${_op}" = ln_symbolic ]; then + ex_log_msg varn "Linking \`${1}' to \`${2}' w/ -fs"; + [ \( -n "${1}" \) -a \( -n "${2}" \) ] && ln -fs -- "${1}" "${2}"; + elif [ "${_op}" = mv ]; then + ex_log_msg varn "Moving \`${1}' to \`${2}' w/ -fs"; + [ \( -n "${1}" \) -a \( -n "${2}" \) ] && mv -f -- "${1}" "${2}"; + elif [ "${_op}" = mkdir ]\ + || [ "${_op}" = rm ]; then + while [ ${#} -gt 0 ]; do + if [ -z "${1}" ]; then + return 1; + elif [ "${_op}" = mkdir ]\ + && [ ! -e "${1}" ]; then + ex_log_msg varn "Making directory \`${1}'."; + mkdir -p -- "${1}"; + elif [ "${_op}" = rm ]\ + && [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then + ex_log_msg varn "Removing directory or file \`${1}'."; + rm -rf -- "${1}"; + fi; shift; + done; + else + ex_log_msg failexit "Error: ex_build_fileop() called w/ invalid parameter(s) \`${@}'."; + fi; +}; + +# vim:filetype=sh diff --git a/subr/ex_rtl_log.subr b/subr/ex_rtl_log.subr new file mode 100644 index 00000000..f4e250a5 --- /dev/null +++ b/subr/ex_rtl_log.subr @@ -0,0 +1,45 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_log_env_vars() { + local _nvar=1 _arg _arg_len_max=0; + ex_log_msg info "Variables for this ${1:-build}:"; shift; + while [ ${_nvar} -le ${#} ]; do + _arg="$(eval echo \${${_nvar}})"; + _arg="${_arg%%=*}"; + if [ ${#_arg} -gt ${_arg_len_max} ]; then + _arg_len_max=${#_arg}; + fi; : $((_nvar+=1)); + done; + while [ ${#} -gt 0 ]; do + ex_log_msg info "$(printf \ + "%${_arg_len_max}.${_arg_len_max}s=%s" \ + "${1%%=*}" "$(ex_get_var_unsafe ${1#*=})")"; + shift; + done; +}; + +ex_log_msg() { + local _lvl="${1}"; shift; + if [ "${_lvl#v}" != "${_lvl}" ]\ + && [ ${ARG_VERBOSE:-0} -eq 0 ]; then + return; + fi; + case "${_lvl}" in + failexit) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;; + fail) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;; + info) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;; + vnfo) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;; + succ) printf "\033[0m\033[${LOG_MSG_SUCC_COLOUR}m"; ;; + warn) printf "\033[0m\033[${LOG_MSG_WARN_COLOUR}m"; ;; + varn) printf "\033[0m\033[${LOG_MSG_WARN_COLOUR}m"; ;; + esac; + if [ ${#} -gt 1 ]; then + printf "==> %s %s %s\033[0m\n" "$(ex_date)" "${1}" "$*"; + else + printf "==> %s %s\033[0m\n" "$(ex_date)" "${1}"; + fi; [ ${_lvl} = failexit ] && exit 1 || return 0; +}; + +# vim:filetype=sh diff --git a/subr/pre_setup_args.subr b/subr/ex_setup_args.subr index e9c10a50..637a7d38 100644 --- a/subr/pre_setup_args.subr +++ b/subr/ex_setup_args.subr @@ -16,7 +16,7 @@ BUILD_ARGS_SPEC=" ARG_VERBOSE:-v ARG_XTRACE:-x"; -pre_setup_args() { +ex_setup_args() { local _spec="${BUILD_ARGS_SPEC}" _spec_arg _found; while [ ${#} -gt 0 ]; do if [ "${1#-}" = "${1}" ]; then @@ -26,11 +26,11 @@ pre_setup_args() { case "${_spec_arg}" in *:${1}) case "${_spec_arg#*:}" in arg:*) - set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;; + ex_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;; selfarg:*) - set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;; + ex_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;; *) - set_var_unsafe "${_spec_arg%%:*}" 1; ;; + ex_set_var_unsafe "${_spec_arg%%:*}" 1; ;; esac; _found=1; break; ;; *) _found=0; ;; esac; @@ -59,7 +59,7 @@ pre_setup_args() { fi; while [ ${#} -gt 0 ]; do case "${1}" in - *=*) set_var_unsafe "${1%%=*}" "${1#*=}"; ;; + *=*) ex_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; *) BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;; esac; shift; done; }; diff --git a/subr/pre_check.subr b/subr/ex_setup_checks.subr index 28e229e9..803810d2 100644 --- a/subr/pre_check.subr +++ b/subr/ex_setup_checks.subr @@ -2,31 +2,31 @@ # set -o errexit -o noglob are assumed. # -pre_check() { +ex_setup_checks() { local __ _exit; for __ in ${CHECK_PATH_VARS}; do - if [ -z "${___:=$(get_var_unsafe "${__}")}" ]; then - log_msg failexit "Error: variable \`${__}' is empty or unset."; + if [ -z "${___:=$(ex_get_var_unsafe "${__}")}" ]; then + ex_log_msg failexit "Error: variable \`${__}' is empty or unset."; elif [ "${___#* *}" != "${___}" ]; then - log_msg failexit "Error: variable \`${__}' contains one or more whitespace characters."; + ex_log_msg failexit "Error: variable \`${__}' contains one or more whitespace characters."; fi; done; for __ in ${CHECK_PREREQ_CMDS} $(eval echo ${CHECK_PREREQ_FILES_DYNAMIC}) ${CHECK_PREREQ_FILES}; do if [ "${__#/}" != "${__}" ]; then if [ ! -e "${__}" ]; then - log_msg fail "Error: missing prerequisite file \`${__}'."; + ex_log_msg fail "Error: missing prerequisite file \`${__}'."; _exit=1; fi; else - if ! test_cmd "${__}"; then - log_msg fail "Error: missing prerequisite command \`${__}'."; + if ! ex_test_cmd "${__}"; then + ex_log_msg fail "Error: missing prerequisite command \`${__}'."; _exit=1; fi; fi; done; for __ in ${CHECK_PREREQ_PERL_MODULES}; do if ! perl -M"${__}" -e "" 2>/dev/null; then - log_msg fail "Error: missing prerequisite Perl module \`${__}'."; + ex_log_msg fail "Error: missing prerequisite Perl module \`${__}'."; _exit=1; fi; done; diff --git a/subr/pre_setup_env.subr b/subr/ex_setup_env.subr index c1876d31..8907d7eb 100644 --- a/subr/pre_setup_env.subr +++ b/subr/ex_setup_env.subr @@ -1,4 +1,4 @@ -pre_setup_env() { +ex_setup_env() { local __; set -o noglob; if [ -z "${DEFAULT_BUILD_CPUS}" ]\ @@ -13,9 +13,9 @@ pre_setup_env() { else if [ "${BUILD}" != debug ]\ && [ "${BUILD}" != release ]; then - log_msg failexit "Error: unknown build type \`${BUILD}'."; + ex_log_msg failexit "Error: unknown build type \`${BUILD}'."; fi; - log_msg failexit "Error: invalid architecture \`${ARCH}'."; + ex_log_msg failexit "Error: invalid architecture \`${ARCH}'."; fi; for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/env.vars ./vars/build.vars; do [ -e ${__} ] && . ${__}; @@ -27,7 +27,7 @@ pre_setup_env() { DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; fi; for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do - if ! lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then + if ! ex_lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then unset "${__}"; fi; done; diff --git a/subr/pre_subdirs.subr b/subr/ex_setup_subdirs.subr index f40b3ba3..9385a339 100644 --- a/subr/pre_subdirs.subr +++ b/subr/ex_setup_subdirs.subr @@ -2,10 +2,10 @@ # set -o errexit -o noglob are assumed. # -pre_subdirs() { +ex_setup_subdirs() { local __; if [ ${ARG_CLEAN:-0} -eq 1 ]; then - log_msg info "-c specified, cleaning prefix..."; + ex_log_msg info "-c specified, cleaning prefix..."; for __ in ${CLEAR_PREFIX_DIRS}; do if [ -e ${PREFIX}/${__} ]; then build_rm ${PREFIX}/${__}; diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr index 70801628..dd2e8f2e 100644 --- a/subr/pkg_build.subr +++ b/subr/pkg_build.subr @@ -10,7 +10,7 @@ pkg_build() { # N.B. We only specify CC= here if the current package does not use GNU # autoconf as it often abuses it by appending -std={gnu99,...} to it # instead of amending CFLAGS. - run_cmd_unsplit make \ + ex_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_BUILD} \ ${PKG_MAKEFLAGS_BUILD_EXTRA} \ AR=${AR} ${_no_autoconf:+CC=${CC}} RANLIB=${RANLIB} \ diff --git a/subr/pkg_configure_autotools.subr b/subr/pkg_configure_autotools.subr index dbad6a30..6bc7593c 100644 --- a/subr/pkg_configure_autotools.subr +++ b/subr/pkg_configure_autotools.subr @@ -12,7 +12,7 @@ pkg_configure_autotools() { && [ ! -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure" ]; then for _script_fname in bootstrap bootstrap.sh autogen.sh ""; do if [ -z "${_script_fname}" ]; then - (build_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf)\ + (ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf)\ || exit 1 && break; elif [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/${_script_fname}" ]; then for _subdir_tgt in "${PKG_BASE_DIR}/${PKG_SUBDIR}/build-aux" "${PKG_BASE_DIR}/${PKG_SUBDIR}"; do @@ -26,7 +26,7 @@ pkg_configure_autotools() { break; fi; done; - (build_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && \ + (ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && \ "${SHELL}" "${_script_fname}") || exit 1 && break; fi; done; @@ -37,7 +37,7 @@ pkg_configure_autotools() { -exec echo install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" {} \; \ -exec install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" {} \;; if [ "${PKG_BUILD_TYPE}" != host ]; then - build_fileop cp "${MIDIPIX_BUILD_PWD}/etc/config.cache" "${PKG_BUILD_DIR}/"; + ex_build_fileop cp "${MIDIPIX_BUILD_PWD}/etc/config.cache" "${PKG_BUILD_DIR}/"; fi; fi; }; diff --git a/subr/pkg_configure_patch.subr b/subr/pkg_configure_patch.subr index f40d73d7..5dfda784 100644 --- a/subr/pkg_configure_patch.subr +++ b/subr/pkg_configure_patch.subr @@ -6,9 +6,9 @@ pkg_configure_patch() { local _patch_fname _patches_done; set +o noglob; for _patch_fname in \ - ${WORKDIR}/chainport-native-${PKG_TARGET}/chainport/${PKG_NAME}.midipix.patch \ - ${WORKDIR}/chainport-native-${PKG_TARGET}/chainport/${PKG_SUBDIR}.midipix.patch \ - ${WORKDIR}/chainport-native-${PKG_TARGET}/chainport/${PKG_SUBDIR%-*}.midipix.patch \ + ${WORKDIR}/chainport-host-invariants/chainport/${PKG_NAME}.midipix.patch \ + ${WORKDIR}/chainport-host-invariants/chainport/${PKG_SUBDIR}.midipix.patch \ + ${WORKDIR}/chainport-host-invariants/chainport/${PKG_SUBDIR%-*}.midipix.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}/*.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR%-*}/*.patch \ @@ -18,7 +18,7 @@ pkg_configure_patch() { ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local@${BUILD_HNAME}.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR%-*}.local@${BUILD_HNAME}.patch; do - if ! lmatch "${_patches_done}" " " "${_patch_fname}"\ + if ! ex_lmatch "${_patches_done}" " " "${_patch_fname}"\ && [ -r "${_patch_fname}" ]; then patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_patch_fname}"; _patches_done="${_patches_done:+${_patches_done} }${_patch_fname}"; diff --git a/subr/pkg_fetch_distclean.subr b/subr/pkg_fetch_distclean.subr new file mode 100644 index 00000000..19f0b741 --- /dev/null +++ b/subr/pkg_fetch_distclean.subr @@ -0,0 +1,15 @@ +# +# set -o errexit -o noglob are assumed. +# + +pkg_fetch_distclean() { + if [ "$(stat -c %i "${PKG_BASE_DIR}")" \ + != "$(stat -c %i "${WORKDIR}")" ]; then + ex_build_fileop cd "${WORKDIR}"; + ex_build_fileop rm "${PKG_BASE_DIR}"; + ex_build_fileop mkdir "${PKG_BASE_DIR}"; + ex_build_fileop cd "${PKG_BASE_DIR}"; + fi; +}; + +# vim:filetype=sh diff --git a/subr/pkg_fetch_extract.subr b/subr/pkg_fetch_extract.subr index 71155b44..33d450d2 100644 --- a/subr/pkg_fetch_extract.subr +++ b/subr/pkg_fetch_extract.subr @@ -5,7 +5,7 @@ pkg_fetch_extract() { if [ -n "${PKG_URL}" ]\ && [ "${PKG_URL_TYPE:-wget}" = wget ]; then - build_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}"; + ex_build_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}"; if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then bunzip2 -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then diff --git a/subr/pkg_fetch_git.subr b/subr/pkg_fetch_git.subr index 0ff61ae2..8340ca4f 100644 --- a/subr/pkg_fetch_git.subr +++ b/subr/pkg_fetch_git.subr @@ -6,20 +6,20 @@ pkgp_fetch_git() { local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}"; if [ "${ARG_OFFLINE:-0}" -eq 0 ]; then if [ -e "${DLCACHEDIR}/${_subdir}" ]; then - (build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\ + (ex_build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\ git pull origin "${_branch:-main}"); else git clone "${_url}" "${DLCACHEDIR}/${_subdir}"; if [ -n "${_branch}" -a \ \( -z "${_branch#main}" \) -a \ \( -z "${_branch#master}" \) ]; then - (build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\ + (ex_build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\ git checkout -b "${_branch}"); fi; fi; fi; - build_fileop rm "${_tgtdir}/${_subdir}"; - build_fileop cp "${DLCACHEDIR}/${_subdir}" "${_tgtdir}"; + ex_build_fileop rm "${_tgtdir}/${_subdir}"; + ex_build_fileop cp "${DLCACHEDIR}/${_subdir}" "${_tgtdir}"; }; pkgp_fetch_urls_git() { diff --git a/subr/pkg_fetch_subdirs.subr b/subr/pkg_fetch_subdirs.subr index 680871e2..7d097d03 100644 --- a/subr/pkg_fetch_subdirs.subr +++ b/subr/pkg_fetch_subdirs.subr @@ -15,9 +15,9 @@ pkg_fetch_subdirs() { PKG_BUILD_DIR="${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; fi; if [ ! -d "${PKG_BUILD_DIR}" ]; then - build_fileop mkdir "${PKG_BUILD_DIR}"; + ex_build_fileop mkdir "${PKG_BUILD_DIR}"; fi; - build_fileop cd "${PKG_BUILD_DIR}"; + ex_build_fileop cd "${PKG_BUILD_DIR}"; }; # vim:filetype=sh diff --git a/subr/pkg_fetch_wget.subr b/subr/pkg_fetch_wget.subr index 5dd0cc55..731354e8 100644 --- a/subr/pkg_fetch_wget.subr +++ b/subr/pkg_fetch_wget.subr @@ -6,7 +6,7 @@ pkgp_fetch_wget() { local _url="${1}" _sha256sum_src="${2}"; if [ -z "${3}" ]; then - _url_dst="${DLCACHEDIR}/$(basename "${_url}")"; + _url_dst="${DLCACHEDIR}/$(ex_basename "${_url}")"; else _url_dst="${DLCACHEDIR}/${3}"; fi; @@ -20,9 +20,9 @@ pkgp_fetch_wget() { set -- $(openssl dgst -sha256 "${_url_dst}"); shift $((${#}-1)); if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then if [ "${ARG_IGNORE_SHA256SUMS:-0}" -eq 0 ]; then - log_msg failexit "Error: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)"; + ex_log_msg failexit "Error: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)"; else - log_msg warn "Warning: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)"; + ex_log_msg warn "Warning: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)"; fi; fi; fi; diff --git a/subr/pkg_finish.subr b/subr/pkg_finish.subr deleted file mode 100644 index 609f2b6e..00000000 --- a/subr/pkg_finish.subr +++ /dev/null @@ -1,9 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_finish() { - :; -}; - -# vim:filetype=sh diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr index fa890d4d..ca85f4d1 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -6,7 +6,7 @@ pkg_install() { local _dst_path; for _dst_path in "${PKG_PREFIX}" "${PKG_PREFIX_EXTRA}"; do if [ -n "${_dst_path}" ]; then - build_fileop mkdir "${_dst_path}"; + ex_build_fileop mkdir "${_dst_path}"; tar -C "${PKG_DESTDIR}" -cpf - . |\ tar -C "${_dst_path}" -xpf -; fi; diff --git a/subr/pkg_install_files.subr b/subr/pkg_install_files.subr index d82b665d..88acf60d 100644 --- a/subr/pkg_install_files.subr +++ b/subr/pkg_install_files.subr @@ -18,16 +18,16 @@ pkgp_install_files() { _ln_fname="${_prefix:+${_prefix}/}${_ln_fname}"; fi; if [ -e "${_ln_fname}" ]; then - build_fileop rm "${_ln_fname}"; + ex_build_fileop rm "${_ln_fname}"; fi; - build_fileop ln_symbolic "${_ln_target}" "${_ln_fname}"; + ex_build_fileop ln_symbolic "${_ln_target}" "${_ln_fname}"; ;; /=*) _mkdir_fname="${1#/=}"; if [ "${_mkdir_fname#/}" = "${_mkdir_fname}" ]; then _mkdir_fname="${_prefix:+${_prefix}/}${_mkdir_fname}"; fi; - build_fileop mkdir "${_mkdir_fname}"; + ex_build_fileop mkdir "${_mkdir_fname}"; ;; *) _file_fname_src="${1%=*}"; @@ -35,7 +35,7 @@ pkgp_install_files() { if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then _file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}"; fi; - build_fileop cp "${_file_fname_src}" "${_file_fname_dst}"; + ex_build_fileop cp "${_file_fname_src}" "${_file_fname_dst}"; ;; esac; shift; done; diff --git a/subr/pkg_install_libs.subr b/subr/pkg_install_libs.subr index 56152a0c..1894a2d0 100644 --- a/subr/pkg_install_libs.subr +++ b/subr/pkg_install_libs.subr @@ -21,8 +21,8 @@ pkgp_install_lib_link() { sort | tail -1)"; if [ -n "${_lib_link_tgt}" ]; then _lib_link_path="${_so_path%.so*}.lib.a"; - build_fileop rm "${_lib_link_path}"; - build_fileop ln_symbolic "$(basename "${_lib_link_tgt}")" \ + ex_build_fileop rm "${_lib_link_path}"; + ex_build_fileop ln_symbolic "$(ex_basename "${_lib_link_tgt}")" \ "${_lib_link_path}"; fi; }; @@ -40,7 +40,7 @@ pkg_install_libs() { *.so) _lib_src_path="${_so_src_path%%.so}.lib.a"; ;; *.so.*) _lib_src_path="${_so_src_path%%.so.*}.${_so_src_path##*.so.}.lib.a"; ;; esac; - _lib_name="$(basename "${_lib_src_path}")"; + _lib_name="$(ex_basename "${_lib_src_path}")"; _so_dst_dir="${_so_src_path%/*}"; fi; if [ ! -L "${_lib_src_path}" ]; then diff --git a/subr/pkg_install_make.subr b/subr/pkg_install_make.subr index a9841655..8207d7e8 100644 --- a/subr/pkg_install_make.subr +++ b/subr/pkg_install_make.subr @@ -3,7 +3,7 @@ # pkg_install_make() { - run_cmd_unsplit make \ + ex_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_INSTALL} \ ${PKG_MAKEFLAGS_INSTALL_EXTRA} \ AR=${AR} CC=${CC} RANLIB=${RANLIB} \ diff --git a/subr/pkg_install_purge_la.subr b/subr/pkg_install_purge_la.subr index be5ab489..61725673 100644 --- a/subr/pkg_install_purge_la.subr +++ b/subr/pkg_install_purge_la.subr @@ -5,7 +5,7 @@ pkg_install_purge_la() { local _la_path; for _la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do - build_fileop rm ${_la_path}; + ex_build_fileop rm ${_la_path}; done; }; diff --git a/subr/pkg_install_strip.subr b/subr/pkg_install_strip.subr index 53282187..e91e6eaf 100644 --- a/subr/pkg_install_strip.subr +++ b/subr/pkg_install_strip.subr @@ -11,8 +11,8 @@ pkgp_strip_tree() { \( -type f -or -type l \)); do set +o errexit; if objdump -sj .debug_info "${_bin_path}" >/dev/null 2>&1; then - log_msg info "Stripping ${_bin_path}..."; - log_msg vnfo "${TARGET}-strip ${_bin_path}"; + ex_log_msg info "Stripping ${_bin_path}..."; + ex_log_msg vnfo "${TARGET}-strip ${_bin_path}"; ${TARGET}-strip ${_bin_path}; fi; set -o errexit; diff --git a/subr/pkg_setup_distclean.subr b/subr/pkg_setup_distclean.subr deleted file mode 100644 index fc5999c8..00000000 --- a/subr/pkg_setup_distclean.subr +++ /dev/null @@ -1,12 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_setup_distclean() { - if [ "$(stat -c %i "${PKG_BASE_DIR}")" \ - != "$(stat -c %i "${WORKDIR}")" ]; then - build_fileop rm "${PKG_BASE_DIR}"; - fi; -}; - -# vim:filetype=sh diff --git a/subr/pkg_setup_subdirs.subr b/subr/pkg_setup_subdirs.subr deleted file mode 100644 index 1fc279cb..00000000 --- a/subr/pkg_setup_subdirs.subr +++ /dev/null @@ -1,10 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_setup_subdirs() { - build_fileop mkdir "${PKG_BASE_DIR}"; - build_fileop cd "${PKG_BASE_DIR}"; -}; - -# vim:filetype=sh diff --git a/subr/pre_state.subr b/subr/pre_state.subr deleted file mode 100644 index 58bfc59a..00000000 --- a/subr/pre_state.subr +++ /dev/null @@ -1,31 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pre_state() { - case "${1}" in - fini) : $((BUILD_TIMES_SECS=$(command date +%s)-${BUILD_TIMES_SECS})); - : $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600)); - : $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60)); - : $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60)); - if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then - build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME}; - fi; - ;; - init) if [ -e ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then - log_msg failexit "Error: another build targeting this architecture and build type is currently in progress."; - else - touch ${BUILD_STATUS_IN_PROGRESS_FNAME}; - fi; - if [ -e ${BUILD_LOG_FNAME} ]; then - mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME}; - fi; - BUILD_DATE_START="$(date %Y-%m-%d-%H-%M-%S)"; - BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}; - BUILD_TIMES_SECS=$(command date +%s); - BUILD_PKGS_FAILED=""; - ;; - esac; -}; - -# vim:filetype=sh |