From c6d6e08feab839a9dc5792071fb803494cc51a69 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Feb 26 2020 21:54:12 +0000 Subject: General cleanup, pt. II. --- diff --git a/build.sh b/build.sh index be59adb..b88aab7 100755 --- a/build.sh +++ b/build.sh @@ -2,93 +2,106 @@ # Copyright (c) 2016, 2017, 2018, 2019 Lucio Andrés Illanes Albornoz # -buildp_dispatch() { - local _msg="${1}" _group_name="${2}" _pkg_name="${3}" \ - _build_group_lc="" _build_group_meta="" _build_groups_lc="" \ - _pkg_names="" _pkg_restart="" _rc=0; +buildp_ast() { + local _param="${1}" _pids_killed=""; + if [ "${_param}" = "abort" ]; then + rtl_log_msg failexit "Build aborted."; + fi; + if [ -n "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then + rtl_fileop rm "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}"; + fi; + if rtl_kill_tree "${$}"\ + && [ -n "${_pids_killed}" ]; then + rtl_log_msg vnfo "Killed PIDs ${_pids_killed}"; + fi; +}; + +buildp_dispatch_fail_pkg() { + local _group_name="${1}" _pkg_name="${2}"; + : $((BUILD_NFAIL+=1)); BUILD_PKGS_FAILED="$(rtl_lconcat "${BUILD_PKGS_FAILED}" "${_pkg_name}")"; + if [ "${ARG_RELAXED:-0}" -eq 1 ]; then + rtl_log_msg fail "$(printf "Build failed in \`%s', check \`%s' for details." "${_pkg_name}" "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log")"; + else rtl_log_msg fail "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log:"; + cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; + if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then + printf "%s" "${_pkg_name}" > "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; + fi; + rtl_log_msg failexit "$(printf "Build failed in \`%s'." "${_pkg_name}")"; + fi; +}; + +buildp_dispatch_group_state() { + local _group_name="${1}"; case "${_msg}" in - # Top-level - start_build) shift; build_init "${@}"; - ex_rtl_log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; - ex_rtl_log_env_vars "build (global)" ${DEFAULT_LOG_ENV_VARS}; - _build_groups_lc="${BUILD_GROUPS:-${GROUPS_DEFAULT}}"; - if ! ex_rtl_lmatch "${ARG_DIST}" "rpm" ","; then - _build_groups_lc="$(ex_rtl_lfilter "${_build_groups_lc}" "host_deps_rpm")"; - fi; - for _build_group_lc in ${_build_groups_lc}; do - ex_pkg_dispatch buildp_dispatch "${_build_group_lc}" "${ARG_PARALLEL:-1}" \ - "${ARG_RESTART}" "${ARG_RESTART_AT}" "${ARG_RESTART_RECURSIVE}"; _rc="${?}"; - _pkg_names="$(ex_rtl_lconcat "${_pkg_names}" "${EX_PKG_NAMES}")"; - if [ "${_rc}" -ne 0 ]; then - break; - fi; - done; - for _pkg_restart in ${ARG_RESTART}; do - if ! ex_rtl_lmatch "${_pkg_restart}" "ALL LAST"\ - && ! ex_rtl_lmatch "${_pkg_names}" "${_pkg_restart}"; then - ex_rtl_log_msg failexit "Error: package \`${_pkg_restart}' unknown."; - fi; - done; - if ! ex_pkg_dispatch buildp_dispatch "invariants" "${ARG_PARALLEL:-1}" "ALL" "ALL" 2; then - break; - fi; - buildp_dispatch finish_build; ;; - finish_build) build_fini; - ex_rtl_log_msg info "${BUILD_NFINI:-0} finished, ${BUILD_NSKIP:-0} skipped, and ${BUILD_NFAIL:-0} failed package(s)."; - ex_rtl_log_msg info "Build time: ${BUILD_TIMES_HOURS:-0} hour(s), ${BUILD_TIMES_MINUTES:-0} minute(s), and ${BUILD_TIMES_SECS:-0} second(s)."; - if [ -n "${BUILD_PKGS_FAILED}" ]; then - ex_rtl_log_msg failexit "Build script failure(s) in: ${BUILD_PKGS_FAILED}."; - fi; ;; + finish_group) rtl_log_msg suc2 "Finished \`${_group_name}' build group."; ;; + start_group) rtl_log_msg inf2 "Starting \`${_group_name}' build group..."; ;; + esac; +}; - # Group build - start_group) ex_rtl_log_msg inf2 "Starting \`${_group_name}' build group..."; ;; - finish_group) ex_rtl_log_msg suc2 "Finished \`${_group_name}' build group."; ;; +buildp_dispatch_pkg_state() { + local _msg="${1}" _group_name="${2}" _pkg_name="${3}"; + case "${_msg}" in + disabled_pkg) : $((BUILD_NSKIP+=1)); rtl_log_msg vnfo "$(printf "Skipping disabled package \`%s.'" "${_pkg_name}")"; ;; + missing_pkg) rtl_log_msg failexit "Error: package \`${_pkg_name}' missing in build.vars."; ;; + skipped_pkg) : $((BUILD_NSKIP+=1)); rtl_log_msg vnfo "$(printf "Skipping finished package \`%s.'" "${_pkg_name}")"; ;; + start_pkg) rtl_log_msg info "$(printf "[%03d/%03d] Starting \`%s' build..." "${4}" "${5}" "${_pkg_name}")"; ;; + step_pkg) rtl_log_msg vucc "$(printf "Finished build step %s of package \`%s'." "${4}" "${_pkg_name}")"; ;; + finish_pkg) + : $((BUILD_NFINI+=1)); + if [ "${ARG_VERBOSE:-0}" -ge 2 ]; then + cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; + fi; + rtl_log_msg succ "$(printf "Finished \`%s' build." "${_pkg_name}")"; ;; + start_pkg_child) + if [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then + rtl_log_env_vars "build" $(set | awk -F= '/^PKG_/{print $1}' | sort); + fi; + if [ "${ARG_VERBOSE:-0}" -ge 3 ]; then + set -o xtrace; + fi; ;; + esac; +}; - # Package build - start_pkg) ex_rtl_log_msg info "$(printf "[%03d/%03d] Starting \`%s' build..." "${4}" "${5}" "${_pkg_name}")"; ;; - finish_pkg) : $((BUILD_NFINI+=1)); - if [ "${ARG_VERBOSE:-0}" -ge 2 ]; then - cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; - fi; - ex_rtl_log_msg succ "$(printf "Finished \`%s' build." "${_pkg_name}")"; ;; - fail_pkg) : $((BUILD_NFAIL+=1)); - BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${_pkg_name}"; - if [ "${ARG_RELAXED:-0}" -eq 1 ]; then - ex_rtl_log_msg fail "$(printf "Build failed in \`%s', check \`%s' for details." "${_pkg_name}" "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log")"; - else - ex_rtl_log_msg fail "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log:"; - cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; - if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then - echo "${_pkg_name}" > "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; - fi; - ex_rtl_log_msg fail "$(printf "Build failed in \`%s'." "${_pkg_name}")"; - if [ "${ARG_PARALLEL:-0}" -eq 1 ]; then - ex_rtl_log_msg fail "Terminating pending builds..."; - pkill -P "${$}"; - fi; - exit 1; - fi; ;; - disabled_pkg) : $((BUILD_NSKIP+=1)); - ex_rtl_log_msg vnfo "$(printf "Skipping disabled package \`%s.'" "${_pkg_name}")"; ;; - skipped_pkg) : $((BUILD_NSKIP+=1)); - ex_rtl_log_msg vnfo "$(printf "Skipping finished package \`%s.'" "${_pkg_name}")"; ;; - step_pkg) ex_rtl_log_msg vucc "$(printf "Finished build step %s of package \`%s'." "${4}" "${_pkg_name}")"; ;; +buildp_dispatch() { + local _msg="${1}"; shift; + case "${_msg}" in + disabled_pkg|finish_pkg|missing_pkg|skipped_pkg|start_pkg|start_pkg_child|step_pkg) + buildp_dispatch_pkg_state "${_msg}" "${@}"; ;; + finish_group|start_group) + buildp_dispatch_group_state "${_msg}" "${@}"; ;; + *) if command -v "buildp_dispatch_${_msg}"; then + "buildp_dispatch_${_msg}" "${@}"; + fi; ;; + esac; +}; - # Child process - exec_finish) ;; - exec_missing) ex_rtl_log_msg failexit "Error: package \`${_pkg_name}' missing in build.vars."; ;; - exec_start) if [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then - ex_rtl_log_env_vars "build" $(set | awk -F= '/^PKG_/{print $1}' | sort); +build() { + local _build_date_start="" _build_time_hours=0 _build_time_mins=0 _build_time_secs=0 \ + BUILD_NFAIL=0 BUILD_NFINI=0 BUILD_NSKIP=0 BUILD_PKGS_FAILED="" EX_PKG_DISPATCH_UNKNOWN=""; + if trap "buildp_ast abort" HUP INT TERM USR1 USR2\ + && trap "buildp_ast exit" EXIT\ + && . ./subr/build_init.subr && build_init "${@}"; then + _build_date_start="$(rtl_date %Y-%m-%d-%H-%M-%S)"; _build_time_secs="$(rtl_date %s)"; + rtl_log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${_build_date_start}."; + rtl_log_env_vars "build (global)" ${DEFAULT_LOG_ENV_VARS}; + if ! ex_pkg_dispatch "${DEFAULT_BUILD_STEPS}" "${DEFAULT_BUILD_VARS}" \ + buildp_dispatch "${BUILD_GROUPS}" "${ARG_PARALLEL:-1}" \ + "${BUILD_WORKDIR}/build.fifo" "${ARG_RESTART}" \ + "${ARG_RESTART_AT}" "${ARG_RESTART_RECURSIVE}" "${BUILD_WORKDIR}"; then + rtl_log_msg failexit "Error: package \`${EX_PKG_DISPATCH_UNKNOWN}' unknown."; + else : $((_build_time_secs=$(rtl_date %s)-${_build_time_secs})); + : $((_build_time_hours=${_build_time_secs}/3600)); + : $((_build_time_minutes=(${_build_time_secs}%3600)/60)); + : $((_build_time_secs=(${_build_time_secs}%3600)%60)); + rtl_log_msg info "${BUILD_NFINI:-0} finished, ${BUILD_NSKIP:-0} skipped, and ${BUILD_NFAIL:-0} failed package(s)."; + rtl_log_msg info "Build time: ${_build_time_hours:-0} hour(s), ${_build_time_minutes:-0} minute(s), and ${_build_time_secs:-0} second(s)."; + if [ -n "${BUILD_PKGS_FAILED}" ]; then + rtl_log_msg failexit "Build script failure(s) in: ${BUILD_PKGS_FAILED}."; fi; - if [ "${ARG_VERBOSE:-0}" -ge 3 ]; then - set -o xtrace; - fi; ;; - exec_step) ex_rtl_log_msg info "Finished build step ${4} of package \`${_pkg_name}'."; ;; - esac; return 0; + fi; + fi; }; -set +o errexit -o noglob; cd "$(dirname "${0}")"; -for __ in $(find subr -name *.subr); do - . "${__}"; done; buildp_dispatch start_build "${@}"; +set +o errexit -o noglob; build "${@}"; # vim:filetype=sh textwidth=0 diff --git a/groups/211.native_packages_cmdline.group b/groups/211.native_packages_cmdline.group index a20ece0..2780c4d 100644 --- a/groups/211.native_packages_cmdline.group +++ b/groups/211.native_packages_cmdline.group @@ -1,6 +1,7 @@ # # Build group native_packages (cmdline) # +GROUP_TARGET="native_packages"; NATIVE_PACKAGES_PACKAGES=" ${NATIVE_PACKAGES_PACKAGES:+${NATIVE_PACKAGES_PACKAGES} } bash bc busybox calcurse coreutils dash datamash dos2unix ed figlet diff --git a/groups/221.native_packages_dev.group b/groups/221.native_packages_dev.group index 0f198eb..38ee197 100644 --- a/groups/221.native_packages_dev.group +++ b/groups/221.native_packages_dev.group @@ -1,6 +1,7 @@ # # Build group native_packages (dev) # +GROUP_TARGET="native_packages"; NATIVE_PACKAGES_PACKAGES=" ${NATIVE_PACKAGES_PACKAGES:+${NATIVE_PACKAGES_PACKAGES} } bison chicken cparser diffutils flex gdb lunix m4 make mandoc nasm patch diff --git a/groups/231.native_packages_etc.group b/groups/231.native_packages_etc.group index 648a8ef..3066191 100644 --- a/groups/231.native_packages_etc.group +++ b/groups/231.native_packages_etc.group @@ -1,6 +1,7 @@ # # Build group native_packages (etc) # +GROUP_TARGET="native_packages"; NATIVE_PACKAGES_PACKAGES=" ${NATIVE_PACKAGES_PACKAGES:+${NATIVE_PACKAGES_PACKAGES} } alsa_lib apr apr_util bdwgc bmake bochs bzip2 clzip cmake cron curl diff --git a/groups/241.native_packages_inet.group b/groups/241.native_packages_inet.group index 7de11db..3d74f8c 100644 --- a/groups/241.native_packages_inet.group +++ b/groups/241.native_packages_inet.group @@ -1,6 +1,7 @@ # # Build group native_packages (inet) # +GROUP_TARGET="native_packages"; NATIVE_PACKAGES_PACKAGES=" ${NATIVE_PACKAGES_PACKAGES:+${NATIVE_PACKAGES_PACKAGES} } apk_tools aria2 bind ca_certificates dropbear fetchmail git gnupg gnutls diff --git a/groups/251.native_packages_lib.group b/groups/251.native_packages_lib.group index 9b33a0c..0fc2ab3 100644 --- a/groups/251.native_packages_lib.group +++ b/groups/251.native_packages_lib.group @@ -1,6 +1,7 @@ # # Build group native_packages (libs) # +GROUP_TARGET="native_packages"; NATIVE_PACKAGES_PACKAGES=" ${NATIVE_PACKAGES_PACKAGES:+${NATIVE_PACKAGES_PACKAGES} } libarchive libasr libassuan libatomic_ops libdmtx libedit libelf libevent diff --git a/groups/261.native_packages_x11.group b/groups/261.native_packages_x11.group index de7a643..19313b2 100644 --- a/groups/261.native_packages_x11.group +++ b/groups/261.native_packages_x11.group @@ -1,6 +1,7 @@ # # Build group native_packages (x11) # +GROUP_TARGET="native_packages"; NATIVE_PACKAGES_PACKAGES=" ${NATIVE_PACKAGES_PACKAGES:+${NATIVE_PACKAGES_PACKAGES} } atk at_spi2_atk at_spi2_core cairo dbus_glib fontconfig freetype diff --git a/groups/999.invariants.group b/groups/999.invariants.group index fd7100f..729c658 100644 --- a/groups/999.invariants.group +++ b/groups/999.invariants.group @@ -1,6 +1,7 @@ # # Build group invariants # +INVARIANTS_FORCE=1; INVARIANTS_NO_LOG_VARS=1; INVARIANTS_PACKAGES="invariants_digest invariants_gitref invariants_minipix invariants_zipdist"; : ${PKG_INVARIANTS_TARBALLS:="invariants_digest invariants_minipix"}; diff --git a/subr/build_init.subr b/subr/build_init.subr index a52ff5f..a1c4f78 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -1,14 +1,6 @@ -buildp_ast() { - local _param="${1}" _pids_killed=""; - rm -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}"; - case "${_param}" in - abort) ex_rtl_log_msg failexit "Build aborted."; ;; - esac; - ex_rtl_kill_tree "${$}"; - if [ -n "${_pids_killed}" ]; then - ex_rtl_log_msg vnfo "Killed PIDs ${_pids_killed}"; - fi; -}; +# +# set +o errexit -o noglob is assumed. +# buildp_init_args() { local _last_pkg=""; _status=""; @@ -25,8 +17,8 @@ buildp_init_args() { fi; fi; case "${ARG_RESTART}" in - ALL) ARG_RESTART_AT=ALL; ;; - LAST) ARG_RESTART_AT=""; ;; + ALL) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=2; ;; + LAST) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=0; ;; "") ;; *:*) ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}"; ;; *) ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")"; ARG_RESTART_AT=ALL; ;; @@ -35,87 +27,116 @@ buildp_init_args() { if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]\ && [ -e "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then _last_pkg="$(cat "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}")"; - ex_rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; - ex_rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}"; + rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; + rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}"; + ARG_RESTART="${_last_pkg}"; fi; fi; - ex_rtl_log_set_vnfo_lvl "${ARG_VERBOSE:-0}"; - BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)"; BUILD_IS_PARENT=1; - BUILD_NFAIL="${BUILD_NFINI:=${BUILD_NSKIP:=0}}"; - BUILD_PKGS_FAILED=""; BUILD_TIMES_SECS="$(ex_rtl_date %s)"; - if [ "${ARG_FETCH_FORCE}" = "ipv4" ]; then - DEFAULT_GIT_ARGS="-4${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}"; - DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; - elif [ "${ARG_FETCH_FORCE}" = "ipv6" ]; then - DEFAULT_GIT_ARGS="-6${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}"; - DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; - fi; + rtl_log_set_vnfo_lvl "${ARG_VERBOSE:-0}"; + case "${ARG_FETCH_FORCE}" in + ipv4) DEFAULT_GIT_ARGS="$(rtl_lconcat "-4" "${DEFAULT_GIT_ARGS}")"; + DEFAULT_WGET_ARGS="$(rtl_lconcat "-4" "${DEFAULT_GIT_ARGS}")"; ;; + ipv6) DEFAULT_GIT_ARGS="$(rtl_lconcat "-6" "${DEFAULT_GIT_ARGS}")"; + DEFAULT_WGET_ARGS="$(rtl_lconcat "-6" "${DEFAULT_GIT_ARGS}")"; ;; + esac; return 0; }; -buildp_init_clean_prefix() { - if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" "prefix" ","; then - ex_rtl_log_msg info "-C prefix specified, cleaning prefix..."; - for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do - ex_rtl_fileop rm "${PREFIX}/${_pname}"; - done; - fi; - return 0; +buildp_init_defaults() { + local _rc=0; _status=""; + + # Command-line arguments + ARCH="nt64"; BUILD="debug"; + ARG_AS_NEEDED=0; ARG_CLEAN_BUILDS=""; ARG_DEBUG_MINIPIX=0; ARG_DIST=""; + ARG_FETCH_FORCE=0; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESTART=""; ARG_VERBOSE=0; + + # Build parameters & state + BUILD_DLCACHEDIR="";BUILD_HNAME=""; BUILD_IS_PARENT=1; BUILD_GROUPS=""; BUILD_TARGET=""; BUILD_USER=""; BUILD_WORKDIR=""; + MIDIPIX_BUILD_PWD=""; PREFIX=""; PREFIX_RPM=""; + + # Global defaults + DEFAULT_BUILD_CPUS=1; + DEFAULT_BUILD_LAST_FAILED_PKG_FNAME="" + DEFAULT_BUILD_LOG_FNAME=""; + DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME=""; + DEFAULT_BUILD_STEPS=""; + DEFAULT_BUILD_VARS=""; + DEFAULT_CLEAR_PREFIX_PATHS=""; + DEFAULT_GIT_ARGS=""; + DEFAULT_GITROOT_HEAD=""; + DEFAULT_LOG_ENV_VARS=""; + DEFAULT_TARGET=""; + DEFAULT_WGET_ARGS=""; + + return "${_rc}"; }; buildp_init_env() { - local _rc=0 _vname="" _vname_val=""; _status=""; - case "${ARG_PARALLEL}" in - auto) - if [ "${DEFAULT_BUILD_CPUS}" -gt 1 ]; then - ARG_PARALLEL=$((${DEFAULT_BUILD_CPUS}/2)); - else - ARG_PARALLEL="${DEFAULT_BUILD_CPUS}"; - fi; ;; - *[^0-9]*) - _rc=10; _status="Error: invalid jobs count \`${ARG_PARALLEL}'."; ;; - esac; - if [ "${_rc}" -eq 0 ]; then - ex_rtl_clean_env "${DEFAULT_CLEAR_ENV_VARS_EXCEPT}"; - if ex_rtl_check_path_vars "${DEFAULT_CHECK_PATH_VARS}"; then - export PATH="${PREFIX}/bin${PATH:+:${PATH}}"; - else - : $((_rc+=(11-1))); - fi; + local _cmd="" _cmds_missing="" _fname="" _rc=0; _status=""; + if ! cd "$(dirname "${0}")" || ! umask 022; then + _rc=1; _status="Error: failed to setup environment"; + else for _cmd in \ + awk bunzip2 cat chmod cmake cp date find flock g++ \ + gcc git grep gunzip gzip hostname install kill \ + ln lzip make mkdir mkfifo mv paste patch perl \ + pgrep pkill printf readlink rm sed seq sha256sum \ + sort stat tail tar test touch tr wget xz zip; do + if ! which "${_cmd}" >/dev/null 2>&1; then + _cmds_missing="$(rtl_lconcat "${_cmds_missing}" "${_cmd}")"; + fi; + done; + if [ -n "${_cmds_missing}" ]; then + _rc=1; _status="Error: missing prerequisite package(s): ${_cmds_missing}"; + elif ! awk -V 2>/dev/null | grep -q "^GNU Awk "; then + _rc=1; _status="Error: awk(1) in \$PATH must be GNU Awk."; + elif ! sed --version 2>/dev/null | grep -q "^GNU sed "; then + _rc=1; _status="Error: sed(1) in \$PATH must be GNU sed."; + else for _fname in $(find subr -name *.subr); do + if ! . "${_fname}"; then + _rc=1; _status="Error: failed to source \`${_fname}'."; break; + fi; + done; fi; fi; return "${_rc}"; }; -buildp_init_exec() { - _status="" - trap "buildp_ast abort" HUP INT TERM USR1 USR2; trap "buildp_ast exit" EXIT; umask 022; - return 0; -}; - buildp_init_files() { local _log_last_fname="" _log_last_ts="" _rc=0; _status="" - if ! ex_rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}"\ - || ex_rtl_lmatch "${ARG_DIST}" "rpm" ","\ - && ! ex_rtl_fileop mkdir "${PREFIX_RPM}"; then - _rc=13; _status="Error: cannot create build directories."; + if ! rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}"\ + || rtl_lmatch "${ARG_DIST}" "rpm" ","\ + && ! rtl_fileop mkdir "${PREFIX_RPM}"; then + _rc=1; _status="Error: cannot create build directories."; elif [ -e "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then - _rc=14; _status="Error: another build targeting this architecture and build type is currently in progress."; + _rc=1; _status="Error: another build targeting this architecture and build type is currently in progress."; + elif ! rtl_clean_env "${DEFAULT_CLEAR_ENV_VARS_EXCEPT}"; then + _rc=1; _status="Error: failed to clean environment."; + elif ! rtl_check_path_vars "${DEFAULT_CHECK_PATH_VARS}"; then + _rc=1; _status="Error: one or more variable containing pathname(s) contains whitespace character(s)."; else touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}"; if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then _log_last_ts="$(stat -c %Y "${DEFAULT_BUILD_LOG_FNAME}")"; _log_last_ts="$(awk 'BEGIN {printf(strftime("%Y-%m-%d-%H-%M-%S", '"${_log_last_ts}"'))}')"; _log_last_fname="${DEFAULT_BUILD_LOG_FNAME}.${_log_last_ts}"; - ex_rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${_log_last_fname}"; - ex_rtl_fileop ln_symbolic "${_log_last_fname}" "${DEFAULT_BUILD_LOG_LAST_FNAME}"; + rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${_log_last_fname}"; + rtl_fileop ln_symbolic "${_log_last_fname}" "${DEFAULT_BUILD_LOG_LAST_FNAME}"; + fi; + rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}"; + if rtl_lmatch "${ARG_CLEAN_BUILDS}" "prefix" ","; then + rtl_log_msg info "-C prefix specified, cleaning prefix..."; + for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do + if ! rtl_fileop rm "${PREFIX}/${_pname}"; then + _rc=1; _status="Error: failed to remove \`${PREFIX}/${_pname}'."; break; + fi; + done; fi; - ex_rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}"; + export PATH="${PREFIX}/bin${PATH:+:${PATH}}"; fi; return "${_rc}"; }; buildp_init_getopts() { - local _opt="" _shiftfl=0; _status=""; + local _opt="" _rc=0 _shiftfl=0 OPTIND=0; _status=""; while [ "${#}" -gt 0 ]; do case "${1}" in --as-needed) ARG_AS_NEEDED=1; _shiftfl=1; ;; @@ -148,108 +169,75 @@ buildp_init_getopts() { if [ "${_rc}" -eq 0 ]; then while [ ${#} -gt 0 ]; do case "${1}" in - *=*) ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; - [^a-zA-Z]*) _rc=2; _status="Error: build group names must start with [a-zA-Z]."; ;; - *[^_a-zA-Z]*) _rc=3; _status="Error: build group names must not contain [^_a-zA-Z]."; ;; - *) BUILD_GROUPS="${BUILD_GROUPS:+${BUILD_GROUPS} }${1}"; ;; + *=*) rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; + [^a-zA-Z]*) _rc=1; _status="Error: build group names must start with [a-zA-Z]."; ;; + *[^_a-zA-Z]*) _rc=1; _status="Error: build group names must not contain [^_a-zA-Z]."; ;; + *) BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "${1}")"; esac; shift; done; fi; return "${_rc}"; }; -buildp_init_prereqs() { - local _cmd="" _cmds_missing="" _rc=0; _status=""; - for _cmd in \ - awk bunzip2 cat chmod cmake cp date find flock g++ \ - gcc git grep gunzip gzip hostname install kill \ - ln lzip make mkdir mkfifo mv paste patch perl \ - pgrep pkill printf readlink rm sed seq sha256sum \ - sort stat tail tar test touch tr wget xz zip; do - if ! which "${_cmd}" >/dev/null 2>&1; then - _cmds_missing="$(ex_rtl_lconcat "${_cmds_missing}" "${_cmd}")"; - fi; - done; - if [ -n "${_cmds_missing}" ]; then - _rc=4; _status="Error: missing prerequisite package(s): ${_cmds_missing}"; - elif ! awk -V 2>/dev/null | grep -q "^GNU Awk "; then - _rc=5; _status="Error: awk(1) in \$PATH must be GNU Awk."; - elif ! sed --version 2>/dev/null | grep -q "^GNU sed "; then - _rc=6; _status="Error: sed(1) in \$PATH must be GNU sed."; - fi; - return "${_rc}"; -}; - -buildp_init_type() { - local _rc=0; _status=""; - : ${ARCH:=nt64}; : ${BUILD:=debug}; - if [ "${ARCH}" = nt32 ]; then - DEFAULT_TARGET="i686-nt32-midipix"; - elif [ "${ARCH}" = nt64 ]; then - DEFAULT_TARGET="x86_64-nt64-midipix"; - else - if [ "${BUILD}" != debug ]\ - && [ "${BUILD}" != release ]; then - _rc=7; _status="Error: unknown build type \`${BUILD}'."; - fi; - _rc=8; _status="Error: invalid architecture \`${ARCH}'."; - fi; - return "${_rc}"; -}; - buildp_init_vars() { - local _fname="" _rc=0; _status=""; - if [ -z "${DEFAULT_BUILD_CPUS}" ]; then - if [ -e /proc/cpuinfo ]; then + local _default_build_groups="" _fname="" _rc=0 _target=""; _status=""; + if ! rtl_lmatch "${ARCH}" "nt32 nt64"; then + _rc=1; _status="Error: invalid architecture \`${ARCH}'."; + elif ! rtl_lmatch "${BUILD}" "debug release"; then + _rc=1; _status="Error: unknown build type \`${BUILD}'."; + elif [ -n "${ARG_PARALLEL}" ] && [ "${ARG_PARALLEL}" != "auto" ]\ + && ! rtl_isnumber "${ARG_PARALLEL}"; then + _rc=1; _status="Error: invalid jobs count \`${ARG_PARALLEL}'."; + else + case "${ARCH}" in + nt32) DEFAULT_TARGET="i686-nt32-midipix"; ;; + nt64) DEFAULT_TARGET="x86_64-nt64-midipix"; ;; + esac; + if [ -e "/proc/cpuinfo" ]; then DEFAULT_BUILD_CPUS="$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo)"; - else - DEFAULT_BUILD_CPUS=1; + if [ "${ARG_PARALLEL}" = "auto" ]\ + && [ "${DEFAULT_BUILD_CPUS}" -gt 1 ]; then + ARG_PARALLEL=$((${DEFAULT_BUILD_CPUS}/2)); + fi; fi; - fi; - for _fname in \ - ${HOME}/midipix_build.vars \ - ${HOME}/.midipix_build.vars \ - ../midipix_build.vars \ - ./vars/env.vars; do - [ -e ${_fname} ] && . ${_fname}; - done; - for _fname in $(find ./groups -name *.group | sort); do - . "${_fname}"; _fname="${_fname##*/}"; _fname="${_fname%.group}"; - if [ "${_fname#[0-9][0-9][0-9].*}" != "${_fname}" ]\ - && [ "${_fname#*[1-9].*}" = "${_fname}" ]\ - && [ "${_fname}" != "999.invariants.group" ]; then - GROUPS_DEFAULT="${GROUPS_DEFAULT:+${GROUPS_DEFAULT} }${_fname#*.}"; + rtl_fileop source_opt \ + "${HOME}/midipix_build.vars" "${HOME}/.midipix_build.vars" \ + ../midipix_build.vars ./vars/env.vars; + if [ -z "${PREFIX}" ]; then + _rc=1; _status="Error: \${PREFIX} empty or unset."; + else + for _fname in $(find ./groups -name *.group | sort); do + rtl_fileop source_opt "${_fname}"; + if [ -n "${BUILD_TARGET}" ]; then + _target="${BUILD_TARGET}"; unset BUILD_TARGET; + else + _fname="${_fname##*/}"; _fname="${_fname%.group}"; _target="${_fname#*.}"; + fi; + _default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_target}")"; + done; + if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then + _default_build_groups="$(rtl_lfilter "${_default_build_groups}" "host_deps_rpm")"; + fi; + if [ -z "${BUILD_GROUPS}" ]; then + BUILD_GROUPS="${_default_build_groups}"; + fi; + BUILD_GROUPS="$(rtl_lfilter "${BUILD_GROUPS}" "invariants")"; + BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "invariants")"; fi; - done; - if [ -z "${PREFIX}" ]; then - _rc=9; _status="Error: \${PREFIX} empty or unset."; fi; return "${_rc}"; }; -build_fini() { - : $((BUILD_TIMES_SECS=$(ex_rtl_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 "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then - ex_rtl_fileop rm ${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}; - fi; -}; - build_init() { - local _rc=0 _status=""; - if ! buildp_init_exec \ + local _fname="" _rc=0 _status=""; + if ! buildp_init_env \ + || ! buildp_init_defaults \ || ! buildp_init_getopts "${@}" \ - || ! buildp_init_prereqs \ - || ! buildp_init_type \ || ! buildp_init_vars \ - || ! buildp_init_env \ || ! buildp_init_args \ - || ! buildp_init_files \ - || ! buildp_init_clean_prefix; then - _rc="${?}"; ex_rtl_log_msg fail "${_status}"; exit "${_rc}"; + || ! buildp_init_files; then + _rc="${?}"; rtl_log_msg fail "${_status}"; exit "${_rc}"; elif [ -n "${_status}" ]; then - ex_rtl_log_msg info "${_status}"; exit 0; + rtl_log_msg info "${_status}"; exit 0; else return "${_rc}"; fi; diff --git a/subr/ex_pkg.subr b/subr/ex_pkg.subr new file mode 100644 index 0000000..fd2df52 --- /dev/null +++ b/subr/ex_pkg.subr @@ -0,0 +1,75 @@ +# +# set +o errexit -o noglob is assumed. +# + +# +# ex_pkg_check_depends() - check single named package for unsatisfied dependencies +# @_pkg_complete: list of completed packages +# @_pkg_name: single package name +# @_pkg_wait: list of in-progress packages +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# +# Return: zero (0) given no outstanding dependencies, non-zero (>0) otherwise +# +ex_pkg_check_depends() { + local _pkg_complete="${1}" _pkg_name="${2}" _pkg_wait="${3}" _restart_recursive="${4}" \ + _pkg_depends="" _pkg_name_depend="" _dependfl=0; + if _pkg_depends="$(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\ + && [ -n "${_pkg_depends}" ]\ + && ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then + for _pkg_name_depend in $(rtl_uniq ${_pkg_depends}); do + if ! rtl_lmatch "${_pkg_complete}" "${_pkg_name_depend}"\ + || rtl_lmatch "${_pkg_wait}" "${_pkg_name_depend}"; then + _dependfl=1; break; + fi; + done; + fi; + return "${_dependfl}"; +}; + +# +# ex_pkg_expand_packages() - expand build group name to list of packages ordered and filtered according to dependency and restart constraints +# @_group_name: build group name +# @_restart: optional comma-separated list of package names to rebuild +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# +# Return: zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_COMPLETE}, ${EXP_PKG_DISABLED}, ${EXP_PKG_FINISHED}, and ${EXP_PKG_NAMES} set post-return. +# +ex_pkg_expand_packages() { + local _group_name="${1}" _restart="${2}" _restart_recursive="${3}" \ + _pkg_name="" _pkg_names="" _restart_check=0; + EXP_PKG_COMPLETE=""; EXP_PKG_DISABLED=""; EXP_PKG_FINISHED=""; EXP_PKG_NAMES=""; + if _pkg_names="$(rtl_get_var_unsafe -u "${_group_name}_PACKAGES")"\ + && [ -n "${_pkg_names}" ]; then + if [ -n "${_restart}" ] && ! rtl_lmatch "${_restart}" "ALL LAST"; then + _pkg_names="$(rtl_lsearch "${_pkg_names}" "${_restart}")"; + fi; + if ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then + _pkg_names="$(rtl_uniq $(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' ${_pkg_names}))"; + fi; + for _pkg_name in ${_pkg_names}; do + if [ "${_restart}" = "ALL" ]\ + || rtl_lmatch "${_restart}" "${_pkg_name}"; then + _restart_check=1; + else + _restart_check=0; + fi; + if [ -n "$(rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" ]; then + EXP_PKG_COMPLETE="$(rtl_lconcat "${EXP_PKG_COMPLETE}" "${_pkg_name}")"; + EXP_PKG_DISABLED="$(rtl_lconcat "${EXP_PKG_DISABLED}" "${_pkg_name}")"; + _pkg_names="$(rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + elif ex_pkg_state_test "${_pkg_name}" finish\ + && [ "${_restart_check:-0}" -eq 0 ]\ + && [ "${_restart_recursive:-0}" -ne 2 ]\ + && [ "x$(rtl_get_var_unsafe -u "${_group_name}_FORCE")" != "x1" ]; then + EXP_PKG_COMPLETE="$(rtl_lconcat "${EXP_PKG_COMPLETE}" "${_pkg_name}")"; + EXP_PKG_FINISHED="$(rtl_lconcat "${EXP_PKG_FINISHED}" "${_pkg_name}")"; + _pkg_names="$(rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + fi; + done; + EXP_PKG_NAMES="${_pkg_names}"; + fi; + return 0; +}; + +# vim:filetype=sh textwidth=0 diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 2d34a90..bd152f2 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -3,49 +3,106 @@ # # -# exp_pkg_check_depends() - check single named package for unsatisfied dependencies -# @_pkg_complete: list of completed packages -# @_pkg_name: single package name -# @_pkg_wait: list of in-progress packages -# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) -# -# Return: zero (0) given no outstanding dependencies, non-zero (>0) otherwise -# -exp_pkg_check_depends() { - local _pkg_complete="${1}" _pkg_name="${2}" _pkg_wait="${3}" _restart_recursive="${4}" \ - _pkg_depends="" _pkg_name_depend="" _dependfl=0; - if _pkg_depends="$(ex_rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(ex_rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\ - && [ -n "${_pkg_depends}" ]\ - && ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then - for _pkg_name_depend in $(ex_rtl_uniq ${_pkg_depends}); do - if ! ex_rtl_lmatch "${_pkg_complete}" "${_pkg_name_depend}"\ - || ex_rtl_lmatch "${_pkg_wait}" "${_pkg_name_depend}"; then - _dependfl=1; break; +# exp_pkg_dispatch_complete() - XXX +# @_dispatch_fn: top-level dispatch function name +# @_group_names: build group name(s) +# @_pkg_disabled: list of disabled packages +# @_pkg_finished: list of finished packages +# +# Return: zero (0) on success, non-zero (>0) on failure. +# +exp_pkg_dispatch_complete() { + local _dispatch_fn="${1}" _group_name="${2}" _pkg_disabled="${3}" _pkg_finished="${4}" _pkg_name=""; + for _pkg_name in ${_pkg_disabled}; do + "${_dispatch_fn}" disabled_pkg "${_group_name}" "${_pkg_name}"; + done; + for _pkg_name in ${_pkg_finished}; do + "${_dispatch_fn}" skipped_pkg "${_group_name}" "${_pkg_name}"; + done; +}; + +# +# exp_pkg_dispatch_group() - dispatch a single build group +# @_build_steps_default: list of default build steps +# @_build_vars_default: list of default build variables +# @_dispatch_fn: top-level dispatch function name +# @_group_name: build group name +# @_njobs_max: maximum count of simultaneous jobs +# @_pipe_path: pathname to build FIFO +# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# @_workdir: pathname to build-specific temporary directory +# +# Return: zero (0) on success, non-zero (>0) on failure. +# +exp_pkg_dispatch_group() { + local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \ + _group_name="${4}" _njobs_max="${5}" _pipe_path="${6}" _restart_at="${7}" \ + _restart_recursive="${8}" _workdir="${9}" _pipe_msg="" _pkg_name="" _rc=0; + rtl_fileop mkfifo "${_pipe_path}"; + while true; do + while [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -gt 0 ] && read _pipe_msg; do + case "${_pipe_msg%% *}" in + done) : $((EXP_PKG_DISPATCH_NJOBS-=1)); _pkg_name="${_pipe_msg#done * }"; + "${_dispatch_fn}" finish_pkg ${_pipe_msg#done }; + EXP_PKG_COMPLETE="$(rtl_lconcat "${EXP_PKG_COMPLETE}" "${_pkg_name}")"; + EXP_PKG_NAMES="$(rtl_lfilter "${EXP_PKG_NAMES}" "${_pkg_name}")"; + EXP_PKG_DISPATCH_WAIT="$(rtl_lfilter "${EXP_PKG_DISPATCH_WAIT}" "${_pkg_name}")"; + if [ -n "${EXP_PKG_NAMES}" ] && [ "${_rc}" -eq 0 ]; then + if [ "${EXP_PKG_DISPATCH_NJOBS}" -ne "${_njobs_max}" ]; then + exp_pkg_dispatch_packages "${_build_steps_default}" \ + "${_build_vars_default}" "${_dispatch_fn}" \ + "${_group_name}" "${_njobs_max}" \ + "${_pipe_path}" "${EXP_PKG_COMPLETE}" \ + "${_restart_at}" "${_restart_recursive}" "${_workdir}"; + fi; + elif [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -eq 0 ]; then + break; + fi; ;; + fail) : $((EXP_PKG_DISPATCH_NJOBS-=1)); _rc=1; + "${_dispatch_fn}" fail_pkg ${_pipe_msg#fail }; ;; + step) "${_dispatch_fn}" step_pkg ${_pipe_msg#step }; ;; + esac; done <>"${_pipe_path}"; + if [ -n "${EXP_PKG_NAMES}" ] && [ "${_rc}" -eq 0 ]; then + if [ "${EXP_PKG_DISPATCH_NJOBS}" -ne "${_njobs_max}" ]; then + exp_pkg_dispatch_packages "${_build_steps_default}" \ + "${_build_vars_default}" "${_dispatch_fn}" \ + "${_group_name}" "${_njobs_max}" "${_pipe_path}" \ + "${EXP_PKG_COMPLETE}" "${_restart_at}" \ + "${_restart_recursive}" "${_workdir}"; fi; - done; - fi; - return "${_dependfl}"; + elif [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -eq 0 ]; then + break; + fi; + done; + rtl_fileop rm "${_pipe_path}"; + return "${_rc}"; }; # # exp_pkg_dispatch_package() - dispatch single named packages -# @_dispatch_fn: top-level dispatch function name -# @_group_name: build group name -# @_pkg_name: single package name -# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_build_steps_default: list of default build steps +# @_build_vars_default: list of default build variables +# @_dispatch_fn: top-level dispatch function name +# @_group_name: build group name +# @_pkg_name: single package name +# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_workdir: pathname to build-specific temporary directory # -# Return: zero (0) on success, non-zero (>0) on failure, ${NJOBS}, ${PKG_COUNT}, ${PKG_NAMES}, and ${PKG_WAIT} may be mutated post-return. +# Return: zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_DISPATCH_NJOBS}, ${EXP_PKG_DISPATCH_COUNT}, ${EXP_PKG_NAMES}, and ${EXP_PKG_DISPATCH_WAIT} may be mutated post-return. # exp_pkg_dispatch_package() { - local _dispatch_fn="${1}" _group_name="${2}" _pkg_name="${3}" _restart_at="${4}"; - if "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}" "$((${PKG_COUNT}+1))" "${PKG_COUNT_MAX}"; then - : $((NJOBS+=1)); : $((PKG_COUNT+=1)); PKG_WAIT="$(ex_rtl_lconcat "${PKG_WAIT}" "${_pkg_name}")"; + local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \ + _group_name="${4}" _pkg_name="${5}" _restart_at="${6}" _workdir="${7}"; + if "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}" "$((${EXP_PKG_DISPATCH_COUNT}+1))" "${EXP_PKG_DISPATCH_COUNT_MAX}"; then + : $((EXP_PKG_DISPATCH_NJOBS+=1)); : $((EXP_PKG_DISPATCH_COUNT+=1)); EXP_PKG_DISPATCH_WAIT="$(rtl_lconcat "${EXP_PKG_DISPATCH_WAIT}" "${_pkg_name}")"; (set +o errexit -o noglob; BUILD_IS_PARENT=0; - if ex_pkg_env "${_group_name}" "${_pkg_name}" "${_restart_at}"; then + if ex_pkg_env "${_build_steps_default}" "${_build_vars_default}" \ + "${_group_name}" "${_pkg_name}" "${_restart_at}" "${_workdir}"; then ex_pkg_exec "${_dispatch_fn}" "${_group_name}" "${_pkg_name}" "${_restart_at}"; else return "${?}"; - fi;) 1>"${BUILD_WORKDIR}/${_pkg_name}_stderrout.log" 2>&1 3>"${_pipe_path}" & + fi;) 1>"${_workdir}/${_pkg_name}_stderrout.log" 2>&1 3>"${_pipe_path}" & else return "${?}"; fi; @@ -53,123 +110,96 @@ exp_pkg_dispatch_package() { # # exp_pkg_dispatch_packages() - dispatch set of packages -# @_dispatch_fn: top-level dispatch function name -# @_group_name: build group name -# @_njobs_max: maximum count of simultaneous jobs -# @_pipe_path: pathname to parent-child process FIFO -# @_pkg_complete: list of completed packages -# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL -# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) -# -# Return: zero (0) on success, non-zero (>0) on failure, ${NJOBS}, ${PKG_COUNT}, ${PKG_NAMES}, and ${PKG_WAIT} may be mutated post-return. +# @_build_steps_default: list of default build steps +# @_build_vars_default: list of default build variables +# @_dispatch_fn: top-level dispatch function name +# @_group_name: build group name +# @_njobs_max: maximum count of simultaneous jobs +# @_pipe_path: pathname to parent-child process FIFO +# @_pkg_complete: list of completed packages +# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# @_workdir: pathname to build-specific temporary directory +# +# Return: zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_DISPATCH_NJOBS}, ${EXP_PKG_DISPATCH_COUNT}, ${EXP_PKG_NAMES}, and ${EXP_PKG_DISPATCH_WAIT} may be mutated post-return. # exp_pkg_dispatch_packages() { - local _dispatch_fn="${1}" _group_name="${2}" _njobs_max="${3}" _pipe_path="${4}" \ - _pkg_complete="${5}" _restart_at="${6}" _restart_recursive="${7}" \ + local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \ + _group_name="${4}" _njobs_max="${5}" _pipe_path="${6}" _pkg_complete="${7}" \ + _restart_at="${8}" _restart_recursive="${9}" _workdir="${10}" \ _njob=0 _pkg_depends="" _pkg_name=""; - for _njob in $(seq 1 $((${_njobs_max}-${NJOBS}))); do - for _pkg_name in ${PKG_NAMES}; do - if ! ex_rtl_lmatch "${_pkg_complete}" "${_pkg_name}"\ - && ! ex_rtl_lmatch "${PKG_WAIT}" "${_pkg_name}"\ - && exp_pkg_check_depends "${_pkg_complete}" "${_pkg_name}" "${PKG_WAIT}" "${_restart_recursive}"; then - exp_pkg_dispatch_package "${_dispatch_fn}" "${_group_name}" "${_pkg_name}" "${_restart_at}"; break; + for _njob in $(seq 1 $((${_njobs_max}-${EXP_PKG_DISPATCH_NJOBS}))); do + for _pkg_name in ${EXP_PKG_NAMES}; do + if ! rtl_lmatch "${_pkg_complete}" "${_pkg_name}"\ + && ! rtl_lmatch "${EXP_PKG_DISPATCH_WAIT}" "${_pkg_name}"\ + && ex_pkg_check_depends "${_pkg_complete}" "${_pkg_name}" "${EXP_PKG_DISPATCH_WAIT}" "${_restart_recursive}"; then + exp_pkg_dispatch_package "${_build_steps_default}" \ + "${_build_vars_default}" "${_dispatch_fn}" \ + "${_group_name}" "${_pkg_name}" "${_restart_at}" \ + "${_workdir}"; break; fi; done; done; }; # -# exp_pkg_expand_packages() - expand build group name to list of packages ordered and filtered according to dependency and restart constraints -# @_group_name: build group name -# @_restart: optional comma-separated list of package names to rebuild -# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# ex_pkg_dispatch() - dispatch a set of build group +# @_build_steps_default: list of default build steps +# @_build_vars_default: list of default build variables +# @_dispatch_fn: top-level dispatch function name +# @_group_names: build group name(s) +# @_njobs_max: maximum count of simultaneous jobs +# @_pipe_path: pathname to build FIFO +# @_restart: optional comma-separated list of package names to rebuild +# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# @_workdir: pathname to build-specific temporary directory # -# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_NAMES} and ${PKG_COMPLETE} set post-return. +# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_DISPATCH_UNKNOWN} mutated post-return. # -exp_pkg_expand_packages() { - local _group_name="${1}" _restart="${2}" _restart_recursive="${3}" _pkg_name="" _pkg_names=""; - if _pkg_names="$(ex_rtl_get_var_unsafe -u "${_group_name}_PACKAGES")"\ - && [ -n "${_pkg_names}" ]; then - if [ -n "${_restart}" ] && ! ex_rtl_lmatch "${_restart}" "ALL LAST"; then - _pkg_names="$(ex_rtl_lsearch "${_pkg_names}" "${_restart}")"; - fi; - if ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then - _pkg_names="$(ex_rtl_uniq $(ex_rtl_lunfold_depends 'PKG_${_name}_DEPENDS' ${_pkg_names}))"; +ex_pkg_dispatch() { + local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \ + _group_names="${4}" _njobs_max="${5}" _pipe_path="${6}" _restart="${7}" \ + _restart_at="${8}" _restart_recursive="${9}" _workdir="${10}" \ + _pkg_name="" _pkg_names="" _rc=0 \ + EXP_PKG_COMPLETE EXP_PKG_DISABLED EXP_PKG_FINISHED EXP_PKG_DISPATCH_COUNT \ + EXP_PKG_DISPATCH_COUNT_MAX EXP_PKG_DISPATCH_NJOBS EXP_PKG_NAMES EXP_PKG_DISPATCH_WAIT; + EX_PKG_DISPATCH_UNKNOWN=""; + for _group_name in ${_group_names}; do + EXP_PKG_COMPLETE="" EXP_PKG_DISABLED="" EXP_PKG_FINISHED=""; + EXP_PKG_DISPATCH_COUNT=0 EXP_PKG_DISPATCH_COUNT_MAX=0 EXP_PKG_DISPATCH_NJOBS=0; + EXP_PKG_NAMES="" EXP_PKG_DISPATCH_WAIT=""; + if "${_dispatch_fn}" start_group "${_group_name}" ""; then + if rtl_fileop mkdir "${_workdir}"\ + && rtl_log_msg vnfo "Resolving \`${_group_name}' dependencies..."\ + && ex_pkg_expand_packages "${_group_name}" "${_restart}" "${_restart_recursive}"\ + && exp_pkg_dispatch_complete "${_dispatch_fn}" "${_group_name}" "${EXP_PKG_DISABLED}" "${EXP_PKG_FINISHED}"\ + && rtl_log_msg vnfo "Resolved \`${_group_name}' dependencies."\ + && EXP_PKG_DISPATCH_COUNT_MAX="$(rtl_llength "${EXP_PKG_NAMES}")"\ + && [ "${EXP_PKG_DISPATCH_COUNT_MAX}" -gt 0 ]; then + _pkg_names="$(rtl_lconcat "${_pkg_names}" "${EXP_PKG_NAMES}")"; + exp_pkg_dispatch_group "${_build_steps_default}" \ + "${_build_vars_default}" "${_dispatch_fn}" "${_group_name}" \ + "${_njobs_max}" "${_pipe_path}" "${_restart_at}" \ + "${_restart_recursive}" "${_workdir}"; _rc="${?}"; + fi; + "${_dispatch_fn}" finish_group "${_group_name}" ""; + if [ "${_rc}" -ne 0 ]; then + break; + fi; fi; - for _pkg_name in ${_pkg_names}; do - if [ -n "$(ex_rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" ]; then - PKG_COMPLETE="$(ex_rtl_lconcat "${PKG_COMPLETE}" "${_pkg_name}")"; - _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; - "${_dispatch_fn}" disabled_pkg "${_group_name}" "${_pkg_name}"; - elif ex_pkg_state_test "${_pkg_name}" finish\ - && ! ex_rtl_lmatch "${_restart}" "${_pkg_name}"\ - && [ "${_restart_recursive:-0}" -ne 2 ]; then - PKG_COMPLETE="$(ex_rtl_lconcat "${PKG_COMPLETE}" "${_pkg_name}")"; - _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; - "${_dispatch_fn}" skipped_pkg "${_group_name}" "${_pkg_name}"; + done; + if ! rtl_lmatch "${_restart}" "ALL LAST"; then + for _pkg_name in ${_restart}; do + if ! rtl_lmatch "${_pkg_names}" "${_restart}"; then + EX_PKG_DISPATCH_UNKNOWN="$(rtl_lconcat "${EX_PKG_DISPATCH_UNKNOWN}" "${_pkg_name}")"; fi; done; - EX_PKG_NAMES="${_pkg_names}"; return 0; fi; -}; - -# -# ex_pkg_dispatch() - dispatch a single build group -# @_dispatch_fn: top-level dispatch function name -# @_group_name: build group name -# @_njobs_max: maximum count of simultaneous jobs -# @_restart: optional comma-separated list of package names to rebuild -# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL -# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) -# -# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_NAMES} set post-return. -# -ex_pkg_dispatch() { - local _dispatch_fn="${1}" _group_name="${2}" _njobs_max="${3}" _restart="${4}" _restart_at="${5}" \ - _restart_recursive="${6}" _pipe_msg="" _pipe_path="${BUILD_WORKDIR}/build.fifo" _pkg_name="" \ - _script_rc=0 NJOBS=0 PKG_COMPLETE="" PKG_COUNT=0 PKG_COUNT_MAX=0 PKG_NAMES="" PKG_WAIT=""; EX_PKG_NAMES=""; - if "${_dispatch_fn}" start_group "${_group_name}" ""; then - if ex_rtl_fileop mkdir "${BUILD_WORKDIR}"\ - && ex_rtl_log_msg vnfo "Resolving \`${_group_name}' dependencies..."\ - && exp_pkg_expand_packages "${_group_name}" "${_restart}" "${_restart_recursive}"\ - && ex_rtl_log_msg vnfo "Resolved \`${_group_name}' dependencies."\ - && PKG_COUNT_MAX="$(ex_rtl_llength "${EX_PKG_NAMES}")"\ - && [ "${PKG_COUNT_MAX}" -gt 0 ]; then - PKG_NAMES="${EX_PKG_NAMES}"; ex_rtl_fileop mkfifo "${_pipe_path}"; - while true; do - while [ "${NJOBS:-0}" -gt 0 ] && read _pipe_msg; do - case "${_pipe_msg%% *}" in - done) : $((NJOBS-=1)); _pkg_name="${_pipe_msg#done * }"; - "${_dispatch_fn}" finish_pkg ${_pipe_msg#done }; - PKG_COMPLETE="$(ex_rtl_lconcat "${PKG_COMPLETE}" "${_pkg_name}")"; - PKG_NAMES="$(ex_rtl_lfilter "${PKG_NAMES}" "${_pkg_name}")"; - PKG_WAIT="$(ex_rtl_lfilter "${PKG_WAIT}" "${_pkg_name}")"; - if [ -n "${PKG_NAMES}" ] && [ "${_script_rc}" -eq 0 ]; then - if [ "${NJOBS}" -ne "${_njobs_max}" ]; then - exp_pkg_dispatch_packages "${_dispatch_fn}" "${_group_name}" "${_njobs_max}" \ - "${_pipe_path}" "${PKG_COMPLETE}" "${_restart_at}" "${_restart_recursive}"; - fi; - elif [ "${NJOBS:-0}" -eq 0 ]; then - break; - fi; ;; - fail) : $((NJOBS-=1)); _script_rc=1; - "${_dispatch_fn}" fail_pkg ${_pipe_msg#fail }; ;; - step) "${_dispatch_fn}" step_pkg ${_pipe_msg#step }; ;; - esac; done <>"${_pipe_path}"; - if [ -n "${PKG_NAMES}" ] && [ "${_script_rc}" -eq 0 ]; then - if [ "${NJOBS}" -ne "${_njobs_max}" ]; then - exp_pkg_dispatch_packages "${_dispatch_fn}" "${_group_name}" "${_njobs_max}" \ - "${_pipe_path}" "${PKG_COMPLETE}" "${_restart_at}" "${_restart_recursive}"; - fi; - elif [ "${NJOBS:-0}" -eq 0 ]; then - break; - fi; - done; - ex_rtl_fileop rm "${_pipe_path}"; - fi; - "${_dispatch_fn}" finish_group "${_group_name}" ""; + if [ -n "${EX_PKG_DISPATCH_UNKNOWN}" ]; then + _rc=1; fi; - return "${_script_rc}"; + return "${_rc}"; }; # vim:filetype=sh textwidth=0 diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr index e92f5e4..7f58d3d 100644 --- a/subr/ex_pkg_env.subr +++ b/subr/ex_pkg_env.subr @@ -4,17 +4,19 @@ # # exp_pkg_env_defaults() - set package variable defaults for single named package -# @_pkg_name: single package name +# @_build_steps_default: list of default build steps +# @_pkg_name: single package name +# @_workdir: pathname to build-specific temporary directory # # Return: zero (0) on success, non-zero (>0) on failure # exp_pkg_env_defaults() { - local _pkg_name="${1}"; + local _build_steps_default="${1}" _pkg_name="${2}" _workdir="${3}"; : ${PKG_NAME:="${_pkg_name}"}; : ${MIDIPIX_BUILD_PWD:="$(pwd)"}; - : ${PKG_BASE_DIR:="${BUILD_WORKDIR}/${_pkg_name}-${PKG_BUILD_TYPE}-${PKG_TARGET}"}; + : ${PKG_BASE_DIR:="${_workdir}/${_pkg_name}-${PKG_BUILD_TYPE}-${PKG_TARGET}"}; : ${PKG_FNAME:="${PKG_URL##*/}"}; - : ${PKG_BUILD_STEPS:="$(ex_rtl_lfilter "${DEFAULT_BUILD_STEPS}" "${PKG_BUILD_STEPS_DISABLE}")"}; + : ${PKG_BUILD_STEPS:="$(rtl_lfilter "${_build_steps_default}" "${PKG_BUILD_STEPS_DISABLE}")"}; if [ -z "${PKG_SUBDIR}" ]; then if [ -n "${PKG_URLS_GIT}" ]; then PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; @@ -36,6 +38,7 @@ exp_pkg_env_defaults() { # # exp_pkg_env_set() - set package variables for single named package +# @_build_vars_default: list of default build variables # @_group_name: build group name # @_pkg_name: single package name # @@ -47,40 +50,44 @@ exp_pkg_env_defaults() { # Return: zero (0) on success, non-zero (>0) on failure # exp_pkg_env_set() { - local _group_name="${1}" _pkg_name="${2}" _var_prefixes="" _vars_set="" _vname=""; - ex_rtl_set_vars _vars_set BUILD_TYPE "DEFAULT ${_group_name} PKG_${_pkg_name}"; - ex_rtl_set_vars _vars_set INHERIT_FROM "PKG_${_pkg_name}"; - _var_prefixes="$(ex_rtl_toupper "DEFAULT DEFAULT_${PKG_BUILD_TYPE} ${_group_name}")"; - for _vname in $(ex_rtl_lfilter "${DEFAULT_BUILD_VARS}" BUILD_TYPE); do + local _build_vars_default="${1}" _group_name="${2}" _pkg_name="${3}" _var_prefixes="" _vars_set="" _vname=""; + rtl_set_vars _vars_set BUILD_TYPE "DEFAULT ${_group_name} PKG_${_pkg_name}"; + rtl_set_vars _vars_set INHERIT_FROM "PKG_${_pkg_name}"; + _var_prefixes="$(rtl_toupper "DEFAULT DEFAULT_${PKG_BUILD_TYPE} ${_group_name}")"; + for _vname in $(rtl_lfilter "${_build_vars_default}" BUILD_TYPE); do if [ -n "${PKG_INHERIT_FROM}" ]; then - ex_rtl_set_vars _vars_set "${_vname}" \ - "$(ex_rtl_lconcat "${_var_prefixes}" "$(ex_rtl_toupper "PKG_${PKG_INHERIT_FROM} PKG_${_pkg_name}")")" + rtl_set_vars _vars_set "${_vname}" \ + "$(rtl_lconcat "${_var_prefixes}" "$(rtl_toupper "PKG_${PKG_INHERIT_FROM} PKG_${_pkg_name}")")" else - ex_rtl_set_vars _vars_set "${_vname}" \ - "$(ex_rtl_lconcat "${_var_prefixes}" "$(ex_rtl_toupper "PKG_${_pkg_name}")")"; + rtl_set_vars _vars_set "${_vname}" \ + "$(rtl_lconcat "${_var_prefixes}" "$(rtl_toupper "PKG_${_pkg_name}")")"; fi; done; - ex_rtl_push_IFS :; for _vname in ${PKG_ENV_VARS_EXTRA}; do + rtl_push_IFS :; for _vname in ${PKG_ENV_VARS_EXTRA}; do export "${_vname}"; - done; ex_rtl_pop_IFS; - ex_rtl_unset_vars $(ex_rtl_lfilter \ + done; rtl_pop_IFS; + rtl_unset_vars $(rtl_lfilter \ "$(set | awk -F= '/^PKG_/{print $1}' | sort)" \ "${_vars_set}"); }; # # ex_pkg_env() - set package variables for single named package -# @_group_name: build group name -# @_pkg_name: single package name -# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_build_steps_default: list of default build steps +# @_build_vars_default: list of default build variables +# @_group_name: build group name +# @_pkg_name: single package name +# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL +# @_workdir: pathname to build-specific temporary directory # # Return: zero (0) on success, non-zero (>0) on failure # ex_pkg_env() { - local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}" _vname=""; - ex_rtl_fileop source_opt "vars/${_pkg_name}.vars"; - if ! exp_pkg_env_set "${_group_name}" "${_pkg_name}"\ - || ! exp_pkg_env_defaults "${_pkg_name}"; then + local _build_steps_default="${1}" _build_vars_default="${2}" _group_name="${3}" \ + _pkg_name="${4}" _restart_at="${5}" _workdir="${6}" _vname=""; + rtl_fileop source_opt "vars/${_pkg_name}.vars"; + if ! exp_pkg_env_set "${_build_vars_default}" "${_group_name}" "${_pkg_name}"\ + || ! exp_pkg_env_defaults "${_build_steps_default}" "${_pkg_name}" "${_workdir}"; then return "${?}"; fi; }; @@ -94,7 +101,7 @@ ex_pkg_env() { # Return: zero (0) on success, non-zero (>0) on failure # ex_pkg_state_set() { - ex_rtl_state_set "${BUILD_WORKDIR}" "${@}"; + rtl_state_set "${_workdir}" "${@}"; }; # @@ -107,7 +114,7 @@ ex_pkg_state_set() { # Return: zero (0) on success, non-zero (>0) on failure # ex_pkg_state_test() { - ex_rtl_state_test "${BUILD_WORKDIR}" "${@}"; + rtl_state_test "${_workdir}" "${@}"; }; # vim:filetype=sh diff --git a/subr/ex_pkg_exec.subr b/subr/ex_pkg_exec.subr index 2d14a01..0a40cfc 100644 --- a/subr/ex_pkg_exec.subr +++ b/subr/ex_pkg_exec.subr @@ -15,21 +15,21 @@ exp_pkg_exec_pre() { if [ -z "${PKG_URL}" ]\ && [ -z "${PKG_URLS_GIT}" ]\ && [ -z "${PKG_VERSION}" ]\ - && ! ex_rtl_test_cmd "pkg_${_pkg_name}_all"; then - "${_dispatch_fn}" exec_missing "${_group_name}" "${_pkg_name}"; + && ! rtl_test_cmd "pkg_${_pkg_name}_all"; then + "${_dispatch_fn}" missing_pkg "${_group_name}" "${_pkg_name}"; return 1; elif ! ex_pkg_state_test "${_pkg_name}" "start" "${_restart_at}"; then if [ "${PKG_NO_CLEAN_BASE_DIR:-0}" -eq 0 ]\ - && ! ex_rtl_fileop rm "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}"\ - || ! ex_rtl_fileop mkdir "${PKG_BASE_DIR}"; then + && ! rtl_fileop rm "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}"\ + || ! rtl_fileop mkdir "${PKG_BASE_DIR}"; then return "${?}"; fi; - if ! ex_rtl_fileop mkdir "${PKG_BUILD_DIR}" "${PKG_DESTDIR}"\ + if ! rtl_fileop mkdir "${PKG_BUILD_DIR}" "${PKG_DESTDIR}"\ || ! ex_pkg_state_set "${_pkg_name}" "start"; then return "${?}"; fi; fi; - ex_rtl_fileop cd "${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BUILD_DIR}"; }; # @@ -44,7 +44,7 @@ exp_pkg_exec_pre() { exp_pkg_exec_step() { local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}" _step="${4}" \ _fn_name="" _pkg_step_fn="" _rc=0; - if ex_rtl_test_cmd "pkg_${_pkg_name}_${_step}"; then + if rtl_test_cmd "pkg_${_pkg_name}_${_step}"; then _pkg_step_fn="pkg_${_pkg_name}_${_step}"; else _pkg_step_fn="pkg_${_step}"; @@ -53,7 +53,7 @@ exp_pkg_exec_step() { "pkg_${_pkg_name}_${_step}_pre" \ "${_pkg_step_fn}" \ "pkg_${_pkg_name}_${_step}_post"; do - if ex_rtl_test_cmd "${_fn_name}"\ + if rtl_test_cmd "${_fn_name}"\ && ! "${_fn_name}" "${_group_name}" "${_pkg_name}" "${_restart_at}"; then _rc=1; break; fi; @@ -80,24 +80,23 @@ ex_pkg_exec() { pkill -U "${$}"; \ fi;" EXIT HUP INT TERM USR1 USR2; if exp_pkg_exec_pre "${_group_name}" "${_pkg_name}" "${_restart_at}"\ - && "${_dispatch_fn}" exec_start "${_group_name}" "${_pkg_name}"; then - if ex_rtl_test_cmd "pkg_${_pkg_name}_all"; then + && "${_dispatch_fn}" start_pkg_child "${_group_name}" "${_pkg_name}"; then + if rtl_test_cmd "pkg_${_pkg_name}_all"; then "pkg_${_pkg_name}_all" "${_restart_at}"; else set -- ${PKG_BUILD_STEPS}; while [ ${#} -gt 0 ]; do _step="${1}"; _step_next="${2}"; shift; - if ex_pkg_state_test "${_pkg_name}" "${_step}" "${_restart_at}"; then + if [ "${PKG_FORCE:-0}" -eq 0 ]\ + && ex_pkg_state_test "${_pkg_name}" "${_step}" "${_restart_at}" ; then continue; elif ! exp_pkg_exec_step "${_group_name}" "${_pkg_name}" "${_restart_at}" "${_step}"; then _rc=1; break; else echo "step ${_group_name} ${_pkg_name} ${_step}" >&3; - "${_dispatch_fn}" exec_step "${_group_name}" "${_pkg_name}" "${_step}"; ex_pkg_state_set "${_pkg_name}" "${_step}" "${_step_next:+-${_step_next}}"; fi; done; fi; - "${_dispatch_fn}" exec_finish "${_group_name}" "${_pkg_name}"; ex_pkg_state_set "${_pkg_name}" finish; fi; return "${_rc}"; diff --git a/subr/ex_rtl.subr b/subr/ex_rtl.subr deleted file mode 100644 index 1c48bb0..0000000 --- a/subr/ex_rtl.subr +++ /dev/null @@ -1,17 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -EXP_RTL_IFS="${IFS}"; - -ex_rtl_basename() { echo "${1##*/}"; }; -ex_rtl_date() { command date "+${1:-${DEFAULT_TIMESTAMP_FMT}}"; }; -ex_rtl_dirname() { echo "${1%/*}"; }; -ex_rtl_pop_IFS() { IFS="${EXP_RTL_IFS}"; }; -ex_rtl_push_IFS() { EXP_RTL_IFS="${IFS}"; IFS="${1}"; }; -ex_rtl_set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; }; -ex_rtl_test_cmd() { command -v "${1}" >/dev/null; }; -ex_rtl_uniq() { echo "${@}" | sed 's/ /\n/g' | awk '!x[$0]++' | paste -s -d" "; }; -ex_rtl_unset_vars() { while [ ${#} -gt 0 ]; do unset "${1}"; shift; done; }; - -# vim:filetype=sh diff --git a/subr/ex_rtl_complex.subr b/subr/ex_rtl_complex.subr deleted file mode 100644 index 682a950..0000000 --- a/subr/ex_rtl_complex.subr +++ /dev/null @@ -1,114 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -ex_rtl_check_path_vars() { - local _vnames="${1}" _rc=0 _vname="" _vname_val=""; _status=""; - for _vname in ${_vnames}; do - _vname_val="$(ex_rtl_get_var_unsafe "${_vname}")"; - if [ -z "${_vname_val}" ]; then - _rc=1; _status="Error: variable \`${_vname}' is empty or unset."; break; - elif [ "${_vname_val#* *}" != "${_vname_val}" ]; then - _rc=2; _status="Error: variable \`${_vname}' contains one or more whitespace characters."; break; - fi; - done; - return "${_rc}"; -}; - -ex_rtl_clean_env() { - local _env_vars_except="${1}" _env_var="" _env_vars=""; - _env_vars="$(export | sed -ne '/^export/{s/^export //;s/=.*$//p}')"; - for _env_var in ${_env_vars}; do - if [ "${_env_var#DEFAULT_}" != "${_env_var}" ]\ - || [ "${_env_var#PKG_}" != "${_env_var}" ]; then - _env_vars_except="${_env_vars_except:+${_env_vars_except} }${_env_var}"; - fi; - done; - ex_rtl_unset_vars $(ex_rtl_lfilter "${_env_vars}" "${_env_vars_except}"); -}; - -ex_rtl_exists_any() { - local _subdir="${1}"; shift; - while [ "${#}" -gt 0 ]; do - if [ -e "${_subdir}/${1}" ]; then - return 0; - else - shift; - fi; - done; return 1; -}; - -ex_rtl_export_vars() { - local _unsetfl=0; [ "x${1}" = "x-u" ] && { _unsetfl=1; shift; }; - while [ "${#}" -ge 2 ]; do - if [ -n "${2}" ]; then - if [ "${_unsetfl:-0}" -eq 0 ]; then - ex_rtl_set_var_unsafe "${1}" "${2}"; export "${1}"; - else - unset "${1}"; - fi; - fi; - shift 2; - done; -}; - -ex_rtl_get_var_unsafe() { - local _vname=""; - if [ "x${1}" = "x-u" ]; then - shift; _vname="$(ex_rtl_toupper "${1}")"; - else - _vname="${1}"; - fi; - eval echo \${${_vname}}; -}; - -ex_rtl_head() { - local _pattern="${1}" _s="${2}"; - while true; do - if [ "${_s%%${_pattern}}" = "${_s}" ]; then - break; - else - _s="${_s%%${_pattern}}"; - fi; - done; - echo "${_s}"; -}; - -ex_rtl_kill_tree() { - local _pid="${1}" _signal="TERM" _pid_child="" _pid_top=""; - for _pid_top in $(pgrep -P "${_pid}"); do - for _pid_child in $(pgrep -P "${_pid_top}" 2>/dev/null); do - _pids_killed="${_pids_killed:+${_pids_killed} }${_pid_child}"; kill "-${_signal}" "${_pid_child}" 2>/dev/null; - done; - _pids_killed="${_pids_killed:+${_pids_killed} }${_pid_top}"; kill "-${_signal}" "${_pid_top}" 2>/dev/null; - done; -}; - -ex_rtl_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}; -}; - -ex_rtl_set_vars() { - local _vars_set_vname="${1}" _vname_dst="${2}" _vname_src_tmpls="${3}" \ - _vars_set_old="" _vars_set_tmp="" _vname_src=""; - for _vname_src in $(ex_rtl_toupper "${_vname_src_tmpls}"); do - _vname_src="${_vname_src}_${_vname_dst}"; - _vval_src="$(ex_rtl_get_var_unsafe "${_vname_src}")"; - if [ -n "${_vval_src}" ]; then - ex_rtl_set_var_unsafe "PKG_${_vname_dst}" "${_vval_src}"; - _vars_set_tmp="${_vars_set_tmp:+${_vars_set_tmp} }PKG_${_vname_dst}"; - fi; - done; - _vars_set_old="$(ex_rtl_get_var_unsafe "${_vars_set_vname}")"; - ex_rtl_set_var_unsafe "${_vars_set_vname}" \ - "${_vars_set_old:+${_vars_set_old} }${_vars_set_tmp}"; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_fetch.subr b/subr/ex_rtl_fetch.subr deleted file mode 100644 index c4ba862..0000000 --- a/subr/ex_rtl_fetch.subr +++ /dev/null @@ -1,92 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -exp_rtl_fetch_url_git() { - local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}" \ - _oldpwd=""; - (set -o errexit -o noglob; trap "rm -f \"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching\"" EXIT; - while true; do - if flock -E 622 -w 3600 4; then - break; - elif [ "${?}" -eq 622 ]; then - continue; - else - exit "${?}"; - fi; - done; - if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git pull ${DEFAULT_GIT_ARGS} origin "${_branch:-main}"); - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git submodule update); - else - git clone ${DEFAULT_GIT_ARGS} "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}"; - if [ -n "${_branch}" ]; then - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git checkout "${_branch}"); - fi; - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git submodule update --init); - fi; - _oldpwd="${PWD}"; ex_rtl_fileop cd "${PKG_BASE_DIR}"; - ex_rtl_fileop rm "${_tgtdir}/${_subdir}"; - ex_rtl_fileop cp "${BUILD_DLCACHEDIR}/${_subdir}" "${_tgtdir}"; - ex_rtl_fileop cd "${_oldpwd}";) 4<>"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching"; - if [ "${?}" -eq 0 ]; then - cd "$(pwd)"; - else - return "${?}"; - fi; -}; - -ex_rtl_fetch_urls_git() { - local _tgtdir="" _url_spec="" _subdir="" _url="" _git_branch=""; - _tgtdir="${1}"; shift; - if [ "${ARG_FETCH_FORCE}" = "offline" ]; then - return 0; - fi; - for _url_spec in "${@}"; do - _subdir="${_url_spec%=*}"; - _url="${_url_spec#*=}"; - _url="${_url%@*}"; - if [ "${_url_spec#*@}" != "${_url_spec}" ]; then - _git_branch=${_url_spec#*@}; - fi; - exp_rtl_fetch_url_git "${_tgtdir}" "${_subdir}" \ - "${_url}" "${_git_branch}"; - done; -}; - -# N.B. URLs ($1) may contain `?' or '&' characters. -ex_rtl_fetch_url_wget() { - local _url="${1}" _sha256sum_src="${2}" _target_fname="${3}" _sha256sum_dst=""; - if [ "${ARG_FETCH_FORCE}" = "offline" ]; then - return 0; - elif [ -z "${_target_fname}" ]; then - _target_fname="$(ex_rtl_basename "${_url}")"; - fi; - _url_dst="${BUILD_DLCACHEDIR}/${_target_fname}"; - (set -o errexit -o noglob; trap "_rc=\"\${?}\" ;rm -f \"${_url_dst}.fetching\"; exit \"\${_rc}\";" EXIT; - while true; do - if flock -E 622 -w 3600 4; then - break; - elif [ "${?}" -eq 622 ]; then - continue; - else - exit "${?}"; - fi; - done; - if [ ! -e "${_url_dst}.fetched" ]; then - wget ${DEFAULT_WGET_ARGS} -O "${_url_dst}" "${_url}"; - if [ -n "${_sha256sum_src}" ]; then - set -- $(sha256sum "${_url_dst}"); - if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then - ex_rtl_log_msg failexit "Error: hash mismatch for URL \`${_url}' (downloaded file: ${_sha256sum_dst}, from build variables: ${_sha256sum_src}.)"; - fi; - fi; - ex_rtl_fileop touch "${_url_dst}.fetched"; - fi;) 4<>"${_url_dst}.fetching"; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_fileop.subr b/subr/ex_rtl_fileop.subr deleted file mode 100644 index 417ec26..0000000 --- a/subr/ex_rtl_fileop.subr +++ /dev/null @@ -1,111 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -exp_rtl_fileop_check() { - local _prefix="${1}" _pname="" _rname=""; shift; - while [ "${#}" -gt 0 ]; do - return 0; - shift; done; -}; - -ex_rtl_fileop() { - local _op="${1}" _dst="" _install_args="" _rc=0 _src=""; shift; - case "${_op}" in - cd) if [ \( -z "${1}" \) -o ! \( -L "${1}" -o -e "${1}" \) ]; then - ex_rtl_log_msg failexit "Invalid or non-existent directory \`${1}'."; - elif exp_rtl_fileop_check "${PREFIX}" "${1}"; then - ex_rtl_log_msg vvvv "Changing working directory to \`${1}'."; - cd -- "${1}"; _rc="${?}"; - fi; ;; - cp_follow) - if [ "${#}" -lt 2 ]; then - ex_rtl_log_msg failexit "Missing parameters (in: cp_follow ${*}.)"; - elif exp_rtl_fileop_check "${PREFIX}" "${*}"; then - _src="${*}"; _src="${_src% *}"; - _dst="${*}"; _dst="${_dst##* }"; - ex_rtl_log_msg vvvv "Copying \`${_src}' into \`${_dst}' w/ -pLR."; - cp -pLR -- "${@}"; _rc="${?}"; - fi; ;; - cp) if [ "${#}" -lt 2 ]; then - ex_rtl_log_msg failexit "Missing parameters (in: cp ${*}.)"; - elif exp_rtl_fileop_check "${PREFIX}" "${*}"; then - _src="${*}"; _src="${_src% *}"; - _dst="${*}"; _dst="${_dst##* }"; - ex_rtl_log_msg vvvv "Copying \`${_src}' into \`${_dst}' w/ -pPR."; - cp -pPR -- "${@}"; _rc="${?}"; - fi; ;; - install) - if [ "${#}" -lt 2 ]; then - ex_rtl_log_msg failexit "Missing parameters (in: install ${*}.)"; - else _dst="$(while [ ""${#}"" -gt 2 ]; do shift; done; echo "${2}")"; - _install_args="$(while [ ""${#}"" -gt 2 ]; do echo "${1}"; shift; done)"; - _src="$(while [ ""${#}"" -gt 2 ]; do shift; done; echo "${1}")"; - if exp_rtl_fileop_check "${PREFIX}" "${_dst}" "${_src}"; then - ex_rtl_log_msg vvvv "Installing \`${_src}' into \`${_dst}' w/ ${_install_args}."; - install "${@}"; _rc="${?}"; - fi; - fi; ;; - ln_symbolic) - if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then - ex_rtl_log_msg failexit "Missing parameters (in: ln_symbolic ${*}.)"; - elif exp_rtl_fileop_check "${PREFIX}" "${2}"; then - if ex_rtl_fileop test "${2}"; then - ex_rtl_fileop rm "${2}"; - fi; - if [ "${?}" -eq 0 ]; then - ex_rtl_log_msg vvvv "Linking \`${1}' to \`${2}' w/ -fs"; - ln -fs -- "${1}" "${2}"; _rc="${?}"; - fi; - fi; ;; - mv) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then - ex_rtl_log_msg failexit "Missing parameters (in: mv ${*}.)"; - elif exp_rtl_fileop_check "${PREFIX}" "${1}" "${2}"; then - ex_rtl_log_msg vvvv "Moving \`${1}' to \`${2}' w/ -fs"; - mv -f -- "${1}" "${2}"; _rc="${?}"; - fi; ;; - mkdir|mkfifo|rm|source_opt|test|touch) - while [ \( "${?}" -eq 0 \) -a \( ""${#}"" -gt 0 \) ]; do - if [ -z "${1}" ]; then - ex_rtl_log_msg failexit "Missing parameters (in: ${_op} ${*}.)"; - elif [ "${_op}" = mkdir ]\ - && [ ! -d "${1}" ]\ - && exp_rtl_fileop_check "${PREFIX}" "${1}"; then - if ex_rtl_fileop test "${1}"; then - ex_rtl_fileop rm "${1}"; - fi; - ex_rtl_log_msg vvvv "Making directory \`${1}'."; - mkdir -p -- "${1}"; _rc="${?}"; - elif [ "${_op}" = mkfifo ]\ - && exp_rtl_fileop_check "${PREFIX}" "${1}"; then - if ex_rtl_fileop test "${1}"; then - ex_rtl_fileop rm "${1}"; - fi; - ex_rtl_log_msg vvvv "Creating FIFO \`${1}'."; - exp_rtl_fileop_check "${PREFIX}" "${1}"; - mkfifo -- "${1}"; _rc="${?}"; - elif [ "${_op}" = rm ]\ - && ex_rtl_fileop test "${1}"\ - && exp_rtl_fileop_check "${PREFIX}" "${1}"; then - ex_rtl_log_msg vvvv "Removing directory or file \`${1}'."; - rm -rf -- "${1}"; _rc="${?}"; - elif [ "${_op}" = source_opt ]\ - && ex_rtl_fileop test "${1}"\ - && exp_rtl_fileop_check "${PREFIX}" "${1}"; then - ex_rtl_log_msg vvvv "Sourcing file \`${1}'."; - . "${1}"; _rc="${?}"; - elif [ "${_op}" = test ]\ - && exp_rtl_fileop_check "${PREFIX}" "${1}"\ - && ! [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then - return 1; - elif [ "${_op}" = touch ]\ - && exp_rtl_fileop_check "${PREFIX}" "${1}"; then - ex_rtl_log_msg vvvv "Touching file \`${1}'."; - touch -- "${1}"; _rc="${?}"; - fi; shift; - done; ;; - *) ex_rtl_log_msg failexit "Error: ex_rtl_fileop() called w/ invalid parameter(s): ${*}"; ;; - esac; return "${_rc}"; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_install.subr b/subr/ex_rtl_install.subr deleted file mode 100644 index 742347d..0000000 --- a/subr/ex_rtl_install.subr +++ /dev/null @@ -1,47 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -ex_rtl_install() { - 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 [ "${_ln_fname#/}" = "${_ln_fname}" ]; then - _ln_fname="${_prefix:+${_prefix}/}${_ln_fname}"; - fi; - if [ -e "${_ln_fname}" ]; then - ex_rtl_fileop rm "${_ln_fname}"; - fi; - ex_rtl_fileop ln_symbolic "${_ln_target}" "${_ln_fname}"; - ;; - /=*) - _mkdir_fname="${1#/=}"; - if [ "${_mkdir_fname#/}" = "${_mkdir_fname}" ]; then - _mkdir_fname="${_prefix:+${_prefix}/}${_mkdir_fname}"; - fi; - ex_rtl_fileop mkdir "${_mkdir_fname}"; - ;; - *) - _file_fname_src="${1%=*}"; - _file_fname_dst="${1#*=}"; - if [ "${_file_fname_src#/}" = "${_file_fname_src}" ]; then - _file_fname_src="${_prefix:+${_prefix}/}${_file_fname_src}"; - fi; - if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then - _file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}"; - fi; - ex_rtl_fileop cp "${_file_fname_src}" "${_file_fname_dst}"; - ;; - esac; shift; - done; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_list.subr b/subr/ex_rtl_list.subr deleted file mode 100644 index fb2bde7..0000000 --- a/subr/ex_rtl_list.subr +++ /dev/null @@ -1,75 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -ex_rtl_lconcat() { - local _list="${1}" _litem_new="${2}" _sep="${3:- }" IFS="${3:-${IFS}}"; - if [ -n "${_list}" ]; then - printf "%s%s%s" "${_list}" "${_sep}" "${_litem_new}"; - else - printf "%s" "${_litem_new}"; - fi; -}; - -ex_rtl_lfilter() { - local _list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS}}" \ - _filterfl="" _litem="" _litem_filter="" _lnew=""; - if [ -z "${_filter}" ]; then - echo "${_list}"; return 0; - else for _litem in ${_list}; do - _filterfl=0; - for _litem_filter in ${_filter}; do - if [ "${_litem_filter}" = "${_litem}" ]; then - _filterfl=1; break; - fi; - done; - if [ "${_filterfl:-0}" -eq 0 ]; then - _lnew="${_lnew:+${_lnew}${_sep}}${_litem}"; - fi; - done; fi; - echo "${_lnew}"; -}; - -ex_rtl_llength() { - local _list="${1}" _sep="${2:- }" IFS="${2:-${IFS}}" _litem="" _llength=0; - for _litem in ${_list}; do - : $((_llength+=1)); - done; - echo "${_llength}"; -}; - -ex_rtl_lmatch() { - local _list="${1}" _item="${2}" _sep="${3}"; - [ -n "$(ex_rtl_lsearch "${_list}" "${_item}" "${_sep}")" ]; -}; - -ex_rtl_lsearch() { - local _list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS}}" \ - _litem="" _litem_filter="" _lnew=""; - if [ -z "${_filter}" ]; then - echo "${_list}"; return 0; - else for _litem in ${_list}; do - for _litem_filter in ${_filter}; do - if [ "${_litem_filter}" = "${_litem}" ]; then - _lnew="${_lnew:+${_lnew}${_sep}}${_litem}"; - break; - fi; - done; - done; fi; - echo "${_lnew}"; -}; - -ex_rtl_lunfold_depends() { - local _vname_template="${1}" _depends="" _name="" _names=""; shift; - for _name in "${@}"; do - if _depends="$(ex_rtl_get_var_unsafe -u "$(eval printf \"%s\" \""${_vname_template}"\")")"\ - && [ -n "${_depends}" ]; then - _depends="$(ex_rtl_lunfold_depends "${_vname_template}" ${_depends})"; - _names="$(ex_rtl_lconcat "${_names}" "${_depends}")"; - fi; - _names="$(ex_rtl_lconcat "${_names}" "${_name}")"; - done; - echo "${_names}"; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_log.subr b/subr/ex_rtl_log.subr deleted file mode 100644 index 514d463..0000000 --- a/subr/ex_rtl_log.subr +++ /dev/null @@ -1,78 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -: ${DEFAULT_LOG_MSG_FAIL_COLOUR:=91}; -: ${DEFAULT_LOG_MSG_INFO_COLOUR:=93}; -: ${DEFAULT_LOG_MSG_INF2_COLOUR:=33}; -: ${DEFAULT_LOG_MSG_SUCC_COLOUR:=92}; -: ${DEFAULT_LOG_MSG_SUC2_COLOUR:=32}; -: ${DEFAULT_LOG_MSG_VNFO_COLOUR:=96}; -: ${DEFAULT_LOG_MSG_VUCC_COLOUR:=90}; -: ${DEFAULT_LOG_MSG_VVFO_COLOUR:=96}; -: ${DEFAULT_LOG_MSG_VVVO_COLOUR:=96}; -: ${DEFAULT_LOG_MSG_VVVV_COLOUR:=96}; - -exp_rtl_log_printf() { - local _attrs="${1}" _msg=""; shift; _msg="$(printf "${@}")"; - if [ "${BUILD_IS_PARENT:-0}" -eq 1 ]\ - && [ -n "${DEFAULT_BUILD_LOG_FNAME}" ]\ - && [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then - printf "%s\n" "${_msg}" >> "${DEFAULT_BUILD_LOG_FNAME}"; - fi; - printf "\033[0m\033[${_attr}m%s\033[0m\n" "${_msg}"; -}; - -ex_rtl_log_env_vars() { - local _nvar=1 _arg="" _arg_len_max=0; - ex_rtl_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_rtl_log_msg info "$(printf \ - "%${_arg_len_max}.${_arg_len_max}s=%s" \ - "${1%%=*}" "$(ex_rtl_get_var_unsafe ${1#*=})")"; - shift; - done; -}; - -ex_rtl_log_set_vnfo_lvl() { - EXP_RTL_LOG_VNFO_LVL="${1}"; -}; - -ex_rtl_log_msg() { - local _lvl="${1}" _lvl_uc="" _attr=""; shift; - if [ "${_lvl}" = vnfo ]\ - || [ "${_lvl}" = vucc ]\ - && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 1 ]; then - return; - elif [ "${_lvl}" = vvfo ]\ - && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 2 ]; then - return; - elif [ "${_lvl}" = vvvo ]\ - && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 3 ]; then - return; - elif [ "${_lvl}" = vvvv ]\ - && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 4 ]; then - return; - fi; - _lvl_uc="$(ex_rtl_toupper "${_lvl%exit}")"; - _attr="$(ex_rtl_get_var_unsafe "DEFAULT_LOG_MSG_${_lvl_uc}_COLOUR")"; - if [ ${#} -gt 1 ]; then - exp_rtl_log_printf "${_attrs}" "==> %s %s %s" "$(ex_rtl_date)" "${1}" "$*"; - else - exp_rtl_log_printf "${_attrs}" "==> %s %s" "$(ex_rtl_date)" "${1}"; - fi; - if [ ${_lvl} = failexit ]; then - exit 1; - else - return 0; - fi; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_state.subr b/subr/ex_rtl_state.subr deleted file mode 100644 index 406da47..0000000 --- a/subr/ex_rtl_state.subr +++ /dev/null @@ -1,40 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -ex_rtl_state_clear() { - local _workdir="${1}" _pkg_name="${2}" _pkg_fname=""; - for _pkg_fname in $(find "${_workdir}" \ - -maxdepth 1 -mindepth 1 -name .${_pkg_name}.\* -type f); do - ex_rtl_fileop rm "${_pkg_fname}"; - done; -}; - -ex_rtl_state_set() { - local _workdir="${1}" _pkg_fname="${2}" _done_fname_pfx=""; - _done_fname_pfx="${_workdir}/.${_pkg_fname}"; - shift 2; while [ ${#} -ge 1 ]; do - if [ -z "${1}" ]; then - shift; continue; - elif [ "${1#-}" != "${1}" ]; then - ex_rtl_fileop rm "${_done_fname_pfx}.${1#-}"; - else - ex_rtl_fileop touch "${_done_fname_pfx}.${1}"; - fi; - shift; done; -}; - -ex_rtl_state_test() { - local _workdir="${1}" _pkg_name="${2}" _build_step="${3}" \ - _restart_at="${4}" _done_fname=""; - _done_fname="${_workdir}/.${_pkg_name}.${_build_step}"; - if [ -z "${_restart_at}" ]; then - ex_rtl_fileop test "${_done_fname}"; - elif [ "${_restart_at}" = "ALL" ]; then - return 1; - else - ! ex_rtl_lmatch "${_restart_at}" "${_build_step}" ","; - fi; -}; - -# vim:filetype=sh diff --git a/subr/ex_rtl_string.subr b/subr/ex_rtl_string.subr deleted file mode 100644 index 9b8874f..0000000 --- a/subr/ex_rtl_string.subr +++ /dev/null @@ -1,83 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -ex_rtl_tolower() { - local _s="${1}" _s_new=""; - while [ -n "${_s}" ]; do - case "${_s}" in - A*) _s_new="${_s_new:+${_s_new}}a"; _s="${_s#A}"; ;; - B*) _s_new="${_s_new:+${_s_new}}b"; _s="${_s#B}"; ;; - C*) _s_new="${_s_new:+${_s_new}}c"; _s="${_s#C}"; ;; - D*) _s_new="${_s_new:+${_s_new}}d"; _s="${_s#D}"; ;; - E*) _s_new="${_s_new:+${_s_new}}e"; _s="${_s#E}"; ;; - F*) _s_new="${_s_new:+${_s_new}}f"; _s="${_s#F}"; ;; - G*) _s_new="${_s_new:+${_s_new}}g"; _s="${_s#G}"; ;; - H*) _s_new="${_s_new:+${_s_new}}h"; _s="${_s#H}"; ;; - I*) _s_new="${_s_new:+${_s_new}}i"; _s="${_s#I}"; ;; - J*) _s_new="${_s_new:+${_s_new}}j"; _s="${_s#J}"; ;; - K*) _s_new="${_s_new:+${_s_new}}k"; _s="${_s#K}"; ;; - L*) _s_new="${_s_new:+${_s_new}}l"; _s="${_s#L}"; ;; - M*) _s_new="${_s_new:+${_s_new}}m"; _s="${_s#M}"; ;; - N*) _s_new="${_s_new:+${_s_new}}n"; _s="${_s#N}"; ;; - O*) _s_new="${_s_new:+${_s_new}}o"; _s="${_s#O}"; ;; - P*) _s_new="${_s_new:+${_s_new}}p"; _s="${_s#P}"; ;; - Q*) _s_new="${_s_new:+${_s_new}}q"; _s="${_s#Q}"; ;; - R*) _s_new="${_s_new:+${_s_new}}r"; _s="${_s#R}"; ;; - S*) _s_new="${_s_new:+${_s_new}}s"; _s="${_s#S}"; ;; - T*) _s_new="${_s_new:+${_s_new}}t"; _s="${_s#T}"; ;; - U*) _s_new="${_s_new:+${_s_new}}u"; _s="${_s#U}"; ;; - V*) _s_new="${_s_new:+${_s_new}}v"; _s="${_s#V}"; ;; - W*) _s_new="${_s_new:+${_s_new}}w"; _s="${_s#W}"; ;; - X*) _s_new="${_s_new:+${_s_new}}x"; _s="${_s#X}"; ;; - Y*) _s_new="${_s_new:+${_s_new}}y"; _s="${_s#Y}"; ;; - Z*) _s_new="${_s_new:+${_s_new}}z"; _s="${_s#Z}"; ;; - [^ABCDEFGHIJKLMNOPQRSTUVWXYZ]*) - _s_new="${_s_new:+${_s_new}}${_s%%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*}"; - while [ "${_s#[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]}" != "${_s}" ]; do - _s="${_s#[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]}"; - done; ;; - esac; done; - echo "${_s_new}"; -}; - -ex_rtl_toupper() { - local _s="${1}" _s_new=""; - while [ -n "${_s}" ]; do - case "${_s}" in - a*) _s_new="${_s_new:+${_s_new}}A"; _s="${_s#a}"; ;; - b*) _s_new="${_s_new:+${_s_new}}B"; _s="${_s#b}"; ;; - c*) _s_new="${_s_new:+${_s_new}}C"; _s="${_s#c}"; ;; - d*) _s_new="${_s_new:+${_s_new}}D"; _s="${_s#d}"; ;; - e*) _s_new="${_s_new:+${_s_new}}E"; _s="${_s#e}"; ;; - f*) _s_new="${_s_new:+${_s_new}}F"; _s="${_s#f}"; ;; - g*) _s_new="${_s_new:+${_s_new}}G"; _s="${_s#g}"; ;; - h*) _s_new="${_s_new:+${_s_new}}H"; _s="${_s#h}"; ;; - i*) _s_new="${_s_new:+${_s_new}}I"; _s="${_s#i}"; ;; - j*) _s_new="${_s_new:+${_s_new}}J"; _s="${_s#j}"; ;; - k*) _s_new="${_s_new:+${_s_new}}K"; _s="${_s#k}"; ;; - l*) _s_new="${_s_new:+${_s_new}}L"; _s="${_s#l}"; ;; - m*) _s_new="${_s_new:+${_s_new}}M"; _s="${_s#m}"; ;; - n*) _s_new="${_s_new:+${_s_new}}N"; _s="${_s#n}"; ;; - o*) _s_new="${_s_new:+${_s_new}}O"; _s="${_s#o}"; ;; - p*) _s_new="${_s_new:+${_s_new}}P"; _s="${_s#p}"; ;; - q*) _s_new="${_s_new:+${_s_new}}Q"; _s="${_s#q}"; ;; - r*) _s_new="${_s_new:+${_s_new}}R"; _s="${_s#r}"; ;; - s*) _s_new="${_s_new:+${_s_new}}S"; _s="${_s#s}"; ;; - t*) _s_new="${_s_new:+${_s_new}}T"; _s="${_s#t}"; ;; - u*) _s_new="${_s_new:+${_s_new}}U"; _s="${_s#u}"; ;; - v*) _s_new="${_s_new:+${_s_new}}V"; _s="${_s#v}"; ;; - w*) _s_new="${_s_new:+${_s_new}}W"; _s="${_s#w}"; ;; - x*) _s_new="${_s_new:+${_s_new}}X"; _s="${_s#x}"; ;; - y*) _s_new="${_s_new:+${_s_new}}Y"; _s="${_s#y}"; ;; - z*) _s_new="${_s_new:+${_s_new}}Z"; _s="${_s#z}"; ;; - [^abcdefghijklmnopqrstuvwxyz]*) - _s_new="${_s_new:+${_s_new}}${_s%%[abcdefghijklmnopqrstuvwxyz]*}"; - while [ "${_s#[^abcdefghijklmnopqrstuvwxyz]}" != "${_s}" ]; do - _s="${_s#[^abcdefghijklmnopqrstuvwxyz]}"; - done; ;; - esac; done; - echo "${_s_new}"; -}; - -# vim:filetype=sh diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr index e7ea6be..2433ea8 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. - ex_rtl_run_cmd_unsplit make \ + rtl_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_BUILD} \ ${PKG_MAKEFLAGS_BUILD_EXTRA} \ "AR=${PKG_AR}" "${_no_autoconf:+CC=${PKG_CC}}" \ diff --git a/subr/pkg_clean.subr b/subr/pkg_clean.subr index 40d5654..b122823 100644 --- a/subr/pkg_clean.subr +++ b/subr/pkg_clean.subr @@ -4,14 +4,14 @@ pkg_clean() { if [ "${PKG_NO_CLEAN:-0}" -eq 0 ]; then - if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" "build" ","; then - ex_rtl_fileop rm "${PKG_BUILD_DIR}" || return "${?}"; + if rtl_lmatch "${ARG_CLEAN_BUILDS}" "build" ","; then + rtl_fileop rm "${PKG_BUILD_DIR}" || return "${?}"; fi; - if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" "dest" ","; then - ex_rtl_fileop rm "${PKG_DESTDIR}" || return "${?}"; + if rtl_lmatch "${ARG_CLEAN_BUILDS}" "dest" ","; then + rtl_fileop rm "${PKG_DESTDIR}" || return "${?}"; fi; - if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" "src" ","; then - ex_rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}" || return "${?}"; + if rtl_lmatch "${ARG_CLEAN_BUILDS}" "src" ","; then + rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}" || return "${?}"; fi; fi; }; diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr index 0adc7ac..c681988 100644 --- a/subr/pkg_configure.subr +++ b/subr/pkg_configure.subr @@ -5,7 +5,7 @@ pkg_configure() { local _rc=0; if [ -x "${PKG_CONFIGURE}" ]; then - ex_rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}" PYTHON "${PKG_PYTHON}"; + rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}" PYTHON "${PKG_PYTHON}"; AR="${PKG_AR}" \ CC="${PKG_CC}" \ RANLIB="${PKG_RANLIB}" \ @@ -14,7 +14,7 @@ pkg_configure() { CXXFLAGS="${PKG_CXXFLAGS_CONFIGURE}${PKG_CXXFLAGS_CONFIGURE_EXTRA:+ ${PKG_CXXFLAGS_CONFIGURE_EXTRA}}" \ LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}" \ "${PKG_CONFIGURE}" ${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA} ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG}; _rc="${?}" - ex_rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}" PYTHON "${PKG_PYTHON}"; + rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}" PYTHON "${PKG_PYTHON}"; fi; return "${?}"; }; diff --git a/subr/pkg_configure_autotools.subr b/subr/pkg_configure_autotools.subr index 7c1ee32..bc3b6c2 100644 --- a/subr/pkg_configure_autotools.subr +++ b/subr/pkg_configure_autotools.subr @@ -4,9 +4,9 @@ pkg_configure_autotools() { local _config_cache="" _fname="" _subdir_tgt=""; - if ex_rtl_exists_any "${PKG_BASE_DIR}/${PKG_SUBDIR}" \ + if rtl_exists_any "${PKG_BASE_DIR}/${PKG_SUBDIR}" \ "config.guess" "configure.ac" "configure.in" "configure"; - then ex_rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}"; + then rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}"; if [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure.ac" ]\ && [ ! -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure" ]; then for _fname in bootstrap bootstrap.sh autogen.sh; do @@ -15,25 +15,25 @@ pkg_configure_autotools() { "${PKG_BASE_DIR}/${PKG_SUBDIR}/build-aux" \ "${PKG_BASE_DIR}/${PKG_SUBDIR}"; do if [ -e "${_subdir_tgt}" ]; then - ex_rtl_fileop install -m 0700 \ + rtl_fileop install -m 0700 \ "${MIDIPIX_BUILD_PWD}/etc/config.sub" \ "${_subdir_tgt}/config.sub" || return "${?}" && break; fi; done; - (ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && \ + (rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && \ /bin/sh "${_fname}") || return "${?}" && break; fi; done; - (ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf) || return "${?}"; + (rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf) || return "${?}"; fi; for _fname in $(find "${PKG_BASE_DIR}/${PKG_SUBDIR}" -name config.sub); do - if ! ex_rtl_fileop mv "${_fname}" "${_fname}.orig"\ - || ! ex_rtl_fileop install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" "${_fname}"; then + if ! rtl_fileop mv "${_fname}" "${_fname}.orig"\ + || ! rtl_fileop install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" "${_fname}"; then return 1; fi; done if [ "${PKG_BUILD_TYPE}" != host ]; then - if ! ex_rtl_fileop touch "${PKG_BUILD_DIR}/config.cache"; then + if ! rtl_fileop touch "${PKG_BUILD_DIR}/config.cache"; then return 1; else for _config_cache in \ "${PKG_CONFIG_CACHE}" \ @@ -45,7 +45,7 @@ pkg_configure_autotools() { sed -i"" "s,%PREFIX%,${PKG_PREFIX},g" "${PKG_BUILD_DIR}/config.cache" || return "${?}"; fi; fi; - ex_rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}"; + rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}"; fi; }; diff --git a/subr/pkg_configure_patch.subr b/subr/pkg_configure_patch.subr index 366a9e5..80690b6 100644 --- a/subr/pkg_configure_patch.subr +++ b/subr/pkg_configure_patch.subr @@ -12,9 +12,9 @@ pkg_configure_patch() { "${_patch_dir}/${_pkg_name_full}.local@${BUILD_HNAME}.patch" \ ${PKG_PATCHES_EXTRA}; do if [ -r "${_patch_fname}" ]\ - && ! ex_rtl_lmatch "${_patches_done}" "${_patch_fname}"; then + && ! rtl_lmatch "${_patches_done}" "${_patch_fname}"; then patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_patch_fname}" || return "${?}"; - _patches_done="$(ex_rtl_lconcat "${_patches_done}" "${_patch_fname}")"; + _patches_done="$(rtl_lconcat "${_patches_done}" "${_patch_fname}")"; fi; done; set -o noglob; }; diff --git a/subr/pkg_configure_patch_pre.subr b/subr/pkg_configure_patch_pre.subr index f38b518..1c572ef 100644 --- a/subr/pkg_configure_patch_pre.subr +++ b/subr/pkg_configure_patch_pre.subr @@ -17,8 +17,8 @@ pkgp_configure_patch_pre_chainport() { local _chainport_patch_fname="${BUILD_WORKDIR}/chainport/patches/${PKG_NAME%%_*}/${PKG_NAME%%_*}-${PKG_VERSION}.midipix.patch"\ _chainport_patch_dname="${PKG_BASE_DIR}/${PKG_SUBDIR}/patches/${PKG_NAME%%_*}" _oldpwd=""; if [ -e "${_chainport_patch_fname}" ]; then - ex_rtl_fileop mkdir "${_chainport_patch_dname}" || return "${?}"; - ex_rtl_fileop cp "${_chainport_patch_fname}" "${_chainport_patch_dname}" || return "${?}"; + rtl_fileop mkdir "${_chainport_patch_dname}" || return "${?}"; + rtl_fileop cp "${_chainport_patch_fname}" "${_chainport_patch_dname}" || return "${?}"; fi; }; diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr index 8e1d193..a23b8b9 100644 --- a/subr/pkg_fetch_download.subr +++ b/subr/pkg_fetch_download.subr @@ -4,10 +4,10 @@ pkg_fetch_download() { if [ -n "${PKG_URL}" ]; then - ex_rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}" || return "${?}"; + rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}" || return "${?}"; fi; if [ -n "${PKG_URLS_GIT}" ]; then - ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT} || return "${?}"; + rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT} || return "${?}"; fi; }; diff --git a/subr/pkg_fetch_extract.subr b/subr/pkg_fetch_extract.subr index 66e5166..9df9f93 100644 --- a/subr/pkg_fetch_extract.subr +++ b/subr/pkg_fetch_extract.subr @@ -14,8 +14,8 @@ pkgp_fetch_extract_type() { pkg_fetch_extract() { if [ -n "${PKG_URL}" ]\ && [ "${PKG_URL_TYPE:-wget}" = wget ]; then - _oldpwd="${PWD}"; ex_rtl_fileop cd "${PKG_BASE_DIR}" || return "${?}"; - ex_rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}" || return "${?}"; + _oldpwd="${PWD}"; rtl_fileop cd "${PKG_BASE_DIR}" || return "${?}"; + rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}" || return "${?}"; case "$(pkgp_fetch_extract_type "${PKG_NAME}")" in bz2) bunzip2 -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf - || return "${?}"; ;; gz) gunzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf - || return "${?}"; ;; @@ -23,7 +23,7 @@ pkg_fetch_extract() { xz) xz -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf - || return "${?}"; ;; *) tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/${PKG_FNAME}" || return "${?}"; ;; esac; - ex_rtl_fileop cd "${_oldpwd}" || return "${?}"; + rtl_fileop cd "${_oldpwd}" || return "${?}"; fi; }; diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr index 46024e8..87182d9 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -4,14 +4,14 @@ pkg_install() { local _pkglist_name=""; - if ! ex_rtl_fileop mkdir "${PKG_PREFIX}"\ + if ! rtl_fileop mkdir "${PKG_PREFIX}"\ || ! find "${PKG_DESTDIR}" -type d -exec chmod 0755 {} \;\ || ! find "${PKG_DESTDIR}" \( -not -perm /0111 \) -type f -exec chmod 0644 {} \;\ || ! find "${PKG_DESTDIR}" -perm /0111 -type f -exec chmod 0755 {} \;\ || ! tar -C "${PKG_DESTDIR}" -cpf - . | tar -C "${PKG_PREFIX}" --overwrite -xpf -; then return "${?}"; else - if ex_rtl_lmatch "${ARG_DIST}" "pkg" ","; then + if rtl_lmatch "${ARG_DIST}" "pkg" ","; then tar -C "${PKG_DESTDIR}" -cpf - . |\ gzip -c -9 - > "${PKG_BASE_DIR}/${PKG_NAME}.tgz" || return "${?}"; fi; diff --git a/subr/pkg_install_files.subr b/subr/pkg_install_files.subr index 92c7ed7..5a4d970 100644 --- a/subr/pkg_install_files.subr +++ b/subr/pkg_install_files.subr @@ -4,7 +4,7 @@ pkgp_install_files() { if [ -n "${PKG_INSTALL_FILES}" ]; then - ex_rtl_install -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES} || return "${?}"; + rtl_install -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES} || return "${?}"; fi; }; @@ -30,7 +30,7 @@ pkgp_install_files_strip() { fi; for _bin_path in $(find "${_tree_root}" -perm /a=x -type f); do if objdump -sj .debug_info "${_bin_path}" >/dev/null 2>&1; then - ex_rtl_log_msg info "Stripping ${_bin_path}..."; + rtl_log_msg info "Stripping ${_bin_path}..."; "${PKG_TARGET}-strip" "${_bin_path}" || return "${?}"; fi; done; diff --git a/subr/pkg_install_libs.subr b/subr/pkg_install_libs.subr index 379a037..a00f15b 100644 --- a/subr/pkg_install_libs.subr +++ b/subr/pkg_install_libs.subr @@ -5,7 +5,7 @@ pkgp_install_libs_purge_la() { local _la_path=""; for _la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do - ex_rtl_fileop rm "${_la_path}" || return "${?}"; + rtl_fileop rm "${_la_path}" || return "${?}"; done; }; @@ -14,8 +14,8 @@ pkgp_install_libs_shared_link() { if _lib_link_tgt="$(find "${_so_dir}" -name "${_lib_name%%.*}.*.lib.a" | sort | tail -1)"\ && [ -n "${_lib_link_tgt}" ]\ && [ "${_lib_link_tgt}" != "${_lib_link_path}" ]; then - if ! ex_rtl_fileop rm "${_lib_link_path}"\ - || ! ex_rtl_fileop ln_symbolic "$(ex_rtl_basename "${_lib_link_tgt}")" "${_lib_link_path}"; then + if ! rtl_fileop rm "${_lib_link_path}"\ + || ! rtl_fileop ln_symbolic "$(rtl_basename "${_lib_link_tgt}")" "${_lib_link_path}"; then return 1; fi; fi; @@ -28,21 +28,21 @@ pkgp_install_libs_shared() { $(find "${PKG_DESTDIR}" \ \( -name "*.so" -or -name "*.so.*" \) -print); do if [ "$(readlink -f "${_so_path}")" != "/dev/null" ]\ - && [ -z "$(ex_rtl_head "[0-9.]" "${_so_src_path##*.so}")" ]; then + && [ -z "$(rtl_head "[0-9.]" "${_so_src_path##*.so}")" ]; then case "${_so_src_path}" in *.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; _so_dst_dir="${_so_src_path%/*}"; - _lib_name="$(ex_rtl_basename "${_lib_src_path}")"; + _lib_name="$(rtl_basename "${_lib_src_path}")"; _lib_dst_path="${_so_dst_dir}/${_lib_name}"; if [ ! -L "${_lib_src_path}" ]\ && [ ! -e "${_lib_dst_path}" ]; then - (ex_rtl_fileop cd "$(ex_rtl_dirname "${_so_src_path}")" &&\ - perk -e "$(ex_rtl_basename "${_so_src_path}")" |\ + (rtl_fileop cd "$(rtl_dirname "${_so_src_path}")" &&\ + perk -e "$(rtl_basename "${_so_src_path}")" |\ "${PKG_TARGET}-mdso" \ - -i "$(ex_rtl_basename "${_lib_dst_path}")" \ - -n "$(ex_rtl_basename "${_so_src_path}")" -) || return "${?}"; + -i "$(rtl_basename "${_lib_dst_path}")" \ + -n "$(rtl_basename "${_so_src_path}")" -) || return "${?}"; fi; pkgp_install_libs_shared_link "${_lib_name}" "${_so_dst_dir}" "${_so_src_path}" || return "${?}"; fi; diff --git a/subr/pkg_install_make.subr b/subr/pkg_install_make.subr index 5cf16fe..45f5d58 100644 --- a/subr/pkg_install_make.subr +++ b/subr/pkg_install_make.subr @@ -3,7 +3,7 @@ # pkg_install_make() { - ex_rtl_run_cmd_unsplit make \ + rtl_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_INSTALL} \ ${PKG_MAKEFLAGS_INSTALL_EXTRA} \ AR=${PKG_AR} CC=${PKG_CC} RANLIB=${PKG_RANLIB} \ diff --git a/subr/pkg_install_rpm.subr b/subr/pkg_install_rpm.subr index b3c939a..ae76ac7 100644 --- a/subr/pkg_install_rpm.subr +++ b/subr/pkg_install_rpm.subr @@ -4,7 +4,7 @@ pkg_install_rpm() { local _pkg_url="" _pkg_version_full="" _pkg_version_rpm="" _rc=0; - if ex_rtl_lmatch "${ARG_DIST}" "rpm" ","\ + if rtl_lmatch "${ARG_DIST}" "rpm" ","\ && [ "${PKG_RPM_DISABLE:-0}" -eq 0 ]\ && [ -x "$(which rpmbuild 2>/dev/null)" ]; then if [ -n "${PKG_URL}" ]; then @@ -17,7 +17,7 @@ pkg_install_rpm() { _pkg_url="Unknown"; fi; fi; - if ! ex_rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/package.spec" \ + if ! rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/package.spec" \ "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec"; then return 1; else while true; do @@ -41,8 +41,8 @@ pkg_install_rpm() { done; if ! find "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}/RPMS" \ -iname \*.rpm -exec cp -pP {} "${PREFIX_RPM}/" \; \ - || ! ex_rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}" \ - || ! ex_rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec" "${PREFIX_RPM}/"; then + || ! rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}" \ + || ! rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec" "${PREFIX_RPM}/"; then return "${?}"; fi; fi; diff --git a/subr/pkg_install_subdirs.subr b/subr/pkg_install_subdirs.subr index 379592f..9455758 100644 --- a/subr/pkg_install_subdirs.subr +++ b/subr/pkg_install_subdirs.subr @@ -7,10 +7,10 @@ pkg_install_subdirs() { for _spec in \ "${PKG_INSTALL_FILES_DESTDIR}" \ "${PKG_INSTALL_FILES_DESTDIR_EXTRA}"; do - ex_rtl_install "${PKG_DESTDIR}" ${_spec} || return "${?}"; + rtl_install "${PKG_DESTDIR}" ${_spec} || return "${?}"; done; if [ "${PKG_PREFIX%/}" = "${PREFIX_NATIVE%/}" ]; then - ex_rtl_install \ + rtl_install \ "${PKG_DESTDIR}/${DEFAULT_TARGET}" ${PKG_INSTALL_FILES_DESTDIR} || return "${?}"; fi; }; diff --git a/subr/rtl.subr b/subr/rtl.subr new file mode 100644 index 0000000..18ddb8d --- /dev/null +++ b/subr/rtl.subr @@ -0,0 +1,17 @@ +# +# set +o errexit -o noglob is assumed. +# + +EXP_RTL_IFS="${IFS}"; + +rtl_basename() { echo "${1##*/}"; }; +rtl_date() { command date "+${1:-${DEFAULT_TIMESTAMP_FMT}}"; }; +rtl_dirname() { echo "${1%/*}"; }; +rtl_pop_IFS() { IFS="${EXP_RTL_IFS}"; }; +rtl_push_IFS() { EXP_RTL_IFS="${IFS}"; IFS="${1}"; }; +rtl_set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; }; +rtl_test_cmd() { command -v "${1}" >/dev/null; }; +rtl_uniq() { echo "${@}" | sed 's/ /\n/g' | awk '!x[$0]++' | paste -s -d" "; }; +rtl_unset_vars() { while [ ${#} -gt 0 ]; do unset "${1}"; shift; done; }; + +# vim:filetype=sh diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr new file mode 100644 index 0000000..6d9750d --- /dev/null +++ b/subr/rtl_complex.subr @@ -0,0 +1,114 @@ +# +# set +o errexit -o noglob is assumed. +# + +rtl_check_path_vars() { + local _vnames="${1}" _rc=0 _vname="" _vname_val=""; _status=""; + for _vname in ${_vnames}; do + _vname_val="$(rtl_get_var_unsafe "${_vname}")"; + if [ -z "${_vname_val}" ]; then + _rc=1; _status="Error: variable \`${_vname}' is empty or unset."; break; + elif [ "${_vname_val#* *}" != "${_vname_val}" ]; then + _rc=2; _status="Error: variable \`${_vname}' contains one or more whitespace characters."; break; + fi; + done; + return "${_rc}"; +}; + +rtl_clean_env() { + local _env_vars_except="${1}" _env_var="" _env_vars=""; + _env_vars="$(export | sed -ne '/^export/{s/^export //;s/=.*$//p}')"; + for _env_var in ${_env_vars}; do + if [ "${_env_var#DEFAULT_}" != "${_env_var}" ]\ + || [ "${_env_var#PKG_}" != "${_env_var}" ]; then + _env_vars_except="${_env_vars_except:+${_env_vars_except} }${_env_var}"; + fi; + done; + rtl_unset_vars $(rtl_lfilter "${_env_vars}" "${_env_vars_except}"); +}; + +rtl_exists_any() { + local _subdir="${1}"; shift; + while [ "${#}" -gt 0 ]; do + if [ -e "${_subdir}/${1}" ]; then + return 0; + else + shift; + fi; + done; return 1; +}; + +rtl_export_vars() { + local _unsetfl=0; [ "x${1}" = "x-u" ] && { _unsetfl=1; shift; }; + while [ "${#}" -ge 2 ]; do + if [ -n "${2}" ]; then + if [ "${_unsetfl:-0}" -eq 0 ]; then + rtl_set_var_unsafe "${1}" "${2}"; export "${1}"; + else + unset "${1}"; + fi; + fi; + shift 2; + done; +}; + +rtl_get_var_unsafe() { + local _vname=""; + if [ "x${1}" = "x-u" ]; then + shift; _vname="$(rtl_toupper "${1}")"; + else + _vname="${1}"; + fi; + eval echo \${${_vname}}; +}; + +rtl_head() { + local _pattern="${1}" _s="${2}"; + while true; do + if [ "${_s%%${_pattern}}" = "${_s}" ]; then + break; + else + _s="${_s%%${_pattern}}"; + fi; + done; + echo "${_s}"; +}; + +rtl_kill_tree() { + local _pid="${1}" _signal="TERM" _pid_child="" _pid_top=""; + for _pid_top in $(pgrep -P "${_pid}"); do + for _pid_child in $(pgrep -P "${_pid_top}" 2>/dev/null); do + _pids_killed="${_pids_killed:+${_pids_killed} }${_pid_child}"; kill "-${_signal}" "${_pid_child}" 2>/dev/null; + done; + _pids_killed="${_pids_killed:+${_pids_killed} }${_pid_top}"; kill "-${_signal}" "${_pid_top}" 2>/dev/null; + done; +}; + +rtl_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}; +}; + +rtl_set_vars() { + local _vars_set_vname="${1}" _vname_dst="${2}" _vname_src_tmpls="${3}" \ + _vars_set_old="" _vars_set_tmp="" _vname_src=""; + for _vname_src in $(rtl_toupper "${_vname_src_tmpls}"); do + _vname_src="${_vname_src}_${_vname_dst}"; + _vval_src="$(rtl_get_var_unsafe "${_vname_src}")"; + if [ -n "${_vval_src}" ]; then + rtl_set_var_unsafe "PKG_${_vname_dst}" "${_vval_src}"; + _vars_set_tmp="${_vars_set_tmp:+${_vars_set_tmp} }PKG_${_vname_dst}"; + fi; + done; + _vars_set_old="$(rtl_get_var_unsafe "${_vars_set_vname}")"; + rtl_set_var_unsafe "${_vars_set_vname}" \ + "${_vars_set_old:+${_vars_set_old} }${_vars_set_tmp}"; +}; + +# vim:filetype=sh diff --git a/subr/rtl_fetch.subr b/subr/rtl_fetch.subr new file mode 100644 index 0000000..d61d785 --- /dev/null +++ b/subr/rtl_fetch.subr @@ -0,0 +1,92 @@ +# +# set +o errexit -o noglob is assumed. +# + +exp_rtl_fetch_url_git() { + local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}" \ + _oldpwd=""; + (set -o errexit -o noglob; trap "rm -f \"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching\"" EXIT; + while true; do + if flock -E 622 -w 3600 4; then + break; + elif [ "${?}" -eq 622 ]; then + continue; + else + exit "${?}"; + fi; + done; + if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then + (rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ + git pull ${DEFAULT_GIT_ARGS} origin "${_branch:-main}"); + (rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ + git submodule update); + else + git clone ${DEFAULT_GIT_ARGS} "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}"; + if [ -n "${_branch}" ]; then + (rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ + git checkout "${_branch}"); + fi; + (rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ + git submodule update --init); + fi; + _oldpwd="${PWD}"; rtl_fileop cd "${PKG_BASE_DIR}"; + rtl_fileop rm "${_tgtdir}/${_subdir}"; + rtl_fileop cp "${BUILD_DLCACHEDIR}/${_subdir}" "${_tgtdir}"; + rtl_fileop cd "${_oldpwd}";) 4<>"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching"; + if [ "${?}" -eq 0 ]; then + cd "$(pwd)"; + else + return "${?}"; + fi; +}; + +rtl_fetch_urls_git() { + local _tgtdir="" _url_spec="" _subdir="" _url="" _git_branch=""; + _tgtdir="${1}"; shift; + if [ "${ARG_FETCH_FORCE}" = "offline" ]; then + return 0; + fi; + for _url_spec in "${@}"; do + _subdir="${_url_spec%=*}"; + _url="${_url_spec#*=}"; + _url="${_url%@*}"; + if [ "${_url_spec#*@}" != "${_url_spec}" ]; then + _git_branch=${_url_spec#*@}; + fi; + exp_rtl_fetch_url_git "${_tgtdir}" "${_subdir}" \ + "${_url}" "${_git_branch}"; + done; +}; + +# N.B. URLs ($1) may contain `?' or '&' characters. +rtl_fetch_url_wget() { + local _url="${1}" _sha256sum_src="${2}" _target_fname="${3}" _sha256sum_dst=""; + if [ "${ARG_FETCH_FORCE}" = "offline" ]; then + return 0; + elif [ -z "${_target_fname}" ]; then + _target_fname="$(rtl_basename "${_url}")"; + fi; + _url_dst="${BUILD_DLCACHEDIR}/${_target_fname}"; + (set -o errexit -o noglob; trap "_rc=\"\${?}\" ;rm -f \"${_url_dst}.fetching\"; exit \"\${_rc}\";" EXIT; + while true; do + if flock -E 622 -w 3600 4; then + break; + elif [ "${?}" -eq 622 ]; then + continue; + else + exit "${?}"; + fi; + done; + if [ ! -e "${_url_dst}.fetched" ]; then + wget ${DEFAULT_WGET_ARGS} -O "${_url_dst}" "${_url}"; + if [ -n "${_sha256sum_src}" ]; then + set -- $(sha256sum "${_url_dst}"); + if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then + rtl_log_msg failexit "Error: hash mismatch for URL \`${_url}' (downloaded file: ${_sha256sum_dst}, from build variables: ${_sha256sum_src}.)"; + fi; + fi; + rtl_fileop touch "${_url_dst}.fetched"; + fi;) 4<>"${_url_dst}.fetching"; +}; + +# vim:filetype=sh diff --git a/subr/rtl_fileop.subr b/subr/rtl_fileop.subr new file mode 100644 index 0000000..cc86178 --- /dev/null +++ b/subr/rtl_fileop.subr @@ -0,0 +1,111 @@ +# +# set +o errexit -o noglob is assumed. +# + +exp_rtl_fileop_check() { + local _prefix="${1}" _pname="" _rname=""; shift; + while [ "${#}" -gt 0 ]; do + return 0; + shift; done; +}; + +rtl_fileop() { + local _op="${1}" _dst="" _install_args="" _rc=0 _src=""; shift; + case "${_op}" in + cd) if [ \( -z "${1}" \) -o ! \( -L "${1}" -o -e "${1}" \) ]; then + rtl_log_msg failexit "Invalid or non-existent directory \`${1}'."; + elif exp_rtl_fileop_check "${PREFIX}" "${1}"; then + rtl_log_msg vvvv "Changing working directory to \`${1}'."; + cd -- "${1}"; _rc="${?}"; + fi; ;; + cp_follow) + if [ "${#}" -lt 2 ]; then + rtl_log_msg failexit "Missing parameters (in: cp_follow ${*}.)"; + elif exp_rtl_fileop_check "${PREFIX}" "${*}"; then + _src="${*}"; _src="${_src% *}"; + _dst="${*}"; _dst="${_dst##* }"; + rtl_log_msg vvvv "Copying \`${_src}' into \`${_dst}' w/ -pLR."; + cp -pLR -- "${@}"; _rc="${?}"; + fi; ;; + cp) if [ "${#}" -lt 2 ]; then + rtl_log_msg failexit "Missing parameters (in: cp ${*}.)"; + elif exp_rtl_fileop_check "${PREFIX}" "${*}"; then + _src="${*}"; _src="${_src% *}"; + _dst="${*}"; _dst="${_dst##* }"; + rtl_log_msg vvvv "Copying \`${_src}' into \`${_dst}' w/ -pPR."; + cp -pPR -- "${@}"; _rc="${?}"; + fi; ;; + install) + if [ "${#}" -lt 2 ]; then + rtl_log_msg failexit "Missing parameters (in: install ${*}.)"; + else _dst="$(while [ ""${#}"" -gt 2 ]; do shift; done; echo "${2}")"; + _install_args="$(while [ ""${#}"" -gt 2 ]; do echo "${1}"; shift; done)"; + _src="$(while [ ""${#}"" -gt 2 ]; do shift; done; echo "${1}")"; + if exp_rtl_fileop_check "${PREFIX}" "${_dst}" "${_src}"; then + rtl_log_msg vvvv "Installing \`${_src}' into \`${_dst}' w/ ${_install_args}."; + install "${@}"; _rc="${?}"; + fi; + fi; ;; + ln_symbolic) + if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then + rtl_log_msg failexit "Missing parameters (in: ln_symbolic ${*}.)"; + elif exp_rtl_fileop_check "${PREFIX}" "${2}"; then + if rtl_fileop test "${2}"; then + rtl_fileop rm "${2}"; + fi; + if [ "${?}" -eq 0 ]; then + rtl_log_msg vvvv "Linking \`${1}' to \`${2}' w/ -fs"; + ln -fs -- "${1}" "${2}"; _rc="${?}"; + fi; + fi; ;; + mv) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then + rtl_log_msg failexit "Missing parameters (in: mv ${*}.)"; + elif exp_rtl_fileop_check "${PREFIX}" "${1}" "${2}"; then + rtl_log_msg vvvv "Moving \`${1}' to \`${2}' w/ -fs"; + mv -f -- "${1}" "${2}"; _rc="${?}"; + fi; ;; + mkdir|mkfifo|rm|source_opt|test|touch) + while [ \( "${?}" -eq 0 \) -a \( ""${#}"" -gt 0 \) ]; do + if [ -z "${1}" ]; then + rtl_log_msg failexit "Missing parameters (in: ${_op} ${*}.)"; + elif [ "${_op}" = mkdir ]\ + && [ ! -d "${1}" ]\ + && exp_rtl_fileop_check "${PREFIX}" "${1}"; then + if rtl_fileop test "${1}"; then + rtl_fileop rm "${1}"; + fi; + rtl_log_msg vvvv "Making directory \`${1}'."; + mkdir -p -- "${1}"; _rc="${?}"; + elif [ "${_op}" = mkfifo ]\ + && exp_rtl_fileop_check "${PREFIX}" "${1}"; then + if rtl_fileop test "${1}"; then + rtl_fileop rm "${1}"; + fi; + rtl_log_msg vvvv "Creating FIFO \`${1}'."; + exp_rtl_fileop_check "${PREFIX}" "${1}"; + mkfifo -- "${1}"; _rc="${?}"; + elif [ "${_op}" = rm ]\ + && rtl_fileop test "${1}"\ + && exp_rtl_fileop_check "${PREFIX}" "${1}"; then + rtl_log_msg vvvv "Removing directory or file \`${1}'."; + rm -rf -- "${1}"; _rc="${?}"; + elif [ "${_op}" = source_opt ]\ + && rtl_fileop test "${1}"\ + && exp_rtl_fileop_check "${PREFIX}" "${1}"; then + rtl_log_msg vvvv "Sourcing file \`${1}'."; + . "${1}"; _rc="${?}"; + elif [ "${_op}" = test ]\ + && exp_rtl_fileop_check "${PREFIX}" "${1}"\ + && ! [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then + return 1; + elif [ "${_op}" = touch ]\ + && exp_rtl_fileop_check "${PREFIX}" "${1}"; then + rtl_log_msg vvvv "Touching file \`${1}'."; + touch -- "${1}"; _rc="${?}"; + fi; shift; + done; ;; + *) rtl_log_msg failexit "Error: rtl_fileop() called w/ invalid parameter(s): ${*}"; ;; + esac; return "${_rc}"; +}; + +# vim:filetype=sh diff --git a/subr/rtl_install.subr b/subr/rtl_install.subr new file mode 100644 index 0000000..a1c70a0 --- /dev/null +++ b/subr/rtl_install.subr @@ -0,0 +1,47 @@ +# +# set +o errexit -o noglob is assumed. +# + +rtl_install() { + 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 [ "${_ln_fname#/}" = "${_ln_fname}" ]; then + _ln_fname="${_prefix:+${_prefix}/}${_ln_fname}"; + fi; + if [ -e "${_ln_fname}" ]; then + rtl_fileop rm "${_ln_fname}"; + fi; + rtl_fileop ln_symbolic "${_ln_target}" "${_ln_fname}"; + ;; + /=*) + _mkdir_fname="${1#/=}"; + if [ "${_mkdir_fname#/}" = "${_mkdir_fname}" ]; then + _mkdir_fname="${_prefix:+${_prefix}/}${_mkdir_fname}"; + fi; + rtl_fileop mkdir "${_mkdir_fname}"; + ;; + *) + _file_fname_src="${1%=*}"; + _file_fname_dst="${1#*=}"; + if [ "${_file_fname_src#/}" = "${_file_fname_src}" ]; then + _file_fname_src="${_prefix:+${_prefix}/}${_file_fname_src}"; + fi; + if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then + _file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}"; + fi; + rtl_fileop cp "${_file_fname_src}" "${_file_fname_dst}"; + ;; + esac; shift; + done; +}; + +# vim:filetype=sh diff --git a/subr/rtl_list.subr b/subr/rtl_list.subr new file mode 100644 index 0000000..056d801 --- /dev/null +++ b/subr/rtl_list.subr @@ -0,0 +1,75 @@ +# +# set +o errexit -o noglob is assumed. +# + +rtl_lconcat() { + local _list="${1}" _litem_new="${2}" _sep="${3:- }" IFS="${3:-${IFS}}"; + if [ -n "${_list}" ]; then + printf "%s%s%s" "${_list}" "${_sep}" "${_litem_new}"; + else + printf "%s" "${_litem_new}"; + fi; +}; + +rtl_lfilter() { + local _list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS}}" \ + _filterfl="" _litem="" _litem_filter="" _lnew=""; + if [ -z "${_filter}" ]; then + echo "${_list}"; return 0; + else for _litem in ${_list}; do + _filterfl=0; + for _litem_filter in ${_filter}; do + if [ "${_litem_filter}" = "${_litem}" ]; then + _filterfl=1; break; + fi; + done; + if [ "${_filterfl:-0}" -eq 0 ]; then + _lnew="${_lnew:+${_lnew}${_sep}}${_litem}"; + fi; + done; fi; + echo "${_lnew}"; +}; + +rtl_llength() { + local _list="${1}" _sep="${2:- }" IFS="${2:-${IFS}}" _litem="" _llength=0; + for _litem in ${_list}; do + : $((_llength+=1)); + done; + echo "${_llength}"; +}; + +rtl_lmatch() { + local _list="${1}" _item="${2}" _sep="${3}"; + [ -n "$(rtl_lsearch "${_list}" "${_item}" "${_sep}")" ]; +}; + +rtl_lsearch() { + local _list="${1}" _filter="${2}" _sep="${3:- }" IFS="${3:-${IFS}}" \ + _litem="" _litem_filter="" _lnew=""; + if [ -z "${_filter}" ]; then + echo "${_list}"; return 0; + else for _litem in ${_list}; do + for _litem_filter in ${_filter}; do + if [ "${_litem_filter}" = "${_litem}" ]; then + _lnew="${_lnew:+${_lnew}${_sep}}${_litem}"; + break; + fi; + done; + done; fi; + echo "${_lnew}"; +}; + +rtl_lunfold_depends() { + local _vname_template="${1}" _depends="" _name="" _names=""; shift; + for _name in "${@}"; do + if _depends="$(rtl_get_var_unsafe -u "$(eval printf \"%s\" \""${_vname_template}"\")")"\ + && [ -n "${_depends}" ]; then + _depends="$(rtl_lunfold_depends "${_vname_template}" ${_depends})"; + _names="$(rtl_lconcat "${_names}" "${_depends}")"; + fi; + _names="$(rtl_lconcat "${_names}" "${_name}")"; + done; + echo "${_names}"; +}; + +# vim:filetype=sh diff --git a/subr/rtl_log.subr b/subr/rtl_log.subr new file mode 100644 index 0000000..e27e81d --- /dev/null +++ b/subr/rtl_log.subr @@ -0,0 +1,78 @@ +# +# set +o errexit -o noglob is assumed. +# + +: ${DEFAULT_LOG_MSG_FAIL_COLOUR:=91}; +: ${DEFAULT_LOG_MSG_INFO_COLOUR:=93}; +: ${DEFAULT_LOG_MSG_INF2_COLOUR:=33}; +: ${DEFAULT_LOG_MSG_SUCC_COLOUR:=92}; +: ${DEFAULT_LOG_MSG_SUC2_COLOUR:=32}; +: ${DEFAULT_LOG_MSG_VNFO_COLOUR:=96}; +: ${DEFAULT_LOG_MSG_VUCC_COLOUR:=90}; +: ${DEFAULT_LOG_MSG_VVFO_COLOUR:=96}; +: ${DEFAULT_LOG_MSG_VVVO_COLOUR:=96}; +: ${DEFAULT_LOG_MSG_VVVV_COLOUR:=96}; + +exp_rtl_log_printf() { + local _attrs="${1}" _msg=""; shift; _msg="$(printf "${@}")"; + if [ "${BUILD_IS_PARENT:-0}" -eq 1 ]\ + && [ -n "${DEFAULT_BUILD_LOG_FNAME}" ]\ + && [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then + printf "%s\n" "${_msg}" >> "${DEFAULT_BUILD_LOG_FNAME}"; + fi; + printf "\033[0m\033[${_attr}m%s\033[0m\n" "${_msg}"; +}; + +rtl_log_env_vars() { + local _nvar=1 _arg="" _arg_len_max=0; + rtl_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 + rtl_log_msg info "$(printf \ + "%${_arg_len_max}.${_arg_len_max}s=%s" \ + "${1%%=*}" "$(rtl_get_var_unsafe ${1#*=})")"; + shift; + done; +}; + +rtl_log_set_vnfo_lvl() { + EXP_RTL_LOG_VNFO_LVL="${1}"; +}; + +rtl_log_msg() { + local _lvl="${1}" _lvl_uc="" _attr=""; shift; + if [ "${_lvl}" = vnfo ]\ + || [ "${_lvl}" = vucc ]\ + && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 1 ]; then + return; + elif [ "${_lvl}" = vvfo ]\ + && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 2 ]; then + return; + elif [ "${_lvl}" = vvvo ]\ + && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 3 ]; then + return; + elif [ "${_lvl}" = vvvv ]\ + && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 4 ]; then + return; + fi; + _lvl_uc="$(rtl_toupper "${_lvl%exit}")"; + _attr="$(rtl_get_var_unsafe "DEFAULT_LOG_MSG_${_lvl_uc}_COLOUR")"; + if [ ${#} -gt 1 ]; then + exp_rtl_log_printf "${_attrs}" "==> %s %s %s" "$(rtl_date)" "${1}" "$*"; + else + exp_rtl_log_printf "${_attrs}" "==> %s %s" "$(rtl_date)" "${1}"; + fi; + if [ ${_lvl} = failexit ]; then + exit 1; + else + return 0; + fi; +}; + +# vim:filetype=sh diff --git a/subr/rtl_state.subr b/subr/rtl_state.subr new file mode 100644 index 0000000..1ee8258 --- /dev/null +++ b/subr/rtl_state.subr @@ -0,0 +1,40 @@ +# +# set +o errexit -o noglob is assumed. +# + +rtl_state_clear() { + local _workdir="${1}" _pkg_name="${2}" _pkg_fname=""; + for _pkg_fname in $(find "${_workdir}" \ + -maxdepth 1 -mindepth 1 -name .${_pkg_name}.\* -type f); do + rtl_fileop rm "${_pkg_fname}"; + done; +}; + +rtl_state_set() { + local _workdir="${1}" _pkg_fname="${2}" _done_fname_pfx=""; + _done_fname_pfx="${_workdir}/.${_pkg_fname}"; + shift 2; while [ ${#} -ge 1 ]; do + if [ -z "${1}" ]; then + shift; continue; + elif [ "${1#-}" != "${1}" ]; then + rtl_fileop rm "${_done_fname_pfx}.${1#-}"; + else + rtl_fileop touch "${_done_fname_pfx}.${1}"; + fi; + shift; done; +}; + +rtl_state_test() { + local _workdir="${1}" _pkg_name="${2}" _build_step="${3}" \ + _restart_at="${4}" _done_fname=""; + _done_fname="${_workdir}/.${_pkg_name}.${_build_step}"; + if [ -z "${_restart_at}" ]; then + rtl_fileop test "${_done_fname}"; + elif [ "${_restart_at}" = "ALL" ]; then + return 1; + else + ! rtl_lmatch "${_restart_at}" "${_build_step}" ","; + fi; +}; + +# vim:filetype=sh diff --git a/subr/rtl_string.subr b/subr/rtl_string.subr new file mode 100644 index 0000000..0e549d3 --- /dev/null +++ b/subr/rtl_string.subr @@ -0,0 +1,93 @@ +# +# set +o errexit -o noglob is assumed. +# + +rtl_isnumber() { + local _s="${1}" _rc=0; + while [ -n "${_s}" ]; do + case "${_s}" in + [0-9]*) _s="${_s#[0-9]}"; ;; + *) _rc=1; break; ;; + esac; done; + return "${_rc}"; +}; + +rtl_tolower() { + local _s="${1}" _s_new=""; + while [ -n "${_s}" ]; do + case "${_s}" in + A*) _s_new="${_s_new:+${_s_new}}a"; _s="${_s#A}"; ;; + B*) _s_new="${_s_new:+${_s_new}}b"; _s="${_s#B}"; ;; + C*) _s_new="${_s_new:+${_s_new}}c"; _s="${_s#C}"; ;; + D*) _s_new="${_s_new:+${_s_new}}d"; _s="${_s#D}"; ;; + E*) _s_new="${_s_new:+${_s_new}}e"; _s="${_s#E}"; ;; + F*) _s_new="${_s_new:+${_s_new}}f"; _s="${_s#F}"; ;; + G*) _s_new="${_s_new:+${_s_new}}g"; _s="${_s#G}"; ;; + H*) _s_new="${_s_new:+${_s_new}}h"; _s="${_s#H}"; ;; + I*) _s_new="${_s_new:+${_s_new}}i"; _s="${_s#I}"; ;; + J*) _s_new="${_s_new:+${_s_new}}j"; _s="${_s#J}"; ;; + K*) _s_new="${_s_new:+${_s_new}}k"; _s="${_s#K}"; ;; + L*) _s_new="${_s_new:+${_s_new}}l"; _s="${_s#L}"; ;; + M*) _s_new="${_s_new:+${_s_new}}m"; _s="${_s#M}"; ;; + N*) _s_new="${_s_new:+${_s_new}}n"; _s="${_s#N}"; ;; + O*) _s_new="${_s_new:+${_s_new}}o"; _s="${_s#O}"; ;; + P*) _s_new="${_s_new:+${_s_new}}p"; _s="${_s#P}"; ;; + Q*) _s_new="${_s_new:+${_s_new}}q"; _s="${_s#Q}"; ;; + R*) _s_new="${_s_new:+${_s_new}}r"; _s="${_s#R}"; ;; + S*) _s_new="${_s_new:+${_s_new}}s"; _s="${_s#S}"; ;; + T*) _s_new="${_s_new:+${_s_new}}t"; _s="${_s#T}"; ;; + U*) _s_new="${_s_new:+${_s_new}}u"; _s="${_s#U}"; ;; + V*) _s_new="${_s_new:+${_s_new}}v"; _s="${_s#V}"; ;; + W*) _s_new="${_s_new:+${_s_new}}w"; _s="${_s#W}"; ;; + X*) _s_new="${_s_new:+${_s_new}}x"; _s="${_s#X}"; ;; + Y*) _s_new="${_s_new:+${_s_new}}y"; _s="${_s#Y}"; ;; + Z*) _s_new="${_s_new:+${_s_new}}z"; _s="${_s#Z}"; ;; + [^ABCDEFGHIJKLMNOPQRSTUVWXYZ]*) + _s_new="${_s_new:+${_s_new}}${_s%%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*}"; + while [ "${_s#[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]}" != "${_s}" ]; do + _s="${_s#[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]}"; + done; ;; + esac; done; + echo "${_s_new}"; +}; + +rtl_toupper() { + local _s="${1}" _s_new=""; + while [ -n "${_s}" ]; do + case "${_s}" in + a*) _s_new="${_s_new:+${_s_new}}A"; _s="${_s#a}"; ;; + b*) _s_new="${_s_new:+${_s_new}}B"; _s="${_s#b}"; ;; + c*) _s_new="${_s_new:+${_s_new}}C"; _s="${_s#c}"; ;; + d*) _s_new="${_s_new:+${_s_new}}D"; _s="${_s#d}"; ;; + e*) _s_new="${_s_new:+${_s_new}}E"; _s="${_s#e}"; ;; + f*) _s_new="${_s_new:+${_s_new}}F"; _s="${_s#f}"; ;; + g*) _s_new="${_s_new:+${_s_new}}G"; _s="${_s#g}"; ;; + h*) _s_new="${_s_new:+${_s_new}}H"; _s="${_s#h}"; ;; + i*) _s_new="${_s_new:+${_s_new}}I"; _s="${_s#i}"; ;; + j*) _s_new="${_s_new:+${_s_new}}J"; _s="${_s#j}"; ;; + k*) _s_new="${_s_new:+${_s_new}}K"; _s="${_s#k}"; ;; + l*) _s_new="${_s_new:+${_s_new}}L"; _s="${_s#l}"; ;; + m*) _s_new="${_s_new:+${_s_new}}M"; _s="${_s#m}"; ;; + n*) _s_new="${_s_new:+${_s_new}}N"; _s="${_s#n}"; ;; + o*) _s_new="${_s_new:+${_s_new}}O"; _s="${_s#o}"; ;; + p*) _s_new="${_s_new:+${_s_new}}P"; _s="${_s#p}"; ;; + q*) _s_new="${_s_new:+${_s_new}}Q"; _s="${_s#q}"; ;; + r*) _s_new="${_s_new:+${_s_new}}R"; _s="${_s#r}"; ;; + s*) _s_new="${_s_new:+${_s_new}}S"; _s="${_s#s}"; ;; + t*) _s_new="${_s_new:+${_s_new}}T"; _s="${_s#t}"; ;; + u*) _s_new="${_s_new:+${_s_new}}U"; _s="${_s#u}"; ;; + v*) _s_new="${_s_new:+${_s_new}}V"; _s="${_s#v}"; ;; + w*) _s_new="${_s_new:+${_s_new}}W"; _s="${_s#w}"; ;; + x*) _s_new="${_s_new:+${_s_new}}X"; _s="${_s#x}"; ;; + y*) _s_new="${_s_new:+${_s_new}}Y"; _s="${_s#y}"; ;; + z*) _s_new="${_s_new:+${_s_new}}Z"; _s="${_s#z}"; ;; + [^abcdefghijklmnopqrstuvwxyz]*) + _s_new="${_s_new:+${_s_new}}${_s%%[abcdefghijklmnopqrstuvwxyz]*}"; + while [ "${_s#[^abcdefghijklmnopqrstuvwxyz]}" != "${_s}" ]; do + _s="${_s#[^abcdefghijklmnopqrstuvwxyz]}"; + done; ;; + esac; done; + echo "${_s_new}"; +}; + +# vim:filetype=sh diff --git a/vars/busybox.vars b/vars/busybox.vars index 71dd3aa..14b33b9 100644 --- a/vars/busybox.vars +++ b/vars/busybox.vars @@ -3,14 +3,14 @@ # pkg_busybox_configure() { - ex_rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/busyboxconfig" "${PKG_BUILD_DIR}/.config"; + rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/busyboxconfig" "${PKG_BUILD_DIR}/.config"; }; pkg_busybox_install_make_post() { set +o noglob - ex_rtl_fileop cp "${PKG_BUILD_DIR}/_install/bin/"* "${PKG_DESTDIR}/bin/"; + rtl_fileop cp "${PKG_BUILD_DIR}/_install/bin/"* "${PKG_DESTDIR}/bin/"; set -o noglob - ex_rtl_fileop cp "${PKG_BUILD_DIR}/_install/lib/libbusybox.so.${PKG_VERSION}" "${PKG_DESTDIR}/lib/"; + rtl_fileop cp "${PKG_BUILD_DIR}/_install/lib/libbusybox.so.${PKG_VERSION}" "${PKG_DESTDIR}/lib/"; }; # vim:filetype=sh diff --git a/vars/ca_certificates.vars b/vars/ca_certificates.vars index 65b8387..69d7bfb 100644 --- a/vars/ca_certificates.vars +++ b/vars/ca_certificates.vars @@ -7,7 +7,7 @@ pkg_ca_certificates_install_make_pre() { }; pkg_ca_certificates_install_make_post() { - ex_rtl_fileop cd "${PKG_DESTDIR}/share/ca-certificates"; + rtl_fileop cd "${PKG_DESTDIR}/share/ca-certificates"; set +o noglob find . -name '*.crt' | sort | cut -b3- > ${PKG_DESTDIR}/etc/ca-certificates.conf set -o noglob diff --git a/vars/chainport_host.vars b/vars/chainport_host.vars index 5db2cdb..aa4450f 100644 --- a/vars/chainport_host.vars +++ b/vars/chainport_host.vars @@ -3,8 +3,8 @@ # pkg_chainport_host_install_make() { - ex_rtl_fileop rm "${BUILD_WORKDIR}/chainport"; - ex_rtl_fileop cp ../chainport "${BUILD_WORKDIR}/chainport"; + rtl_fileop rm "${BUILD_WORKDIR}/chainport"; + rtl_fileop cp ../chainport "${BUILD_WORKDIR}/chainport"; }; # vim:filetype=sh diff --git a/vars/clang_host.vars b/vars/clang_host.vars index 32e9cc7..ada3ba3 100644 --- a/vars/clang_host.vars +++ b/vars/clang_host.vars @@ -3,10 +3,10 @@ # pkg_clang_host_configure() { - ex_rtl_fileop rm "../cfe-${PKG_VERSION}-host"; - ex_rtl_fileop mkdir "../cfe-${PKG_VERSION}-host"; - ex_rtl_fileop cd "../cfe-${PKG_VERSION}-host"; - ex_rtl_log_msg info "Bootstrapping clang_host..."; + rtl_fileop rm "../cfe-${PKG_VERSION}-host"; + rtl_fileop mkdir "../cfe-${PKG_VERSION}-host"; + rtl_fileop cd "../cfe-${PKG_VERSION}-host"; + rtl_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); - ex_rtl_log_msg info "Finished bootstrapping clang_host."; + rtl_log_msg info "Finished bootstrapping clang_host."; }; # vim:filetype=sh diff --git a/vars/cmake.vars b/vars/cmake.vars index 21b22c4..4417026 100644 --- a/vars/cmake.vars +++ b/vars/cmake.vars @@ -3,7 +3,7 @@ # pkg_cmake_configure() { - ex_rtl_fileop cp "${PREFIX}/share/cmake-${PKG_VERSION%.*}/Modules/Platform/BSDOS.cmake" \ + rtl_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/dbus_host.vars b/vars/dbus_host.vars index 8536b3d..65b6d7e 100644 --- a/vars/dbus_host.vars +++ b/vars/dbus_host.vars @@ -3,7 +3,7 @@ # pkg_dbus_host_install_pre() { - ex_rtl_fileop rm "${PKG_DESTDIR}/etc" "${PKG_DESTDIR}/var"; + rtl_fileop rm "${PKG_DESTDIR}/etc" "${PKG_DESTDIR}/var"; }; # vim:filetype=sh diff --git a/vars/env.vars b/vars/env.vars index 3238321..26fb483 100644 --- a/vars/env.vars +++ b/vars/env.vars @@ -17,15 +17,17 @@ DEFAULT_BUILD_VARS=" CFLAGS_BUILD_EXTRA CFLAGS_CONFIGURE CFLAGS_CONFIGURE_EXTRA \ CFLAGS_INSTALL_EXTRA CONFIG_CACHE CONFIG_CACHE_EXTRA \ CONFIG_CACHE_LOCAL CONFIGURE CONFIGURE_ARGS CONFIGURE_ARGS_EXTRA \ - CXX CXXFLAGS_CONFIGURE CXXFLAGS_CONFIGURE_EXTRA DEPENDS DESTDIR DISABLED \ - ENV_VARS_EXTRA FNAME GITROOT INHERIT_FROM INSTALL_FILES INSTALL_FILES \ + CXX CXXFLAGS_CONFIGURE CXXFLAGS_CONFIGURE_EXTRA \ + DEPENDS DESTDIR DISABLED ENV_VARS_EXTRA FNAME \ + FORCE GITROOT INHERIT_FROM INSTALL_FILES INSTALL_FILES \ INSTALL_FILES_DESTDIR INSTALL_FILES_DESTDIR_EXTRA INSTALL_TARGET \ INSTALL_TARGET_EXTRA IN_TREE LDFLAGS_BUILD_EXTRA LDFLAGS_CONFIGURE \ LDFLAGS_CONFIGURE_EXTRA LDFLAGS_INSTALL_EXTRA LIBTOOL MAKE \ - MAKE_INSTALL_VNAME MAKEFLAGS_BUILD MAKEFLAGS_BUILD_EXTRA MAKEFLAGS_INSTALL \ - MAKEFLAGS_INSTALL_EXTRA NO_CLEAN NO_CLEAN_BASE_DIR NO_LOG_VARS PYTHON \ - PATCHES_EXTRA PKG_CONFIG PKG_CONFIG_PATH PKGLIST_DISABLE PREFIX RANLIB \ - RPM_DISABLE SHA256SUM SUBDIR TARGET URL URL_TYPE URLS_GIT VERSION"; + MAKE_INSTALL_VNAME MAKEFLAGS_BUILD MAKEFLAGS_BUILD_EXTRA \ + MAKEFLAGS_INSTALL MAKEFLAGS_INSTALL_EXTRA NO_CLEAN \ + NO_CLEAN_BASE_DIR NO_LOG_VARS PYTHON PATCHES_EXTRA PKG_CONFIG \ + PKG_CONFIG_PATH PKGLIST_DISABLE PREFIX RANLIB RPM_DISABLE \ + SHA256SUM SUBDIR TARGET URL URL_TYPE URLS_GIT VERSION"; # Path names : ${PREFIX_ROOT:=${HOME}/midipix}; @@ -68,10 +70,10 @@ DEFAULT_BUILD_VARS=" : ${DEFAULT_CFLAGS_RELEASE:="-g0 -O0"}; : ${DEFAULT_CFLAGS_RELEASE_HOST:="-g0 -O0"}; : ${DEFAULT_CFLAGS_RELEASE_RUNTIME:="-g0 -O0"}; -: ${DEFAULT_CFLAGS:=$(ex_rtl_get_var_unsafe "DEFAULT_CFLAGS_$(ex_rtl_toupper "${BUILD}")")}; +: ${DEFAULT_CFLAGS:=$(rtl_get_var_unsafe "DEFAULT_CFLAGS_$(rtl_toupper "${BUILD}")")}; : ${DEFAULT_CFLAGS_CONFIGURE:=${DEFAULT_CFLAGS}}; -: ${DEFAULT_CFLAGS_HOST:=$(ex_rtl_get_var_unsafe "DEFAULT_CFLAGS_$(ex_rtl_toupper "${BUILD}")_HOST")}; -: ${DEFAULT_CFLAGS_RUNTIME:=$(ex_rtl_get_var_unsafe "DEFAULT_CFLAGS_$(ex_rtl_toupper "${BUILD}")_RUNTIME")}; +: ${DEFAULT_CFLAGS_HOST:=$(rtl_get_var_unsafe "DEFAULT_CFLAGS_$(rtl_toupper "${BUILD}")_HOST")}; +: ${DEFAULT_CFLAGS_RUNTIME:=$(rtl_get_var_unsafe "DEFAULT_CFLAGS_$(rtl_toupper "${BUILD}")_RUNTIME")}; : ${DEFAULT_GITROOT:=git://midipix.org}; : ${DEFAULT_GITROOT_HEAD:=git://midipix.org}; : ${DEFAULT_LOG_MSG_FAIL_COLOUR:=91}; diff --git a/vars/gcc.vars b/vars/gcc.vars index 6167532..ec22fe6 100644 --- a/vars/gcc.vars +++ b/vars/gcc.vars @@ -61,9 +61,9 @@ pkgp_gcc_setup_env() { }; pkgp_gcc_configure() { - ex_rtl_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; - ex_rtl_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; - ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; "../cbb-gcc-${PKG_VERSION}/configure" "${@}"\ --disable-bootstrap \ --disable-libmudflap \ @@ -94,18 +94,18 @@ pkg_gcc_stage1_host_all() { }; pkg_gcc_stage1_cross_mingw32_all() { - ex_rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"; - ex_rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"; - ex_rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"; - ex_rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"; + rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"; + rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"; + rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"; + rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"; pkg_gcc_stage1_all "${@}"; }; pkg_gcc_stage1_native_mingw32_all() { - ex_rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"; - ex_rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"; - ex_rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"; - ex_rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"; + rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"; + rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"; + rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"; + rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"; pkg_gcc_stage1_all "${@}"; }; @@ -113,8 +113,8 @@ pkg_gcc_stage1_all() { local __="" _restart_at="${1}"; case "${PKG_NAME}" in gcc_stage1_host) - ex_rtl_fileop ln_symbolic . "${PREFIX_CROSS}/usr"; - ex_rtl_fileop mkdir "${PREFIX_CROSS}/usr/include"; + rtl_fileop ln_symbolic . "${PREFIX_CROSS}/usr"; + rtl_fileop mkdir "${PREFIX_CROSS}/usr/include"; pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross; ;; gcc_stage1_cross_mingw32) @@ -126,7 +126,7 @@ pkg_gcc_stage1_all() { esac; # GCC, stage1. if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then - ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; + rtl_fetch_urls_git "${PKG_BASE_DIR}" "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; pkgp_gcc_state_set fetch patch; fi; if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then @@ -169,7 +169,7 @@ pkg_gcc_stage1_all() { --without-headers; ;; esac; else - ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; fi; if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-gcc; @@ -190,8 +190,8 @@ pkg_gcc_stage1_all() { esac; __="$(uname -s)"; if [ "${__#*CYGWIN*}" != "${__}" ]; then - ex_rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.dll.a" \ - ex_rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.so"; + rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.dll.a" \ + rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.so"; fi; pkgp_gcc_state_set install_make install; fi; @@ -206,7 +206,7 @@ pkg_gcc_runtime_host_all() { local _vis_hide="vis_hide=-fvisibility=hidden"; export MAKE="make LIBTOOL=slibtool ${_vis_hide}"; pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross; - ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; # GCC, compiler runtime. if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-target-libgcc ${_vis_hide}; @@ -230,7 +230,7 @@ pkg_gcc_libstdcpp_v3_host_all() { local _restart_at="${1}"; export MAKE="make LIBTOOL=slibtool"; pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross; - ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; # GCC, libstdc++-v3. if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-target-libstdc++-v3; @@ -254,7 +254,7 @@ pkg_gcc_full_host_all() { local _restart_at="${1}"; export MAKE="make LIBTOOL=slibtool"; pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross; - ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; # GCC, everything else. if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD}; @@ -281,7 +281,7 @@ pkg_gcc_full_all() { # GCC, native. pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" native; if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then - ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; + rtl_fetch_urls_git "${PKG_BASE_DIR}" "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; pkgp_gcc_state_set fetch patch; fi; if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then @@ -292,9 +292,9 @@ pkg_gcc_full_all() { fi; pkgp_gcc_setup_env "${PKG_VERSION}"; if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then - ex_rtl_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}"; + rtl_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}"; if [ \! -d "${PKG_PREFIX}/${PKG_TARGET}/usr" ]; then - ex_rtl_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr"; + rtl_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr"; fi; if [ "${ARCH}" = nt32 ]; then _configure_host="i686-nt32-midipix"; @@ -311,7 +311,7 @@ pkg_gcc_full_all() { --with-mpfr="${PKG_PREFIX}" \ --with-sysroot=; else - ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; + rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; fi; if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then make ${PKG_MAKEFLAGS_BUILD} all-gcc; diff --git a/vars/ghostscript.vars b/vars/ghostscript.vars index aed9239..ee6ec5e 100644 --- a/vars/ghostscript.vars +++ b/vars/ghostscript.vars @@ -3,10 +3,10 @@ # pkg_ghostscript_configure_patch_pre() { - ex_rtl_fileop rm "${PKG_BASE_DIR}/ghostscript-9.26/zlib"; - ex_rtl_fileop rm "${PKG_BASE_DIR}/ghostscript-9.26/libpng"; - ex_rtl_fileop rm "${PKG_PREFIX}/freetype"; - ex_rtl_fileop rm "${PKG_PREFIX}/lcms2mt"; + rtl_fileop rm "${PKG_BASE_DIR}/ghostscript-9.26/zlib"; + rtl_fileop rm "${PKG_BASE_DIR}/ghostscript-9.26/libpng"; + rtl_fileop rm "${PKG_PREFIX}/freetype"; + rtl_fileop rm "${PKG_PREFIX}/lcms2mt"; }; # vim:filetype=sh diff --git a/vars/git.vars b/vars/git.vars index 78e8746..d872c7e 100644 --- a/vars/git.vars +++ b/vars/git.vars @@ -10,7 +10,7 @@ pkg_git_install_make_post() { local __="" _new=""; for __ in $(find "${PKG_DESTDIR}" -name "Git*::*" -type f); do _new="$(echo ${__} | sed "s/::/./g")"; - ex_rtl_fileop mv "${__}" "${_new}"; + rtl_fileop mv "${__}" "${_new}"; done; }; diff --git a/vars/install_strip_host.vars b/vars/install_strip_host.vars index 1fb3386..1a60be7 100644 --- a/vars/install_strip_host.vars +++ b/vars/install_strip_host.vars @@ -4,9 +4,9 @@ pkg_install_strip_host_all() { if [ -e "${PREFIX}/bin/${PKG_TARGET}-install-strip" ]; then - ex_rtl_fileop rm "${PREFIX}/bin/${PKG_TARGET}-install-strip"; + rtl_fileop rm "${PREFIX}/bin/${PKG_TARGET}-install-strip"; fi; - ex_rtl_fileop mkdir "${PREFIX}/bin"; + rtl_fileop mkdir "${PREFIX}/bin"; cat > "${PREFIX}/bin/${PKG_TARGET}-install-strip" < "${PREFIX}/build.gitref"); + (rtl_fileop cd "${MIDIPIX_BUILD_PWD}" && git rev-parse HEAD > "${PREFIX}/build.gitref"); }; # vim:filetype=sh diff --git a/vars/invariants_minipix.vars b/vars/invariants_minipix.vars index 258a2cf..1c188ec 100644 --- a/vars/invariants_minipix.vars +++ b/vars/invariants_minipix.vars @@ -16,22 +16,22 @@ pkgp_invariants_minipix_is_newer() { pkg_invariants_minipix_all() { local _dname="" _fname="" _pname=""; - if ex_rtl_lmatch "${ARG_DIST}" "minipix" ","; then + if rtl_lmatch "${ARG_DIST}" "minipix" ","; then for _dname in "${PREFIX_MINIPIX}/bin" "${PREFIX_MINIPIX}/share"; do if [ ! -e "${_dname}" ]; then - ex_rtl_fileop mkdir "${_dname}"; + rtl_fileop mkdir "${_dname}"; fi; done; for _fname in clear reset tset; do if [ -e "${PREFIX_NATIVE}/bin/${_fname}" ]\ && pkgp_invariants_minipix_is_newer "${PREFIX_NATIVE}/bin/${_fname}" "${PREFIX_MINIPIX}/bin"; then - ex_rtl_fileop cp_follow "${PREFIX_NATIVE}/bin/${_fname}" "${PREFIX_MINIPIX}/bin"; + rtl_fileop cp_follow "${PREFIX_NATIVE}/bin/${_fname}" "${PREFIX_MINIPIX}/bin"; fi; done; for _pname in $([ -e "${PREFIX}/minipix_dist/bin" ] && find "${PREFIX}/minipix_dist/bin" \ -maxdepth 1 -perm /a=x -type f -and \( -not -name "lib*" \)); do if pkgp_invariants_minipix_is_newer "${_pname}" "${PREFIX_MINIPIX}/bin"; then - ex_rtl_fileop cp_follow "${_pname}" "${PREFIX_MINIPIX}/bin"; + rtl_fileop cp_follow "${_pname}" "${PREFIX_MINIPIX}/bin"; fi; done; for _fname in libc.so libcrypto.so.45 libexpat.so.1 liblzma.so.5 libmagic.so.1 \ @@ -41,7 +41,7 @@ pkg_invariants_minipix_all() { libuuid.so.1; do if [ -e "${PREFIX_NATIVE}/lib/${_fname}" ]\ && pkgp_invariants_minipix_is_newer "${PREFIX_NATIVE}/lib/${_fname}" "${PREFIX_MINIPIX}/bin"; then - ex_rtl_fileop cp_follow \ + rtl_fileop cp_follow \ "${PREFIX_NATIVE}/lib/${_fname}" "${PREFIX_MINIPIX}/bin"; fi; done; @@ -53,23 +53,23 @@ pkg_invariants_minipix_all() { for _fname in nano vim; do if [ -e "${PREFIX}/minipix_dist/share/${_fname}" ]\ && pkgp_invariants_minipix_is_newer "${PREFIX}/minipix_dist/share/${_fname}" "${PREFIX_MINIPIX}/share"; then - ex_rtl_fileop cp_follow "${PREFIX}/minipix_dist/share/${_fname}" "${PREFIX_MINIPIX}/share"; + rtl_fileop cp_follow "${PREFIX}/minipix_dist/share/${_fname}" "${PREFIX_MINIPIX}/share"; fi; done; if [ ! -L "${PREFIX_MINIPIX}/share/nanorc" ]; then - ex_rtl_fileop ln_symbolic "nano/nanorc.nanorc" "${PREFIX_MINIPIX}/share/nanorc"; + rtl_fileop ln_symbolic "nano/nanorc.nanorc" "${PREFIX_MINIPIX}/share/nanorc"; fi; if [ ! -L "${PREFIX_MINIPIX}/share/vimrc" ]; then - ex_rtl_fileop ln_symbolic "vim/vim74/vimrc_example.vim" "${PREFIX_MINIPIX}/share/vimrc"; + rtl_fileop ln_symbolic "vim/vim74/vimrc_example.vim" "${PREFIX_MINIPIX}/share/vimrc"; fi; for _fname in putty putty-256color screen screen-256color xterm xterm-256color; do _dname="share/terminfo/${_fname%${_fname#[a-zA-Z]}}"; if [ ! -e "${PREFIX_MINIPIX}/${_dname}" ]; then - ex_rtl_fileop mkdir "${PREFIX_MINIPIX}/${_dname}"; + rtl_fileop mkdir "${PREFIX_MINIPIX}/${_dname}"; fi; if [ -e "${PREFIX_NATIVE}/${_dname}/${_fname}" ]\ && pkgp_invariants_minipix_is_newer "${PREFIX_NATIVE}/${_dname}/${_fname}" "${PREFIX_MINIPIX}/${_dname}"; then - ex_rtl_fileop cp_follow "${PREFIX_NATIVE}/${_dname}/${_fname}" "${PREFIX_MINIPIX}/${_dname}"; + rtl_fileop cp_follow "${PREFIX_NATIVE}/${_dname}/${_fname}" "${PREFIX_MINIPIX}/${_dname}"; fi; done; fi; diff --git a/vars/invariants_zipdist.vars b/vars/invariants_zipdist.vars index 58f87a4..eb47d24 100644 --- a/vars/invariants_zipdist.vars +++ b/vars/invariants_zipdist.vars @@ -4,18 +4,18 @@ pkg_invariants_zipdist_all() { local _dist_fname="" _pkg_name="" _pkglist_fname="${PREFIX}/pkglist.native"; - if ex_rtl_lmatch "${ARG_DIST}" "zipdist" ","; then - ex_rtl_log_msg info "Building deployable distribution ZIP archive..."; + if rtl_lmatch "${ARG_DIST}" "zipdist" ","; then + rtl_log_msg info "Building deployable distribution ZIP archive..."; for _pkg_name in $(cat "${_pkglist_fname}"); do if ! stat "${BUILD_WORKDIR}/${_pkg_name}-native-${DEFAULT_TARGET}" >/dev/null 2>&1; then - ex_rtl_log_msg failexit "Error: missing package build directory for package \`${_pkg_name}'."; + rtl_log_msg failexit "Error: missing package build directory for package \`${_pkg_name}'."; fi; done; _dist_fname="${DEFAULT_ZIPDIST_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.zip"; if [ -e "${BUILD_WORKDIR}/zipdist" ]; then - ex_rtl_fileop rm "${BUILD_WORKDIR}/zipdist"; + rtl_fileop rm "${BUILD_WORKDIR}/zipdist"; fi; - ex_rtl_fileop mkdir "${BUILD_WORKDIR}/zipdist"; + rtl_fileop mkdir "${BUILD_WORKDIR}/zipdist"; "${BUILD_WORKDIR}/mpackage/mpackage.sh" \ --defroot="${DEFAULT_ZIPDIST_DEFROOT}" \ --flysyms \ @@ -29,15 +29,15 @@ pkg_invariants_zipdist_all() { --target="${DEFAULT_TARGET}" \ --tmproot="${BUILD_WORKDIR}/zipdist/tmproot" \ --zipfile="${PREFIX}/${_dist_fname}"; - ex_rtl_log_msg info "Finished building deployable distribution ZIP archive."; + rtl_log_msg info "Finished building deployable distribution ZIP archive."; if [ -n "${DEFAULT_ZIPDIST_SIGN_GPG_KEY}" ]\ && [ -x "$(which gpg 2>/dev/null)" ]\ && gpg --list-keys "${DEFAULT_ZIPDIST_SIGN_GPG_KEY}" >/dev/null 2>&1; then - ex_rtl_log_msg info "Signing deployable distribution ZIP archive..."; + rtl_log_msg info "Signing deployable distribution ZIP archive..."; gpg --armor --passphrase-file /dev/null \ --local-user "${DEFAULT_ZIPDIST_SIGN_GPG_KEY}" \ --sign "${PREFIX}/${_dist_fname}"; - ex_rtl_log_msg info "Signed deployable distribution ZIP archive."; + rtl_log_msg info "Signed deployable distribution ZIP archive."; fi; fi; }; diff --git a/vars/libressl_host.vars b/vars/libressl_host.vars index f8bbe85..033aa5a 100644 --- a/vars/libressl_host.vars +++ b/vars/libressl_host.vars @@ -3,7 +3,7 @@ # pkg_libressl_host_install_pre() { - ex_rtl_fileop rm "${PKG_DESTDIR}/etc"; + rtl_fileop rm "${PKG_DESTDIR}/etc"; }; # vim:filetype=sh diff --git a/vars/libtool_host.vars b/vars/libtool_host.vars index d564ae9..2c37c03 100644 --- a/vars/libtool_host.vars +++ b/vars/libtool_host.vars @@ -10,7 +10,7 @@ pkg_libtool_host_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. - ex_rtl_run_cmd_unsplit make \ + rtl_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_BUILD} \ ${PKG_MAKEFLAGS_BUILD_EXTRA} \ "AR=${PKG_AR}" "${_no_autoconf:+CC=${PKG_CC}}" \ diff --git a/vars/libxml2.vars b/vars/libxml2.vars index 8effa8d..99fecd5 100644 --- a/vars/libxml2.vars +++ b/vars/libxml2.vars @@ -4,7 +4,7 @@ pkg_libxml2_install_make_post() { if [ -e "${PKG_DESTDIR}/bin/${PKG_TARGET}-xml2-config" ]; then - ex_rtl_fileop rm "${PKG_DESTDIR}/bin/${PKG_TARGET}-xml2-config"; + rtl_fileop rm "${PKG_DESTDIR}/bin/${PKG_TARGET}-xml2-config"; fi; cat > "${PKG_DESTDIR}/bin/${PKG_TARGET}-xml2-config" < "${PKG_DESTDIR}/bin/${PKG_TARGET}-pkg-config" < "${PKG_DESTDIR}/lib/rpm/elfdeps"; chmod +x "${PKG_DESTDIR}/lib/rpm/elfdeps"; - ex_rtl_fileop rm "${PKG_DESTDIR}/var"; + rtl_fileop rm "${PKG_DESTDIR}/var"; }; # vim:filetype=sh diff --git a/vars/texinfo.vars b/vars/texinfo.vars index 59a60fe..3a7a3d0 100644 --- a/vars/texinfo.vars +++ b/vars/texinfo.vars @@ -3,12 +3,12 @@ # pkg_texinfo_build_pre() { - ex_rtl_run_cmd_unsplit make \ + rtl_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_BUILD} \ ${PKG_MAKEFLAGS_BUILD_EXTRA} \ "LIBTOOL=${PKG_LIBTOOL:-slibtool}" \ -C tools; - ex_rtl_run_cmd_unsplit make \ + rtl_run_cmd_unsplit make \ ${PKG_MAKEFLAGS_BUILD} \ ${PKG_MAKEFLAGS_BUILD_EXTRA} \ "LIBTOOL=${PKG_LIBTOOL:-slibtool}" \ diff --git a/vars/texinfo_host.vars b/vars/texinfo_host.vars index 5aa6f96..2a441f2 100644 --- a/vars/texinfo_host.vars +++ b/vars/texinfo_host.vars @@ -4,7 +4,7 @@ pkg_texinfo_host_install_make_post() { if [ -e "${PKG_DESTDIR}/bin/makeinfo" ]; then - ex_rtl_fileop mv "${PKG_DESTDIR}/bin/makeinfo" "${PKG_DESTDIR}/bin/makeinfo.dist"; + rtl_fileop mv "${PKG_DESTDIR}/bin/makeinfo" "${PKG_DESTDIR}/bin/makeinfo.dist"; fi; cat > "${PKG_DESTDIR}/bin/makeinfo" <