From ce047ee9f0c206ef68dca70ff156fbcd29ea2ba5 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Feb 01 2017 02:20:19 +0000 Subject: subr/build.subr, build.sh: merged into build.sh. subr/{pkg,rtl}.subr: merged into subr/rtl.subr. --- diff --git a/build.sh b/build.sh index e9b96b8..73ff2f8 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,17 @@ # Copyright (c) 2016 Lucio Andrés Illanes Albornoz # +bp_subst_tgts() { + while [ ${#} -ge 1 ]; do + case "${1}" in + devroot) + echo ${DEVROOT_PACKAGES}; ;; + world) echo ${WORLD_PACKAGES}; ;; + *) echo ${1}; ;; + esac; shift; + done; +}; + # # Clear the environment. # Source subroutine scripts. @@ -10,7 +21,10 @@ for __ in subr/*.subr; do . ./${__}; done; -check_cpuinfo; +if [ -z "${BUILD_CPUS}" ] \ +&& [ -e /proc/cpuinfo ]; then + BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo); +fi; while [ ${#} -gt 0 ]; do case ${1} in -c) ARG_CLEAN=1; ;; @@ -39,7 +53,20 @@ host_toolchain|native_toolchain|runtime|lib_packages|leaf_packages|devroot|world *) exec cat etc/build.usage; ;; esac; shift; done; -source_vars; clear_env; + +# +# Source variables. +# Clear environment. +# +for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/build.vars; do + [ -e ${__} ] && . ${__}; +done; +for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do + if ! match_list "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then + unset "${__}"; + fi; +done; + if [ -z "${BUILD_TARGETS_META}" ]; then BUILD_TARGETS_META=world; fi; @@ -52,16 +79,88 @@ BUILD_TARGETS_META="invariants ${BUILD_TARGETS_META}"; # Check whether all prerequisite Perl modules exist. # Clean ${PREFIX} if requested. # Create directory hierarchy and usr -> . symlinks. -check_paths; clean_prefix; create_dirs; -init_build_log; init_build_progress_file; -{(init_build_vars; +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; +elif [ -n "${__exit}" ]; then + unset __exit; +fi; +if [ ${ARG_CLEAN:-0} -eq 1 ]; then + log_msg info "-c specified, cleaning prefix..."; + for __ in ${CLEAR_PREFIX_DIRS}; do + if [ -e ${PREFIX}/${__} ]; then + secure_rm ${PREFIX}/${__}; + fi; + done; +fi; +insecure_mkdir ${PREFIX} ${PREFIX}/x86_64-w64-mingw32 ${PREFIX_NATIVE} ${PREFIX_CROSS} ${PREFIX_TARGET}/lib ${DLCACHEDIR} ${WORKDIR}; +for __ in ${PREFIX}/usr ${PREFIX_NATIVE}/usr; do + if [ ! -L "${__}" ]; then + secure_rm "${__}"; ln -sf -- . "${__}"; + fi; +done; +if [ ! -L ${PREFIX}/x86_64-w64-mingw32/mingw ]; then + secure_rm ${PREFIX}/x86_64-w64-mingw32/mingw; + ln -sf . ${PREFIX}/x86_64-w64-mingw32/mingw; +fi; +if [ ! -d ${PREFIX}/x86_64-w64-mingw32/mingw/include ]; then + secure_rm ${PREFIX}/x86_64-w64-mingw32/mingw/include; + insecure_mkdir ${PREFIX}/x86_64-w64-mingw32/mingw/include; +fi; +if [ ! -L ${PREFIX}/man ]; then + secure_rm ${PREFIX}/man; + ln -sf share/man ${PREFIX}/man; +fi; +if [ ! -L ${PREFIX_NATIVE}/man ]; then + secure_rm ${PREFIX_NATIVE}/man; + ln -sf share/man ${PREFIX_NATIVE}/man; +fi; +insecure_mkdir ${PREFIX_MINIPIX}/bin; +for __ in lib libexec share; do + if [ ! -e ${PREFIX_MINIPIX}/${__} ]; then + ln -sf bin ${PREFIX_MINIPIX}/${__}; + fi; +done; +if [ -e ${BUILD_LOG_FNAME} ]; then + mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME}; +fi; +touch ${BUILD_STATUS_IN_PROGRESS_FNAME}; +{( +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); if [ ${ARG_CHECK_UPDATES:-0} -eq 0 ]; then log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; log_env_vars "build (global)" ${LOG_ENV_VARS}; else log_msg info "Version check run started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; fi; -for BUILD_TARGET_LC in $(subst_tgts ${BUILD_TARGETS_META}); do +for BUILD_TARGET_LC in $(bp_subst_tgts ${BUILD_TARGETS_META}); do BUILD_TARGET=$(echo ${BUILD_TARGET_LC} | tr a-z A-Z); for BUILD_PACKAGE_LC in $(get_var_unsafe ${BUILD_TARGET}_PACKAGES); do BUILD_PACKAGE=$(echo ${BUILD_PACKAGE_LC} | tr a-z A-Z); @@ -150,10 +249,15 @@ done; for __ in copy_etc strip tarballs; do post_${__}; done; -fini_build_vars; +: $((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)); 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)."; -fini_build_progress_file; +if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then + secure_rm ${BUILD_STATUS_IN_PROGRESS_FNAME}; +fi; exit ${BUILD_SCRIPT_RC})} 2>&1 | tee ${BUILD_LOG_FNAME} & TEE_PID=${!}; trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \ diff --git a/subr/build.subr b/subr/build.subr deleted file mode 100644 index 41cb4d8..0000000 --- a/subr/build.subr +++ /dev/null @@ -1,143 +0,0 @@ -# -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. -# - -check_cpuinfo() { - if [ -z "${BUILD_CPUS}" ] \ - && [ -e /proc/cpuinfo ]; then - BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo); - fi; -}; - -clear_env() { - for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do - if ! match_list "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then - unset "${__}"; - fi; - done; -}; - -check_paths() { - 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; - elif [ -n "${__exit}" ]; then - unset __exit; - fi; -}; - -clean_prefix() { - if [ ${ARG_CLEAN:-0} -eq 1 ]; then - log_msg info "-c specified, cleaning prefix..."; - for __ in ${CLEAR_PREFIX_DIRS}; do - if [ -e ${PREFIX}/${__} ]; then - secure_rm ${PREFIX}/${__}; - fi; - done; - fi; -}; - -create_dirs() { - insecure_mkdir ${PREFIX} ${PREFIX}/x86_64-w64-mingw32 ${PREFIX_NATIVE} ${PREFIX_CROSS} ${PREFIX_TARGET}/lib ${DLCACHEDIR} ${WORKDIR}; - for __ in ${PREFIX}/usr ${PREFIX_NATIVE}/usr; do - if [ ! -L "${__}" ]; then - secure_rm "${__}"; ln -sf -- . "${__}"; - fi; - done; - if [ ! -L ${PREFIX}/x86_64-w64-mingw32/mingw ]; then - secure_rm ${PREFIX}/x86_64-w64-mingw32/mingw; - ln -sf . ${PREFIX}/x86_64-w64-mingw32/mingw; - fi; - if [ ! -d ${PREFIX}/x86_64-w64-mingw32/mingw/include ]; then - secure_rm ${PREFIX}/x86_64-w64-mingw32/mingw/include; - insecure_mkdir ${PREFIX}/x86_64-w64-mingw32/mingw/include; - fi; - if [ ! -L ${PREFIX}/man ]; then - secure_rm ${PREFIX}/man; - ln -sf share/man ${PREFIX}/man; - fi; - if [ ! -L ${PREFIX_NATIVE}/man ]; then - secure_rm ${PREFIX_NATIVE}/man; - ln -sf share/man ${PREFIX_NATIVE}/man; - fi; - insecure_mkdir ${PREFIX_MINIPIX}/bin; - for __ in lib libexec share; do - if [ ! -e ${PREFIX_MINIPIX}/${__} ]; then - ln -sf bin ${PREFIX_MINIPIX}/${__}; - fi; - done; -}; - -fini_build_progress_file() { - if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then - secure_rm ${BUILD_STATUS_IN_PROGRESS_FNAME}; - fi; -}; - -fini_build_vars() { - : $((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)); -}; - -init_build_log() { - if [ -e ${BUILD_LOG_FNAME} ]; then - mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME}; - fi; -}; - -init_build_progress_file() { - touch ${BUILD_STATUS_IN_PROGRESS_FNAME}; -}; - -init_build_vars() { - 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); -}; - -source_vars() { - for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/build.vars; do - [ -e ${__} ] && . ${__}; - done; -}; - -subst_tgts() { - while [ ${#} -ge 1 ]; do - case "${1}" in - devroot) - echo ${DEVROOT_PACKAGES}; ;; - world) echo ${WORLD_PACKAGES}; ;; - *) echo ${1}; ;; - esac; shift; - done; -}; - -# vim:filetype=sh diff --git a/subr/pkg.subr b/subr/pkg.subr deleted file mode 100644 index 2130feb..0000000 --- a/subr/pkg.subr +++ /dev/null @@ -1,124 +0,0 @@ -# -# . ./build.vars and set -o errexit -o noglob are assumed. -# See warning at the top of build.vars. -# - -is_build_script_done() { - if [ "${1}" = "clean" ]; 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 - fi; - else - return 1; # Build - fi; - elif [ -f ${WORKDIR}/.${2:-${BUILD_PACKAGE_LC}}.${1} ]; then - return 0; # Skip - else - return 1; # Build - fi; -}; - -log_env_vars() { - 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 [ ${#} -gt 0 ]; do - log_msg info "$(printf \ - "%${_lev_arg_len_max}.${_lev_arg_len_max}s=%s" \ - "${1%%=*}" "$(get_var_unsafe ${1#*=})")"; - shift; - done; unset _lev_arg_len_max; -}; - -parse_with_pkg_name() { - PKG_NAME=${1}; shift; - _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 ${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; - 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; -}; - -run_cmd_unsplit() { - _rcu_cmd=${1}; shift; - while [ ${#} -gt 0 ]; do - [ -n "${1}" ] &&\ - _rcu_cmdline="${_rcu_cmdline:+${_rcu_cmdline}:}${1}"; - shift; - done; - push_IFS :; ${_rcu_cmd} ${_rcu_cmdline}; _rcu_rc=$?; pop_IFS; - unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc}; -}; - -set_build_script_done() { - _sbsd_script_fname=${BUILD_PACKAGE_LC}; - _sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname}; - while [ $# -ge 1 ]; do - if [ "${1#-}" != "${1}" ]; then - secure_rm ${_sbsd_done_fname}.${1#-}; - else - touch ${_sbsd_done_fname}.${1}; - log_msg info "Finished build step ${1} of \`${_sbsd_script_fname}'."; - fi; shift; - done; unset _sbsd_script_fname _sbsd_done_fname; -}; - -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; -}; - -# vim:filetype=sh diff --git a/subr/rtl.subr b/subr/rtl.subr index 6f15a43..70fcbe3 100644 --- a/subr/rtl.subr +++ b/subr/rtl.subr @@ -102,4 +102,123 @@ secure_rm() { done; }; + +is_build_script_done() { + if [ "${1}" = "clean" ]; 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 + fi; + else + return 1; # Build + fi; + elif [ -f ${WORKDIR}/.${2:-${BUILD_PACKAGE_LC}}.${1} ]; then + return 0; # Skip + else + return 1; # Build + fi; +}; + +log_env_vars() { + 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 [ ${#} -gt 0 ]; do + log_msg info "$(printf \ + "%${_lev_arg_len_max}.${_lev_arg_len_max}s=%s" \ + "${1%%=*}" "$(get_var_unsafe ${1#*=})")"; + shift; + done; unset _lev_arg_len_max; +}; + +parse_with_pkg_name() { + PKG_NAME=${1}; shift; + _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 ${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; + 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; +}; + +run_cmd_unsplit() { + _rcu_cmd=${1}; shift; + while [ ${#} -gt 0 ]; do + [ -n "${1}" ] &&\ + _rcu_cmdline="${_rcu_cmdline:+${_rcu_cmdline}:}${1}"; + shift; + done; + push_IFS :; ${_rcu_cmd} ${_rcu_cmdline}; _rcu_rc=$?; pop_IFS; + unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc}; +}; + +set_build_script_done() { + _sbsd_script_fname=${BUILD_PACKAGE_LC}; + _sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname}; + while [ $# -ge 1 ]; do + if [ "${1#-}" != "${1}" ]; then + secure_rm ${_sbsd_done_fname}.${1#-}; + else + touch ${_sbsd_done_fname}.${1}; + log_msg info "Finished build step ${1} of \`${_sbsd_script_fname}'."; + fi; shift; + done; unset _sbsd_script_fname _sbsd_done_fname; +}; + +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; +}; + # vim:filetype=sh