diff options
Diffstat (limited to 'subr')
29 files changed, 220 insertions, 186 deletions
diff --git a/subr/build_init.subr b/subr/build_init.subr index 91784f83..6d1635db 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # buildp_init_args() { @@ -11,86 +11,72 @@ buildp_init_args() { && [ -e "${PREFIX}/build.gitref" ]\ && [ "$(git rev-parse HEAD)" = "$(cat "${PREFIX}/build.gitref")" ]; then _rc=0; _status="Git repository has not changed since last build and --as-needed was specified."; - else case "${ARG_PARALLEL}" in - auto) if ! ARG_PARALLEL="$(rtl_get_cpu_count)"; then - _rc=1; _status="Error: failed to get CPU count."; - else - ARG_PARALLEL=$((${ARG_PARALLEL}/2)); - fi; ;; - "") ARG_PARALLEL=1; ;; - *) if ! rtl_isnumber "${ARG_PARALLEL}"; then - _rc=1; _status="Error: invalid jobs count \`${ARG_PARALLEL}'."; - fi; ;; + else 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; + case "${ARG_RESTART}" in + \*\*\*[a-zA-Z]*) + ARG_RESTART="${ARG_RESTART#\*\*\*}"; ARG_RESTART_RECURSIVE=3; ;; + \*\*[a-zA-Z]*) ARG_RESTART="${ARG_RESTART#\*\*}"; ARG_RESTART_RECURSIVE=2; ;; + \*[a-zA-Z]*) ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1; ;; + ALL) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=2; ;; + LAST) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=0; + 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}")"; + rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; + rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}"; + ARG_RESTART="${_last_pkg}"; + else + _rc=1; _status="Error: cannot rebuild last failed package."; + fi; ;; esac; if [ "${_rc:-0}" -eq 0 ]; then - DEFAULT_BUILD_CPUS="${ARG_PARALLEL}"; - 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; case "${ARG_RESTART}" in - \*\*\*[a-zA-Z]*) - ARG_RESTART="${ARG_RESTART#\*\*\*}"; ARG_RESTART_RECURSIVE=3; ;; - \*\*[a-zA-Z]*) ARG_RESTART="${ARG_RESTART#\*\*}"; ARG_RESTART_RECURSIVE=2; ;; - \*[a-zA-Z]*) ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1; ;; - ALL) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=2; ;; - LAST) ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=0; - 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}")"; - rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; - rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}"; - ARG_RESTART="${_last_pkg}"; - else - _rc=1; _status="Error: cannot rebuild last failed package."; - fi; ;; + *:*) ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="$(rtl_llift "${ARG_RESTART%%:*}" "," " ")"; ;; + *) ARG_RESTART="$(rtl_llift "${ARG_RESTART}" "," " ")"; ARG_RESTART_AT=ALL; ;; esac; - if [ "${_rc:-0}" -eq 0 ]; then - case "${ARG_RESTART}" in - *:*) ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="$(rtl_llift "${ARG_RESTART%%:*}" "," " ")"; ;; - *) ARG_RESTART="$(rtl_llift "${ARG_RESTART}" "," " ")"; ARG_RESTART_AT=ALL; ;; - esac; - if ! ex_pkg_load_groups; then - _rc=1; _status="Error: failed to load build groups."; - else if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then - EX_PKG_BUILD_GROUPS="$(rtl_lfilter "${EX_PKG_BUILD_GROUPS}" "host_deps_rpm")"; + if ! ex_pkg_load_groups; then + _rc=1; _status="Error: failed to load build groups."; + else if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then + EX_PKG_BUILD_GROUPS="$(rtl_lfilter "${EX_PKG_BUILD_GROUPS}" "host_deps_rpm")"; + fi; + if [ -z "${BUILD_GROUPS}" ]; then + BUILD_GROUPS="${EX_PKG_BUILD_GROUPS}"; + else for _group in ${BUILD_GROUPS}; do + if ! rtl_lmatch "${EX_PKG_BUILD_GROUPS}" "${_group}"; then + _rc=1; _status="Error: unknown build group \`${_group}'."; break; + fi; + done; + fi; + if [ "${_rc:-0}" -eq 0 ]; then + if [ -n "${ARG_DIST}" ]; then + BUILD_GROUPS="$(rtl_lconcat "$(rtl_lfilter "${BUILD_GROUPS}" "dist")" "dist")"; fi; - if [ -z "${BUILD_GROUPS}" ]; then - BUILD_GROUPS="${EX_PKG_BUILD_GROUPS}"; - else for _group in ${BUILD_GROUPS}; do - if ! rtl_lmatch "${EX_PKG_BUILD_GROUPS}" "${_group}"; then - _rc=1; _status="Error: unknown build group \`${_group}'."; break; + if [ -n "${ARG_RESTART}" ]; then + for _pkg_name in ${ARG_RESTART}; do + if ! ex_pkg_find_package "${BUILD_GROUPS}" "${_pkg_name}" >/dev/null; then + _pkg_names_unknown="$(rtl_lconcat "${_pkg_names_unknown}" "${_pkg_name}")"; fi; done; + case "$(rtl_llength "${_pkg_names_unknown}")" in + 0) ;; + 1) _rc=1; _status="Error: unknown package \`${_pkg_names_unknown}'."; ;; + *) _rc=1; _status="Error: unknown packages: $(rtl_subst "${_pkg_names_unknown}" " " ", ")"; ;; + esac; fi; - if [ "${_rc:-0}" -eq 0 ]; then - if [ -n "${ARG_DIST}" ]; then - BUILD_GROUPS="$(rtl_lconcat "$(rtl_lfilter "${BUILD_GROUPS}" "dist")" "dist")"; - fi; - if [ -n "${ARG_RESTART}" ]; then - for _pkg_name in ${ARG_RESTART}; do - if ! ex_pkg_find_package "${BUILD_GROUPS}" "${_pkg_name}" >/dev/null; then - _pkg_names_unknown="$(rtl_lconcat "${_pkg_names_unknown}" "${_pkg_name}")"; - fi; - done; - case "$(rtl_llength "${_pkg_names_unknown}")" in - 0) ;; - 1) _rc=1; _status="Error: unknown package \`${_pkg_names_unknown}'."; ;; - *) _rc=1; _status="Error: unknown packages: $(rtl_subst "${_pkg_names_unknown}" " " ", ")"; ;; - esac; - fi; - if [ "${_rc}" -eq 0 ]; then - case "${ARG_VERBOSE:-0}" in - 0) rtl_fileop_set_log 0; rtl_log_set_lvl 0; ;; - 1) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; - 2) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; - 3) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; - 4) rtl_fileop_set_log 1; rtl_log_set_lvl 3; ;; - *) _rc=1; _status="Error: invalid verbosity level (max. -vvvv)"; ;; - esac; - fi; + if [ "${_rc}" -eq 0 ]; then + case "${ARG_VERBOSE:-0}" in + 0) rtl_fileop_set_log 0; rtl_log_set_lvl 0; ;; + 1) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; + 2) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; + 3) rtl_fileop_set_log 0; rtl_log_set_lvl 2; ;; + 4) rtl_fileop_set_log 1; rtl_log_set_lvl 3; ;; + *) _rc=1; _status="Error: invalid verbosity level (max. -vvvv)"; ;; + esac; fi; fi; fi; @@ -156,7 +142,7 @@ buildp_init_getopts() { : ${ARCH:="nt64"}; : ${BUILD:="debug"}; ARG_AS_NEEDED=0; ARG_CLEAN_BUILDS=""; ARG_DEBUG_MINIPIX=0; ARG_DIST=1; ARG_DUMP_IN=""; ARG_DUMP_ON_ABORT=0; ARG_FETCH_FORCE=0; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESTART=""; - ARG_VERBOSE=0; + ARG_RESTART_AT=""; ARG_RESTART_RECURSIVE=""; ARG_VERBOSE=0; while [ "${#}" -gt 0 ]; do case "${1}" in --as-needed) ARG_AS_NEEDED=1; _shiftfl=1; ;; @@ -209,6 +195,22 @@ buildp_init_getopts() { *) BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "${_arg}")"; ;; esac; shift; done; + if [ "${_rc:-0}" -eq 0 ]; then + case "${ARG_PARALLEL}" in + auto) if ! ARG_PARALLEL="$(rtl_get_cpu_count)"; then + _rc=1; _status="Error: failed to get CPU count."; + else + ARG_PARALLEL=$((${ARG_PARALLEL}/2)); + fi; ;; + "") ARG_PARALLEL=1; ;; + *) if ! rtl_isnumber "${ARG_PARALLEL}"; then + _rc=1; _status="Error: invalid jobs count \`${ARG_PARALLEL}'."; + fi; ;; + esac; + if [ "${_rc:-0}" -eq 0 ]; then + DEFAULT_BUILD_CPUS="${ARG_PARALLEL}"; + fi; + fi; fi; return "${_rc}"; }; diff --git a/subr/ex_pkg.subr b/subr/ex_pkg.subr index 3dcfbc7e..e19d987d 100644 --- a/subr/ex_pkg.subr +++ b/subr/ex_pkg.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # # @@ -130,14 +130,14 @@ ex_pkg_load_groups() { local _build_groups="" _fname="" _group="" _groups=""; for _fname in $(find ./groups -name *.group | sort); do rtl_fileop source_opt "${_fname}"; - if [ -n "${GROUP_TARGET}" ]; then + if [ -n "${GROUP_TARGET:-}" ]; then _group="${GROUP_TARGET}"; unset GROUP_TARGET; else _group="${_fname##*/}"; _group="${_group%.group}"; _group="${_group#*.}"; fi; if ! rtl_lmatch "${_groups}" "${_group}"; then _groups="$(rtl_lconcat "${_groups}" "${_group}")"; - if [ -n "${GROUP_AUTO}" ]; then + if [ -n "${GROUP_AUTO:-}" ]; then if [ "${GROUP_AUTO:-0}" -ne 0 ]; then _build_groups="$(rtl_lconcat "${_build_groups}" "${_group}")"; fi; diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 44ed8d43..669357cd 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # # @@ -129,7 +129,7 @@ exp_pkg_dispatch_package() { printf \"fail %s %s\n\" \"${_group_name}\" \"${_pkg_name}\" >&3; \ pkill -U "${$}"; \ fi;" EXIT HUP INT TERM USR1 USR2; - set +o errexit -o noglob; BUILD_IS_PARENT=0; rtl_log_set_fname ""; rtl_log_set_no_attr 1; + set +o errexit -o noglob -o nounset; BUILD_IS_PARENT=0; rtl_log_set_fname ""; rtl_log_set_no_attr 1; if ex_pkg_env "${_build_steps_default}" "${_build_vars_default}" \ "${_group_name}" 0 "${_pkg_name}" "${_restart_at}" "${_workdir}"; then ex_pkg_exec "${_dispatch_fn}" "${_group_name}" "${_pkg_name}" "${_restart_at}"; diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr index 48b57535..ca701296 100644 --- a/subr/ex_pkg_env.subr +++ b/subr/ex_pkg_env.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # # @@ -15,17 +15,23 @@ exp_pkg_env_defaults() { : ${PKG_NAME:="${_pkg_name}"}; : ${MIDIPIX_BUILD_PWD:="$(pwd)"}; : ${PKG_BASE_DIR:="${_workdir}/${_pkg_name}-${PKG_BUILD_TYPE}-${PKG_TARGET}"}; - : ${PKG_FNAME:="${PKG_URL##*/}"}; - : ${PKG_BUILD_STEPS:="$(rtl_lfilter "${_build_steps_default}" "${PKG_BUILD_STEPS_DISABLE}")"}; - if [ -z "${PKG_SUBDIR}" ]; then - if [ -n "${PKG_URLS_GIT}" ]; then + if [ -n "${PKG_BUILD_STEPS_DISABLE:-}" ]; then + : ${PKG_BUILD_STEPS:="$(rtl_lfilter "${_build_steps_default}" "${PKG_BUILD_STEPS_DISABLE:-}")"}; + else + : ${PKG_BUILD_STEPS:="${_build_steps_default}"}; + fi; + if [ -n "${PKG_URL:-}" ]; then + : ${PKG_FNAME:="${PKG_URL##*/}"}; + fi; + if [ -z "${PKG_SUBDIR:-}" ]; then + if [ -n "${PKG_URLS_GIT:-}" ]; then PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; - else case "${PKG_FNAME}" in + else case "${PKG_FNAME:-}" in *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;; *) PKG_SUBDIR="${_pkg_name}"; ;; esac; fi; fi; - if [ -z "${PKG_BUILD_DIR}" ]; then + if [ -z "${PKG_BUILD_DIR:-}" ]; then case "${PKG_IN_TREE:-0}" in 0) PKG_BUILD_DIR="obj"; ;; 1) PKG_BUILD_DIR="${PKG_SUBDIR}"; ;; @@ -57,7 +63,7 @@ exp_pkg_env_set() { 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 + if [ -n "${PKG_INHERIT_FROM:-}" ]; then rtl_set_vars _vars_set "${_vname}" \ "$(rtl_lconcat "${_var_prefixes}" \ "$(rtl_toupper "PKG_${PKG_INHERIT_FROM} PKG_${_pkg_name}")")" @@ -67,7 +73,7 @@ exp_pkg_env_set() { "$(rtl_toupper "PKG_${_pkg_name}")")"; fi; done; - IFS0="${IFS}"; IFS=":"; for _vname in ${PKG_ENV_VARS_EXTRA}; do + IFS0="${IFS}"; IFS=":"; for _vname in ${PKG_ENV_VARS_EXTRA:-}; do export "${_vname}"; done; IFS="${IFS0}"; if [ "${_nounset:-0}" -eq 0 ]; then diff --git a/subr/ex_pkg_exec.subr b/subr/ex_pkg_exec.subr index 4519ce25..d21289b7 100644 --- a/subr/ex_pkg_exec.subr +++ b/subr/ex_pkg_exec.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # exp_pkg_exec_filter_vars_fn() { @@ -27,9 +27,9 @@ exp_pkg_exec_filter_vars_fn() { # exp_pkg_exec_pre() { local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}"; - if [ -z "${PKG_URL}" ]\ - && [ -z "${PKG_URLS_GIT}" ]\ - && [ -z "${PKG_VERSION}" ]\ + if [ -z "${PKG_URL:-}" ]\ + && [ -z "${PKG_URLS_GIT:-}" ]\ + && [ -z "${PKG_VERSION:-}" ]\ && ! rtl_test_cmd "pkg_${_pkg_name}_all"; then "${_dispatch_fn}" missing_pkg "${_group_name}" "${_pkg_name}"; return 1; @@ -94,7 +94,7 @@ ex_pkg_exec() { "pkg_${_pkg_name}_all" "${_restart_at}"; _rc="${?}"; else set -- ${PKG_BUILD_STEPS}; while [ ${#} -gt 0 ]; do - _step="${1}"; _step_next="${2}"; shift; + _step="${1}"; _step_next="${2:-}"; shift; if [ "${ARG_DUMP_IN}" = "${_step}" ]; then printf "" > "${BUILD_WORKDIR}/${_pkg_name}.dump"; rtl_filter_vars exp_pkg_exec_filter_vars_fn >> "${BUILD_WORKDIR}/${_pkg_name}.dump"; diff --git a/subr/pkg_build.subr b/subr/pkg_build.subr index 2433ea81..d1808213 100644 --- a/subr/pkg_build.subr +++ b/subr/pkg_build.subr @@ -1,27 +1,35 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_build() { - local _no_autoconf=""; - if [ ! -x "${PKG_CONFIGURE}" ]; then + local _libtool="" _no_autoconf=""; + case "${PKG_LIBTOOL:-}" in + "") _libtool=""; ;; + none) _libtool=""; ;; + *) _libtool="${PKG_LIBTOOL}"; ;; + esac; + if [ ! -x "${PKG_CONFIGURE:-}" ]; then _no_autoconf=1; fi; # 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. - rtl_run_cmd_unsplit make \ - ${PKG_MAKEFLAGS_BUILD} \ - ${PKG_MAKEFLAGS_BUILD_EXTRA} \ - "AR=${PKG_AR}" "${_no_autoconf:+CC=${PKG_CC}}" \ - "RANLIB=${PKG_RANLIB}" \ - "${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_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}}"\ - "${PKG_PKG_CONFIG:+PKG_CONFIG=${PKG_PKG_CONFIG}}" \ - "${PKG_PKG_CONFIG_PATH:+PKG_CONFIG_PATH=${PKG_PKG_CONFIG_PATH}}"\ - "LIBTOOL=${PKG_LIBTOOL:-slibtool}"; + rtl_run_cmd_unsplit make \ + ${PKG_MAKEFLAGS_BUILD:-} \ + ${PKG_MAKEFLAGS_BUILD_EXTRA:-} \ + "AR=${PKG_AR}" "${_no_autoconf:+CC=${PKG_CC}}" "RANLIB=${PKG_RANLIB}" \ + "${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}" \ + "${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}" \ + "${PKG_CPPFLAGS_BUILD:+CPPFLAGS=${PKG_CPPFLAGS_BUILD}}" \ + "${PKG_CPPFLAGS_BUILD_EXTRA:+CPPFLAGS+=${PKG_CPPFLAGS_BUILD_EXTRA}}" \ + "${PKG_CXXFLAGS_BUILD:+CXXFLAGS=${PKG_CXXFLAGS_BUILD}}" \ + "${PKG_CXXFLAGS_BUILD_EXTRA:+CXXFLAGS+=${PKG_CXXFLAGS_BUILD_EXTRA}}" \ + "${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}" \ + "${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}" \ + "${PKG_PKG_CONFIG:+PKG_CONFIG=${PKG_PKG_CONFIG}}" \ + "${PKG_PKG_CONFIG_PATH:+PKG_CONFIG_PATH=${PKG_PKG_CONFIG_PATH}}" \ + ${_libtool:+"LIBTOOL=${_libtool}"}; }; # vim:filetype=sh diff --git a/subr/pkg_clean.subr b/subr/pkg_clean.subr index a7df7920..39b0ead5 100644 --- a/subr/pkg_clean.subr +++ b/subr/pkg_clean.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_clean() { diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr index 974e708f..f2b64f92 100644 --- a/subr/pkg_configure.subr +++ b/subr/pkg_configure.subr @@ -1,20 +1,27 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_configure() { local _rc=0; - if [ -x "${PKG_CONFIGURE}" ]; then - rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}" PYTHON "${PKG_PYTHON}"; + if [ -x "${PKG_CONFIGURE:-}" ]; then + 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}" \ - 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}; _rc="${?}" - rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}" PYTHON "${PKG_PYTHON}"; + 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:-}; + _rc="${?}" + rtl_export_vars -u \ + PKG_CONFIG "${PKG_PKG_CONFIG:-}" \ + PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH:-}" \ + PYTHON "${PKG_PYTHON:-}"; return "${_rc}"; fi; }; diff --git a/subr/pkg_configure_autotools.subr b/subr/pkg_configure_autotools.subr index 32daedc1..86a9dd39 100644 --- a/subr/pkg_configure_autotools.subr +++ b/subr/pkg_configure_autotools.subr @@ -1,12 +1,12 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_configure_autotools() { local _config_cache="" _fname="" _subdir_tgt=""; if rtl_exists_any "${PKG_BASE_DIR}/${PKG_SUBDIR}" \ "config.guess" "configure.ac" "configure.in" "configure"; - then 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 [ "${PKG_FORCE_AUTORECONF:-0}" -eq 1 ]\ && ! (cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoreconf -fiv); then return 1; @@ -50,10 +50,11 @@ pkg_configure_autotools() { if ! rtl_fileop touch "${PKG_BUILD_DIR}/config.cache"; then return 1; else for _config_cache in \ - "${PKG_CONFIG_CACHE}" \ - "${PKG_CONFIG_CACHE_LOCAL}" \ - "${PKG_CONFIG_CACHE_EXTRA}"; - do if ! printf "%s" "${_config_cache}" |\ + "${PKG_CONFIG_CACHE:-}" \ + "${PKG_CONFIG_CACHE_LOCAL:-}" \ + "${PKG_CONFIG_CACHE_EXTRA:-}"; + do if [ -n "${_config_cache}" ]\ + && ! printf "%s\n" "${_config_cache}" |\ tr " " "\n" >> "${PKG_BUILD_DIR}/config.cache"; then return 1; fi; @@ -63,7 +64,7 @@ pkg_configure_autotools() { fi; fi; fi; - 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 88f3f3d1..6b4bcdd3 100644 --- a/subr/pkg_configure_patch.subr +++ b/subr/pkg_configure_patch.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_configure_patch() { @@ -10,7 +10,7 @@ pkg_configure_patch() { "${_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 + ${PKG_PATCHES_EXTRA:-}; do if [ -r "${_patch_fname}" ]\ && ! rtl_lmatch "${_patches_done}" "${_patch_fname}"; then if ! patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_patch_fname}"; then diff --git a/subr/pkg_configure_patch_pre.subr b/subr/pkg_configure_patch_pre.subr index 434b1cf7..c78b65b2 100644 --- a/subr/pkg_configure_patch_pre.subr +++ b/subr/pkg_configure_patch_pre.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkgp_configure_patch_pre() { @@ -15,8 +15,11 @@ pkgp_configure_patch_pre() { }; 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=""; + local _chainport_patch_dname="" _chainport_patch_fname="" _oldpwd=""; + _chainport_patch_dname="${PKG_BASE_DIR}/${PKG_SUBDIR}/patches/${PKG_NAME%%_*}"; + if [ -n "${PKG_VERSION:-}" ]; then + _chainport_patch_fname="${BUILD_WORKDIR}/chainport/patches/${PKG_NAME%%_*}/${PKG_NAME%%_*}-${PKG_VERSION}.midipix.patch"; + fi; if [ -e "${_chainport_patch_fname}" ]; then if ! rtl_fileop mkdir "${_chainport_patch_dname}"\ || ! rtl_fileop cp "${_chainport_patch_fname}" "${_chainport_patch_dname}"; then diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr index 126675ad..57cad8be 100644 --- a/subr/pkg_fetch_download.subr +++ b/subr/pkg_fetch_download.subr @@ -1,14 +1,14 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_fetch_download() { - if [ -n "${PKG_URL}" ]; then + if [ -n "${PKG_URL:-}" ]; then if ! rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}"; then return 1; fi; fi; - if [ -n "${PKG_URLS_GIT}" ]; then + if [ -n "${PKG_URLS_GIT:-}" ]; then if ! rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT}; then return 1; fi; diff --git a/subr/pkg_fetch_extract.subr b/subr/pkg_fetch_extract.subr index 8a9d8319..e91e7a6a 100644 --- a/subr/pkg_fetch_extract.subr +++ b/subr/pkg_fetch_extract.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkgp_fetch_extract_type() { @@ -12,7 +12,7 @@ pkgp_fetch_extract_type() { }; pkg_fetch_extract() { - if [ -n "${PKG_URL}" ]; then + if [ -n "${PKG_URL:-}" ]; then _oldpwd="${PWD}"; if ! rtl_fileop cd "${PKG_BASE_DIR}"\ || ! rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}"; then diff --git a/subr/pkg_install.subr b/subr/pkg_install.subr index 4cefa2d1..8a033572 100644 --- a/subr/pkg_install.subr +++ b/subr/pkg_install.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_install() { @@ -44,7 +44,7 @@ pkg_install() { return 1; else _pkglist_name="${PKG_BASE_DIR##*/}"; _pkglist_name="${_pkglist_name%%-*}"; - if ! printf "%s" "${_pkglist_name}" >> "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then + if ! printf "%s\n" "${_pkglist_name}" >> "${PREFIX}/pkglist.${PKG_BUILD_TYPE}"; then return 1; fi; fi; diff --git a/subr/pkg_install_files.subr b/subr/pkg_install_files.subr index 2c6703fb..76460da3 100644 --- a/subr/pkg_install_files.subr +++ b/subr/pkg_install_files.subr @@ -1,9 +1,9 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkgp_install_files() { - if [ -n "${PKG_INSTALL_FILES}" ]; then + if [ -n "${PKG_INSTALL_FILES:-}" ]; then if ! rtl_install -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES}; then return 1; fi; diff --git a/subr/pkg_install_libs.subr b/subr/pkg_install_libs.subr index 76c7bfdb..a13105ab 100644 --- a/subr/pkg_install_libs.subr +++ b/subr/pkg_install_libs.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkgp_install_libs_purge_la() { diff --git a/subr/pkg_install_make.subr b/subr/pkg_install_make.subr index 4babac8f..a5e58f60 100644 --- a/subr/pkg_install_make.subr +++ b/subr/pkg_install_make.subr @@ -1,16 +1,22 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_install_make() { - rtl_run_cmd_unsplit make \ - ${PKG_MAKEFLAGS_INSTALL} \ - ${PKG_MAKEFLAGS_INSTALL_EXTRA} \ - AR=${PKG_AR} CC=${PKG_CC} RANLIB=${PKG_RANLIB} \ - "${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}" \ - "LIBTOOL=${PKG_LIBTOOL:-slibtool}" \ - "${PKG_MAKE_INSTALL_VNAME:-DESTDIR}=${PKG_DESTDIR}/" \ - ${PKG_INSTALL_TARGET:=install}; + local _libtool=""; + case "${PKG_LIBTOOL:-}" in + "") _libtool=""; ;; + none) _libtool=""; ;; + *) _libtool="${PKG_LIBTOOL}"; ;; + esac; + rtl_run_cmd_unsplit make \ + ${PKG_MAKEFLAGS_INSTALL:-} \ + ${PKG_MAKEFLAGS_INSTALL_EXTRA:-} \ + AR="${PKG_AR}" CC="${PKG_CC}" RANLIB="${PKG_RANLIB}" \ + "${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}" \ + ${_libtool:+"LIBTOOL=${_libtool}"} \ + "${PKG_MAKE_INSTALL_VNAME:-DESTDIR}=${PKG_DESTDIR}/" \ + ${PKG_INSTALL_TARGET:-install}; }; # vim:filetype=sh diff --git a/subr/pkg_install_rpm.subr b/subr/pkg_install_rpm.subr index 6cc373ff..c0ba3e5e 100644 --- a/subr/pkg_install_rpm.subr +++ b/subr/pkg_install_rpm.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_install_rpm() { @@ -7,9 +7,9 @@ pkg_install_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 + if [ -n "${PKG_URL:-}" ]; then _pkg_url="${PKG_URL}"; _pkg_version_full="${PKG_VERSION}"; _pkg_version_rpm="${PKG_VERSION%%-*}"; - elif [ -n "${PKG_URLS_GIT}" ]; then + elif [ -n "${PKG_URLS_GIT:-}" ]; then _pkg_version_rpm="$(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse HEAD)"; _pkg_version_full="${_pkg_version_rpm} ($(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse --abbrev-ref HEAD))"; _pkg_url="${PKG_URLS_GIT%% *}"; _pkg_url="${_pkg_url##*=}"; _pkg_url="${_pkg_url%%@*}"; diff --git a/subr/pkg_install_subdirs.subr b/subr/pkg_install_subdirs.subr index 8e6e0429..c9e4cd39 100644 --- a/subr/pkg_install_subdirs.subr +++ b/subr/pkg_install_subdirs.subr @@ -1,12 +1,12 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkg_install_subdirs() { local _spec=""; for _spec in \ - "${PKG_INSTALL_FILES_DESTDIR}" \ - "${PKG_INSTALL_FILES_DESTDIR_EXTRA}"; do + "${PKG_INSTALL_FILES_DESTDIR:-}" \ + "${PKG_INSTALL_FILES_DESTDIR_EXTRA:-}"; do if ! rtl_install "${PKG_DESTDIR}" ${_spec}; then return 1; fi; diff --git a/subr/pkgtool_init.subr b/subr/pkgtool_init.subr index f92572fb..309dc612 100644 --- a/subr/pkgtool_init.subr +++ b/subr/pkgtool_init.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # pkgtoolp_init_args() { diff --git a/subr/rtl.subr b/subr/rtl.subr index f029a8e1..ef9d63ea 100644 --- a/subr/rtl.subr +++ b/subr/rtl.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # rtl_basename() { local _fname="${1##*/}"; printf "%s" "${_fname}"; }; diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr index 0e39178d..2ce5dd16 100644 --- a/subr/rtl_complex.subr +++ b/subr/rtl_complex.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # rtl_check_path_vars() { @@ -117,7 +117,7 @@ rtl_get_var_unsafe() { else _vname="${1}"; fi; - eval echo \${${_vname}}; + eval echo \${${_vname}} 2>/dev/null; }; rtl_get_vars_fast() { diff --git a/subr/rtl_fetch.subr b/subr/rtl_fetch.subr index e93d69eb..1fd72e99 100644 --- a/subr/rtl_fetch.subr +++ b/subr/rtl_fetch.subr @@ -1,11 +1,12 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset 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; + (set -o errexit -o noglob -o nounset; + trap "rm -f \"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching\"" EXIT; while true; do if flock -E 622 -w 3600 4; then break; @@ -67,7 +68,8 @@ rtl_fetch_url_wget() { _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; + (set -o errexit -o noglob -o nounset; + trap "_rc=\"\${?}\" ;rm -f \"${_url_dst}.fetching\"; exit \"\${_rc}\";" EXIT; while true; do if flock -E 622 -w 3600 4; then break; diff --git a/subr/rtl_fileop.subr b/subr/rtl_fileop.subr index fd45f67f..64538c59 100644 --- a/subr/rtl_fileop.subr +++ b/subr/rtl_fileop.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # # @@ -28,28 +28,28 @@ rtl_fileop() { case "${_op}" in cd) if [ \( -z "${1}" \) -o ! \( -L "${1}" -o -e "${1}" \) ]; then rtl_log_msg fatalexit "Invalid or non-existent directory \`%s'." "${1}"; - elif rtlp_fileop_check "${PREFIX}" "${1}"; then + elif rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Changing working directory to \`${1}'."; cd -- "${1}"; _rc="${?}"; fi; ;; chmod) if [ "${#}" -lt 2 ]; then rtl_log_msg fatalexit "Missing parameters (in: chmod %s.)" "${*}"; elif _mode="${1}" && shift\ - && rtlp_fileop_check "${PREFIX}" "${*}"; then + && rtlp_fileop_check "${PREFIX:-}" "${*}"; then rtlp_fileop_log "Changing file mode bits of \`${*}' to \`${_mode}'."; chmod -- "${_mode}" "${@}"; _rc="${?}"; fi; ;; chown) if [ "${#}" -lt 2 ]; then rtl_log_msg fatalexit "Missing parameters (in: chown %s.)" "${*}"; elif _owner="${1}" && shift\ - && rtlp_fileop_check "${PREFIX}" "${*}"; then + && rtlp_fileop_check "${PREFIX:-}" "${*}"; then rtlp_fileop_log "Changing file owner of \`${*}' to \`${_owner}'."; chown -- "${_owner}" "${@}"; _rc="${?}"; fi; ;; cp_follow) if [ "${#}" -lt 2 ]; then rtl_log_msg fatalexit "Missing parameters (in: cp_follow %s}.)" "${*}"; - elif rtlp_fileop_check "${PREFIX}" "${*}"; then + elif rtlp_fileop_check "${PREFIX:-}" "${*}"; then _src="${*}"; _src="${_src% *}"; _dst="${*}"; _dst="${_dst##* }"; rtlp_fileop_log "Copying \`${_src}' into \`${_dst}' w/ -pLR."; @@ -57,7 +57,7 @@ rtl_fileop() { fi; ;; cp) if [ "${#}" -lt 2 ]; then rtl_log_msg fatalexit "Missing parameters (in: cp %s.)" "${*}"; - elif rtlp_fileop_check "${PREFIX}" "${*}"; then + elif rtlp_fileop_check "${PREFIX:-}" "${*}"; then _src="${*}"; _src="${_src% *}"; _dst="${*}"; _dst="${_dst##* }"; rtlp_fileop_log "Copying \`${_src}' into \`${_dst}' w/ -pPR."; @@ -69,7 +69,7 @@ rtl_fileop() { else _dst="$(while [ ""${#}"" -gt 2 ]; do shift; done; printf "%s" "${2}")"; _install_args="$(while [ ""${#}"" -gt 2 ]; do printf "%s" "${1}"; shift; done)"; _src="$(while [ ""${#}"" -gt 2 ]; do shift; done; printf "%s" "${1}")"; - if rtlp_fileop_check "${PREFIX}" "${_dst}" "${_src}"; then + if rtlp_fileop_check "${PREFIX:-}" "${_dst}" "${_src}"; then rtlp_fileop_log "Installing \`${_src}' into \`${_dst}' w/ ${_install_args}."; install "${@}"; _rc="${?}"; fi; @@ -77,7 +77,7 @@ rtl_fileop() { ln_symbolic) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then rtl_log_msg fatalexit "Missing parameters (in: ln_symbolic %s.)" "${*}"; - elif rtlp_fileop_check "${PREFIX}" "${2}"; then + elif rtlp_fileop_check "${PREFIX:-}" "${2}"; then if rtl_fileop test "${2}"; then rtl_fileop rm "${2}"; fi; @@ -88,7 +88,7 @@ rtl_fileop() { fi; ;; mv) if [ \( -z "${1}" \) -o \( -z "${2}" \) ]; then rtl_log_msg fatalexit "Missing parameters (in: mv %s.)" "${*}"; - elif rtlp_fileop_check "${PREFIX}" "${1}" "${2}"; then + elif rtlp_fileop_check "${PREFIX:-}" "${1}" "${2}"; then rtlp_fileop_log "Moving \`${1}' to \`${2}' w/ -fs"; mv -f -- "${1}" "${2}"; _rc="${?}"; fi; ;; @@ -98,36 +98,36 @@ rtl_fileop() { rtl_log_msg fatalexit "Missing parameters (in: %s %s.)" "${_op}" "${*}"; elif [ "${_op}" = mkdir ]\ && [ ! -d "${1}" ]\ - && rtlp_fileop_check "${PREFIX}" "${1}"; then + && rtlp_fileop_check "${PREFIX:-}" "${1}"; then if rtl_fileop test "${1}"; then rtl_fileop rm "${1}"; fi; rtlp_fileop_log "Making directory \`${1}'."; mkdir -p -- "${1}"; _rc="${?}"; elif [ "${_op}" = mkfifo ]\ - && rtlp_fileop_check "${PREFIX}" "${1}"; then + && rtlp_fileop_check "${PREFIX:-}" "${1}"; then if rtl_fileop test "${1}"; then rtl_fileop rm "${1}"; fi; rtlp_fileop_log "Creating FIFO \`${1}'."; - rtlp_fileop_check "${PREFIX}" "${1}"; + rtlp_fileop_check "${PREFIX:-}" "${1}"; mkfifo -- "${1}"; _rc="${?}"; elif [ "${_op}" = rm ]\ && rtl_fileop test "${1}"\ - && rtlp_fileop_check "${PREFIX}" "${1}"; then + && rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Removing directory or file \`${1}'."; rm -rf -- "${1}"; _rc="${?}"; elif [ "${_op}" = source_opt ]\ && rtl_fileop test "${1}"\ - && rtlp_fileop_check "${PREFIX}" "${1}"; then + && rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Sourcing file \`${1}'."; . "${1}"; _rc="${?}"; elif [ "${_op}" = test ]\ - && rtlp_fileop_check "${PREFIX}" "${1}"\ + && rtlp_fileop_check "${PREFIX:-}" "${1}"\ && ! [ \( -L "${1}" \) -o \( -e "${1}" \) ]; then return 1; elif [ "${_op}" = touch ]\ - && rtlp_fileop_check "${PREFIX}" "${1}"; then + && rtlp_fileop_check "${PREFIX:-}" "${1}"; then rtlp_fileop_log "Touching file \`${1}'."; touch -- "${1}"; _rc="${?}"; fi; shift; diff --git a/subr/rtl_install.subr b/subr/rtl_install.subr index a1c70a01..b57c68f2 100644 --- a/subr/rtl_install.subr +++ b/subr/rtl_install.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # rtl_install() { diff --git a/subr/rtl_list.subr b/subr/rtl_list.subr index b1105bab..c4c563bf 100644 --- a/subr/rtl_list.subr +++ b/subr/rtl_list.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # rtl_lconcat() { @@ -45,7 +45,7 @@ rtl_llift() { }; rtl_lmatch() { - local _list="${1}" _item="${2}" _sep="${3}"; + local _list="${1}" _item="${2}" _sep="${3:- }"; [ -n "$(rtl_lsearch "${_list}" "${_item}" "${_sep}")" ]; }; diff --git a/subr/rtl_log.subr b/subr/rtl_log.subr index 860ccf03..b91d1374 100644 --- a/subr/rtl_log.subr +++ b/subr/rtl_log.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # # diff --git a/subr/rtl_state.subr b/subr/rtl_state.subr index 1ee8258b..6d539563 100644 --- a/subr/rtl_state.subr +++ b/subr/rtl_state.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # rtl_state_clear() { @@ -25,8 +25,7 @@ rtl_state_set() { }; rtl_state_test() { - local _workdir="${1}" _pkg_name="${2}" _build_step="${3}" \ - _restart_at="${4}" _done_fname=""; + 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}"; diff --git a/subr/rtl_string.subr b/subr/rtl_string.subr index 2dd9e27a..e642bebe 100644 --- a/subr/rtl_string.subr +++ b/subr/rtl_string.subr @@ -1,5 +1,5 @@ # -# set +o errexit -o noglob is assumed. +# set +o errexit -o noglob -o nounset is assumed. # rtl_isnumber() { |