summaryrefslogtreecommitdiffhomepage
path: root/subr
diff options
context:
space:
mode:
Diffstat (limited to 'subr')
-rw-r--r--subr/build_args.subr (renamed from subr/ex_setup_args.subr)34
-rw-r--r--subr/build_checks.subr40
-rw-r--r--subr/build_init.subr60
-rw-r--r--subr/ex_pkg_dispatch.subr94
-rw-r--r--subr/ex_pkg_env.subr114
-rw-r--r--subr/ex_pkg_exec.subr60
-rw-r--r--subr/ex_pkg_state.subr67
-rw-r--r--subr/ex_pkg_steps.subr66
-rw-r--r--subr/ex_pkg_vars.subr40
-rw-r--r--subr/ex_rtl.subr49
-rw-r--r--subr/ex_rtl_fetch.subr63
-rw-r--r--subr/ex_rtl_fileop.subr103
-rw-r--r--subr/ex_rtl_install.subr44
-rw-r--r--subr/ex_rtl_log.subr40
-rw-r--r--subr/ex_rtl_state.subr32
-rw-r--r--subr/ex_setup_checks.subr38
-rw-r--r--subr/ex_setup_env.subr36
-rw-r--r--subr/ex_setup_subdirs.subr49
-rw-r--r--subr/pkg_build.subr11
-rw-r--r--subr/pkg_build_clean.subr9
-rw-r--r--subr/pkg_configure.subr18
-rw-r--r--subr/pkg_configure_autotools.subr8
-rw-r--r--subr/pkg_configure_patch.subr33
-rw-r--r--subr/pkg_fetch_distclean.subr15
-rw-r--r--subr/pkg_fetch_extract.subr28
-rw-r--r--subr/pkg_fetch_git.subr42
-rw-r--r--subr/pkg_fetch_subdirs.subr23
-rw-r--r--subr/pkg_fetch_wget.subr35
-rw-r--r--subr/pkg_install.subr2
-rw-r--r--subr/pkg_install_files.subr47
-rw-r--r--subr/pkg_install_libs.subr45
-rw-r--r--subr/pkg_install_make.subr6
-rw-r--r--subr/pkg_install_purge_la.subr2
-rw-r--r--subr/pkg_install_strip.subr19
-rw-r--r--subr/pkg_install_subdirs.subr24
35 files changed, 667 insertions, 729 deletions
diff --git a/subr/ex_setup_args.subr b/subr/build_args.subr
index 2f00c6dc..38f10c50 100644
--- a/subr/ex_setup_args.subr
+++ b/subr/build_args.subr
@@ -5,7 +5,6 @@ BUILD_ARGS_SPEC="
BUILD:arg:-b
ARG_CLEAN:-c
ARG_DEBUG_MINIPIX:--debug-minipix
- ARG_IGNORE_SHA256SUMS:-i
ARG_OFFLINE:-N
ARG_RELAXED:-R
ARG_RESTART:arg:-r
@@ -13,12 +12,12 @@ BUILD_ARGS_SPEC="
ARG_TARBALL:selfarg:-t.bz2
ARG_TARBALL:selfarg:-t.gz
ARG_TARBALL:selfarg:-t.xz
- ARG_VERBOSE:-v
- ARG_VERBOSE2:-vv
- ARG_VERBOSE3:-vvv
+ ARG_VERBOSE:selfarg:-v
+ ARG_VERBOSE:selfarg:-vv
+ ARG_VERBOSE:selfarg:-vvv
ARG_XTRACE:-x";
-ex_setup_args() {
+build_args() {
local _spec="${BUILD_ARGS_SPEC}" _spec_arg _found;
while [ ${#} -gt 0 ]; do
if [ "${1#-}" = "${1}" ]; then
@@ -28,11 +27,11 @@ ex_setup_args() {
case "${_spec_arg}" in
*:${1}) case "${_spec_arg#*:}" in
arg:*)
- ex_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
+ ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
selfarg:*)
- ex_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
+ ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
*)
- ex_set_var_unsafe "${_spec_arg%%:*}" 1; ;;
+ ex_rtl_set_var_unsafe "${_spec_arg%%:*}" 1; ;;
esac; _found=1; break; ;;
*) _found=0; ;;
esac;
@@ -50,22 +49,25 @@ ex_setup_args() {
TARBALL_SUFFIX=xz;
fi;
fi;
- if [ "${ARG_VERBOSE3:-0}" -eq 1 ]\
- || [ "${ARG_XTRACE:-0}" -eq 1 ]; then
- ARG_VERBOSE2=1;
- fi;
- if [ "${ARG_VERBOSE2:-0}" -eq 1 ]; then
- ARG_VERBOSE=1;
+ case "${ARG_VERBOSE}" in
+ -v) ARG_VERBOSE=1; ;;
+ -vv) ARG_VERBOSE=2; ;;
+ -vvv) ARG_VERBOSE=3; ;;
+ esac;
+ if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
+ ARG_VERBOSE=2;
fi;
if [ -n "${ARG_RESTART}" ]; then
if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then
ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}";
+ else
+ ARG_RESTART_AT=ALL;
fi;
- BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
+ ARG_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
fi;
while [ ${#} -gt 0 ]; do
case "${1}" in
- *=*) ex_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
+ *=*) ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
*) BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;;
esac; shift; done;
};
diff --git a/subr/build_checks.subr b/subr/build_checks.subr
new file mode 100644
index 00000000..08abc684
--- /dev/null
+++ b/subr/build_checks.subr
@@ -0,0 +1,40 @@
+build_checks() {
+ local __ _exit _pname;
+ for __ in ${DEFAULT_CHECK_PATH_VARS}; do
+ if [ -z "${___:=$(ex_rtl_get_var_unsafe "${__}")}" ]; then
+ ex_rtl_log_msg failexit "Error: variable \`${__}' is empty or unset.";
+ elif [ "${___#* *}" != "${___}" ]; then
+ ex_rtl_log_msg failexit "Error: variable \`${__}' contains one or more whitespace characters.";
+ fi;
+ done;
+ for __ in ${DEFAULT_CHECK_PREREQ_CMDS} $(eval echo ${DEFAULT_CHECK_PREREQ_FILES_DYNAMIC}) ${DEFAULT_CHECK_PREREQ_FILES}; do
+ if [ "${__#/}" != "${__}" ]; then
+ if [ ! -e "${__}" ]; then
+ ex_rtl_log_msg fail "Error: missing prerequisite file \`${__}'.";
+ _exit=1;
+ fi;
+ else
+ if ! ex_rtl_test_cmd "${__}"; then
+ ex_rtl_log_msg fail "Error: missing prerequisite command \`${__}'.";
+ _exit=1;
+ fi;
+ fi;
+ done;
+ for __ in ${DEFAULT_CHECK_PREREQ_PERL_MODULES}; do
+ if ! perl -M"${__}" -e "" 2>/dev/null; then
+ ex_rtl_log_msg fail "Error: missing prerequisite Perl module \`${__}'.";
+ _exit=1;
+ fi;
+ done;
+ if [ ${_exit:-0} = 1 ]; then
+ exit 1;
+ fi;
+ if [ ${ARG_CLEAN:-0} -eq 1 ]; then
+ ex_rtl_log_msg info "-c specified, cleaning prefix...";
+ for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do
+ ex_rtl_fileop rm ${PREFIX}/${_pname};
+ done;
+ fi;
+};
+
+# vim:filetype=sh
diff --git a/subr/build_init.subr b/subr/build_init.subr
new file mode 100644
index 00000000..95ac397d
--- /dev/null
+++ b/subr/build_init.subr
@@ -0,0 +1,60 @@
+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 __;
+ set -o noglob;
+ if [ -z "${DEFAULT_BUILD_CPUS}" ]\
+ && [ -e /proc/cpuinfo ]; then
+ DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
+ fi;
+ : ${ARCH:=nt64}; : ${BUILD:=debug};
+ if [ "${ARCH}" = nt32 ]; then
+ DEFAULT_TARGET="i686-nt32-midipix";
+ elif [ "${ARCH}" = nt64 ]; then
+ DEFAULT_TARGET="x86_64-nt64-midipix";
+ else
+ if [ "${BUILD}" != debug ]\
+ && [ "${BUILD}" != release ]; then
+ ex_rtl_log_msg failexit "Error: unknown build type \`${BUILD}'.";
+ fi;
+ ex_rtl_log_msg failexit "Error: invalid architecture \`${ARCH}'.";
+ fi;
+ for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/env.vars ./vars/midipix.vars ./vars/build.vars; do
+ [ -e ${__} ] && . ${__};
+ done;
+ export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
+ if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then
+ DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
+ elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then
+ DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
+ fi;
+ ex_rtl_unset_vars $(ex_rtl_lfilter_not \
+ "$(export | sed -e 's/^export //' -e 's/=.*$//')" \
+ "${DEFAULT_CLEAR_ENV_VARS_EXCEPT}");
+ ex_rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}";
+ if [ -e "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
+ ex_rtl_log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
+ else
+ touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
+ fi;
+ if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then
+ mv -- "${DEFAULT_BUILD_LOG_FNAME} ${DEFAULT_BUILD_LOG_LAST_FNAME}";
+ fi;
+ BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)";
+ BUILD_NFINI="${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}";
+ BUILD_TIMES_SECS="$(ex_rtl_date %s)";
+ BUILD_PKGS_FAILED="";
+ trap "rm -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}"; \
+ ex_rtl_log_msg failexit \"Build aborted.\";" \
+ HUP INT TERM USR1 USR2;
+};
+
+# vim:filetype=sh
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr
index f099dd6a..90a23717 100644
--- a/subr/ex_pkg_dispatch.subr
+++ b/subr/ex_pkg_dispatch.subr
@@ -3,47 +3,61 @@
#
ex_pkg_dispatch() {
- local _tgt_name="${1}" _pkg_name="${2}" \
- _restart="${3}" _restart_at="${4}" \
- _stdout_path _stderr_path \
- _pipe_path _pipe_msg _script_rc=1;
- if ex_pkg_state_test "${_pkg_name}" finish \
- && [ -z "${_restart}" ] \
- && [ "${_tgt_name}" != "INVARIANTS" ]; then
- return 0;
- else
- _pipe_path="${WORKDIR}/${_pkg_name}_build.fifo";
- ex_build_fileop rm "${_pipe_path}"; mkfifo "${_pipe_path}";
- _stderr_path="${WORKDIR}/${_pkg_name}_stderr.log";
- _stdout_path="${WORKDIR}/${_pkg_name}_stdout.log";
- ex_build_fileop rm "${_stderr_path}" "${_stdout_path}";
+ local _tgt_name="${1}" _restart="${2}" _restart_at="${3}" \
+ _dispatch_fn="${4}" _tgt_name_uc \
+ _pkg_names _pkg_name _pkg_name_uc \
+ _pipe_path _stderrout_path _pipe_msg _script_rc;
+ ex_rtl_fileop mkdir "${BUILD_WORKDIR}";
+ _pipe_path="${BUILD_WORKDIR}/build.fifo";
+ _tgt_name_uc="$(ex_rtl_toupper "${_tgt_name}")";
+ "${_dispatch_fn}" start_target "" "${_tgt_name}";
+ _pkg_names="$(ex_rtl_get_var_unsafe ${_tgt_name_uc}_PACKAGES)";
+ if [ -n "${_restart}" ]; then
+ _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_restart}")";
fi;
- (set -o errexit -o noglob;
- trap "if [ \${?} -eq 0 ]; then \
- echo \"done ${PKG_NAME}\" >&3; \
- else \
- echo \"fail ${PKG_NAME}\" >&3; \
- fi;" EXIT HUP INT TERM USR1 USR2;
- if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
- set -o xtrace;
- fi;
- ex_pkg_vars;
- if [ "${PKG_DISABLED:-0}" -eq 1 ]; then
- ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'";
- else
- ex_pkg_env;
- ex_pkg_steps "${_tgt_name}" "${_pkg_name}" \
- "${_restart}" "${_restart_at}";
- fi;) 1>"${_stdout_path}" 2>"${_stderr_path}" \
- 3>"${_pipe_path}" &
- while read _pipe_msg; do
- case "${_pipe_msg%% *}" in
- done) _script_rc=0; break; ;;
- fail) _script_rc=1; break; ;;
- *) _script_rc=1; break; ;;
- esac; done <"${_pipe_path}";
- ex_build_fileop rm "${_pipe_path}";
- return "${_script_rc:-1}";
+ for _pkg_name in ${_pkg_names}; do
+ _pkg_name_uc="$(ex_rtl_toupper "${_pkg_name}")";
+ if [ -n "$(ex_rtl_get_var_unsafe PKG_${_pkg_name_uc}_DISABLED)" ]; then
+ "${_dispatch_fn}" disabled_pkg "${_pkg_name}" "${_tgt_name}";
+ continue;
+ elif ex_pkg_state_test "${_pkg_name}" finish\
+ && [ -z "${_restart_at}" ]; then
+ "${_dispatch_fn}" skipped_pkg "${_pkg_name}" "${_tgt_name}";
+ continue;
+ else
+ ex_rtl_fileop mkfifo "${_pipe_path}";
+ _stderrout_path="${BUILD_WORKDIR}/${_pkg_name}_stderrout.log";
+ _script_rc=1;
+ "${_dispatch_fn}" start_pkg "${_pkg_name}" "${_tgt_name}";
+ fi;
+ (set -o errexit -o noglob;
+ ex_pkg_env "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
+ trap "if [ \${?} -eq 0 ]; then \
+ echo \"done ${PKG_NAME}\" >&3; \
+ else \
+ echo \"fail ${PKG_NAME}\" >&3; \
+ fi;" EXIT HUP INT TERM USR1 USR2;
+ ex_pkg_exec "${_pkg_name}" "${_tgt_name}" "${_restart_at}" \
+ "${_dispatch_fn}";) 1>"${_stderrout_path}" 2>&1 3>"${_pipe_path}" &
+ while read _pipe_msg; do
+ case "${_pipe_msg%% *}" in
+ done) _script_rc=0;
+ "${_dispatch_fn}" finish_pkg "${_pkg_name}" "${_tgt_name}";
+ break; ;;
+ fail) _script_rc=1;
+ "${_dispatch_fn}" fail_pkg "${_pkg_name}" "${_tgt_name}";
+ break; ;;
+ step) "${_dispatch_fn}" step_pkg ${_pipe_msg#step }; ;;
+ *) _script_rc=1;
+ "${_dispatch_fn}" fail_pkg "${_pkg_name}" "${_tgt_name}";
+ break; ;;
+ esac; done <"${_pipe_path}";
+ ex_rtl_fileop rm "${_pipe_path}";
+ if [ "${_script_rc:-1}" -eq 1 ]; then
+ return 1;
+ fi;
+ done;
+ "${_dispatch_fn}" finish_target "" "${_tgt_name}";
};
# vim:filetype=sh
diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr
index 853d785c..822ac054 100644
--- a/subr/ex_pkg_env.subr
+++ b/subr/ex_pkg_env.subr
@@ -2,67 +2,65 @@
# set -o errexit -o noglob are assumed.
#
+exp_pkg_env_source() {
+ local _pkg_name="${1}" _tgt_name="${2}" \
+ _tgt_name_uc _pkg_name_uc _build_type_uc \
+ _vname_dst _vars_set="";
+ if [ "${_pkg_name#*_flavour_*}" != "${_pkg_name}" ]; then
+ PKG_NAME_PARENT="${PKG_NAME%_flavour_*}";
+ ex_pkg_env_source "${PKG_NAME_PARENT}";
+ fi;
+ ex_rtl_fileop source_opt "vars/${_pkg_name}.vars";
+ _tgt_name_uc="$(ex_rtl_toupper "${_tgt_name}")";
+ _pkg_name_uc="$(ex_rtl_toupper "${_pkg_name}")";
+ ex_rtl_set_vars BUILD_TYPE \
+ "DEFAULT ${_tgt_name_uc} PKG_${_pkg_name_uc}" \
+ _vars_set;
+ _build_type_uc="$(ex_rtl_toupper "${PKG_BUILD_TYPE}")";
+ for _vname_dst in $(ex_rtl_lfilter_not \
+ "${DEFAULT_BUILD_VARS}" BUILD_TYPE); do
+ ex_rtl_set_vars "${_vname_dst}" \
+ "DEFAULT DEFAULT_${_build_type_uc} \
+ ${_tgt_name_uc} PKG_${_pkg_name_uc}" \
+ _vars_set;
+ done;
+ ex_rtl_unset_vars $(ex_rtl_lfilter_not \
+ "$(set | awk -F= '/^PKG_/{print $1}' | sort)" \
+ "${_vars_set}");
+};
+
ex_pkg_env() {
- local _vname;
- if [ -z "${PKG_URL}" ]\
- && [ -z "${PKG_URLS_GIT}" ]\
- && [ -z "${PKG_VERSION}" ]\
- && ! ex_test_cmd "pkg_${PKG_NAME}_all"; then
- ex_log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars.";
- return 1;
- else
- [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)";
- [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}";
- [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}";
- case "${PKG_BASE_DIR}" in
- ?*) ;;
- *) PKG_BASE_DIR="${WORKDIR}/${PKG_NAME}-${PKG_BUILD_TYPE:-native}-${PKG_TARGET}";
- if [ -n "${ARG_RESTART}" ]\
- && [ -z "${ARG_RESTART_AT}" ]; then
- ex_build_fileop rm "${PKG_BASE_DIR}";
- fi; ;;
- esac;
- ex_build_fileop mkdir "${PKG_BASE_DIR}";
- ex_build_fileop cd "${PKG_BASE_DIR}";
- PKG_DESTDIR="${PKG_BASE_DIR}/destdir";
- case "${PKG_BUILD_TYPE}" in
- host) export AR="ar";
- export CC="gcc";
- export CXX="g++";
- export RANLIB="ranlib"; ;;
- *) export AR="${PKG_TARGET}-ar";
- export CC="${PKG_TARGET}-gcc";
- export CXX="${PKG_TARGET}-g++";
- export RANLIB="${PKG_TARGET}-ranlib";
- if [ -x "${PREFIX}/bin/${TARGET}-pkg-config" ]; then
- export PKGCONFIG="${PREFIX}/bin/${TARGET}-pkg-config";
- export PKG_CONFIG="${PREFIX}/bin/${TARGET}-pkg-config";
- export PKG_CONFIG_LIBDIR="${PKG_PREFIX}/lib/pkgconfig";
- fi;
- ;;
- esac;
- export LIBTOOL="${PKG_SLIBTOOL:-slibtool}";
- export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
- case "${PKG_SUBDIR}" in
- ?*) ;;
- *) case "${PKG_URLS_GIT}" in
- ?*) PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; ;;
- *) case "${PKG_FNAME}" in
- *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;;
- *) PKG_SUBDIR="${PKG_NAME}"; ;;
- esac; ;;
- esac; ;;
+ local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}" _vname;
+ exp_pkg_env_source "${_pkg_name}" "${_tgt_name}";
+ : ${PKG_NAME:="${_pkg_name}"};
+ : ${MIDIPIX_BUILD_PWD:="$(pwd)"};
+ : ${PKG_BASE_DIR:="${BUILD_WORKDIR}/${_pkg_name}-${PKG_BUILD_TYPE}-${PKG_TARGET}"};
+ : ${PKG_FNAME:="${PKG_URL##*/}"};
+ : ${PKG_BUILD_STEPS:="$(ex_rtl_lfilter_not "${DEFAULT_BUILD_STEPS}" \
+ "${PKG_BUILD_STEPS_DISABLE}")"};
+ if [ -z "${PKG_SUBDIR}" ]; then
+ if [ -n "${PKG_URLS_GIT}" ]; then
+ PKG_SUBDIR="${PKG_URLS_GIT%%=*}";
+ else case "${PKG_FNAME}" in
+ *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;;
+ *) PKG_SUBDIR="${_pkg_name}"; ;;
+ esac; fi;
+ fi;
+ if [ -z "${PKG_BUILD_DIR}" ]; then
+ case "${PKG_IN_TREE:-0}" in
+ 0) PKG_BUILD_DIR="obj"; ;;
+ 1) PKG_BUILD_DIR="${PKG_SUBDIR}"; ;;
esac;
- ex_push_IFS :;
- for _vname in ${PKG_ENV_VARS_EXTRA}; do
- export "${_vname}";
- done; ex_pop_IFS;
- if [ -n "${PKG_ENV_VARS}" ]\
- && [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then
- PKG_ENV_VARS="$(echo "${PKG_ENV_VARS}" | tr " " "\n" | sort | tr "\n" " ")";
- ex_log_env_vars "build" ${PKG_ENV_VARS};
- fi;
fi;
+ PKG_BUILD_DIR="${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
+ PKG_CONFIGURE="${PKG_BASE_DIR}/${PKG_CONFIGURE:-${PKG_SUBDIR}/configure}";
+ PKG_DESTDIR="${PKG_BASE_DIR}/${PKG_DESTDIR:-destdir}";
+ ex_rtl_push_IFS :; for _vname in ${PKG_ENV_VARS_EXTRA}; do
+ export "${_vname}";
+ done; ex_rtl_pop_IFS;
};
+ex_pkg_state_set() { ex_rtl_state_set "${BUILD_WORKDIR}" "${@}"; };
+ex_pkg_state_test() { ex_rtl_state_test "${BUILD_WORKDIR}" "${@}"; };
+
# vim:filetype=sh
diff --git a/subr/ex_pkg_exec.subr b/subr/ex_pkg_exec.subr
new file mode 100644
index 00000000..21bc3a88
--- /dev/null
+++ b/subr/ex_pkg_exec.subr
@@ -0,0 +1,60 @@
+#
+# set -o errexit -o noglob are assumed.
+#
+
+exp_pkg_exec_pre() {
+ local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}";
+ if [ -z "${PKG_URL}" ]\
+ && [ -z "${PKG_URLS_GIT}" ]\
+ && [ -z "${PKG_VERSION}" ]\
+ && ! ex_rtl_test_cmd "pkg_${_pkg_name}_all"; then
+ "${_dispatch_fn}" exec_missing "${_pkg_name}" "${_tgt_name}";
+ return 1;
+ elif ! ex_pkg_state_test "${_pkg_name}" "start" "${_restart_at}"; then
+ if [ "${PKG_NO_CLEAN_BASE_DIR:-0}" -eq 0 ]; then
+ ex_rtl_fileop rm "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}";
+ ex_rtl_fileop mkdir "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}";
+ fi;
+ ex_pkg_state_set "${_pkg_name}" "start";
+ fi;
+ ex_rtl_fileop cd "${PKG_BUILD_DIR}";
+};
+
+ex_pkg_exec() {
+ local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}" \
+ _step _step_cmd _step_cmd_pfx _step_rc;
+ exp_pkg_exec_pre "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
+ "${_dispatch_fn}" exec_start "${_pkg_name}" "${_tgt_name}";
+ if ex_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}"; shift;
+ if ex_pkg_state_test "${_pkg_name}" "${_step}" \
+ "${_restart_at}"; then
+ continue;
+ else ex_rtl_try_run \
+ "pkg_${_pkg_name}_${_step}_pre" \
+ "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
+ if ex_rtl_test_cmd "pkg_${_pkg_name}_${_step}"; then
+ ex_rtl_try_run "pkg_${_pkg_name}_${_step}" \
+ "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
+ else
+ ex_rtl_try_run "pkg_${_step}" \
+ "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
+ fi;
+ ex_rtl_try_run \
+ "pkg_${_pkg_name}_${_step}_post" \
+ "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
+
+ fi;
+ echo "step ${_pkg_name} ${_tgt_name} ${_step}" >&3;
+ "${_dispatch_fn}" exec_step "${_pkg_name}" "${_tgt_name}" "${_step}";
+ ex_pkg_state_set "${_pkg_name}" "${_step}" "${1:+-${1}}";
+ done;
+ "${_dispatch_fn}" exec_finish "${_pkg_name}" "${_tgt_name}";
+ ex_pkg_state_set "${_pkg_name}" finish;
+ fi;
+};
+
+# vim:filetype=sh
diff --git a/subr/ex_pkg_state.subr b/subr/ex_pkg_state.subr
deleted file mode 100644
index cb86bf2f..00000000
--- a/subr/ex_pkg_state.subr
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-ex_pkg_state_build_dir() {
- PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}";
-};
-
-ex_pkg_state_fini() {
- : $((BUILD_TIMES_SECS=$(ex_date %s)-${BUILD_TIMES_SECS}));
- : $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
- : $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
- : $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
- if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
- ex_build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME};
- fi;
-};
-
-ex_pkg_state_init() {
- if [ -e ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then
- ex_log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
- else
- touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
- fi;
- if [ -e ${BUILD_LOG_FNAME} ]; then
- mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME};
- fi;
- BUILD_DATE_START="$(ex_date %Y-%m-%d-%H-%M-%S)";
- BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
- BUILD_TIMES_SECS=$(ex_date %s);
- BUILD_PKGS_FAILED="";
- trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \
- ex_log_msg failexit \"Build aborted.\";" \
- HUP INT TERM USR1 USR2;
-};
-
-ex_pkg_state_push() {
- local _pkg_fname="${1}";
- local _done_fname_pfx="${WORKDIR}/.${_pkg_fname}";
- shift; while [ ${#} -ge 1 ]; do
- if [ "${1#-}" != "${1}" ]; then
- ex_build_fileop rm "${_done_fname_pfx}.${1#-}";
- else
- touch "${_done_fname_pfx}.${1}";
- ex_log_msg info "Finished build step ${1} of package \`${_pkg_fname}'.";
- fi; shift;
- done;
-};
-
-ex_pkg_state_test() {
- local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${3}";
- if [ -z "${_restart_at}" ]; then
- if [ -e "${_done_fname}" ]; then
- return 0; # Skip
- else
- return 1; # Build
- fi;
- elif [ "${_restart_at}" = "ALL" ]; then
- return 1; # Build
- elif ex_lmatch "${_restart_at}" , "${2}"; then
- return 1; # Build
- else
- return 0; # Skip
- fi;
-};
-
-# vim:filetype=sh
diff --git a/subr/ex_pkg_steps.subr b/subr/ex_pkg_steps.subr
deleted file mode 100644
index f756d815..00000000
--- a/subr/ex_pkg_steps.subr
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-ex_pkg_steps() {
- local _tgt_name="${1}" _pkg_name="${2}" \
- _restart="${3}" _restart_at="${4}" \
- _step _step_type \
- _step_cmds _step_cmd_args \
- _step_cmd_pfx _step_cmd _step_next;
- set -- $(ex_lfilter_not "${BUILD_STEPS}" "${PKG_BUILD_STEPS_DISABLE}");
- while [ ${#} -gt 0 ]; do
- _step="${1}"; _step_next="${2}";
- _step_cmds=""; _step_cmd_args="";
- _step_type="${_step#*:}";
- _step="${_step%%:*}";
- _step_cmd_pfx="pkg_${_pkg_name}_${_step}";
- case "${_step_type}" in
- dynamic)
- if [ "${_tgt_name}" = "INVARIANTS" ]; then
- _step_cmds="${_step_cmd_pfx} pkg_${_step}";
- elif [ -n "${_restart}" ]; then
- if [ -z "${_restart_at}" ]\
- || ex_lmatch "${_restart_at}" , "${_step}"; then
- _step_cmds="${_step_cmd_pfx} pkg_${_step}";
- fi;
- elif ! ex_pkg_state_test "${_pkg_name}" "${_step}"; then
- _step_cmds="${_step_cmd_pfx} pkg_${_step}";
- fi; ;;
- invariant)
- _step_cmds="pkg_${_step}"; ;;
- variant)
- if ex_lmatch "${_restart_at}" "," "${_step}"; then
- _step_cmds="${_step_cmd_pfx} pkg_${_step}";
- fi; ;;
- virtual)
- _step_cmds="pkg_${_pkg_name}_${_step}";
- _step_cmd_args="${_restart_at:-ALL}"; ;;
- all)
- if ex_test_cmd "pkg_${_pkg_name}_${_step}"; then
- "${_step_cmd_pfx}" "${_restart_at:-ALL}";
- break;
- fi; ;;
- finish) ex_pkg_state_push "${_pkg_name}" finish; ;;
- *) ;;
- esac;
- for _step_cmd in ${_step_cmds}; do
- if ex_test_cmd "${_step_cmd}"; then
- ex_test_cmd "${_step_cmd_pfx}_pre" \
- && "${_step_cmd_pfx}_pre"
- "${_step_cmd}" ${_step_cmd_args};
- ex_test_cmd "${_step_cmd_pfx}_post" \
- && "${_step_cmd_pfx}_post"
- if [ "${_step_type}" != "invariant" ] \
- && [ -n "${_step_next}" ]; then
- ex_pkg_state_push "${_pkg_name}" "${_step}";
- ex_pkg_state_push "${_pkg_name}" "-${_step_next}";
- else
- ex_pkg_state_push "${_pkg_name}" "${_step}";
- fi; break;
- fi;
- done;
- shift; done;
-};
-
-# vim:filetype=sh
diff --git a/subr/ex_pkg_vars.subr b/subr/ex_pkg_vars.subr
deleted file mode 100644
index 9c23b0d5..00000000
--- a/subr/ex_pkg_vars.subr
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-exp_pkg_vars() {
- local _pkg_name="${1}" _pkg_name_uc _build_uc _vname_dst _vname_src;
- _pkg_name_uc="$(ex_toupper "${_pkg_name}")";
- _build_uc="$(ex_toupper "${BUILD}")";
- for _vname_dst in PREFIX ${PKG_BUILD_VARS}; do
- for _vname_src in \
- "DEFAULT_${_vname_dst}" \
- "${BUILD_TARGET}_${_vname_dst}" \
- "PKG_${_pkg_name_uc}_${_vname_dst}" \
- "PKG_${_pkg_name_uc}_${_vname_dst}_${_build_uc}"; do
- if [ -n "$(ex_get_var_unsafe "${_vname_src}")" ]; then
- ex_set_var_unsafe "PKG_${_vname_dst}" "$(ex_get_var_unsafe ${_vname_src})";
- if ! ex_lmatch "${PKG_ENV_VARS}" " " "${_vname_src}"; then
- PKG_ENV_VARS="${PKG_ENV_VARS:+${PKG_ENV_VARS} }${_vname_src}";
- fi;
- fi;
- done;
- done;
-};
-
-ex_pkg_vars() {
- local _vars_path;
- for _vars_path in vars/${PKG_NAME}.vars; do
- if [ -e "${_vars_path}" ]\
- || [ -L "${_vars_path}" ]; then
- . "${_vars_path}";
- fi;
- done;
- if [ "${PKG_NAME#*_flavour_*}" != "${PKG_NAME}" ]; then
- PKG_NAME_PARENT="${_pkg_name%_flavour_*}";
- exp_pkg_vars "${PKG_NAME_PARENT}";
- fi;
- exp_pkg_vars "${PKG_NAME}";
-};
-
-# vim:filetype=sh
diff --git a/subr/ex_rtl.subr b/subr/ex_rtl.subr
index 0ab30885..cd9d1bee 100644
--- a/subr/ex_rtl.subr
+++ b/subr/ex_rtl.subr
@@ -2,21 +2,21 @@
# set -o errexit -o noglob are assumed.
#
-EXP_IFS_NL="
-";
+EXP_RTL_IFS="${IFS}";
-ex_basename() { echo "${1##*/}"; };
-ex_date() { command date "+${1:-${TIMESTAMP_FMT}}"; };
-ex_dirname() { echo "${1%/*}"; };
-ex_get_var_unsafe() { eval echo \${${1}}; };
-ex_set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; };
-ex_pop_IFS() { IFS="${EXP_OLDIFS}"; };
-ex_push_IFS() { EXP_OLDIFS="${IFS}"; IFS="${1}"; };
-ex_push_IFS_nl() { ex_push_IFS "${EXP_IFS_NL}"; };
-ex_test_cmd() { command -v "${1}" >/dev/null; };
-ex_toupper() { echo "${1}" | tr a-z A-Z; };
+ex_rtl_basename() { echo "${1##*/}"; };
+ex_rtl_date() { command date "+${1:-${DEFAULT_TIMESTAMP_FMT}}"; };
+ex_rtl_dirname() { echo "${1%/*}"; };
+ex_rtl_get_var_unsafe() { eval echo \${${1}}; };
+ex_rtl_pop_IFS() { IFS="${EXP_RTL_IFS}"; };
+ex_rtl_push_IFS() { EXP_RTL_IFS="${IFS}"; IFS="${1}"; };
+ex_rtl_try_run() { ex_rtl_test_cmd "${1}" && { "${@}" || exit ${?}; }; };
+ex_rtl_set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; };
+ex_rtl_test_cmd() { command -v "${1}" >/dev/null; };
+ex_rtl_toupper() { echo "${1}" | tr a-z A-Z; };
+ex_rtl_unset_vars() { while [ ${#} -gt 0 ]; do unset "${1}"; shift; done; };
-ex_lfilter() {
+ex_rtl_lfilter() {
local _list="${1}" _filter="${2}" _lnew _litem _litem_filter;
if [ -z "${_filter}" ]; then
echo "${_list}"; return 0;
@@ -31,7 +31,7 @@ ex_lfilter() {
echo "${_lnew}";
};
-ex_lfilter_not() {
+ex_rtl_lfilter_not() {
local _list="${1}" _filter="${2}" _lnew _litem _litem_filter _filterfl;
if [ -z "${_filter}" ]; then
echo "${_list}"; return 0;
@@ -49,7 +49,7 @@ ex_lfilter_not() {
echo "${_lnew}";
};
-ex_lmatch() {
+ex_rtl_lmatch() {
local _cmp="${3}" IFS="${2}"; set -- ${1};
while [ ${#} -gt 0 ]; do
if [ "${1}" = "${_cmp}" ]; then
@@ -58,7 +58,7 @@ ex_lmatch() {
done; return 1;
};
-ex_run_cmd_unsplit() {
+ex_rtl_run_cmd_unsplit() {
local _cmd="${1}" _cmdline _rc IFS; shift;
while [ ${#} -gt 0 ]; do
[ -n "${1}" ] &&\
@@ -69,4 +69,21 @@ ex_run_cmd_unsplit() {
return ${_rc};
};
+ex_rtl_set_vars() {
+ local _vname_dst="${1}" _vname_src_tmpls="${2}" \
+ _vars_set_vname="${3}" _vname_src _vars_set_tmp="" \
+ _vars_set_old;
+ for _vname_src in ${_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
new file mode 100644
index 00000000..c5dfc559
--- /dev/null
+++ b/subr/ex_rtl_fetch.subr
@@ -0,0 +1,63 @@
+#
+# set -o errexit -o noglob are assumed.
+#
+
+exp_rtl_fetch_url_git() {
+ local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}" \
+ _oldpwd;
+ if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then
+ (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
+ git pull origin "${_branch:-main}");
+ else
+ git clone "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}";
+ if [ -n "${_branch}" -a \
+ \( -z "${_branch#main}" \) -a \
+ \( -z "${_branch#master}" \) ]; then
+ (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
+ git checkout -b "${_branch}");
+ fi;
+ 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}";
+};
+
+ex_rtl_fetch_urls_git() {
+ local _tgtdir _url_spec _subdir _url _git_branch;
+ _tgtdir="${1}"; shift;
+ 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}";
+ if [ -z "${3}" ]; then
+ _url_dst="${BUILD_DLCACHEDIR}/$(ex_rtl_basename "${_url}")";
+ else
+ _url_dst="${BUILD_DLCACHEDIR}/${3}";
+ fi;
+ if [ -e "${_url_dst}.fetched" ]; then
+ return 0;
+ else
+ wget ${DEFAULT_WGET_ARGS} -c -O "${_url_dst}" "${_url}";
+ fi;
+ if [ -n "${_sha256sum_src}" ]; then
+ set -- $(openssl dgst -sha256 "${_url_dst}"); shift $((${#}-1));
+ if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then
+ ex_rtl_log_msg failexit "Error: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)";
+ fi;
+ fi;
+ touch "${_url_dst}.fetched";
+};
+
+# vim:filetype=sh
diff --git a/subr/ex_rtl_fileop.subr b/subr/ex_rtl_fileop.subr
index 9cf44231..0666e7d0 100644
--- a/subr/ex_rtl_fileop.subr
+++ b/subr/ex_rtl_fileop.subr
@@ -2,38 +2,91 @@
# set -o errexit -o noglob are assumed.
#
-ex_build_fileop() {
- local _op="${1}"; shift;
- if [ "${_op}" = cd ]; then
- ex_log_msg vvvo "Changing working directory to \`${1}'.";
- [ \( -n "${1}" \) -a \( -L "${1}" -o -e "${1}" \) ] && cd -- "${1}";
- elif [ "${_op}" = cp ]; then
- ex_log_msg vvvo "Copying \`${1}' to \`${2}' w/ -pPR.";
- [ ${#} -ge 2 ] && cp -pPR -- "${@}";
- elif [ "${_op}" = ln_symbolic ]; then
- ex_log_msg vvvo "Linking \`${1}' to \`${2}' w/ -fs";
- [ \( -n "${1}" \) -a \( -n "${2}" \) ] && ln -fs -- "${1}" "${2}";
- elif [ "${_op}" = mv ]; then
- ex_log_msg vvvo "Moving \`${1}' to \`${2}' w/ -fs";
- [ \( -n "${1}" \) -a \( -n "${2}" \) ] && mv -f -- "${1}" "${2}";
- elif [ "${_op}" = mkdir ]\
- || [ "${_op}" = rm ]; then
+exp_rtl_fileop_check() {
+ local _prefix="${1}" _pname _rname; shift;
+ while [ ${#} -gt 0 ]; do
+ return 0;
+ shift; done;
+};
+
+ex_rtl_fileop() {
+ local _op="${1}" _src _dst; 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}'.";
+ else
+ ex_rtl_log_msg vvvo "Changing working directory to \`${1}'.";
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
+ cd -- "${1}";
+ fi; ;;
+ cp) if [ ${#} -lt 2 ]; then
+ ex_rtl_log_msg failexit "Missing parameters (in: cp ${*}.)";
+ else
+ _src="${*}"; _src="${_src% *}";
+ _dst="${*}"; _dst="${_dst##* }";
+ ex_rtl_log_msg vvvo "Copying \`${_src}' into \`${_dst}' w/ -pPR.";
+ exp_rtl_fileop_check "${PREFIX}" "${*}";
+ cp -pPR -- "${@}";
+ fi; ;;
+ ln_symbolic)
+ if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then
+ ex_rtl_log_msg failexit "Missing parameters (in: ln_symbolic ${*}.)";
+ else
+ exp_rtl_fileop_check "${PREFIX}" "${2}";
+ if ex_rtl_fileop test "${2}"; then
+ ex_rtl_fileop rm "${2}";
+ fi;
+ ex_rtl_log_msg vvvo "Linking \`${1}' to \`${2}' w/ -fs";
+ ln -fs -- "${1}" "${2}";
+ fi; ;;
+ mv) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then
+ ex_rtl_log_msg failexit "Missing parameters (in: mv ${*}.)";
+ else
+ ex_rtl_log_msg vvvo "Moving \`${1}' to \`${2}' w/ -fs";
+ exp_rtl_fileop_check "${PREFIX}" "${1}" "${2}";
+ mv -f -- "${1}" "${2}";
+ fi; ;;
+ mkdir|mkfifo|rm|source_opt|test|touch)
while [ ${#} -gt 0 ]; do
if [ -z "${1}" ]; then
- return 1;
+ ex_rtl_log_msg failexit "Missing parameters (in: ${_op} ${*}.)";
elif [ "${_op}" = mkdir ]\
- && [ ! -e "${1}" ]; then
- ex_log_msg vvvo "Making directory \`${1}'.";
+ && [ ! -d "${1}" ]; then
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
+ if ex_rtl_fileop test "${1}"; then
+ ex_rtl_fileop rm "${1}";
+ fi;
+ ex_rtl_log_msg vvvo "Making directory \`${1}'.";
mkdir -p -- "${1}";
+ elif [ "${_op}" = mkfifo ]; then
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
+ if ex_rtl_fileop test "${1}"; then
+ ex_rtl_fileop rm "${1}";
+ fi;
+ ex_rtl_log_msg vvvo "Creating FIFO \`${1}'.";
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
+ mkfifo -- "${1}";
elif [ "${_op}" = rm ]\
- && [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then
- ex_log_msg vvvo "Removing directory or file \`${1}'.";
+ && ex_rtl_fileop test "${1}"; then
+ ex_rtl_log_msg vvvo "Removing directory or file \`${1}'.";
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
rm -rf -- "${1}";
+ elif [ "${_op}" = source_opt ]\
+ && ex_rtl_fileop test "${1}"; then
+ ex_rtl_log_msg vvvo "Sourcing file \`${1}'.";
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
+ . "${1}";
+ elif [ "${_op}" = test ]\
+ && ! [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then
+ return 1;
+ elif [ "${_op}" = touch ]; then
+ ex_rtl_log_msg vvvo "Touching file \`${1}'.";
+ exp_rtl_fileop_check "${PREFIX}" "${1}";
+ touch -- "${1}";
fi; shift;
- done;
- else
- ex_log_msg failexit "Error: ex_build_fileop() called w/ invalid parameter(s) \`${@}'.";
- fi;
+ done; ;;
+ *) ex_rtl_log_msg failexit "Error: ex_rtl_fileop() called w/ invalid parameter(s): ${*}"; ;;
+ esac; return 0;
};
# vim:filetype=sh
diff --git a/subr/ex_rtl_install.subr b/subr/ex_rtl_install.subr
new file mode 100644
index 00000000..5dc2a088
--- /dev/null
+++ b/subr/ex_rtl_install.subr
@@ -0,0 +1,44 @@
+#
+# set -o errexit -o noglob are 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_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_log.subr b/subr/ex_rtl_log.subr
index c44085a6..71e52fa2 100644
--- a/subr/ex_rtl_log.subr
+++ b/subr/ex_rtl_log.subr
@@ -2,9 +2,9 @@
# set -o errexit -o noglob are assumed.
#
-ex_log_env_vars() {
+ex_rtl_log_env_vars() {
local _nvar=1 _arg _arg_len_max=0;
- ex_log_msg info "Variables for this ${1:-build}:"; shift;
+ ex_rtl_log_msg info "Variables for this ${1:-build}:"; shift;
while [ ${_nvar} -le ${#} ]; do
_arg="$(eval echo \${${_nvar}})";
_arg="${_arg%%=*}";
@@ -13,38 +13,44 @@ ex_log_env_vars() {
fi; : $((_nvar+=1));
done;
while [ ${#} -gt 0 ]; do
- ex_log_msg info "$(printf \
+ ex_rtl_log_msg info "$(printf \
"%${_arg_len_max}.${_arg_len_max}s=%s" \
- "${1%%=*}" "$(ex_get_var_unsafe ${1#*=})")";
+ "${1%%=*}" "$(ex_rtl_get_var_unsafe ${1#*=})")";
shift;
done;
};
-ex_log_msg() {
+ex_rtl_log_set_vnfo_lvl() {
+ EXP_RTL_LOG_VNFO_LVL="${1}";
+};
+
+ex_rtl_log_msg() {
local _lvl="${1}"; shift;
if [ "${_lvl}" = vnfo ]\
- && [ ${ARG_VERBOSE:-0} -eq 0 ]; then
+ && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 1 ]; then
return;
elif [ "${_lvl}" = vvfo ]\
- && [ ${ARG_VERBOSE2:-0} -eq 0 ]; then
+ && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 2 ]; then
return;
elif [ "${_lvl}" = vvvo ]\
- && [ ${ARG_VERBOSE3:-0} -eq 0 ]; then
+ && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 3 ]; then
return;
fi;
case "${_lvl}" in
- failexit) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
- fail) printf "\033[0m\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
- info) printf "\033[0m\033[${LOG_MSG_INFO_COLOUR}m"; ;;
- vnfo) printf "\033[0m\033[${LOG_MSG_VNFO_COLOUR}m"; ;;
- vvfo) printf "\033[0m\033[${LOG_MSG_VVFO_COLOUR}m"; ;;
- vvvo) printf "\033[0m\033[${LOG_MSG_VVVO_COLOUR}m"; ;;
- succ) printf "\033[0m\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
+ failexit) printf "\033[0m\033[${DEFAULT_LOG_MSG_FAIL_COLOUR}m"; ;;
+ fail) printf "\033[0m\033[${DEFAULT_LOG_MSG_FAIL_COLOUR}m"; ;;
+ info) printf "\033[0m\033[${DEFAULT_LOG_MSG_INFO_COLOUR}m"; ;;
+ inf2) printf "\033[0m\033[${DEFAULT_LOG_MSG_INF2_COLOUR}m"; ;;
+ vnfo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VNFO_COLOUR}m"; ;;
+ vvfo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VVFO_COLOUR}m"; ;;
+ vvvo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VVVO_COLOUR}m"; ;;
+ succ) printf "\033[0m\033[${DEFAULT_LOG_MSG_SUCC_COLOUR}m"; ;;
+ suc2) printf "\033[0m\033[${DEFAULT_LOG_MSG_SUC2_COLOUR}m"; ;;
esac;
if [ ${#} -gt 1 ]; then
- printf "==> %s %s %s\033[0m\n" "$(ex_date)" "${1}" "$*";
+ printf "==> %s %s %s\033[0m\n" "$(ex_rtl_date)" "${1}" "$*";
else
- printf "==> %s %s\033[0m\n" "$(ex_date)" "${1}";
+ printf "==> %s %s\033[0m\n" "$(ex_rtl_date)" "${1}";
fi; [ ${_lvl} = failexit ] && exit 1 || return 0;
};
diff --git a/subr/ex_rtl_state.subr b/subr/ex_rtl_state.subr
new file mode 100644
index 00000000..fa07ff35
--- /dev/null
+++ b/subr/ex_rtl_state.subr
@@ -0,0 +1,32 @@
+#
+# set -o errexit -o noglob are assumed.
+#
+
+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_setup_checks.subr b/subr/ex_setup_checks.subr
deleted file mode 100644
index 803810d2..00000000
--- a/subr/ex_setup_checks.subr
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-ex_setup_checks() {
- local __ _exit;
- for __ in ${CHECK_PATH_VARS}; do
- if [ -z "${___:=$(ex_get_var_unsafe "${__}")}" ]; then
- ex_log_msg failexit "Error: variable \`${__}' is empty or unset.";
- elif [ "${___#* *}" != "${___}" ]; then
- ex_log_msg failexit "Error: variable \`${__}' contains one or more whitespace characters.";
- fi;
- done;
- for __ in ${CHECK_PREREQ_CMDS} $(eval echo ${CHECK_PREREQ_FILES_DYNAMIC}) ${CHECK_PREREQ_FILES}; do
- if [ "${__#/}" != "${__}" ]; then
- if [ ! -e "${__}" ]; then
- ex_log_msg fail "Error: missing prerequisite file \`${__}'.";
- _exit=1;
- fi;
- else
- if ! ex_test_cmd "${__}"; then
- ex_log_msg fail "Error: missing prerequisite command \`${__}'.";
- _exit=1;
- fi;
- fi;
- done;
- for __ in ${CHECK_PREREQ_PERL_MODULES}; do
- if ! perl -M"${__}" -e "" 2>/dev/null; then
- ex_log_msg fail "Error: missing prerequisite Perl module \`${__}'.";
- _exit=1;
- fi;
- done;
- if [ ${_exit:-0} = 1 ]; then
- exit 1;
- fi;
-};
-
-# vim:filetype=sh
diff --git a/subr/ex_setup_env.subr b/subr/ex_setup_env.subr
deleted file mode 100644
index 8907d7eb..00000000
--- a/subr/ex_setup_env.subr
+++ /dev/null
@@ -1,36 +0,0 @@
-ex_setup_env() {
- local __;
- set -o noglob;
- if [ -z "${DEFAULT_BUILD_CPUS}" ]\
- && [ -e /proc/cpuinfo ]; then
- DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
- fi;
- : ${ARCH:=nt64}; : ${BUILD:=debug};
- if [ "${ARCH}" = nt32 ]; then
- TARGET="i686-nt32-midipix";
- elif [ "${ARCH}" = nt64 ]; then
- TARGET="x86_64-nt64-midipix";
- else
- if [ "${BUILD}" != debug ]\
- && [ "${BUILD}" != release ]; then
- ex_log_msg failexit "Error: unknown build type \`${BUILD}'.";
- fi;
- ex_log_msg failexit "Error: invalid architecture \`${ARCH}'.";
- fi;
- for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/env.vars ./vars/build.vars; do
- [ -e ${__} ] && . ${__};
- done;
- export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
- if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then
- DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
- elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then
- DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
- fi;
- for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do
- if ! ex_lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then
- unset "${__}";
- fi;
- done;
-};
-
-# vim:filetype=sh
diff --git a/subr/ex_setup_subdirs.subr b/subr/ex_setup_subdirs.subr
deleted file mode 100644
index e6f0fbf9..00000000
--- a/subr/ex_setup_subdirs.subr
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-ex_setup_subdirs() {
- local _pname;
- if [ ${ARG_CLEAN:-0} -eq 1 ]; then
- ex_log_msg info "-c specified, cleaning prefix...";
- for _pname in ${CLEAR_PREFIX_PATHS}; do
- ex_build_fileop rm ${PREFIX}/${_pname};
- done;
- fi;
- pkg_install_files "" \
- /=${DLCACHEDIR} \
- /=${WORKDIR} \
- /=${PREFIX} \
- /=${PREFIX}/bin \
- /=${PREFIX}/lib/pkgconfig \
- /=${PREFIX}/share/doc \
- /=${PREFIX}/share/info \
- /=${PREFIX}/share/man \
- /=${PREFIX}/${TARGET}/bin \
- /=${PREFIX}/${TARGET}/lib \
- /=${PREFIX}/x86_64-w64-mingw32 \
- /=${PREFIX_CROSS} \
- /=${PREFIX_MINIPIX}/bin \
- /=${PREFIX_NATIVE} \
- /=${PREFIX_NATIVE}/share/doc \
- /=${PREFIX_NATIVE}/share/info \
- /=${PREFIX_NATIVE}/share/man \
- /=${PREFIX_NATIVE}/${TARGET}/lib \
- @.=${PREFIX}/usr \
- @.=${PREFIX}/x86_64-w64-mingw32/mingw \
- /=${PREFIX}/x86_64-w64-mingw32/mingw/include \
- @.=${PREFIX_NATIVE}/usr \
- @../lib/pkgconfig=${PREFIX}/share/pkgconfig \
- @lib=${PREFIX}/lib64 \
- @bin=${PREFIX_MINIPIX}/lib \
- @bin=${PREFIX_MINIPIX}/libexec \
- @bin=${PREFIX_MINIPIX}/share \
- @share/doc=${PREFIX}/doc \
- @share/info=${PREFIX}/info \
- @share/man=${PREFIX}/man \
- @share/doc=${PREFIX_NATIVE}/doc \
- @share/info=${PREFIX_NATIVE}/info \
- @share/man=${PREFIX_NATIVE}/man;
-};
-
-# vim:filetype=sh
diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr
index dd2e8f2e..038bd564 100644
--- a/subr/pkg_build.subr
+++ b/subr/pkg_build.subr
@@ -10,16 +10,19 @@ 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_run_cmd_unsplit make \
+ ex_rtl_run_cmd_unsplit make \
${PKG_MAKEFLAGS_BUILD} \
${PKG_MAKEFLAGS_BUILD_EXTRA} \
- AR=${AR} ${_no_autoconf:+CC=${CC}} RANLIB=${RANLIB} \
+ "AR=${PKG_AR}" "${_no_autoconf:+CC=${PKG_CC}}" \
+ "RANLIB=${PKG_RANLIB}" \
"${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}" \
- "${CFLAGS_FOR_BUILD:+CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD}}" \
"${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}" \
"${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}" \
"${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}"\
- "LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
+ "${PKG_PKGCONFIG:+PKGCONFIG=${PKG_PKGCONFIG}}" \
+ "${PKG_PKG_CONFIG:+PKG_CONFIG=${PKG_PKG_CONFIG}}" \
+ "${PKG_PKG_CONFIG_LIBPATH:+PKG_CONFIG_LIBPATH=${PKG_PKG_CONFIG_LIBPATH}}"\
+ "LIBTOOL=${PKG_LIBTOOL:-slibtool}";
};
# vim:filetype=sh
diff --git a/subr/pkg_build_clean.subr b/subr/pkg_build_clean.subr
deleted file mode 100644
index 8b2e909d..00000000
--- a/subr/pkg_build_clean.subr
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-pkg_build_clean() {
- make clean;
-};
-
-# vim:filetype=sh
diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr
index acc67a09..23ef26d5 100644
--- a/subr/pkg_configure.subr
+++ b/subr/pkg_configure.subr
@@ -3,18 +3,26 @@
#
pkg_configure() {
- if [ -n "${PKG_CONFIGURE}" ]; then
- PKG_CONFIGURE="${PKG_BASE_DIR}/${PKG_CONFIGURE}";
- else
- PKG_CONFIGURE="${PKG_BASE_DIR}/${PKG_SUBDIR}/configure";
- fi;
if [ -x "${PKG_CONFIGURE}" ]; then
+ if [ -n "${PKG_PKGCONFIG}" ]; then
+ export PKGCONFIG="${PKG_PKGCONFIG}";
+ fi;
+ if [ -n "${PKG_PKG_CONFIG}" ]; then
+ export PKG_CONFIG="${PKG_PKG_CONFIG}";
+ fi;
+ if [ -n "${PKG_PKG_CONFIG_LIB_PATH}" ]; then
+ export PKG_CONFIG_LIBPATH="${PKG_PKG_CONFIG_LIBPATH}";
+ fi;
+ AR="${PKG_AR}" \
+ CC="${PKG_CC}" \
+ RANLIB="${PKG_RANLIB}" \
CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}" \
CPPFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}" \
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};
+ unset PKGCONFIG PKG_CONFIG PKG_CONFIG_LIBPATH;
fi;
};
diff --git a/subr/pkg_configure_autotools.subr b/subr/pkg_configure_autotools.subr
index 219b1719..1617895d 100644
--- a/subr/pkg_configure_autotools.subr
+++ b/subr/pkg_configure_autotools.subr
@@ -12,7 +12,7 @@ pkg_configure_autotools() {
&& [ ! -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure" ]; then
for _script_fname in bootstrap bootstrap.sh autogen.sh ""; do
if [ -z "${_script_fname}" ]; then
- (ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf)\
+ (ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf)\
|| exit 1 && break;
elif [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/${_script_fname}" ]; then
for _subdir_tgt in "${PKG_BASE_DIR}/${PKG_SUBDIR}/build-aux" "${PKG_BASE_DIR}/${PKG_SUBDIR}"; do
@@ -26,7 +26,7 @@ pkg_configure_autotools() {
break;
fi;
done;
- (ex_build_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && \
+ (ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && \
"${SHELL}" "${_script_fname}") || exit 1 && break;
fi;
done;
@@ -39,10 +39,10 @@ pkg_configure_autotools() {
if [ "${PKG_BUILD_TYPE}" != host ]; then
if [ -n "${PKG_CONFIG_CACHE}" ]; then
echo "${PKG_CONFIG_CACHE}" |\
- tr " " "\n" >> "${PKG_BUILD_DIR}/config.cache";
+ tr " " "\n" > "${PKG_BUILD_DIR}/config.cache";
if [ -n "${PKG_CONFIG_CACHE_EXTRA}" ]; then
echo "${PKG_CONFIG_CACHE_EXTRA}" |\
- tr " " "\n" >> "${PKG_BUILD_DIR}/config.cache";
+ tr " " "\n" >> "${PKG_BUILD_DIR}/config.cache";
fi;
fi;
sed -i"" "s,%PREFIX%,${PKG_PREFIX},g" "${PKG_BUILD_DIR}/config.cache";
diff --git a/subr/pkg_configure_patch.subr b/subr/pkg_configure_patch.subr
index ff078fec..57939126 100644
--- a/subr/pkg_configure_patch.subr
+++ b/subr/pkg_configure_patch.subr
@@ -3,23 +3,26 @@
#
pkg_configure_patch() {
- local _patch_fname _patches_done;
- set +o noglob;
- for _patch_fname in \
- ${WORKDIR}/chainport-host-invariants/chainport/${PKG_NAME%_host}${PKG_VERSION:+-${PKG_VERSION}}.midipix.patch \
- ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch \
- ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}${PKG_VERSION:+-${PKG_VERSION}}.local.patch \
- ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}${PKG_VERSION:+-${PKG_VERSION}}.local@${BUILD_HNAME}.patch \
- ${PKG_NAME_PARENT:+${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME_PARENT}/*.patch} \
- ${PKG_NAME_PARENT:+${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME_PARENT}${PKG_VERSION:+-${PKG_VERSION}}.local.patch} \
- ${PKG_NAME_PARENT:+${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME_PARENT}${PKG_VERSION:+-${PKG_VERSION}}.local@${BUILD_HNAME}.patch}; do
- if ! ex_lmatch "${_patches_done}" " " "${_patch_fname}"\
- && [ -r "${_patch_fname}" ]; then
- patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_patch_fname}";
- _patches_done="${_patches_done:+${_patches_done} }${_patch_fname}";
+ local _pkg_name _pkg_name_full _patch_dir _patch_fname _patches_done;
+ for _pkg_name in "${PKG_NAME}" "${PKG_NAME_PARENT}"; do
+ if [ -z "${_pkg_name}" ]; then
+ continue;
+ else
+ _pkg_name_full="${_pkg_name}${PKG_VERSION:+-${PKG_VERSION}}";
+ _patch_dir="${MIDIPIX_BUILD_PWD}/patches";
fi;
+ set +o noglob; for _patch_fname in \
+ ${_patch_dir}/${_pkg_name}/*.patch \
+ ${_patch_dir}/${_pkg_name_full}.local.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
+ patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_patch_fname}";
+ _patches_done="${_patches_done:+${_patches_done} }${_patch_fname}";
+ fi;
+ done; set -o noglob;
done;
- set -o noglob;
};
# vim:filetype=sh
diff --git a/subr/pkg_fetch_distclean.subr b/subr/pkg_fetch_distclean.subr
deleted file mode 100644
index 19f0b741..00000000
--- a/subr/pkg_fetch_distclean.subr
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-pkg_fetch_distclean() {
- if [ "$(stat -c %i "${PKG_BASE_DIR}")" \
- != "$(stat -c %i "${WORKDIR}")" ]; then
- ex_build_fileop cd "${WORKDIR}";
- ex_build_fileop rm "${PKG_BASE_DIR}";
- ex_build_fileop mkdir "${PKG_BASE_DIR}";
- ex_build_fileop cd "${PKG_BASE_DIR}";
- fi;
-};
-
-# vim:filetype=sh
diff --git a/subr/pkg_fetch_extract.subr b/subr/pkg_fetch_extract.subr
index 33d450d2..1ab1e4f0 100644
--- a/subr/pkg_fetch_extract.subr
+++ b/subr/pkg_fetch_extract.subr
@@ -3,24 +3,24 @@
#
pkg_fetch_extract() {
+ local _oldpwd;
if [ -n "${PKG_URL}" ]\
&& [ "${PKG_URL_TYPE:-wget}" = wget ]; then
- ex_build_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}";
- if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then
- bunzip2 -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
- elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then
- gunzip -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
- elif [ "${PKG_FNAME##*.tar.}" = "xz" ]; then
- xz -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
- elif [ "${PKG_FNAME##*.t}" = "bz2" ]; then
- bunzip2 -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
- elif [ "${PKG_FNAME##*.t}" = "gz" ]; then
- gunzip -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
- elif [ "${PKG_FNAME##*.t}" = "xz" ]; then
- xz -d < "${DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
+ _oldpwd="${PWD}"; ex_rtl_fileop cd "${PKG_BASE_DIR}";
+ ex_rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}";
+ if [ "${PKG_FNAME##*.tar.}" = "bz2" ]\
+ || [ "${PKG_FNAME##*.t}" = "bz2" ]; then
+ bunzip2 -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
+ elif [ "${PKG_FNAME##*.tar.}" = "gz" ]\
+ || [ "${PKG_FNAME##*.t}" = "gz" ]; then
+ gunzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
+ elif [ "${PKG_FNAME##*.tar.}" = "xz" ]\
+ || [ "${PKG_FNAME##*.t}" = "xz" ]; then
+ xz -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
else
- tar -C "${PKG_BASE_DIR}" -xf "${DLCACHEDIR}/${PKG_FNAME}";
+ tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/${PKG_FNAME}";
fi;
+ ex_rtl_fileop cd "${_oldpwd}";
fi;
};
diff --git a/subr/pkg_fetch_git.subr b/subr/pkg_fetch_git.subr
index 8340ca4f..67c05458 100644
--- a/subr/pkg_fetch_git.subr
+++ b/subr/pkg_fetch_git.subr
@@ -2,47 +2,9 @@
# set -o errexit -o noglob are assumed.
#
-pkgp_fetch_git() {
- local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}";
- if [ "${ARG_OFFLINE:-0}" -eq 0 ]; then
- if [ -e "${DLCACHEDIR}/${_subdir}" ]; then
- (ex_build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\
- git pull origin "${_branch:-main}");
- else
- git clone "${_url}" "${DLCACHEDIR}/${_subdir}";
- if [ -n "${_branch}" -a \
- \( -z "${_branch#main}" \) -a \
- \( -z "${_branch#master}" \) ]; then
- (ex_build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\
- git checkout -b "${_branch}");
- fi;
- fi;
- fi;
- ex_build_fileop rm "${_tgtdir}/${_subdir}";
- ex_build_fileop cp "${DLCACHEDIR}/${_subdir}" "${_tgtdir}";
-};
-
-pkgp_fetch_urls_git() {
- local _tgtdir _url_spec _subdir _url _git_branch;
- _tgtdir="${1}"; shift;
- for _url_spec in "${@}"; do
- _subdir="${_url_spec%=*}";
- _url="${_url_spec#*=}";
- _url="${_url%@*}";
- if [ "${_url_spec#*@}" != "${_url_spec}" ]; then
- _git_branch=${_url_spec#*@};
- fi;
- pkgp_fetch_git "${_tgtdir}" "${_subdir}" "${_url}" "${_git_branch}";
- done;
-};
-
pkg_fetch_git() {
- if [ ${#} -gt 0 ]; then
- pkgp_fetch_urls_git "${PKG_BASE_DIR}" "${@}";
- else
- if [ -n "${PKG_URLS_GIT}" ]; then
- pkgp_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT};
- fi;
+ if [ -n "${PKG_URLS_GIT}" ]; then
+ ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT};
fi;
};
diff --git a/subr/pkg_fetch_subdirs.subr b/subr/pkg_fetch_subdirs.subr
deleted file mode 100644
index 7d097d03..00000000
--- a/subr/pkg_fetch_subdirs.subr
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# set -o errexit -o noglob are assumed.
-#
-
-pkg_fetch_subdirs() {
- if [ -z "${PKG_BUILD_DIR}" ]; then
- if [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure" ]\
- || [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure.ac" ]\
- || [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure.in" ]; then
- PKG_BUILD_DIR="${PKG_BASE_DIR}/obj";
- else
- PKG_BUILD_DIR="${PKG_BASE_DIR}/${PKG_SUBDIR}";
- fi;
- else
- PKG_BUILD_DIR="${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
- fi;
- if [ ! -d "${PKG_BUILD_DIR}" ]; then
- ex_build_fileop mkdir "${PKG_BUILD_DIR}";
- fi;
- ex_build_fileop cd "${PKG_BUILD_DIR}";
-};
-
-# vim:filetype=sh
diff --git a/subr/pkg_fetch_wget.subr b/subr/pkg_fetch_wget.subr
index 95fdc081..56fe79d3 100644
--- a/subr/pkg_fetch_wget.subr
+++ b/subr/pkg_fetch_wget.subr
@@ -2,40 +2,9 @@
# set -o errexit -o noglob are assumed.
#
-# N.B. URLs ($1) may contain `?' or '&' characters.
-pkgp_fetch_wget() {
- local _url="${1}" _sha256sum_src="${2}";
- if [ -z "${3}" ]; then
- _url_dst="${DLCACHEDIR}/$(ex_basename "${_url}")";
- else
- _url_dst="${DLCACHEDIR}/${3}";
- fi;
- if [ "${ARG_OFFLINE:-0}" -eq 1 ]\
- || [ -e "${_url_dst}.fetched" ]; then
- return 0;
- else
- wget ${DEFAULT_WGET_ARGS} -c -O "${_url_dst}" "${_url}";
- fi;
- if [ -n "${_sha256sum_src}" ]; then
- set -- $(openssl dgst -sha256 "${_url_dst}"); shift $((${#}-1));
- if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then
- if [ "${ARG_IGNORE_SHA256SUMS:-0}" -eq 0 ]; then
- ex_log_msg failexit "Error: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)";
- else
- ex_log_msg vnfo "Warning: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)";
- fi;
- fi;
- fi;
- touch "${_url_dst}.fetched";
-};
-
pkg_fetch_wget() {
- if [ -n "${1}" ]; then
- pkgp_fetch_wget "${1}" "${2}";
- else
- if [ -n "${PKG_URL}" ]; then
- pkgp_fetch_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}";
- fi;
+ if [ -n "${PKG_URL}" ]; then
+ ex_rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}";
fi;
};
diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr
index c4a0c03a..0d74ecf8 100644
--- a/subr/pkg_install.subr
+++ b/subr/pkg_install.subr
@@ -3,7 +3,7 @@
#
pkg_install() {
- ex_build_fileop mkdir "${PKG_PREFIX}";
+ ex_rtl_fileop mkdir "${PKG_PREFIX}";
tar -C "${PKG_DESTDIR}" -cpf - . |\
tar -C "${PKG_PREFIX}" -xpf -;
};
diff --git a/subr/pkg_install_files.subr b/subr/pkg_install_files.subr
index 88acf60d..31f101ea 100644
--- a/subr/pkg_install_files.subr
+++ b/subr/pkg_install_files.subr
@@ -2,52 +2,9 @@
# set -o errexit -o noglob are assumed.
#
-pkgp_install_files() {
- local _verbose _prefix _ln_target _ln_fname _mkdir_fname \
- _file_fname_src _file_fname_dst;
- if [ "${1}" = "-v" ]; then
- _verbose=1; shift;
- fi; _prefix="${1}"; shift;
- while [ ${#} -gt 0 ]; do
- case "${1}" in
- @*=*)
- _ln_target="${1%=*}";
- _ln_target="${_ln_target#@}";
- _ln_fname="${1#*=}";
- if [ "${_ln_fname#/}" = "${_ln_fname}" ]; then
- _ln_fname="${_prefix:+${_prefix}/}${_ln_fname}";
- fi;
- if [ -e "${_ln_fname}" ]; then
- ex_build_fileop rm "${_ln_fname}";
- fi;
- ex_build_fileop ln_symbolic "${_ln_target}" "${_ln_fname}";
- ;;
- /=*)
- _mkdir_fname="${1#/=}";
- if [ "${_mkdir_fname#/}" = "${_mkdir_fname}" ]; then
- _mkdir_fname="${_prefix:+${_prefix}/}${_mkdir_fname}";
- fi;
- ex_build_fileop mkdir "${_mkdir_fname}";
- ;;
- *)
- _file_fname_src="${1%=*}";
- _file_fname_dst="${1#*=}";
- if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then
- _file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}";
- fi;
- ex_build_fileop cp "${_file_fname_src}" "${_file_fname_dst}";
- ;;
- esac; shift;
- done;
-};
-
pkg_install_files() {
- if [ ${#} -ge 2 ]; then
- pkgp_install_files -v "${@}";
- else
- if [ -n "${PKG_INSTALL_FILES}" ]; then
- pkgp_install_files -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES};
- fi;
+ if [ -n "${PKG_INSTALL_FILES}" ]; then
+ ex_rtl_install -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES};
fi;
};
diff --git a/subr/pkg_install_libs.subr b/subr/pkg_install_libs.subr
index c4b49c6e..c3ce16a8 100644
--- a/subr/pkg_install_libs.subr
+++ b/subr/pkg_install_libs.subr
@@ -4,29 +4,28 @@
pkgp_install_lib_check() {
local _so_path="${1}" _so_ver="${1##*.so}";
- if [ -z "${_so_ver}" ]; then
+ if [ -z "${_so_path}" ]; then
return 1;
- fi;
- while [ -n "${_so_ver}" ]; do
+ else while [ -n "${_so_ver}" ]; do
if [ "${_so_ver#[0-9.]}" = "${_so_ver}" ]; then
return 1;
else
_so_ver="${_so_ver#[0-9.]}";
fi;
- done; return 0;
+ done; return 0; fi;
};
pkgp_install_lib_link() {
- local _so_path="${1}" _so_dir="${2}" _lib_name="${3}" \
+ local _so_path="${1}" _so_dir="${2}" _lib_name="${3}" \
_lib_link_tgt _lib_link_path;
_lib_link_path="${_so_path%.so*}.lib.a";
- _lib_link_tgt="$(find "${_so_dir}" \
- -name "${_lib_name%%.*}.*.lib.a" |\
+ _lib_link_tgt="$(find "${_so_dir}" \
+ -name "${_lib_name%%.*}.*.lib.a" |\
sort | tail -1)";
if [ -n "${_lib_link_tgt}" ]\
&& [ "${_lib_link_tgt}" != "${_lib_link_path}" ]; then
- ex_build_fileop rm "${_lib_link_path}";
- ex_build_fileop ln_symbolic "$(ex_basename "${_lib_link_tgt}")" \
+ ex_rtl_fileop rm "${_lib_link_path}";
+ ex_rtl_fileop ln_symbolic "$(ex_rtl_basename "${_lib_link_tgt}")" \
"${_lib_link_path}";
fi;
};
@@ -34,25 +33,29 @@ pkgp_install_lib_link() {
pkg_install_libs() {
local _so_src_path _so_dst_dir _lib_src_path _lib_name _lib_dst_path;
if [ "${PKG_BUILD_TYPE}" != "host" ]; then
- for _so_src_path in \
- $(find "${PKG_DESTDIR}" \
+ for _so_src_path in \
+ $(find "${PKG_DESTDIR}" \
\( -name "*.so" -or -name "*.so.*" \) -print);
- do if ! pkgp_install_lib_check "${_so_src_path}" \
+ do if ! pkgp_install_lib_check "${_so_src_path}" \
|| [ "$(readlink -f "${_so_src_path}")" = "/dev/null" ]; then
continue;
- else case "${_so_src_path}" in
+ else _so_dst_dir="${_so_src_path%/*}";
+ 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;
- _lib_name="$(ex_basename "${_lib_src_path}")";
- _so_dst_dir="${_so_src_path%/*}";
- fi;
- if [ ! -L "${_lib_src_path}" ]; then
+ _lib_name="$(ex_rtl_basename "${_lib_src_path}")";
_lib_dst_path="${_so_dst_dir}/${_lib_name}";
- perk -e "${_so_src_path}" |\
- "${PKG_TARGET}-mdso" \
- -i "${_lib_dst_path}" \
- -n "${_so_src_path}" -;
+ fi;
+ if [ ! -L "${_lib_src_path}" ]\
+ && [ ! -e "${_lib_dst_path}" ]; then
+ set -o xtrace
+ (ex_rtl_fileop cd "$(ex_rtl_dirname "${_so_src_path}")";
+ perk -e "$(ex_rtl_basename "${_so_src_path}")" |\
+ "${PKG_TARGET}-mdso" \
+ -i "$(ex_rtl_basename "${_lib_dst_path}")" \
+ -n "$(ex_rtl_basename "${_so_src_path}")" -);
+ set +o xtrace
fi;
pkgp_install_lib_link "${_so_src_path}" "${_so_dst_dir}" "${_lib_name}";
done;
diff --git a/subr/pkg_install_make.subr b/subr/pkg_install_make.subr
index 8207d7e8..48489c53 100644
--- a/subr/pkg_install_make.subr
+++ b/subr/pkg_install_make.subr
@@ -3,16 +3,16 @@
#
pkg_install_make() {
- ex_run_cmd_unsplit make \
+ ex_rtl_run_cmd_unsplit make \
${PKG_MAKEFLAGS_INSTALL} \
${PKG_MAKEFLAGS_INSTALL_EXTRA} \
- AR=${AR} CC=${CC} RANLIB=${RANLIB} \
+ AR=${PKG_AR} CC=${PKG_CC} RANLIB=${PKG_RANLIB} \
"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}" \
"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}" \
"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}" \
"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}" \
"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}" \
- "LIBTOOL=${PKG_SLIBTOOL:-slibtool}" \
+ "LIBTOOL=${PKG_LIBTOOL:-slibtool}" \
"${PKG_MAKE_INSTALL_VNAME:-DESTDIR}=${PKG_DESTDIR}/" \
${PKG_INSTALL_TARGET:=install};
};
diff --git a/subr/pkg_install_purge_la.subr b/subr/pkg_install_purge_la.subr
index 61725673..53559628 100644
--- a/subr/pkg_install_purge_la.subr
+++ b/subr/pkg_install_purge_la.subr
@@ -5,7 +5,7 @@
pkg_install_purge_la() {
local _la_path;
for _la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do
- ex_build_fileop rm ${_la_path};
+ ex_rtl_fileop rm ${_la_path};
done;
};
diff --git a/subr/pkg_install_strip.subr b/subr/pkg_install_strip.subr
index e91e6eaf..5d232a3c 100644
--- a/subr/pkg_install_strip.subr
+++ b/subr/pkg_install_strip.subr
@@ -2,8 +2,8 @@
# set -o errexit -o noglob are assumed.
#
-pkgp_strip_tree() {
- local _tree_root="${1}" _bin_path;
+pkg_strip() {
+ local _tree_root="${PKG_DESTDIR}/bin" _bin_path;
if [ ! -e "${_tree_root}" ]; then
return;
fi;
@@ -11,21 +11,12 @@ pkgp_strip_tree() {
\( -type f -or -type l \)); do
set +o errexit;
if objdump -sj .debug_info "${_bin_path}" >/dev/null 2>&1; then
- ex_log_msg info "Stripping ${_bin_path}...";
- ex_log_msg vnfo "${TARGET}-strip ${_bin_path}";
- ${TARGET}-strip ${_bin_path};
+ ex_rtl_log_msg info "Stripping ${_bin_path}...";
+ ex_rtl_log_msg vnfo "${PKG_TARGET}-strip ${_bin_path}";
+ ${PKG_TARGET}-strip ${_bin_path};
fi;
set -o errexit;
done;
};
-pkg_strip() {
- if [ "${PKG_NAME%flavour_minipix}" != "${PKG_NAME}" ] \
- && [ ${ARG_DEBUG_MINIPIX:-0} -eq 0 ]; then
- pkgp_strip_tree "${PKG_DESTDIR}";
- elif [ "${BUILD}" = release ]; then
- pkgp_strip_tree "${PKG_DESTDIR}/bin";
- fi;
-};
-
# vim:filetype=sh
diff --git a/subr/pkg_install_subdirs.subr b/subr/pkg_install_subdirs.subr
index c7b0d089..0ddbf5cf 100644
--- a/subr/pkg_install_subdirs.subr
+++ b/subr/pkg_install_subdirs.subr
@@ -3,20 +3,16 @@
#
pkg_install_subdirs() {
- pkg_install_files "${PKG_DESTDIR}" \
- /=bin \
- /=lib \
- /=lib/pkgconfig \
- /=sbin \
- /=share/doc \
- /=share/info \
- /=share/man/man1 \
- @.=usr \
- @../lib/pkgconfig=share/pkgconfig \
- @lib=lib64 \
- @share/doc=doc \
- @share/info=info \
- @share/man=man;
+ local _spec;
+ for _spec in "${PKG_INSTALL_FILES_DESTDIR}" \
+ "${PKG_INSTALL_FILES_DESTDIR_EXTRA}"; do
+ ex_rtl_install "${PKG_DESTDIR}" ${_spec};
+ done;
+ if [ "${PKG_PREFIX%/}" = "${PREFIX_NATIVE%/}" ]; then
+ ex_rtl_install \
+ "${PKG_DESTDIR}/${DEFAULT_TARGET}" \
+ ${PKG_INSTALL_FILES_DESTDIR};
+ fi;
};
# vim:filetype=sh