|
|
e9fa07 |
#
|
|
|
8d7a8a |
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂa Andrea Illanes Albornoz <lucia@luciaillanes.de>
|
|
|
e9fa07 |
# set +o errexit -o noglob -o nounset is assumed.
|
|
|
e9fa07 |
#
|
|
|
d82a0f |
# Package variable and environment variable preparation
|
|
|
d82a0f |
# Package build (step) state setting and testing
|
|
|
d82a0f |
#
|
|
|
e9fa07 |
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
# exp_pkg_env_defaults() - set package variable defaults for single named package
|
|
|
e9fa07 |
# @_build_steps_default: list of default build steps
|
|
|
e9fa07 |
# @_pkg_name: single package name
|
|
|
e9fa07 |
# @_workdir: pathname to build-specific temporary directory
|
|
|
e9fa07 |
#
|
|
|
99f4d8 |
# Returns: zero (0) on success, non-zero (>0) on failure
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
exp_pkg_env_defaults() {
|
|
|
e9fa07 |
local _epped_build_steps_default="${1}" _epped_pkg_name="${2}" _epped_workdir="${3}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
: ${PKG_NAME:="${_epped_pkg_name}"};
|
|
|
e9fa07 |
: ${MIDIPIX_BUILD_PWD:="$(pwd)"};
|
|
|
e9fa07 |
: ${PKG_BASE_DIR:="${_epped_workdir}/${_epped_pkg_name}-${PKG_BUILD_TYPE}-${PKG_TARGET}"};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${PKG_BUILD_STEPS_DISABLE:+1}" = 1 ]; then
|
|
|
e9fa07 |
rtl_lfilter2 \$_epped_build_steps_default \$PKG_BUILD_STEPS "${PKG_BUILD_STEPS_DISABLE:-}";
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
: ${PKG_BUILD_STEPS:="${_epped_build_steps_default}"};
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${PKG_URL:+1}" = 1 ]; then
|
|
|
e9fa07 |
: ${PKG_FNAME:="${PKG_URL##*/}"};
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${PKG_SUBDIR:+1}" != 1 ]; then
|
|
|
e9fa07 |
if [ "${PKG_URLS_GIT:+1}" = 1 ]\
|
|
|
e9fa07 |
&& [ "${PKG_FNAME:+1}" = 1 ]; then
|
|
|
4243a1 |
rtl_log_msgV "fatalexit" "${MSG_pkg_fail_missing_vars}";
|
|
|
e9fa07 |
elif [ "${PKG_URLS_GIT:+1}" = 1 ]; then
|
|
|
e9fa07 |
PKG_SUBDIR="${PKG_URLS_GIT%%=*}";
|
|
|
e9fa07 |
else case "${PKG_FNAME:-}" in
|
|
|
e9fa07 |
*.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;;
|
|
|
e9fa07 |
*) PKG_SUBDIR="${_epped_pkg_name}"; ;;
|
|
|
e9fa07 |
esac; fi;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if [ "${PKG_BUILD_DIR:+1}" != 1 ]; then
|
|
|
e9fa07 |
case "${PKG_IN_TREE:-0}" in
|
|
|
e9fa07 |
0) PKG_BUILD_DIR="obj"; ;;
|
|
|
e9fa07 |
1) PKG_BUILD_DIR="${PKG_SUBDIR}"; ;;
|
|
|
e9fa07 |
esac;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
PKG_BUILD_DIR="${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
|
|
|
e9fa07 |
PKG_CONFIGURE="${PKG_BASE_DIR}/${PKG_CONFIGURE:-${PKG_SUBDIR}/configure}";
|
|
|
e9fa07 |
PKG_DESTDIR="${PKG_BASE_DIR}/${PKG_DESTDIR:-destdir}";
|
|
|
e9fa07 |
PKG_DESTDIR_HOST="${PKG_BASE_DIR}/${PKG_DESTDIR_HOST:-destdir_host}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
# exp_pkg_env_set() - set package variables for single named package
|
|
|
e9fa07 |
# @_build_vars_default: list of default build variables
|
|
|
e9fa07 |
# @_group_name: build group name
|
|
|
e9fa07 |
# @_pkg_name: single package name
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
# Sets package variables from either defaults, defaults specific to build type,
|
|
|
e9fa07 |
# build group, package to inherit from if any, or package for a single named
|
|
|
e9fa07 |
# package, and exports variables optionally named in ${PKG_ENV_VARS_EXTRA}.
|
|
|
e9fa07 |
#
|
|
|
99f4d8 |
# Returns: zero (0) on success, non-zero (>0) on failure
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
exp_pkg_env_set() {
|
|
|
1b1772 |
local _eppes_build_vars_default="${1}" _eppes_group_name="${2}" _eppes_pkg_name="${3}" \
|
|
|
1b1772 |
_eppes_lvars="" _eppes_var_prefixes="" _eppes_vars_set="" \
|
|
|
e9fa07 |
_eppes_vars_unset="" _eppes_vname="" _eppes_vnames="" IFS IFS0;
|
|
|
e9fa07 |
|
|
|
4243a1 |
rtl_set_var _eppes_vars_set BUILD_TYPE "DEFAULT ${_eppes_group_name} PKG_${_eppes_pkg_name}";
|
|
|
4243a1 |
rtl_set_var _eppes_vars_set INHERIT_FROM "PKG_${_eppes_pkg_name}";
|
|
|
e9fa07 |
_eppes_var_prefixes="DEFAULT DEFAULT_${PKG_BUILD_TYPE} ${_eppes_group_name}";
|
|
|
e9fa07 |
rtl_toupper \$_eppes_var_prefixes;
|
|
|
e9fa07 |
rtl_lfilter2 \$_eppes_build_vars_default \$_eppes_vnames BUILD_TYPE;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
for _eppes_vname in ${_eppes_vnames}; do
|
|
|
e9fa07 |
if [ "${PKG_INHERIT_FROM:+1}" = 1 ]; then
|
|
|
e9fa07 |
_eppes_lvars="PKG_${PKG_INHERIT_FROM} PKG_${PKG_INHERIT_FROM}_${BUILD_KIND} PKG_${_eppes_pkg_name} PKG_${_eppes_pkg_name}_${BUILD_KIND}";
|
|
|
e9fa07 |
rtl_toupper \$_eppes_lvars;
|
|
|
e9fa07 |
rtl_lconcat2 \$_eppes_lvars \$_eppes_var_prefixes "${_eppes_lvars}";
|
|
|
4243a1 |
rtl_set_var _eppes_vars_set "${_eppes_vname}" "${_eppes_lvars}";
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
_eppes_lvars="PKG_${_eppes_pkg_name} PKG_${_eppes_pkg_name}_${BUILD_KIND}";
|
|
|
e9fa07 |
rtl_toupper \$_eppes_lvars;
|
|
|
e9fa07 |
rtl_lconcat2 \$_eppes_lvars \$_eppes_var_prefixes "${_eppes_lvars}";
|
|
|
4243a1 |
rtl_set_var _eppes_vars_set "${_eppes_vname}" "${_eppes_lvars}";
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
done;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
IFS0="${IFS:- }"; IFS=":"; for _eppes_vname in ${PKG_ENV_VARS_EXTRA:-}; do
|
|
|
e9fa07 |
export "${_eppes_vname}";
|
|
|
e9fa07 |
done; IFS="${IFS0}";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
# ex_pkg_env() - set package variables for single named package
|
|
|
e9fa07 |
# @_build_steps_default: list of default build steps
|
|
|
e9fa07 |
# @_build_vars_default: list of default build variables
|
|
|
e9fa07 |
# @_group_name: build group name
|
|
|
e9fa07 |
# @_pkg_name: single package name
|
|
|
e9fa07 |
# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL or LAST
|
|
|
e9fa07 |
# @_workdir: pathname to build-specific temporary directory
|
|
|
e9fa07 |
#
|
|
|
99f4d8 |
# Returns: zero (0) on success, non-zero (>0) on failure
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
ex_pkg_env() {
|
|
|
fd38dc |
local _epe_build_steps_default="${1}" _epe_build_vars_default="${2}" \
|
|
|
fd38dc |
_epe_group_name="${3}" _epe_pkg_name="${4}" _epe_restart_at="${5}" \
|
|
|
fd38dc |
_epe_workdir="${6}" \
|
|
|
fd38dc |
_epe_inherit_from="" _epe_pkg_version="" _epe_vars_file="" \
|
|
|
fd38dc |
_epe_vars_file_parent="" _epe_vname="";
|
|
|
e9fa07 |
|
|
|
e9fa07 |
if rtl_get_var_unsafe \$_epe_inherit_from -u "PKG_${_epe_pkg_name}_INHERIT_FROM"\
|
|
|
e9fa07 |
&& [ "${_epe_inherit_from:+1}" = 1 ]; then
|
|
|
703de4 |
rtl_get_var_unsafe \$_epe_vars_file_parent -u "PKG_${_epe_inherit_from}_VARS_FILE";
|
|
|
703de4 |
rtl_get_var_unsafe \$_epe_vars_file -u "PKG_${_epe_pkg_name}_VARS_FILE";
|
|
|
703de4 |
if [ "${_epe_vars_file:+1}" != 1 ]; then
|
|
|
703de4 |
_epe_vars_file="${_epe_vars_file_parent}";
|
|
|
703de4 |
fi;
|
|
|
e9fa07 |
else
|
|
|
e9fa07 |
rtl_get_var_unsafe \$_epe_vars_file -u "PKG_${_epe_pkg_name}_VARS_FILE";
|
|
|
e9fa07 |
fi;
|
|
|
703de4 |
|
|
|
e9fa07 |
if [ "${_epe_vars_file:+1}" != 1 ]; then
|
|
|
fd38dc |
rtl_get_var_unsafe \$_epe_pkg_version -u "PKG_${_epe_pkg_name}_VERSION";
|
|
|
138059 |
ex_pkg_get_default \
|
|
|
138059 |
\$_epe_vars_file 1 \
|
|
|
138059 |
"${_epe_pkg_name}" "${_epe_pkg_version}" \
|
|
|
138059 |
"vars_file" \
|
|
|
fd38dc |
|| return 1;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
rtl_fileop source_opt "${_epe_vars_file}" "${_epe_group_name}/${_epe_pkg_name}.${_epe_group_name}";
|
|
|
e9fa07 |
if ! exp_pkg_env_set "${_epe_build_vars_default}" "${_epe_group_name}" "${_epe_pkg_name}"\
|
|
|
e9fa07 |
|| ! exp_pkg_env_defaults "${_epe_build_steps_default}" "${_epe_pkg_name}" "${_epe_workdir}"; then
|
|
|
e9fa07 |
return 1;
|
|
|
e9fa07 |
fi;
|
|
|
e9fa07 |
|
|
|
e9fa07 |
return 0;
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
# ex_pkg_state_set() - update build step status for single named package
|
|
|
e9fa07 |
# @_pkg_name: single package name
|
|
|
e9fa07 |
# @_build_step: build step set status of
|
|
|
dbea96 |
# @...: optional list of build steps to invalidate status of
|
|
|
e9fa07 |
#
|
|
|
99f4d8 |
# Returns: zero (0) on success, non-zero (>0) on failure
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
ex_pkg_state_set() {
|
|
|
e9fa07 |
rtl_state_set "${BUILD_WORKDIR}" "${@}";
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
|
|
|
e9fa07 |
ex_pkg_state_set2() {
|
|
|
e9fa07 |
local _epss2_workdir="${1}"; shift;
|
|
|
e9fa07 |
rtl_state_set "${_epss2_workdir}" "${@}";
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
# ex_pkg_state_test() - test build step status of single named package
|
|
|
e9fa07 |
# @_pkg_name: single package name
|
|
|
e9fa07 |
# @_build_step: build step to test status of
|
|
|
e9fa07 |
# @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL or LAST
|
|
|
e9fa07 |
#
|
|
|
99f4d8 |
# Returns: zero (0) on success, non-zero (>0) on failure
|
|
|
e9fa07 |
#
|
|
|
e9fa07 |
ex_pkg_state_test() {
|
|
|
e9fa07 |
rtl_state_test "${BUILD_WORKDIR}" "${@}";
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
e9fa07 |
ex_pkg_state_test2() {
|
|
|
e9fa07 |
local _epst2_workdir="${1}"; shift;
|
|
|
e9fa07 |
rtl_state_test "${_epst2_workdir}" "${@}";
|
|
|
e9fa07 |
};
|
|
|
e9fa07 |
|
|
|
64844b |
# vim:filetype=sh textwidth=0
|