From 32ad217d197203a97dfcc0076e748731d2315c0b Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Nov 22 2017 02:35:10 +0000 Subject: subr/*: reorganised as {ex{,_{pkg,rtl,setup}},pkg}_*. --- diff --git a/build.sh b/build.sh index 2057826..c54400a 100755 --- a/build.sh +++ b/build.sh @@ -3,48 +3,50 @@ # for __ in $(find subr -name *.subr); do . "${__}"; done; -pre_setup_args "${@}"; pre_setup_env; pre_check; pre_subdirs; -pre_state init; {( -log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; -log_env_vars "build (global)" ${LOG_ENV_VARS}; -for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do - BUILD_TARGET="$(toupper "${BUILD_TARGET_LC}")"; - BUILD_PACKAGES="$(get_var_unsafe ${BUILD_TARGET}_PACKAGES)"; - if [ "${BUILD_TARGET}" != "INVARIANTS" ]\ - && [ -n "${BUILD_PACKAGES_RESTART}" ]; then - BUILD_PACKAGES="$(lfilter "${BUILD_PACKAGES}" "${BUILD_PACKAGES_RESTART}")"; - fi; - for PKG_NAME in ${BUILD_PACKAGES}; do - pkg_setup_dispatch "${BUILD_TARGET}" "${PKG_NAME}" \ - "${ARG_RESTART}" "${ARG_RESTART_AT}"; - BUILD_SCRIPT_RC=${?}; - case ${BUILD_SCRIPT_RC} in - 0) log_msg succ "Finished \`${PKG_NAME}' build."; - : $((BUILD_NFINI+=1)); continue; ;; - *) log_msg fail "Build failed in \`${PKG_NAME}' (last return code ${BUILD_SCRIPT_RC}.)."; - : $((BUILD_NFAIL+=1)); - if [ ${ARG_RELAXED:-0} -eq 1 ]; then - BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}"; - continue; - else - break; - fi; - esac; +ex_setup_args "${@}"; ex_setup_env; ex_setup_checks; ex_setup_subdirs; +ex_pkg_state_init; {( +ex_log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; +ex_log_env_vars "build (global)" ${LOG_ENV_VARS}; +for BUILD_TARGET_META in invariants ${BUILD_TARGETS_META:-world}; do + for BUILD_TARGET_LC in $(ex_get_var_unsafe "$(ex_toupper "${BUILD_TARGET_META}")_TARGET"); do + BUILD_TARGET="$(ex_toupper "${BUILD_TARGET_LC}")"; + BUILD_PACKAGES="$(ex_get_var_unsafe ${BUILD_TARGET}_PACKAGES)"; + if [ "${BUILD_TARGET}" != "INVARIANTS" ]\ + && [ -n "${BUILD_PACKAGES_RESTART}" ]; then + BUILD_PACKAGES="$(ex_lfilter "${BUILD_PACKAGES}" "${BUILD_PACKAGES_RESTART}")"; + fi; + for PKG_NAME in ${BUILD_PACKAGES}; do + ex_pkg_dispatch "${BUILD_TARGET}" "${PKG_NAME}" \ + "${ARG_RESTART}" "${ARG_RESTART_AT}"; + BUILD_SCRIPT_RC=${?}; + case ${BUILD_SCRIPT_RC} in + 0) ex_log_msg succ "Finished \`${PKG_NAME}' build."; + : $((BUILD_NFINI+=1)); continue; ;; + *) ex_log_msg fail "Build failed in \`${PKG_NAME}' (last return code ${BUILD_SCRIPT_RC}.)."; + : $((BUILD_NFAIL+=1)); + if [ ${ARG_RELAXED:-0} -eq 1 ]; then + BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}"; + continue; + else + break; + fi; + esac; + done; + if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then + break; + fi; done; - if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then - break; - fi; -done; pre_state fini; -log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s)."; -log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s)."; +done; ex_pkg_state_fini; +ex_log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s)."; +ex_log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s)."; if [ ${ARG_RELAXED:-0} -eq 1 ]\ && [ -n "${BUILD_PKGS_FAILED}" ]; then - log_msg info "Build script failure(s) in: ${BUILD_PKGS_FAILED}."; + ex_log_msg info "Build script failure(s) in: ${BUILD_PKGS_FAILED}."; fi; exit "${BUILD_SCRIPT_RC:-0}")} 2>&1 | tee "${BUILD_LOG_FNAME}" & TEE_PID="${!}"; trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \ - log_msg fail \"Build aborted.\"; \ + ex_log_msg fail \"Build aborted.\"; \ echo kill ${TEE_PID}; \ kill ${TEE_PID}" HUP INT TERM USR1 USR2; wait; diff --git a/etc/build.usage b/etc/build.usage index c68dc4c..165f957 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -12,7 +12,7 @@ usage: ./build.sh [-x] [-4|6] [-a nt32|nt64] [-b debug|release] [-c] [-h] -r package[,...][:step] Restart the specified comma-separated build(s) completely or at the optionally specified step. Currently defined steps are: - setup_distclean, fetch_wget, fetch_git, fetch_extract, + fetch_distclean, fetch_wget, fetch_git, fetch_extract, configure_patch_pre, configure_autotools, configure_patch, configure, build_clean, build, install_subdirs, install_make, install_files, install_libs, install_pkgconfig, install_purge_la, diff --git a/subr/build.subr b/subr/build.subr deleted file mode 100644 index 526d9f2..0000000 --- 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/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr new file mode 100644 index 0000000..99c9ff8 --- /dev/null +++ b/subr/ex_pkg_dispatch.subr @@ -0,0 +1,71 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_pkg_dispatch() { + local _tgt_name="${1}" _pkg_name="${2}" \ + _restart="${3}" _restart_at="${4}" \ + _pkg_step_cmds _pkg_step_cmd_args; + if [ "${_pkg_name#*_flavour_*}" != "${_pkg_name}" ]; then + 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" ]\ + || ! 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 + dynamic) + if [ "${_tgt_name}" = "INVARIANTS" ]; then + _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; + elif [ -n "${_restart}" ]; then + if [ -z "${_restart_at}" ]\ + || ex_lmatch "${_restart_at}" , "${1%:*}"; then + _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; + fi; + 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 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 ex_test_cmd "pkg_${_pkg_name}_${1%:*}"; then + "pkg_${_pkg_name}_${1%:*}" "${_restart_at:-ALL}"; + break; + fi; ;; + finish) ex_pkg_state_push "${_pkg_name}" finish; ;; + *) ;; + esac; + for __ in ${_pkg_step_cmds}; do + if ex_test_cmd "${__}"; then + ex_test_cmd "pkg_${_pkg_name}_${1%:*}_pre" \ + && "pkg_${_pkg_name}_${1%:*}_pre" + "${__}" ${_pkg_step_cmd_args}; + ex_test_cmd "pkg_${_pkg_name}_${1%:*}_post" \ + && "pkg_${_pkg_name}_${1%:*}_post" + if [ "${1#*:}" != "invariant" ]\ + && [ ${#} -ge 2 ]; then + ex_pkg_state_push "${_pkg_name}" "${1%:*}" "-${2#*:}"; + else + ex_pkg_state_push "${_pkg_name}" "${1%:*}"; + fi; break; + fi; + done; + shift; done; + fi); return ${?}; +}; + +# vim:filetype=sh diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr new file mode 100644 index 0000000..240c628 --- /dev/null +++ b/subr/ex_pkg_env.subr @@ -0,0 +1,63 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_pkg_env() { + local _vname; + if [ -z "${PKG_URL}" ]\ + && [ -z "${PKG_URLS_GIT}" ]\ + && [ -z "${PKG_VERSION}" ]\ + && ! test_cmd "pkg_${PKG_NAME}_all"; then + ex_log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; + elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then + ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'"; + exit 0; + else + [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; + [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; + [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; + case "${PKG_BASE_DIR}" in + ?*) ;; + *) PKG_BASE_DIR="${WORKDIR}/${PKG_NAME}-${PKG_BUILD_TYPE:-native}-${PKG_TARGET}"; + if [ -n "${ARG_RESTART}" ]\ + && [ -z "${ARG_RESTART_AT}" ]; then + ex_build_fileop rm "${PKG_BASE_DIR}"; + fi; ;; + esac; + PKG_DESTDIR="${PKG_BASE_DIR}/destdir"; + case "${PKG_BUILD_TYPE}" in + host) export AR="ar"; + export CC="gcc"; + export CXX="g++"; + export RANLIB="ranlib"; + export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; + export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; ;; + *) export AR="${PKG_TARGET}-ar"; + export CC="${PKG_TARGET}-gcc"; + export CXX="${PKG_TARGET}-g++"; + export RANLIB="${PKG_TARGET}-ranlib"; + export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; + export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; ;; + esac; + case "${PKG_SUBDIR}" in + ?*) ;; + *) case "${PKG_URLS_GIT}" in + ?*) PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; ;; + *) case "${PKG_FNAME}" in + *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;; + *) PKG_SUBDIR="${PKG_NAME}"; ;; + 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" " ")"; + ex_log_env_vars "build" ${PKG_ENV_VARS}; + fi; +}; + +# vim:filetype=sh diff --git a/subr/ex_pkg_state.subr b/subr/ex_pkg_state.subr new file mode 100644 index 0000000..4cc0a8b --- /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/ex_pkg_vars.subr b/subr/ex_pkg_vars.subr new file mode 100644 index 0000000..07c2cac --- /dev/null +++ b/subr/ex_pkg_vars.subr @@ -0,0 +1,39 @@ +# +# set -o errexit -o noglob are assumed. +# + +exp_pkg_vars() { + local _pkg_name="${1}" _pkg_name_uc _build_uc _vname_dst _vname_src; + _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 "$(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; + done; + done; +}; + +ex_pkg_vars() { + local _vars_path; + for _vars_path in vars/${PKG_NAME}.vars; do + if [ -e "${_vars_path}" ]\ + || [ -L "${_vars_path}" ]; then + . "${_vars_path}"; + fi; + done; + if [ -n "${PKG_NAME_PARENT}" ]; then + exp_pkg_vars "${PKG_NAME_PARENT}"; + fi; + 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 0000000..b014a38 --- /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 0000000..3732ab5 --- /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 0000000..f4e250a --- /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/ex_setup_args.subr b/subr/ex_setup_args.subr new file mode 100644 index 0000000..637a7d3 --- /dev/null +++ b/subr/ex_setup_args.subr @@ -0,0 +1,67 @@ +BUILD_ARGS_SPEC=" + ARG_IPV4_ONLY:-4 + ARG_IPV6_ONLY:-6 + ARCH:arg:-a + BUILD:arg:-b + ARG_CLEAN:-c + ARG_DEBUG_MINIPIX:--debug-minipix + ARG_IGNORE_SHA256SUMS:-i + ARG_OFFLINE:-N + ARG_RELAXED:-R + ARG_RESTART:arg:-r + ARG_TARBALL:selfarg:-t + ARG_TARBALL:selfarg:-t.bz2 + ARG_TARBALL:selfarg:-t.gz + ARG_TARBALL:selfarg:-t.xz + ARG_VERBOSE:-v + ARG_XTRACE:-x"; + +ex_setup_args() { + local _spec="${BUILD_ARGS_SPEC}" _spec_arg _found; + while [ ${#} -gt 0 ]; do + if [ "${1#-}" = "${1}" ]; then + break; + fi; + for _spec_arg in ${_spec}; do + case "${_spec_arg}" in + *:${1}) case "${_spec_arg#*:}" in + arg:*) + ex_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;; + selfarg:*) + ex_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;; + *) + ex_set_var_unsafe "${_spec_arg%%:*}" 1; ;; + esac; _found=1; break; ;; + *) _found=0; ;; + esac; + done; + if [ "${_found:-0}" -eq 0 ]; then + exec cat etc/build.usage; + else + shift; + fi; + done; + if [ -n "${ARG_TARBALL}" ]; then + if [ "${ARG_TARBALL#-t.}" != "${ARG_TARBALL}" ]; then + TARBALL_SUFFIX="${ARG_TARBALL#-t.}"; + else + TARBALL_SUFFIX=xz; + fi; + fi; + if [ "${ARG_XTRACE:-0}" -eq 1 ]; then + set -o xtrace; + fi; + if [ -n "${ARG_RESTART}" ]; then + if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then + ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}"; + fi; + BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")"; + fi; + while [ ${#} -gt 0 ]; do + case "${1}" in + *=*) ex_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; + *) BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;; + esac; shift; done; +}; + +# vim:filetype=sh diff --git a/subr/ex_setup_checks.subr b/subr/ex_setup_checks.subr new file mode 100644 index 0000000..803810d --- /dev/null +++ b/subr/ex_setup_checks.subr @@ -0,0 +1,38 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_setup_checks() { + local __ _exit; + for __ in ${CHECK_PATH_VARS}; do + if [ -z "${___:=$(ex_get_var_unsafe "${__}")}" ]; then + ex_log_msg failexit "Error: variable \`${__}' is empty or unset."; + elif [ "${___#* *}" != "${___}" ]; then + 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 + ex_log_msg fail "Error: missing prerequisite file \`${__}'."; + _exit=1; + fi; + else + 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 + ex_log_msg fail "Error: missing prerequisite Perl module \`${__}'."; + _exit=1; + fi; + done; + if [ ${_exit:-0} = 1 ]; then + exit 1; + fi; +}; + +# vim:filetype=sh diff --git a/subr/ex_setup_env.subr b/subr/ex_setup_env.subr new file mode 100644 index 0000000..8907d7e --- /dev/null +++ b/subr/ex_setup_env.subr @@ -0,0 +1,36 @@ +ex_setup_env() { + local __; + set -o noglob; + if [ -z "${DEFAULT_BUILD_CPUS}" ]\ + && [ -e /proc/cpuinfo ]; then + DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo); + fi; + : ${ARCH:=nt64}; : ${BUILD:=debug}; + if [ "${ARCH}" = nt32 ]; then + TARGET="i686-nt32-midipix"; + elif [ "${ARCH}" = nt64 ]; then + TARGET="x86_64-nt64-midipix"; + else + if [ "${BUILD}" != debug ]\ + && [ "${BUILD}" != release ]; then + ex_log_msg failexit "Error: unknown build type \`${BUILD}'."; + fi; + 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 ${__} ] && . ${__}; + done; + export PATH="${PREFIX}/bin${PATH:+:${PATH}}"; + if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then + DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; + elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then + DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; + fi; + for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do + if ! ex_lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then + unset "${__}"; + fi; + done; +}; + +# vim:filetype=sh diff --git a/subr/ex_setup_subdirs.subr b/subr/ex_setup_subdirs.subr new file mode 100644 index 0000000..9385a33 --- /dev/null +++ b/subr/ex_setup_subdirs.subr @@ -0,0 +1,41 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_setup_subdirs() { + local __; + if [ ${ARG_CLEAN:-0} -eq 1 ]; then + ex_log_msg info "-c specified, cleaning prefix..."; + for __ in ${CLEAR_PREFIX_DIRS}; do + if [ -e ${PREFIX}/${__} ]; then + build_rm ${PREFIX}/${__}; + fi; + done; + fi; + pkg_install_files "" \ + /=${DLCACHEDIR} \ + /=${WORKDIR} \ + /=${PREFIX} \ + /=${PREFIX}/bin \ + /=${PREFIX}/share/man \ + /=${PREFIX}/${TARGET}/bin \ + /=${PREFIX}/${TARGET}/lib \ + /=${PREFIX}/x86_64-w64-mingw32 \ + /=${PREFIX_CROSS} \ + /=${PREFIX_MINIPIX}/bin \ + /=${PREFIX_NATIVE} \ + /=${PREFIX_NATIVE}/share/man \ + /=${PREFIX_NATIVE}/${TARGET}/lib \ + @.=${PREFIX}/usr \ + @.=${PREFIX}/x86_64-w64-mingw32/mingw \ + /=${PREFIX}/x86_64-w64-mingw32/mingw/include \ + @.=${PREFIX_NATIVE}/usr \ + @lib=${PREFIX}/lib64 \ + @bin=${PREFIX_MINIPIX}/lib \ + @bin=${PREFIX_MINIPIX}/libexec \ + @bin=${PREFIX_MINIPIX}/share \ + @share/man=${PREFIX}/man \ + @share/man=${PREFIX_NATIVE}/man; +}; + +# vim:filetype=sh diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr index 7080162..dd2e8f2 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 dbad6a3..6bc7593 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 f40d73d..5dfda78 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 0000000..19f0b74 --- /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 71155b4..33d450d 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 0ff61ae..8340ca4 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 680871e..7d097d0 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 5dd0cc5..731354e 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 609f2b6..0000000 --- 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 fa890d4..ca85f4d 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 d82b665..88acf60 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 56152a0..1894a2d 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 a984165..8207d7e 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 be5ab48..6172567 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 5328218..e91e6ea 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_dispatch.subr b/subr/pkg_setup_dispatch.subr deleted file mode 100644 index c448257..0000000 --- a/subr/pkg_setup_dispatch.subr +++ /dev/null @@ -1,67 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_setup_dispatch() { - local _tgt_name="${1}" _pkg_name="${2}" \ - _restart="${3}" _restart_at="${4}" \ - _pkg_step_cmds _pkg_step_cmd_args; - if [ "${_pkg_name#*_flavour_*}" != "${_pkg_name}" ]; then - PKG_NAME_PARENT="${_pkg_name%_flavour_*}"; - fi; - (set -o errexit -o noglob; - 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)"); - while [ ${#} -gt 0 ]; do - _pkg_step_cmds=""; _pkg_step_cmd_args=""; - case "${1#*:}" in - dynamic) - if [ "${_tgt_name}" = "INVARIANTS" ]; then - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; - elif [ -n "${_restart}" ]; then - if [ -z "${_restart_at}" ]\ - || lmatch "${_restart_at}" , "${1%:*}"; then - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; - fi; - elif ! is_build_script_done "${_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 - _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 - "pkg_${_pkg_name}_${1%:*}" "${_restart_at:-ALL}"; - break; - fi; ;; - *) break; ;; - esac; - for __ in ${_pkg_step_cmds}; do - if test_cmd "${__}"; then - test_cmd "pkg_${_pkg_name}_${1%:*}_pre" \ - && "pkg_${_pkg_name}_${1%:*}_pre" - "${__}" ${_pkg_step_cmd_args}; - test_cmd "pkg_${_pkg_name}_${1%:*}_post" \ - && "pkg_${_pkg_name}_${1%:*}_post" - if [ "${1#*:}" != "always" ]\ - && [ ${#} -ge 2 ]; then - set_build_script_done "${_pkg_name}" "${1%:*}" "-${2#*:}"; - else - set_build_script_done "${_pkg_name}" "${1%:*}"; - fi; break; - fi; - done; - shift; done; - fi); return ${?}; -}; - -# vim:filetype=sh diff --git a/subr/pkg_setup_distclean.subr b/subr/pkg_setup_distclean.subr deleted file mode 100644 index fc5999c..0000000 --- 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_env.subr b/subr/pkg_setup_env.subr deleted file mode 100644 index f8d720d..0000000 --- a/subr/pkg_setup_env.subr +++ /dev/null @@ -1,60 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_setup_env() { - 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."; - elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then - 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 - ?*) ;; - *) 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}"; - fi; ;; - esac; - PKG_DESTDIR="${PKG_BASE_DIR}/destdir"; - case "${PKG_BUILD_TYPE}" in - host) export AR="ar"; - export CC="gcc"; - export CXX="g++"; - export RANLIB="ranlib"; - export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; - export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; ;; - *) export AR="${PKG_TARGET}-ar"; - export CC="${PKG_TARGET}-gcc"; - export CXX="${PKG_TARGET}-g++"; - export RANLIB="${PKG_TARGET}-ranlib"; - export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; - export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; ;; - esac; - case "${PKG_SUBDIR}" in - ?*) ;; - *) case "${PKG_URLS_GIT}" in - ?*) PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; ;; - *) case "${PKG_FNAME}" in - *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;; - *) PKG_SUBDIR="${PKG_NAME}"; ;; - esac; ;; - esac; ;; - esac; - 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}; - fi; -}; - -# vim:filetype=sh diff --git a/subr/pkg_setup_subdirs.subr b/subr/pkg_setup_subdirs.subr deleted file mode 100644 index 1fc279c..0000000 --- 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/pkg_setup_vars.subr b/subr/pkg_setup_vars.subr deleted file mode 100644 index fc9f853..0000000 --- a/subr/pkg_setup_vars.subr +++ /dev/null @@ -1,39 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkgp_setup_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}")"; - 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 - PKG_ENV_VARS="${PKG_ENV_VARS:+${PKG_ENV_VARS} }${_vname_src}"; - fi; - fi; - done; - done; -}; - -pkg_setup_vars() { - local _vars_path; - for _vars_path in vars/${PKG_NAME}.vars; do - if [ -e "${_vars_path}" ]\ - || [ -L "${_vars_path}" ]; then - . "${_vars_path}"; - fi; - done; - if [ -n "${PKG_NAME_PARENT}" ]; then - pkgp_setup_pkg_vars "${PKG_NAME_PARENT}"; - fi; - pkgp_setup_pkg_vars "${PKG_NAME}"; -}; - -# vim:filetype=sh diff --git a/subr/pre_check.subr b/subr/pre_check.subr deleted file mode 100644 index 28e229e..0000000 --- a/subr/pre_check.subr +++ /dev/null @@ -1,38 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pre_check() { - local __ _exit; - for __ in ${CHECK_PATH_VARS}; do - if [ -z "${___:=$(get_var_unsafe "${__}")}" ]; then - log_msg failexit "Error: variable \`${__}' is empty or unset."; - elif [ "${___#* *}" != "${___}" ]; then - 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 \`${__}'."; - _exit=1; - fi; - else - if ! test_cmd "${__}"; then - 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 \`${__}'."; - _exit=1; - fi; - done; - if [ ${_exit:-0} = 1 ]; then - exit 1; - fi; -}; - -# vim:filetype=sh diff --git a/subr/pre_setup_args.subr b/subr/pre_setup_args.subr deleted file mode 100644 index e9c10a5..0000000 --- a/subr/pre_setup_args.subr +++ /dev/null @@ -1,67 +0,0 @@ -BUILD_ARGS_SPEC=" - ARG_IPV4_ONLY:-4 - ARG_IPV6_ONLY:-6 - ARCH:arg:-a - BUILD:arg:-b - ARG_CLEAN:-c - ARG_DEBUG_MINIPIX:--debug-minipix - ARG_IGNORE_SHA256SUMS:-i - ARG_OFFLINE:-N - ARG_RELAXED:-R - ARG_RESTART:arg:-r - ARG_TARBALL:selfarg:-t - ARG_TARBALL:selfarg:-t.bz2 - ARG_TARBALL:selfarg:-t.gz - ARG_TARBALL:selfarg:-t.xz - ARG_VERBOSE:-v - ARG_XTRACE:-x"; - -pre_setup_args() { - local _spec="${BUILD_ARGS_SPEC}" _spec_arg _found; - while [ ${#} -gt 0 ]; do - if [ "${1#-}" = "${1}" ]; then - break; - fi; - for _spec_arg in ${_spec}; do - case "${_spec_arg}" in - *:${1}) case "${_spec_arg#*:}" in - arg:*) - set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;; - selfarg:*) - set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;; - *) - set_var_unsafe "${_spec_arg%%:*}" 1; ;; - esac; _found=1; break; ;; - *) _found=0; ;; - esac; - done; - if [ "${_found:-0}" -eq 0 ]; then - exec cat etc/build.usage; - else - shift; - fi; - done; - if [ -n "${ARG_TARBALL}" ]; then - if [ "${ARG_TARBALL#-t.}" != "${ARG_TARBALL}" ]; then - TARBALL_SUFFIX="${ARG_TARBALL#-t.}"; - else - TARBALL_SUFFIX=xz; - fi; - fi; - if [ "${ARG_XTRACE:-0}" -eq 1 ]; then - set -o xtrace; - fi; - if [ -n "${ARG_RESTART}" ]; then - if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then - ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}"; - fi; - BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")"; - fi; - while [ ${#} -gt 0 ]; do - case "${1}" in - *=*) set_var_unsafe "${1%%=*}" "${1#*=}"; ;; - *) BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;; - esac; shift; done; -}; - -# vim:filetype=sh diff --git a/subr/pre_setup_env.subr b/subr/pre_setup_env.subr deleted file mode 100644 index c1876d3..0000000 --- a/subr/pre_setup_env.subr +++ /dev/null @@ -1,36 +0,0 @@ -pre_setup_env() { - local __; - set -o noglob; - if [ -z "${DEFAULT_BUILD_CPUS}" ]\ - && [ -e /proc/cpuinfo ]; then - DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo); - fi; - : ${ARCH:=nt64}; : ${BUILD:=debug}; - if [ "${ARCH}" = nt32 ]; then - TARGET="i686-nt32-midipix"; - elif [ "${ARCH}" = nt64 ]; then - TARGET="x86_64-nt64-midipix"; - else - if [ "${BUILD}" != debug ]\ - && [ "${BUILD}" != release ]; then - log_msg failexit "Error: unknown build type \`${BUILD}'."; - fi; - 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 ${__} ] && . ${__}; - done; - export PATH="${PREFIX}/bin${PATH:+:${PATH}}"; - if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then - DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; - elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then - 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 - unset "${__}"; - fi; - done; -}; - -# vim:filetype=sh diff --git a/subr/pre_state.subr b/subr/pre_state.subr deleted file mode 100644 index 58bfc59..0000000 --- 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 diff --git a/subr/pre_subdirs.subr b/subr/pre_subdirs.subr deleted file mode 100644 index f40b3ba..0000000 --- a/subr/pre_subdirs.subr +++ /dev/null @@ -1,41 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pre_subdirs() { - local __; - if [ ${ARG_CLEAN:-0} -eq 1 ]; then - log_msg info "-c specified, cleaning prefix..."; - for __ in ${CLEAR_PREFIX_DIRS}; do - if [ -e ${PREFIX}/${__} ]; then - build_rm ${PREFIX}/${__}; - fi; - done; - fi; - pkg_install_files "" \ - /=${DLCACHEDIR} \ - /=${WORKDIR} \ - /=${PREFIX} \ - /=${PREFIX}/bin \ - /=${PREFIX}/share/man \ - /=${PREFIX}/${TARGET}/bin \ - /=${PREFIX}/${TARGET}/lib \ - /=${PREFIX}/x86_64-w64-mingw32 \ - /=${PREFIX_CROSS} \ - /=${PREFIX_MINIPIX}/bin \ - /=${PREFIX_NATIVE} \ - /=${PREFIX_NATIVE}/share/man \ - /=${PREFIX_NATIVE}/${TARGET}/lib \ - @.=${PREFIX}/usr \ - @.=${PREFIX}/x86_64-w64-mingw32/mingw \ - /=${PREFIX}/x86_64-w64-mingw32/mingw/include \ - @.=${PREFIX_NATIVE}/usr \ - @lib=${PREFIX}/lib64 \ - @bin=${PREFIX_MINIPIX}/lib \ - @bin=${PREFIX_MINIPIX}/libexec \ - @bin=${PREFIX_MINIPIX}/share \ - @share/man=${PREFIX}/man \ - @share/man=${PREFIX_NATIVE}/man; -}; - -# vim:filetype=sh diff --git a/vars/build.vars b/vars/build.vars index b42b68e..a792d3d 100644 --- a/vars/build.vars +++ b/vars/build.vars @@ -1,6 +1,7 @@ # # Build target invariants # +INVARIANTS_BUILD_TYPE="host"; INVARIANTS_PACKAGES="chainport"; : ${PKG_CHAINPORT_URLS_GIT:="chainport=${DEFAULT_GITROOT}/ports/chainport"}; : ${PKG_CHAINPORT_BUILD_STEPS_DISABLE:="configure:dynamic build:dynamic install_make:dynamic install:dynamic"}; @@ -949,6 +950,7 @@ DIST_PACKAGES="dist_etc dist_digest dist_tarballs"; # # Build meta-targets # +INVARIANTS_TARGET="invariants"; DEVROOT_TARGET="host_toolchain native_toolchain runtime"; DEV_TARGET="${DEVROOT_TARGET} dev_packages"; WORLD_TARGET="${DEVROOT_TARGET} host_packages lib_packages leaf_packages minipix dist"; diff --git a/vars/clang_host.vars b/vars/clang_host.vars index 06bf200..01413be 100644 --- a/vars/clang_host.vars +++ b/vars/clang_host.vars @@ -3,10 +3,10 @@ # pkg_clang_host_configure() { - build_fileop rm "../cfe-${PKG_VERSION}-host"; - build_fileop mkdir "../cfe-${PKG_VERSION}-host"; - build_fileop cd "../cfe-${PKG_VERSION}-host"; - log_msg info "Bootstrapping clang_host..."; + ex_build_fileop rm "../cfe-${PKG_VERSION}-host"; + ex_build_fileop mkdir "../cfe-${PKG_VERSION}-host"; + ex_build_fileop cd "../cfe-${PKG_VERSION}-host"; + ex_log_msg info "Bootstrapping clang_host..."; ("${PREFIX}/bin/cmake" \ "../cfe-${PKG_VERSION}.src" \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \ @@ -19,7 +19,7 @@ pkg_clang_host_configure() { -DLLVM_PREFIX="${PKG_PREFIX}" \ -G "Unix Makefiles" \ -Wno-dev); - log_msg info "Finished bootstrapping clang_host."; + ex_log_msg info "Finished bootstrapping clang_host."; }; # vim:filetype=sh diff --git a/vars/cmake.vars b/vars/cmake.vars index de8aa90..2c8d19d 100644 --- a/vars/cmake.vars +++ b/vars/cmake.vars @@ -3,7 +3,7 @@ # pkg_cmake_configure() { - build_fileop cp "${PREFIX}/share/cmake-${PKG_VERSION%.*}/Modules/Platform/BSDOS.cmake" \ + ex_build_fileop cp "${PREFIX}/share/cmake-${PKG_VERSION%.*}/Modules/Platform/BSDOS.cmake" \ "${PREFIX}/share/cmake-${PKG_VERSION%.*}/Modules/Platform/Midipix.cmake"; rm -f config.cache; env CFLAGS="-L${PKG_PREFIX}/lib --sysroot=${PKG_PREFIX}" \ diff --git a/vars/dist_digest.vars b/vars/dist_digest.vars index 5d28af3..de94df7 100644 --- a/vars/dist_digest.vars +++ b/vars/dist_digest.vars @@ -5,9 +5,9 @@ pkg_dist_digest_all() { local __; if [ -n "${ARG_TARBALL}" ]; then - log_msg info "Compiling SHA256 sums..."; + ex_log_msg info "Compiling SHA256 sums..."; if [ -e "${PREFIX}/SHA256SUMS" ]; then - build_fileop mv "${PREFIX}/SHA256SUMS" "${PREFIX}/SHA256SUMS.last"; + ex_build_fileop mv "${PREFIX}/SHA256SUMS" "${PREFIX}/SHA256SUMS.last"; fi; (cd "${PREFIX}"; for __ in $(find "${PREFIX_NATIVE#${PREFIX}/}" -type f -perm /a=x \ diff --git a/vars/dist_tarballs.vars b/vars/dist_tarballs.vars index 43f5218..f39ac17 100644 --- a/vars/dist_tarballs.vars +++ b/vars/dist_tarballs.vars @@ -11,12 +11,12 @@ pkgp_dist_tarball_dist() { -not -path ./tmp -not -path ./tmp/\*) \ midipix_shortcut.vbs midipix.sh README SHA256SUMS |\ "${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_FNAME}"; - log_msg info "Finished building binary distribution tarball."; + ex_log_msg info "Finished building binary distribution tarball."; if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SIGN_GPG_KEY}" ] && \ gpg --list-keys "${TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then gpg --armor --passphrase-file /dev/null \ --local-user "${TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_FNAME}"; - log_msg info "Signed binary distribution tarball."; + ex_log_msg info "Signed binary distribution tarball."; fi; }; @@ -24,12 +24,12 @@ pkgp_dist_tarball_toolchain() { TARBALL_CROSS_FNAME="${TARBALL_CROSS_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${TARBALL_SUFFIX}"; tar -cpf - bin include lib lib64 libexec share "${TARGET}" |\ "${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_CROSS_FNAME}"; - log_msg info "Finished building toolchain tarball."; + ex_log_msg info "Finished building toolchain tarball."; if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SIGN_GPG_KEY}" ] && \ gpg --list-keys "${TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then gpg --armor --passphrase-file /dev/null \ --local-user "${TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_CROSS_FNAME}"; - log_msg info "Signed toolchain tarball."; + ex_log_msg info "Signed toolchain tarball."; fi; }; @@ -38,36 +38,36 @@ pkgp_dist_tarball_minipix() { tar -cpf - minipix \ midipix_shortcut.vbs midipix.sh README |\ "${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_MINIPIX_FNAME}"; - log_msg info "Finished building binary Minipix distribution tarball."; + ex_log_msg info "Finished building binary Minipix distribution tarball."; if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SIGN_GPG_KEY}" ] && \ gpg --list-keys "${TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then gpg --armor --passphrase-file /dev/null \ --local-user "${TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_MINIPIX_FNAME}"; - log_msg info "Signed binary Minipix distribution tarball."; + ex_log_msg info "Signed binary Minipix distribution tarball."; fi; }; pkgp_dist_tarball_src() { TARBALL_SRC_FNAME="${TARBALL_SRC_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${TARBALL_SUFFIX}"; - log_msg info "Building source tarball..."; + ex_log_msg info "Building source tarball..."; tar -cpf - $(find tmp -mindepth 2 -maxdepth 2 \ -not -path tmp/.\* \ -not -path tmp/ntctty/.git \ -not -path tmp/psxscl/.git \ -not -path tmp/ptycon/.git) |\ "${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_SRC_FNAME}"; - log_msg info "Finished building source tarball."; + ex_log_msg info "Finished building source tarball."; if [ -x "$(which gpg 2>/dev/null)" -a -n "${TARBALL_SIGN_GPG_KEY}" ] && \ gpg --list-keys "${TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then gpg --armor --passphrase-file /dev/null \ --local-user "${TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_SRC_FNAME}"; - log_msg info "Signed source tarball."; + ex_log_msg info "Signed source tarball."; fi; }; pkg_dist_tarballs_all() { if [ -n "${ARG_TARBALL}" ]; then - log_msg info "Building distribution tarballs..."; + ex_log_msg info "Building distribution tarballs..."; case "${TARBALL_SUFFIX}" in bz2) if [ -n "$(which pbzip2 2>/dev/null)" ]; then TARBALL_COMPRESS_CMD="pbzip2"; @@ -81,9 +81,9 @@ pkg_dist_tarballs_all() { fi; ;; xz) TARBALL_COMPRESS_CMD="xz"; TARBALL_COMPRESS_ARGS="-T0"; ;; - *) log_msg failexit "Unknown tarball suffix \`.${TARBALL_SUFFIX}'."; + *) ex_log_msg failexit "Unknown tarball suffix \`.${TARBALL_SUFFIX}'."; esac; - build_fileop cd "${PREFIX}"; PREFIX_BASENAME="${PREFIX_NATIVE##*/}"; + ex_build_fileop cd "${PREFIX}"; PREFIX_BASENAME="${PREFIX_NATIVE##*/}"; pkgp_dist_tarball_dist; pkgp_dist_tarball_toolchain; pkgp_dist_tarball_minipix; if [ "${BUILD}" = "debug" ]; then pkgp_dist_tarball_src; diff --git a/vars/env.vars b/vars/env.vars index 0ed6175..cac525c 100644 --- a/vars/env.vars +++ b/vars/env.vars @@ -16,14 +16,13 @@ : ${PREFIX_CROSS:=${PREFIX}/${TARGET}}; : ${DLCACHEDIR:=${PREFIX_ROOT}/dlcache}; : ${WORKDIR:=${PREFIX}/tmp}; -: ${BUILD_STEPS:="setup_vars:invariant setup_env:invariant setup_distclean:variant setup_subdirs:invariant - all:all - fetch_wget:dynamic fetch_git:dynamic fetch_extract:dynamic fetch_subdirs:invariant fetch:virtual +: ${BUILD_STEPS:="all:all + fetch_distclean:variant fetch_wget:dynamic fetch_git:dynamic fetch_extract:dynamic fetch_subdirs:invariant fetch:virtual configure_patch_pre:dynamic configure_autotools:dynamic configure_patch:dynamic configure:dynamic build_clean:variant build:dynamic install_subdirs:dynamic install_make:dynamic install_files:dynamic install_libs:dynamic install_pkgconfig:dynamic install_purge_la:dynamic install_strip:dynamic install:dynamic - finish:invariant"}; + finish:finish"}; : ${PKG_BUILD_VARS:="BASE_DIR BUILD_DIR BUILD_STEPS_DISABLE BUILD_TYPE CFLAGS_BUILD_EXTRA CFLAGS_CONFIGURE CFLAGS_CONFIGURE_EXTRA CFLAGS_INSTALL_EXTRA CONFIGURE CONFIGURE_ARGS @@ -45,10 +44,10 @@ : ${DEFAULT_CFLAGS_RELEASE:="-g0 -O2"}; : ${DEFAULT_CFLAGS_RELEASE_HOST:="-g0 -O2"}; : ${DEFAULT_CFLAGS_RELEASE_RUNTIME:="-g0 -O2"}; -: ${DEFAULT_CFLAGS:=$(get_var_unsafe "DEFAULT_CFLAGS_$(toupper "${BUILD}")")}; +: ${DEFAULT_CFLAGS:=$(ex_get_var_unsafe "DEFAULT_CFLAGS_$(ex_toupper "${BUILD}")")}; : ${DEFAULT_CFLAGS_CONFIGURE:=${DEFAULT_CFLAGS}}; -: ${DEFAULT_CFLAGS_HOST:=$(get_var_unsafe "DEFAULT_CFLAGS_$(toupper "${BUILD}")_HOST")}; -: ${DEFAULT_CFLAGS_RUNTIME:=$(get_var_unsafe "DEFAULT_CFLAGS_$(toupper "${BUILD}")_RUNTIME")}; +: ${DEFAULT_CFLAGS_HOST:=$(ex_get_var_unsafe "DEFAULT_CFLAGS_$(ex_toupper "${BUILD}")_HOST")}; +: ${DEFAULT_CFLAGS_RUNTIME:=$(ex_get_var_unsafe "DEFAULT_CFLAGS_$(ex_toupper "${BUILD}")_RUNTIME")}; : ${DEFAULT_GITROOT:=git://midipix.org}; : ${DEFAULT_GITROOT_HEAD:=git://midipix.org}; : ${DEFAULT_MAKE_INSTALL_VNAME:=DESTDIR}; diff --git a/vars/gcc.vars b/vars/gcc.vars index 5391aee..277ba8a 100644 --- a/vars/gcc.vars +++ b/vars/gcc.vars @@ -39,9 +39,9 @@ pkgp_gcc_setup_env() { }; pkgp_gcc_configure() { - build_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; - build_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; - build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_build_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_build_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; "../cbb-gcc-${PKG_GCC_VERSION}/configure" "${@}"\ --disable-bootstrap \ --disable-libmudflap \ @@ -64,7 +64,7 @@ pkgp_gcc_configure() { --enable-threads=posix \ --target="${PKG_TARGET}" \ --with-fpmath=sse; - set_build_script_done "${PKG_NAME}" configure -build; + ex_pkg_state_push "${PKG_NAME}" configure -build; }; pkg_gcc_stage1_cross_x86_64_w64_mingw32_all() { @@ -84,33 +84,33 @@ pkg_gcc_stage1_all() { case "${PKG_NAME}" in gcc_stage1) PKG_GCC_VERSION="${PKG_GCC_STAGE1_VERSION}"; - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" cross; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_VERSION}" cross; ;; gcc_stage1_cross_x86_64_w64_mingw32) PKG_GCC_VERSION="${PKG_GCC_STAGE1_CROSS_X86_64_W64_MINGW32_VERSION}"; - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" cross; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_VERSION}" cross; ;; gcc_stage1_native_x86_64_w64_mingw32) PKG_GCC_VERSION="${PKG_GCC_STAGE1_NATIVE_X86_64_W64_MINGW32_VERSION}"; - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" native; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_VERSION}" native; ;; esac; # GCC, stage1. - if ! is_build_script_done "${PKG_NAME}" fetch "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then pkg_fetch_git "cbb-gcc-${PKG_GCC_VERSION}=${DEFAULT_GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION}"; - set_build_script_done "${PKG_NAME}" fetch -patch; + ex_pkg_state_push "${PKG_NAME}" fetch -patch; fi; - if ! is_build_script_done "${PKG_NAME}" patch "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then if [ -e "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" ]; then patch -b -d "${PKG_BASE_DIR}" -p0 < "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch"; fi; - set_build_script_done "${PKG_NAME}" patch -configure; + ex_pkg_state_push "${PKG_NAME}" patch -configure; fi; pkgp_gcc_setup_env "${PKG_GCC_VERSION}"; - if ! is_build_script_done "${PKG_NAME}" configure "${_restart_at}"; then - build_fileop mkdir "${PKG_PREFIX}/include"; + if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then + ex_build_fileop mkdir "${PKG_PREFIX}/include"; [ \! -d "${PKG_PREFIX}/usr" ] && \ - build_fileop ln_symbolic . "${PKG_PREFIX}/usr"; + ex_build_fileop ln_symbolic . "${PKG_PREFIX}/usr"; case "${PKG_NAME}" in gcc_stage1) pkgp_gcc_configure \ @@ -137,13 +137,13 @@ pkg_gcc_stage1_all() { --without-headers; ;; esac; else - build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; fi; - if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-gcc; - set_build_script_done "${PKG_NAME}" build -install; + ex_pkg_state_push "${PKG_NAME}" build -install; fi; - if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then case "${PKG_NAME}" in gcc_stage1) make ${PKG_MAKEFLAGS_BUILD} install-gcc; ;; @@ -154,10 +154,10 @@ pkg_gcc_stage1_all() { esac; __="$(uname -s)"; if [ "${__#*CYGWIN*}" != "${__}" ]; then - build_fileop ln_symbolic "${PREFIX}/libexec/gcc/${PKG_TARGET}/${PKG_GCC_VERSION}/liblto_plugin.dll.a" \ - build_fileop ln_symbolic "${PREFIX}/libexec/gcc/${PKG_TARGET}/${PKG_GCC_VERSION}/liblto_plugin.so"; + ex_build_fileop ln_symbolic "${PREFIX}/libexec/gcc/${PKG_TARGET}/${PKG_GCC_VERSION}/liblto_plugin.dll.a" \ + ex_build_fileop ln_symbolic "${PREFIX}/libexec/gcc/${PKG_TARGET}/${PKG_GCC_VERSION}/liblto_plugin.so"; fi; - set_build_script_done "${PKG_NAME}" install finish; + ex_pkg_state_push "${PKG_NAME}" install finish; fi; exit 0; }; @@ -165,16 +165,16 @@ pkg_gcc_stage1_all() { pkg_gcc_runtime_all() { local _restart_at="${1}"; export MAKE="make LIBTOOL=slibtool"; - set_build_dir "cbb-gcc-${PKG_GCC_RUNTIME_VERSION}" cross; - build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_RUNTIME_VERSION}" cross; + ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; # GCC, compiler runtime. - if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-target-libgcc; - set_build_script_done "${PKG_NAME}" build -install; + ex_pkg_state_push "${PKG_NAME}" build -install; fi; - if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} install-target-libgcc; - set_build_script_done "${PKG_NAME}" install finish; + ex_pkg_state_push "${PKG_NAME}" install finish; fi; exit 0; }; @@ -182,16 +182,16 @@ pkg_gcc_runtime_all() { pkg_gcc_libstdcpp_v3_all() { local _restart_at="${1}"; export MAKE="make LIBTOOL=slibtool"; - set_build_dir "cbb-gcc-${PKG_GCC_LIBSTDCPP_V3_VERSION}" cross; - build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_LIBSTDCPP_V3_VERSION}" cross; + ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; # GCC, libstdc++-v3. - if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-target-libstdc++-v3; - set_build_script_done "${PKG_NAME}" build -install; + ex_pkg_state_push "${PKG_NAME}" build -install; fi; - if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} install-target-libstdc++-v3; - set_build_script_done "${PKG_NAME}" install finish; + ex_pkg_state_push "${PKG_NAME}" install finish; fi; exit 0; }; @@ -199,16 +199,16 @@ pkg_gcc_libstdcpp_v3_all() { pkg_gcc_full_all() { local _restart_at="${1}"; export MAKE="make LIBTOOL=slibtool"; - set_build_dir "cbb-gcc-${PKG_GCC_FULL_VERSION}" cross; - build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_FULL_VERSION}" cross; + ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; # GCC, everything else. - if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD}; - set_build_script_done "${PKG_NAME}" build -install; + ex_pkg_state_push "${PKG_NAME}" build -install; fi; - if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} install; - set_build_script_done "${PKG_NAME}" install finish; + ex_pkg_state_push "${PKG_NAME}" install finish; fi; exit 0; }; @@ -218,12 +218,12 @@ pkg_gcc_native_all() { PKG_GCC_VERSION="${PKG_GCC_NATIVE_VERSION}"; export MAKE="make LIBTOOL=slibtool"; # GCC, native. - set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" native; + ex_pkg_state_build_dir "cbb-gcc-${PKG_GCC_VERSION}" native; pkgp_gcc_setup_env "${PKG_GCC_VERSION}"; - if ! is_build_script_done "${PKG_NAME}" configure "${_restart_at}"; then - build_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}"; + if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then + ex_build_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}"; if [ \! -d "${PKG_PREFIX}/${PKG_TARGET}/usr" ]; then - build_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr"; + ex_build_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr"; fi; if [ "${ARCH}" = nt32 ]; then _configure_host="i686-nt32-midipix"; @@ -240,18 +240,18 @@ pkg_gcc_native_all() { --with-mpfr="${PKG_PREFIX}" \ --with-sysroot=; else - build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; fi; - if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-gcc; make ${PKG_MAKEFLAGS_BUILD} all-target-libgcc; make ${PKG_MAKEFLAGS_BUILD} all-target-libstdc++-v3; make ${PKG_MAKEFLAGS_BUILD} all; - set_build_script_done "${PKG_NAME}" build -install; + ex_pkg_state_push "${PKG_NAME}" build -install; fi; - if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then + if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} "DESTDIR=${PKG_PREFIX}" install; - set_build_script_done "${PKG_NAME}" install finish; + ex_pkg_state_push "${PKG_NAME}" install finish; fi; exit 0; }; diff --git a/vars/git.vars b/vars/git.vars index 873d092..fc5fb89 100644 --- a/vars/git.vars +++ b/vars/git.vars @@ -6,7 +6,7 @@ pkg_git_install_post() { local __ _new; for __ in $(find "${PKG_DESTDIR}" -name "Git*::*" -type f); do _new="$(echo ${__} | sed "s/::/./g")"; - build_fileop mv "${__}" "${_new}"; + ex_build_fileop mv "${__}" "${_new}"; done; }; diff --git a/vars/install_strip_host.vars b/vars/install_strip_host.vars index 081226b..5e8524a 100644 --- a/vars/install_strip_host.vars +++ b/vars/install_strip_host.vars @@ -4,7 +4,7 @@ pkg_install_strip_host_all() { if [ -e "${PREFIX}/bin/${TARGET}-install-strip" ]; then - build_fileop rm "${PREFIX}/bin/${TARGET}-install-strip"; + ex_build_fileop rm "${PREFIX}/bin/${TARGET}-install-strip"; fi; cat > "${PREFIX}/bin/${TARGET}-install-strip" < "${PREFIX}/bin/${TARGET}-xml2-config" < "${PREFIX}/bin/${TARGET}-pkg-config" <