diff options
Diffstat (limited to 'subr')
-rw-r--r-- | subr/build.subr | 307 | ||||
-rw-r--r-- | subr/mode_check_updates.subr | 3 | ||||
-rw-r--r-- | subr/pkg_000000.subr | 39 | ||||
-rw-r--r-- | subr/pkg_all.subr | 10 | ||||
-rw-r--r-- | subr/pkg_autoconf.subr | 5 | ||||
-rw-r--r-- | subr/pkg_build.subr | 4 | ||||
-rw-r--r-- | subr/pkg_build_dir.subr | 4 | ||||
-rw-r--r-- | subr/pkg_clean.subr | 4 | ||||
-rw-r--r-- | subr/pkg_configure.subr | 4 | ||||
-rw-r--r-- | subr/pkg_disabled.subr | 3 | ||||
-rw-r--r-- | subr/pkg_distclean.subr | 4 | ||||
-rw-r--r-- | subr/pkg_extract.subr | 4 | ||||
-rw-r--r-- | subr/pkg_fetch.subr | 68 | ||||
-rw-r--r-- | subr/pkg_finish.subr | 9 | ||||
-rw-r--r-- | subr/pkg_install.subr | 28 | ||||
-rw-r--r-- | subr/pkg_patch.subr | 20 | ||||
-rw-r--r-- | subr/pkg_patch_pre.subr | 7 | ||||
-rw-r--r-- | subr/pkg_setup_env.subr | 4 | ||||
-rw-r--r-- | subr/post_build_files.subr | 2 | ||||
-rw-r--r-- | subr/post_copy_etc.subr | 2 | ||||
-rw-r--r-- | subr/post_strip.subr | 3 | ||||
-rw-r--r-- | subr/post_tarballs.subr | 2 | ||||
-rw-r--r-- | subr/pre_build_files.subr | 2 | ||||
-rw-r--r-- | subr/pre_prereqs.subr | 13 | ||||
-rw-r--r-- | subr/pre_setup_env.subr | 3 | ||||
-rw-r--r-- | subr/pre_subdirs.subr | 3 |
26 files changed, 248 insertions, 309 deletions
diff --git a/subr/build.subr b/subr/build.subr index bd2e2581..1341e973 100644 --- a/subr/build.subr +++ b/subr/build.subr @@ -1,129 +1,36 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # -date() { command date +"${1:-${TIMESTAMP_FMT}}"; }; +date() { command date "+${1:-${TIMESTAMP_FMT}}"; }; get_var_unsafe() { eval echo \${${1}}; }; -set_var_unsafe() { eval ${1}=\"${2}\"; }; -push_IFS() { _pI_IFS="${IFS}"; IFS="${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}; }; -split() { push_IFS "${1}"; set -- ${2}; pop_IFS; echo "${*}"; }; test_cmd() { command -v "${1}" >/dev/null; }; -unsplit() { push_IFS "${1}"; shift; set -- "${@}"; echo "${*}"; pop_IFS; }; - -get_vars_unsafe() { - while [ ${#} -gt 0 ]; do - _gvu_vval="$(eval echo \${${1}})"; - [ -z "${_gvu_vval}" ] || _gvu_vval_="${_gvu_vval}"; - shift; - done; echo "${_gvu_vval_}"; - unset _gvu_vval _gvu_vval_; -}; - -set_env_vars_with_sep() { - _sevws_sep=${1}; shift; push_IFS ${_sevws_sep}; set -- ${1}; - while [ ${#} -gt 0 ]; do - export "${1}"; shift; - done; unset _sevws_sep; pop_IFS; -}; - -lfilter() { - _lf_list="${1}"; _lf_filter="${2}"; _lf_lnew=""; - for _lf_litem in ${_lf_list}; do - for _lf_lfilter in ${_lf_filter}; do - if [ "${_lf_lfilter}" = "${_lf_litem}" ]; then - _lf_lnew="${_lf_lnew:+${_lf_lnew} }${_lf_litem}"; break; - fi; - done; - done; - echo ${_lf_lnew}; unset _lf_list _lf_filter _lf_lnew _lf_litem _lf_lfilter; -}; - -log_msg() { - _lm_lvl=${1}; shift; - if [ "${_lm_lvl#v}" != "${_lm_lvl}" ]\ - && [ ${ARG_VERBOSE:-0} -eq 0 ]; then - return; - fi; - case ${_lm_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 "${TIMESTAMP_FMT}")" "${1}" "$*"; - else - printf "==> %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}"; - fi; [ ${_lm_lvl} = failexit ] && exit 1 || unset _lm_lvl; -}; - -install_files() { - if [ "${1}" = "-v" ]; then - _if_verbose="${1}"; shift; - fi; _if_prefix="${1}"; shift; - while [ ${#} -gt 0 ]; do - case "${1}" in - @*=*) - __ln_target="${1%=*}"; - __ln_target="${__ln_target#@}"; - __ln_fname="${1#*=}"; - if [ -e ${__ln_fname} ]; then - if [ ${_if_verbose:-0} -eq 1 ]; then - echo build_fileop rm ${__ln_fname}; - fi; - build_fileop rm ${__ln_fname}; - fi; - build_fileop ln_symbolic ${__ln_target} ${_if_prefix:+${_if_prefix}/}${__ln_fname}; - ;; - /=*) - __mkdir_fname="${1#/=}"; - build_fileop mkdir ${_if_prefix:+${_if_prefix}/}${__mkdir_fname}; - ;; - *) - __file_fname_src="${1%=*}"; - __file_fname_dst="${1#*=}"; - build_fileop cp ${__file_fname_src} ${_if_prefix:+${_if_prefix}/}${__file_fname_dst}; - ;; - esac; shift; - done; unset _if_verbose _if_prefix; -}; - -match_list() { - _ml_cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS; - while [ ${#} -gt 0 ]; do - if [ "${1}" = "${_ml_cmp}" ]; then - unset _ml_cmp; return 0; - fi; shift; - done; unset _ml_cmp; return 1; -}; build_fileop() { - _bf_op=${1}; shift; - if [ "${_bf_op}" = cd ]; then + local _op="${1}"; shift; + if [ "${_op}" = cd ]; then log_msg varn "Changing working directory to \`${1}'."; [ \( -n "${1}" \) -a \( -e "${1}" \) ] && cd -- ${1}; - elif [ "${_bf_op}" = cp ]; then + elif [ "${_op}" = cp ]; then log_msg varn "Copying \`${1}' to \`${2}' w/ -pPR."; [ ${#} -ge 2 ] && cp -pPR -- "${@}"; - elif [ "${_bf_op}" = ln_symbolic ]; then + elif [ "${_op}" = ln_symbolic ]; then log_msg varn "Linking \`${1}' to \`${2}' w/ -fs"; [ \( -n "${1}" \) -a \( -n "${2}" \) ] && ln -fs -- ${1} ${2}; - elif [ "${_bf_op}" = mkdir ]\ - || [ "${_bf_op}" = rm ]; then + elif [ "${_op}" = mkdir ]\ + || [ "${_op}" = rm ]; then while [ ${#} -gt 0 ]; do if [ -z "${1}" ]; then return 1; - elif [ "${_bf_op}" = mkdir ]\ + elif [ "${_op}" = mkdir ]\ && [ ! -e "${1}" ]; then log_msg varn "Making directory \`${1}'."; mkdir -p -- "${1}"; - elif [ "${_bf_op}" = rm ]\ + elif [ "${_op}" = rm ]\ && [ -e "${1}" ]; then log_msg varn "Removing directory or file \`${1}'."; rm -rf -- "${1}"; @@ -134,120 +41,138 @@ build_fileop() { fi; }; -is_build_script_done() { - if [ "${1}" = "clean" ]\ - || [ "${1}" = distclean ]; then - if match_list "${ARG_RESTART}" , ${BUILD_PACKAGE_LC} \ - && [ -n "${ARG_RESTART_AT}" ] \ - && match_list "${ARG_RESTART_AT}" , "${1}"; then - return 1; # Build - else - return 0; # Skip - fi; - elif [ "${ARG_RESTART}" = "ALL" ]; then - return 1; # Build - elif match_list "${ARG_RESTART}" , ${BUILD_PACKAGE_LC}; then - if [ -n "${ARG_RESTART_AT}" ]; then - if [ "${ARG_RESTART_AT}" = "ALL" ]; then - return 1; # Build - elif match_list "${ARG_RESTART_AT}" , "${1}"; then - return 1; # Build - else - return 0; # Skip +install_files() { + local _verbose _prefix _ln_target _ln_fname _mkdir_fname \ + _file_fname_src _file_fname_dst; + if [ "${1}" = "-v" ]; then + _verbose="${1}"; shift; + fi; _prefix="${1}"; shift; + while [ ${#} -gt 0 ]; do + case "${1}" in + @*=*) + _ln_target="${1%=*}"; + _ln_target="${_ln_target#@}"; + _ln_fname="${1#*=}"; + if [ -e ${_ln_fname} ]; then + if [ ${_verbose:-0} -eq 1 ]; then + echo build_fileop rm ${_ln_fname}; fi; - else - return 1; # Build + build_fileop rm ${_ln_fname}; fi; - elif [ -f ${WORKDIR}/.${2:-${BUILD_PACKAGE_LC}}.${1} ]; then - return 0; # Skip + build_fileop ln_symbolic ${_ln_target} ${_prefix:+${_prefix}/}${_ln_fname}; + ;; + /=*) + _mkdir_fname="${1#/=}"; + build_fileop mkdir ${_prefix:+${_prefix}/}${_mkdir_fname}; + ;; + *) + _file_fname_src="${1%=*}"; + _file_fname_dst="${1#*=}"; + build_fileop cp ${_file_fname_src} ${_prefix:+${_prefix}/}${_file_fname_dst}; + ;; + esac; shift; + done; +}; + +is_build_script_done() { + local _done_fname="${WORKDIR}/.${1}.${2}"; + if [ -e "${_done_fname}" ]; then + return 0; # Skip else - return 1; # Build + return 1; # Build fi; }; set_build_script_done() { - _sbsd_script_fname=${BUILD_PACKAGE_LC}; - _sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname}; - while [ $# -ge 1 ]; do + local _pkg_fname="${1}"; + local _done_fname_pfx="${WORKDIR}/.${_pkg_fname}"; + shift; while [ ${#} -ge 1 ]; do if [ "${1#-}" != "${1}" ]; then - build_fileop rm ${_sbsd_done_fname}.${1#-}; + build_fileop rm "${_done_fname_pfx}.${1#-}"; else - touch ${_sbsd_done_fname}.${1}; - log_msg info "Finished build step ${1} of \`${_sbsd_script_fname}'."; + touch "${_done_fname_pfx}.${1}"; + log_msg info "Finished build step ${1} of package \`${_pkg_fname}'."; fi; shift; - done; unset _sbsd_script_fname _sbsd_done_fname; + done; +}; + +lfilter() { + local _list="${1}" _filter="${2}" _lnew _litem _lfilter; + for _litem in ${_list}; do + for _lfilter in ${_filter}; do + if [ "${_lfilter}" = "${_litem}" ]; then + _lnew="${_lnew:+${_lnew} }${_litem}"; break; + fi; + done; + done; + echo ${_lnew}; }; log_env_vars() { + local _nvar _arg _arg_len_max; log_msg info "Variables for this ${1:-build}:"; shift; - while [ ${_lev_nvar:=0} -lt ${#} ]; do - _lev_arg="$(eval echo \${${_lev_nvar}})"; - _lev_arg="${_lev_arg%%=*}"; - if [ ${#_lev_arg} -gt ${_lev_arg_len_max:=0} ]; then - _lev_arg_len_max=${#_lev_arg}; - fi; : $((_lev_nvar+=1)); - done; unset _lev_nvar _lev_arg; + while [ ${_nvar:=0} -lt ${#} ]; do + _arg="$(eval echo \${${_nvar}})"; + _arg="${_arg%%=*}"; + if [ ${#_arg} -gt ${_arg_len_max:=0} ]; then + _arg_len_max=${#_arg}; + fi; : $((_nvar+=1)); + done; while [ ${#} -gt 0 ]; do log_msg info "$(printf \ - "%${_lev_arg_len_max}.${_lev_arg_len_max}s=%s" \ + "%${_arg_len_max}.${_arg_len_max}s=%s" \ "${1%%=*}" "$(get_var_unsafe ${1#*=})")"; shift; - done; unset _lev_arg_len_max; + done; }; -parse_with_pkg_name() { - PKG_NAME=${1}; shift; PKG_TARGET=${TARGET}; - MIDIPIX_BUILD_PWD=$(pwd); build_fileop cd ${WORKDIR}; - for __ in vars/${PKG_NAME}.vars; do - [ -e ${MIDIPIX_BUILD_PWD}/${__} ] && . ${MIDIPIX_BUILD_PWD}/${__}; - done; - _pwpn_pkg_name_uc=$(echo ${PKG_NAME} | tr a-z A-Z); - if [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URL)" ]\ - && [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_URLS_GIT)" ]\ - && [ -z "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_VERSION)" ]; then - unset _pwpn_pkg_name_uc; - log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; - else - for _pwpn_vname in PREFIX ${PKG_BUILD_VARS}; do - if [ -n "$(get_var_unsafe DEFAULT_${_pwpn_vname})" ]; then - set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe DEFAULT_${_pwpn_vname})"; - fi; - if [ -n "$(get_var_unsafe ${BUILD_TARGET}_${_pwpn_vname})" ]; then - set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe ${BUILD_TARGET}_${_pwpn_vname})"; - fi; - if [ "${BUILD}" = "debug" ] \ - && [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_DEBUG)" ]; then - set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_DEBUG)"; - elif [ "${BUILD}" = "release" ] \ - && [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_RELEASE)" ]; then - set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname}_RELEASE)"; - elif [ -n "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname})" ]; then - set_var_unsafe PKG_${_pwpn_vname} "$(get_var_unsafe PKG_${_pwpn_pkg_name_uc}_${_pwpn_vname})"; - fi; - done; unset _pwpn_vname; +log_msg() { + local _lvl="${1}"; shift; + if [ "${_lvl#v}" != "${_lvl}" ]\ + && [ ${ARG_VERBOSE:-0} -eq 0 ]; then + return; fi; - [ -z "${PKG_FNAME}" ] && PKG_FNAME=${PKG_URL##*/}; - [ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR=${PKG_FNAME%%.tar*}; - [ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}"; - for _pwpn_env_var in $(set); do - if [ "${_pwpn_env_var#PKG_${_pwpn_pkg_name_uc}}" != "${_pwpn_env_var}" ]; then - _pwpn_env_vars="${_pwpn_env_vars:+${_pwpn_env_vars} }${_pwpn_env_var%%=*}"; - fi; - done; - if [ -n "${_pwpn_env_vars}" ]; then - log_env_vars "build" ${_pwpn_env_vars}; - fi; unset _pwpn_pkg_name_uc _pwpn_env_var _pwpn_env_vars; + 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; +}; + +match_list() { + 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; }; run_cmd_unsplit() { - _rcu_cmd=${1}; shift; + local _cmd="${1}" _cmdline _rc; shift; while [ ${#} -gt 0 ]; do [ -n "${1}" ] &&\ - _rcu_cmdline="${_rcu_cmdline:+${_rcu_cmdline}:}${1}"; + _cmdline="${_cmdline:+${_cmdline}:}${1}"; shift; done; - push_IFS :; ${_rcu_cmd} ${_rcu_cmdline}; _rcu_rc=$?; pop_IFS; - unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc}; + 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() { diff --git a/subr/mode_check_updates.subr b/subr/mode_check_updates.subr index 312b81e0..51cf707d 100644 --- a/subr/mode_check_updates.subr +++ b/subr/mode_check_updates.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # modep_cpu_get_fnames() { diff --git a/subr/pkg_000000.subr b/subr/pkg_000000.subr new file mode 100644 index 00000000..f531eca4 --- /dev/null +++ b/subr/pkg_000000.subr @@ -0,0 +1,39 @@ +# +# set -o errexit -o noglob are assumed. +# + +pkg_000000() { + local _pkg_name_uc _vars_fname _vname _build_uc __ _log_env_vars; + _pkg_name_uc="$(echo ${PKG_NAME} | tr a-z A-Z)"; + for _vars_fname in vars/${PKG_NAME}.vars; do + [ -e "${_vars_fname}" ] && . "${_vars_fname}"; + done; + for _vname in PREFIX ${PKG_BUILD_VARS}; do + _build_uc="$(echo ${BUILD} | tr a-z A-Z)"; + for __ in "DEFAULT_${_vname}" \ + "${BUILD_TARGET}_${_vname}" \ + "PKG_${_pkg_name_uc}_${_vname}" \ + "PKG_${_pkg_name_uc}_${_vname}_${_build_uc}"; do + set_var_unsafe "PKG_${_vname}" "$(get_var_unsafe ${__})"; + done; + done; + if [ -z "${PKG_URL}" -a -z "${PKG_URLS_GIT}" -a -z "${PKG_VERSION}" ]; then + log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; + else + [ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}"; + [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; + [ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR="${PKG_FNAME%%.tar*}"; + [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; + [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; + fi; + for __ in $(set); do + if [ "${__#PKG_${_pkg_name_uc}}" != "${__}" ]; then + _log_env_vars="${_log_env_vars:+${_log_env_vars} }${__%%=*}"; + fi; + done; + if [ -n "${_log_env_vars}" ]; then + log_env_vars "build" ${_log_env_vars}; + fi; +}; + +# vim:filetype=sh diff --git a/subr/pkg_all.subr b/subr/pkg_all.subr deleted file mode 100644 index df96e00f..00000000 --- a/subr/pkg_all.subr +++ /dev/null @@ -1,10 +0,0 @@ -# -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. -# - -pkg_all() { - :; -}; - -# vim:filetype=sh diff --git a/subr/pkg_autoconf.subr b/subr/pkg_autoconf.subr index 6390dc97..5260bf19 100644 --- a/subr/pkg_autoconf.subr +++ b/subr/pkg_autoconf.subr @@ -1,9 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_autoconf() { + local __; if [ -e ${PKG_SUBDIR}/configure -o \ -e ${PKG_SUBDIR}/configure.ac -o \ -e ${PKG_SUBDIR}/configure.in -o \ @@ -36,7 +36,6 @@ pkg_autoconf() { build_fileop cp ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/; done; fi; - set_build_script_done autoconf -patch; }; # vim:filetype=sh diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr index 58a9e55c..9ef158a6 100644 --- a/subr/pkg_build.subr +++ b/subr/pkg_build.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_build() { @@ -21,7 +20,6 @@ pkg_build() { "${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}"; unset __no_autoconf; fi; - set_build_script_done build -install; }; # vim:filetype=sh diff --git a/subr/pkg_build_dir.subr b/subr/pkg_build_dir.subr index 7d500758..3285521f 100644 --- a/subr/pkg_build_dir.subr +++ b/subr/pkg_build_dir.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_build_dir() { @@ -10,7 +9,6 @@ pkg_build_dir() { if [ ! -d "${PKG_BUILD_DIR}" ]; then build_fileop mkdir ${PKG_BUILD_DIR}; fi; - set_build_script_done build_dir -patch_pre; }; # vim:filetype=sh diff --git a/subr/pkg_clean.subr b/subr/pkg_clean.subr index bd0e1d93..4cfaa15a 100644 --- a/subr/pkg_clean.subr +++ b/subr/pkg_clean.subr @@ -1,11 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_clean() { make clean; - set_build_script_done clean -build; }; # vim:filetype=sh diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr index 598c2366..b631a429 100644 --- a/subr/pkg_configure.subr +++ b/subr/pkg_configure.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_configure() { @@ -13,7 +12,6 @@ pkg_configure() { ${PKG_CONFIGURE} \ ${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA} ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG}; fi; - set_build_script_done configure clean -build; }; # vim:filetype=sh diff --git a/subr/pkg_disabled.subr b/subr/pkg_disabled.subr index 9fb3f2f0..43cef71f 100644 --- a/subr/pkg_disabled.subr +++ b/subr/pkg_disabled.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_disabled() { diff --git a/subr/pkg_distclean.subr b/subr/pkg_distclean.subr index ed380727..f721a9fb 100644 --- a/subr/pkg_distclean.subr +++ b/subr/pkg_distclean.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_distclean() { @@ -8,7 +7,6 @@ pkg_distclean() { build_fileop rm ${PKG_BUILD_DIR}; build_fileop mkdir ${PKG_BUILD_DIR}; fi; - set_build_script_done distclean -configure; }; # vim:filetype=sh diff --git a/subr/pkg_extract.subr b/subr/pkg_extract.subr index f63cefa0..95c32d5d 100644 --- a/subr/pkg_extract.subr +++ b/subr/pkg_extract.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_extract() { @@ -29,7 +28,6 @@ pkg_extract() { pkg_${PKG_NAME}_extract_post; fi; fi; - set_build_script_done extract -build_dir; }; # vim:filetype=sh diff --git a/subr/pkg_fetch.subr b/subr/pkg_fetch.subr index 5c2fee73..fd78a3c1 100644 --- a/subr/pkg_fetch.subr +++ b/subr/pkg_fetch.subr @@ -1,70 +1,67 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # # N.B. URLs ($1) may contain `?' or '&' characters. pkgp_fetch() { - _f_url="${1}"; _f_sha256sum_src="${2}"; + local _url="${1}" _sha256sum_src="${2}"; if [ -z "${3}" ]; then - _f_url_dst="${DLCACHEDIR}/$(basename "${_f_url}")"; + _url_dst="${DLCACHEDIR}/$(basename "${_url}")"; else - _f_url_dst="${DLCACHEDIR}/${3}"; + _url_dst="${DLCACHEDIR}/${3}"; fi; if [ ${ARG_OFFLINE:-0} -eq 1 ]\ - || [ -e ${_f_url_dst}.fetched ]; then - unset _f_url _f_sha256sum_src _f_url_dst; + || [ -e ${_url_dst}.fetched ]; then return 0; else - wget ${WGET_ARGS} -c -O ${_f_url_dst} "${_f_url}"; + wget ${WGET_ARGS} -c -O ${_url_dst} "${_url}"; fi; - if [ -n "${_f_sha256sum_src}" ]; then - set -- $(openssl dgst -sha256 ${_f_url_dst}); shift $((${#}-1)); - if [ "${_f_sha256sum_dst:=${1}}" != "${_f_sha256sum_src}" ]; then + if [ -n "${_sha256sum_src}" ]; then + 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 \`${_f_url}' (is: ${_f_sha256sum_dst}, should be: ${_f_sha256sum_src}.)"; + 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 \`${_f_url}' (is: ${_f_sha256sum_dst}, should be: ${_f_sha256sum_src}.)"; + log_msg warn "Warning: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)"; fi; fi; fi; - touch ${_f_url_dst}.fetched; - unset _f_url _f_url_dst _f_sha256sum_src _f_sha256sum_dst; + touch ${_url_dst}.fetched; }; pkgp_fetch_git() { - _fg_subdir="${1}"; _fg_url="${2}"; _fg_branch="${3}"; + local _subdir="${1}" _url="${2}" _branch="${3}"; if [ ${ARG_OFFLINE:-0} -eq 0 ]; then - if [ -e "${DLCACHEDIR}/${_fg_subdir}" ]; then - build_fileop cd ${DLCACHEDIR}/${_fg_subdir} &&\ - git pull origin ${_fg_branch:-main} &&\ + if [ -e "${DLCACHEDIR}/${_subdir}" ]; then + build_fileop cd ${DLCACHEDIR}/${_subdir} &&\ + git pull origin ${_branch:-main} &&\ build_fileop cd ${OLDPWD}; else - git clone ${_fg_url} ${DLCACHEDIR}/${_fg_subdir}; - if [ -n "${_fg_branch}" -a \ - \( -z "${_fg_branch#main}" \) -a \ - \( -z "${_fg_branch#master}" \) ]; then - build_fileop cd ${DLCACHEDIR}/${_fg_subdir} &&\ - git checkout -b ${_fg_branch} &&\ + git clone ${_url} ${DLCACHEDIR}/${_subdir}; + if [ -n "${_branch}" -a \ + \( -z "${_branch#main}" \) -a \ + \( -z "${_branch#master}" \) ]; then + build_fileop cd ${DLCACHEDIR}/${_subdir} &&\ + git checkout -b ${_branch} &&\ build_fileop cd ${OLDPWD}; fi; fi; fi; - build_fileop rm ${_fg_subdir}; - build_fileop cp ${DLCACHEDIR}/${_fg_subdir} .; + build_fileop rm ${_subdir}; + build_fileop cp ${DLCACHEDIR}/${_subdir} .; }; pkgp_fetch_urls_git() { - for _ppfu_url_spec in "${@}"; do - _ppfu_subdir=${_ppfu_url_spec%=*}; - _ppfu_url=${_ppfu_url_spec#*=}; - _ppfu_url=${_ppfu_url%@*}; - if [ "${_ppfu_url_spec#*@}" != "${_ppfu_url_spec}" ]; then - _ppfu_git_branch=${_ppfu_url_spec#*@}; + local _url_spec _subdir _url _git_branch; + for _url_spec in "${@}"; do + _subdir=${_url_spec%=*}; + _url=${_url_spec#*=}; + _url=${_url%@*}; + if [ "${_url_spec#*@}" != "${_url_spec}" ]; then + _git_branch=${_url_spec#*@}; fi; - pkgp_fetch_git ${_ppfu_subdir} ${_ppfu_url} ${_ppfu_git_branch}; + pkgp_fetch_git ${_subdir} ${_url} ${_git_branch}; done; - unset _ppfu_url_spec _ppfu_subdir _ppfu_url _ppfu_git_branch; }; pkg_fetch() { @@ -81,7 +78,6 @@ pkg_fetch() { if [ -n "${PKG_URLS_GIT}" ]; then pkgp_fetch_urls_git ${PKG_URLS_GIT}; fi; - set_build_script_done fetch -extract; fi; }; diff --git a/subr/pkg_finish.subr b/subr/pkg_finish.subr new file mode 100644 index 00000000..609f2b6e --- /dev/null +++ b/subr/pkg_finish.subr @@ -0,0 +1,9 @@ +# +# 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 ad451e80..673dd92d 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -1,9 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkgp_install_clean_lib() { + local __; if [ -d ${PKG_PREFIX}/lib ]; then for __ in $(find ${PKG_PREFIX}/lib -type f -name \*.la); do build_fileop rm ${__}; @@ -12,28 +12,29 @@ pkgp_install_clean_lib() { }; pkgp_install_dlltool() { + local _so_fname _so_name; if [ "${PKG_BUILD_TYPE}" != "host" ] \ && test_cmd perk \ && test_cmd ${PKG_TARGET}-dlltool; then - for __so_fname in \ + for _so_fname in \ $(find \( -name "*.so" \ -or -name "*.so.[0-9]" \ -or -name "*.so.[0-9].[0-9]" \ -or -name "*.so.[0-9].[0-9].[0-9]" \) -printf '%P\n'); do - if [ \( -e ${__so_fname%.so}.lib.a \) -o \ - \( ! -e ${PKG_PREFIX}/lib/$(basename ${__so_fname}) \) ]; + if [ \( -e ${_so_fname%.so}.lib.a \) -o \ + \( ! -e ${PKG_PREFIX}/lib/$(basename ${_so_fname}) \) ]; then continue; else - __so_name="${__so_fname%.so}"; - echo perk -epdlltool ${__so_fname} \> ${__so_fname%.so}.def; - perk -epdlltool ${__so_fname} > ${__so_fname%.so}.def; - echo ${PKG_TARGET}-dlltool -l ${__so_fname%.so}.lib.a \ - -D ${__so_fname} -d ${__so_fname%.so}.def; - ${PKG_TARGET}-dlltool -l ${__so_fname%.so}.lib.a \ - -D ${__so_fname} -d ${__so_fname%.so}.def; - build_fileop cp ${__so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; + _so_name="${_so_fname%.so}"; + echo perk -epdlltool ${_so_fname} \> ${_so_fname%.so}.def; + perk -epdlltool ${_so_fname} > ${_so_fname%.so}.def; + echo ${PKG_TARGET}-dlltool -l ${_so_fname%.so}.lib.a \ + -D ${_so_fname} -d ${_so_fname%.so}.def; + ${PKG_TARGET}-dlltool -l ${_so_fname%.so}.lib.a \ + -D ${_so_fname} -d ${_so_fname%.so}.def; + build_fileop cp ${_so_fname%.so}.lib.a "${PKG_PREFIX}/lib"; fi; done; fi; @@ -73,7 +74,6 @@ pkg_install() { (install_files -v ${PKG_PREFIX} ${PKG_INSTALL_FILES}); fi; pkgp_install_dlltool; - set_build_script_done install -finish; }; # vim:filetype=sh diff --git a/subr/pkg_patch.subr b/subr/pkg_patch.subr index 089c0c16..63e1b450 100644 --- a/subr/pkg_patch.subr +++ b/subr/pkg_patch.subr @@ -1,30 +1,26 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_patch() { + local _patch_fname; if [ -d ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME} ]; then set +o noglob; - for __patch_fname in ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch; do - patch -b -d ${PKG_SUBDIR} -p1 < ${__patch_fname}; + for _patch_fname in ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch; do + patch -b -d ${PKG_SUBDIR} -p1 < ${_patch_fname}; done; set -o noglob; fi; - for __patch_fname in \ + for _patch_fname in \ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local.patch \ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local@${BUILD_HNAME}.patch \ ${WORKDIR}/chainport/${PKG_SUBDIR}.midipix.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local.patch \ ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do - if [ -r "${__patch_fname}" ]; then - patch -b -d ${PKG_SUBDIR} -p1 < ${__patch_fname}; + if [ -r "${_patch_fname}" ]; then + patch -b -d ${PKG_SUBDIR} -p1 < ${_patch_fname}; fi; - done; unset __patch_fname; - if test_cmd pkg_${PKG_NAME}_patch_post; then - pkg_${PKG_NAME}_patch_post; - fi; - set_build_script_done patch -setup; + done; }; # vim:filetype=sh diff --git a/subr/pkg_patch_pre.subr b/subr/pkg_patch_pre.subr index 2671d32c..566299a2 100644 --- a/subr/pkg_patch_pre.subr +++ b/subr/pkg_patch_pre.subr @@ -1,9 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_patch_pre() { + local __; for __ in \ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local.patch \ ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch \ @@ -13,11 +13,10 @@ pkg_patch_pre() { if [ -r "${__}" ]; then patch -b -d ${PKG_SUBDIR} -p1 < ${__}; fi; - done; unset __; + done; if test_cmd pkg_${PKG_NAME}_patch_pre_post; then pkg_${PKG_NAME}_patch_pre_post; fi; - set_build_script_done patch_pre -autoconf; }; # vim:filetype=sh diff --git a/subr/pkg_setup_env.subr b/subr/pkg_setup_env.subr index 9faf3875..34dfa1fb 100644 --- a/subr/pkg_setup_env.subr +++ b/subr/pkg_setup_env.subr @@ -1,6 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. +# set -o errexit -o noglob are assumed. # pkg_setup_env() { @@ -30,7 +29,6 @@ pkg_setup_env() { export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; fi; build_fileop cd ${PKG_BUILD_DIR}; - set_build_script_done setup distclean -configure; }; # vim:filetype=sh diff --git a/subr/post_build_files.subr b/subr/post_build_files.subr index 0f629eb1..6c74a7c9 100644 --- a/subr/post_build_files.subr +++ b/subr/post_build_files.subr @@ -1,5 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # post_build_files() { diff --git a/subr/post_copy_etc.subr b/subr/post_copy_etc.subr index fe48521b..9681e14a 100644 --- a/subr/post_copy_etc.subr +++ b/subr/post_copy_etc.subr @@ -1,5 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # post_copy_etc() { diff --git a/subr/post_strip.subr b/subr/post_strip.subr index 68b8e2e4..5225021b 100644 --- a/subr/post_strip.subr +++ b/subr/post_strip.subr @@ -1,8 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # post_strip() { + local __; if [ ${BUILD_SCRIPT_RC:-0} -eq 0 ]\ && [ "${BUILD}" = release ]; then for __ in $(find ${PREFIX_NATIVE}/bin -perm -0100 \( -type f -or -type l \)); do diff --git a/subr/post_tarballs.subr b/subr/post_tarballs.subr index d55d2a41..245d3a64 100644 --- a/subr/post_tarballs.subr +++ b/subr/post_tarballs.subr @@ -1,5 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # postp_tarball_dist() { diff --git a/subr/pre_build_files.subr b/subr/pre_build_files.subr index dc65759d..700ea740 100644 --- a/subr/pre_build_files.subr +++ b/subr/pre_build_files.subr @@ -1,5 +1,5 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # pre_build_files() { diff --git a/subr/pre_prereqs.subr b/subr/pre_prereqs.subr index c5a965b3..f048365e 100644 --- a/subr/pre_prereqs.subr +++ b/subr/pre_prereqs.subr @@ -1,8 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # pre_prereqs() { + local __ _exit; for __ in ${CHECK_PATH_VARS}; do if [ -z "${___:=$(get_var_unsafe "${__}")}" ]; then log_msg failexit "Error: variable \`${__}' is empty or unset."; @@ -14,25 +15,23 @@ pre_prereqs() { if [ "${__#/}" != "${__}" ]; then if [ ! -e "${__}" ]; then log_msg fail "Error: missing prerequisite file \`${__}'."; - __exit=1; + _exit=1; fi; else if ! test_cmd "${__}"; then log_msg fail "Error: missing prerequisite command \`${__}'."; - __exit=1; + _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; + _exit=1; fi; done; - if [ ${__exit:-0} = 1 ]; then + if [ ${_exit:-0} = 1 ]; then exit 1; - elif [ -n "${__exit}" ]; then - unset __exit; fi; }; diff --git a/subr/pre_setup_env.subr b/subr/pre_setup_env.subr index c454393e..0f2c9442 100644 --- a/subr/pre_setup_env.subr +++ b/subr/pre_setup_env.subr @@ -1,8 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# set -o errexit -o noglob are assumed. # pre_setup_env() { + local __; if [ -z "${BUILD_CPUS}" ]\ && [ -e /proc/cpuinfo ]; then BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo); diff --git a/subr/pre_subdirs.subr b/subr/pre_subdirs.subr index 383ab55a..92980b80 100644 --- a/subr/pre_subdirs.subr +++ b/subr/pre_subdirs.subr @@ -1,8 +1,9 @@ # -# . ./build.vars and set -o errexit -o noglob are assumed. +# 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 |