|
|
8f29b4 |
#
|
|
|
8f29b4 |
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂa Andrea Illanes Albornoz <lucia@luciaillanes.de>
|
|
|
8f29b4 |
# set +o errexit -o noglob -o nounset is assumed.
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# ex_pkg_check_depends() - check single named package for unsatisfied dependencies
|
|
|
8f29b4 |
# @_checkfl: enable (1) or inhibit (0) dependency expansion
|
|
|
8f29b4 |
# @_rpkg_disabled: in reference to variable of list of disabled packages
|
|
|
8f29b4 |
# @_rpkg_finished: in reference to variable of list of finished packages
|
|
|
8f29b4 |
# @_pkg_name: single package name
|
|
|
8f29b4 |
# @_rpkg_names: in reference to variable of list of package names
|
|
|
8f29b4 |
# @_workdir: pathname to build-specific temporary directory
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# Returns: zero (0) given no outstanding dependencies, non-zero (>0) otherwise
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
ex_pkg_check_depends() {
|
|
|
8f29b4 |
local _epcd_checkfl="${1}" _epcd_rpkg_disabled="${2}" _epcd_rpkg_finished="${3#\$}" \
|
|
|
8f29b4 |
_epcd_pkg_name="${4}" _epcd_rpkg_names="${5#\$}" _epcd_workdir="${6}" \
|
|
|
8f29b4 |
_epcd_dependfl=0 _epcd_depends="" _epcd_pkg_name_depend="";
|
|
|
8f29b4 |
|
|
|
8f29b4 |
if [ "${_epcd_checkfl}" -eq 1 ]\
|
|
|
8f29b4 |
&& rtl_get_var_unsafe \$_epcd_depends -u "PKG_"${_epcd_pkg_name}"_DEPENDS"\
|
|
|
8f29b4 |
&& [ "${_epcd_depends:+1}" = 1 ]; then
|
|
|
8f29b4 |
for _epcd_pkg_name_depend in ${_epcd_depends}; do
|
|
|
8f29b4 |
if ! rtl_lmatch "${_epcd_rpkg_disabled}" "${_epcd_pkg_name_depend}"\
|
|
|
8f29b4 |
&& ! ex_pkg_state_test2 "${_epcd_workdir}" "${_epcd_pkg_name_depend}" finish;
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
if ! rtl_lmatch "${_epcd_rpkg_names}" "${_epcd_pkg_name_depend}"; then
|
|
|
8f29b4 |
rtl_log_msgV "fatalexit" "${MSG_build_unknown_dep}" "${_epcd_pkg_name_depend}" "${_epcd_pkg_name}";
|
|
|
8f29b4 |
else
|
|
|
8f29b4 |
_epcd_dependfl=1; break;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
return "${_epcd_dependfl}";
|
|
|
8f29b4 |
};
|
|
|
8f29b4 |
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# ex_pkg_check_depends_unknown() - check single named package for unknown dependencies
|
|
|
8f29b4 |
# @_pkg_name: single package name
|
|
|
8f29b4 |
# @_rpkg_names_set: in reference to variable of set of package names
|
|
|
8f29b4 |
# @_rpkg_unknown: out reference to variable of list of finished packages
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# Returns: zero (0) given no unknown dependencies, non-zero (>0) otherwise
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
ex_pkg_check_depends_unknown() {
|
|
|
8f29b4 |
local _epcdu_pkg_name="${1}" _epcdu_rpkg_names_set="${2#\$}" \
|
|
|
8f29b4 |
_epcdu_rpkg_unknown="${3#\$}" \
|
|
|
8f29b4 |
_epcdu_defined=0 _epcdu_depends="" _epcdu_pkg_name_depend="" \
|
|
|
8f29b4 |
_epcdu_rc=0;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
if rtl_get_var_unsafe \$_epcdu_depends -u "PKG_"${_epcdu_pkg_name}"_DEPENDS"\
|
|
|
8f29b4 |
&& [ "${_epcdu_depends:+1}" = 1 ]; then
|
|
|
8f29b4 |
for _epcdu_pkg_name_depend in ${_epcdu_depends}; do
|
|
|
8f29b4 |
if [ "${_epcdu_pkg_name_depend#*:*}" != "${_epcdu_pkg_name_depend}" ]; then
|
|
|
8f29b4 |
continue;
|
|
|
8f29b4 |
elif ! rtl_get_var_unsafe \$_epcdu_defined "${_epcdu_rpkg_names_set}_${_epcdu_pkg_name_depend}"\
|
|
|
8f29b4 |
|| [ "${_epcdu_defined:-0}" -eq 0 ]; then
|
|
|
8f29b4 |
rtl_lconcat "${_epcdu_rpkg_unknown}" "${_epcdu_pkg_name_depend}";
|
|
|
8f29b4 |
_epcdu_rc=1;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
return "${_epcdu_rc}";
|
|
|
8f29b4 |
};
|
|
|
8f29b4 |
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# ex_pkg_unfold_depends() - unfold list of package names into dependency-expanded set of complete, disabled, finished, and outstanding package names
|
|
|
8f29b4 |
# @_rdisabled: in reference to out variable of disabled packages
|
|
|
8f29b4 |
# @_rfinished: in reference to out variable of finished packages
|
|
|
8f29b4 |
# @_rnames: out reference to variable of package names
|
|
|
8f29b4 |
# @_checkfl: enable (1) or inhibit (0) dependency expansion
|
|
|
8f29b4 |
# @_forcefl: enable (1) or inhibit (0) forcibly rebuilding finished packages
|
|
|
8f29b4 |
# @_group_name: build group name
|
|
|
8f29b4 |
# @_pkg_names: list of package names
|
|
|
8f29b4 |
# @_restart: optional whitespace-separated list of package names to rebuild
|
|
|
8f29b4 |
# @_test_finished: only exclude disabled packages (0,) split finished packages
|
|
|
8f29b4 |
# @_workdir: pathname to build-specific temporary directory
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# Returns: zero (0) on success, non-zero (>0) on failure.
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
ex_pkg_unfold_depends() {
|
|
|
8f29b4 |
local _epud_rdisabled="${1#\$}" _epud_rfinished="${2#\$}" _epud_rnames="${3#\$}" \
|
|
|
8f29b4 |
_epud_checkfl="${4}" _epud_forcefl="${5}" _epud_group_name="${6}" \
|
|
|
8f29b4 |
_epud_pkg_names="${7}" _epud_restart="${8}" _epud_test_finished="${9}" \
|
|
|
8f29b4 |
_epud_workdir="${10}" \
|
|
|
8f29b4 |
_epud_depends="" _epud_pkg_disabled="" _epud_pkg_force="" _epud_pkg_name="" \
|
|
|
8f29b4 |
_epud_pkg_name_depend="" _epud_pkg_names_new="" _epud_pkg_names_set="" \
|
|
|
8f29b4 |
_epud_pkg_unknown="" _epud_restartfl=0 _epud_unknown_depends=0;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
if [ "${_epud_restart:+1}" = 1 ]\
|
|
|
8f29b4 |
&& ! rtl_lmatch \$_epud_restart "ALL LAST"; then
|
|
|
8f29b4 |
rtl_lsearch \$_epud_pkg_names "${_epud_restart}";
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
if [ "${_epud_restart:+1}" = 1 ]\
|
|
|
8f29b4 |
&& [ "${_epud_checkfl:-0}" -eq 1 ]; then
|
|
|
8f29b4 |
rtl_lunfold_dependsV 'PKG_${_rld_name}_DEPENDS' \$_epud_pkg_names ${_epud_pkg_names};
|
|
|
8f29b4 |
_epud_pkg_names="$(rtl_uniq ${_epud_pkg_names})";
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
rtl_llift_set \$_epud_pkg_names \$_epud_pkg_names_set;
|
|
|
8f29b4 |
for _epud_pkg_name in ${_epud_pkg_names}; do
|
|
|
8f29b4 |
if rtl_get_var_unsafe \$_epud_depends -u "PKG_"${_epud_pkg_name}"_DEPENDS"\
|
|
|
8f29b4 |
&& [ "${_epud_depends:+1}" = 1 ]; then
|
|
|
8f29b4 |
_epud_pkg_unknown="";
|
|
|
8f29b4 |
if ! ex_pkg_check_depends_unknown "${_epud_pkg_name}" \$_epud_pkg_names_set \$_epud_pkg_unknown; then
|
|
|
8f29b4 |
for _epud_pkg_name_depend in ${_epud_pkg_unknown}; do
|
|
|
8f29b4 |
rtl_log_msgV "warning" "${MSG_build_unknown_dep}" "${_epud_pkg_name_depend}" "${_epud_pkg_name}";
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
_epud_unknown_depends=1;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
if [ "${_epud_restart}" = "ALL" ]\
|
|
|
8f29b4 |
|| rtl_lmatch \$_epud_restart "${_epud_pkg_name}"; then
|
|
|
8f29b4 |
_epud_restartfl=1;
|
|
|
8f29b4 |
else
|
|
|
8f29b4 |
_epud_restartfl=0;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
if rtl_get_var_unsafe \$_epud_pkg_disabled -u "PKG_${_epud_pkg_name}_DISABLED"\
|
|
|
8f29b4 |
&& [ "${_epud_pkg_disabled}" = 1 ];
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
rtl_lconcat "${_epud_rdisabled}" "${_epud_pkg_name}";
|
|
|
8f29b4 |
|
|
|
8f29b4 |
elif [ "${_epud_test_finished:-1}" -eq 1 ]\
|
|
|
8f29b4 |
&& ex_pkg_state_test2 "${_epud_workdir}" "${_epud_pkg_name}" finish\
|
|
|
8f29b4 |
&& [ "${_epud_restartfl:-0}" -eq 0 ]\
|
|
|
8f29b4 |
&& [ "${_epud_forcefl:-0}" -ne 1 ]\
|
|
|
8f29b4 |
&& rtl_get_var_unsafe \$_epud_pkg_force -u "${_epud_group_name}_FORCE"\
|
|
|
8f29b4 |
&& [ "${_epud_pkg_force}" != 1 ];
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
rtl_lconcat "${_epud_rfinished}" "${_epud_pkg_name}";
|
|
|
8f29b4 |
|
|
|
8f29b4 |
else
|
|
|
8f29b4 |
rtl_lconcat \$_epud_pkg_names_new "${_epud_pkg_name}";
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
rtl_llift_unset \$_epud_pkg_names_set;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
if [ "${_epud_unknown_depends}" -eq 1 ]; then
|
|
|
8f29b4 |
rtl_log_msgV "warning" "${MSG_build_unknown_deps}";
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
eval ${_epud_rdisabled}='$(rtl_uniq2 "${_epud_rdisabled}")';
|
|
|
8f29b4 |
eval ${_epud_rfinished}='$(rtl_uniq2 "${_epud_rfinished}")';
|
|
|
8f29b4 |
eval ${_epud_rnames}='$(rtl_uniq "${_epud_pkg_names_new}")';
|
|
|
8f29b4 |
|
|
|
8f29b4 |
return 0;
|
|
|
8f29b4 |
};
|
|
|
8f29b4 |
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# ex_pkg_unfold_rdepends() - unfold list of package names into reverse dependency-expanded set of complete, disabled, finished, and outstanding package names
|
|
|
8f29b4 |
# @_rdisabled: in reference to out variable of disabled packages
|
|
|
8f29b4 |
# @_rfinished: in reference to out variable of finished packages
|
|
|
8f29b4 |
# @_rnames: out reference to variable of package names
|
|
|
8f29b4 |
# @_group_name: build group name
|
|
|
8f29b4 |
# @_pkg_names: list of package names
|
|
|
8f29b4 |
# @_restart: optional whitespace-separated list of package names to rebuild
|
|
|
8f29b4 |
# @_test_finished: only exclude disabled packages (0,) split finished packages
|
|
|
8f29b4 |
# @_workdir: pathname to build-specific temporary directory
|
|
|
8f29b4 |
# @_recursefl: resolve recursively ("recurse") or non-recursively ("norecurse")
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
# Returns: zero (0) on success, non-zero (>0) on failure.
|
|
|
8f29b4 |
#
|
|
|
8f29b4 |
ex_pkg_unfold_rdepends() {
|
|
|
8f29b4 |
local _epur_rdisabled="${1#\$}" _epur_rfinished="${2#\$}" _epur_rnames="${3#\$}" \
|
|
|
8f29b4 |
_epur_group_name="${4}" _epur_pkg_names="${5}" _epur_restart="${6}" \
|
|
|
8f29b4 |
_epur_test_finished="${7}" _epur_workdir="${8}" _epur_recursefl="${9}" \
|
|
|
8f29b4 |
_epur_depends="" _epur_disabled=0 _epur_force=0 _epur_pkg_depends="" \
|
|
|
8f29b4 |
_epur_pkg_name="" _epur_pkg_names_new="" _epur_pkg_name_depend="" \
|
|
|
8f29b4 |
_epur_pkg_name_rdepend="" _epur_pkg_rdepends="";
|
|
|
8f29b4 |
|
|
|
8f29b4 |
for _epur_pkg_name_depend in ${_epur_restart}; do
|
|
|
8f29b4 |
for _epur_pkg_name in ${_epur_pkg_names}; do
|
|
|
8f29b4 |
if [ "${_epur_pkg_name}" = "${_epur_pkg_name_depend}" ]; then
|
|
|
8f29b4 |
continue;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
elif rtl_get_var_unsafe \$_epur_depends -u "PKG_"${_epur_pkg_name}"_DEPENDS"\
|
|
|
8f29b4 |
&& rtl_lunfold_dependsV 'PKG_${_rld_name}_DEPENDS' \$_epur_pkg_depends ${_epur_depends}\
|
|
|
8f29b4 |
&& [ "${_epur_pkg_depends:+1}" = 1 ]\
|
|
|
8f29b4 |
&& rtl_lmatch \$_epur_pkg_depends "${_epur_pkg_name_depend}";
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
case "${_epur_recursefl}" in
|
|
|
8f29b4 |
recurse) _epur_pkg_rdepends="${_epur_pkg_name} ${_epur_pkg_depends}"; ;;
|
|
|
8f29b4 |
norecurse) _epur_pkg_rdepends="${_epur_pkg_name}"; ;;
|
|
|
8f29b4 |
esac;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
for _epur_pkg_name_rdepend in ${_epur_pkg_rdepends}; do
|
|
|
8f29b4 |
if rtl_get_var_unsafe \$_epur_disabled -u "PKG_${_epur_pkg_name_rdepend}_DISABLED"\
|
|
|
8f29b4 |
&& [ "${_epur_disabled}" = 1 ];
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
rtl_lconcat "${_epur_rdisabled}" "${_epur_pkg_name_rdepend}";
|
|
|
8f29b4 |
|
|
|
8f29b4 |
elif [ "${_epur_test_finished}" -eq 1 ]\
|
|
|
8f29b4 |
&& ex_pkg_state_test2 "${_epur_workdir}" "${_epur_pkg_name_rdepend}" finish\
|
|
|
8f29b4 |
&& rtl_get_var_unsafe \$_epur_force -u "${_epur_group_name}_FORCE"\
|
|
|
8f29b4 |
&& [ "${_epur_force}" != 1 ];
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
rtl_lconcat "${_epur_rfinished}" "${_epur_pkg_name_rdepend}";
|
|
|
8f29b4 |
|
|
|
8f29b4 |
elif [ "${_epur_test_finished:-1}" -eq 0 ]\
|
|
|
8f29b4 |
|| ! ex_pkg_state_test2 "${_epur_workdir}" "${_epur_pkg_name_rdepend}" finish\
|
|
|
8f29b4 |
|| ( rtl_get_var_unsafe \$_epur_force -u "${_epur_group_name}_FORCE"\
|
|
|
8f29b4 |
&& [ "${_epur_force}" = 1 ] );
|
|
|
8f29b4 |
then
|
|
|
8f29b4 |
rtl_lconcat \$_epur_pkg_names_new "${_epur_pkg_name_rdepend}";
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
fi;
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
done;
|
|
|
8f29b4 |
|
|
|
8f29b4 |
eval ${_epur_rdisabled}='$(rtl_uniq2 "${_epur_rdisabled}")';
|
|
|
8f29b4 |
eval ${_epur_rfinished}='$(rtl_uniq2 "${_epur_rfinished}")';
|
|
|
8f29b4 |
eval ${_epur_rnames}='$(rtl_uniq "${_epur_pkg_names_new}")';
|
|
|
8f29b4 |
|
|
|
8f29b4 |
return 0;
|
|
|
8f29b4 |
};
|
|
|
8f29b4 |
|
|
|
8f29b4 |
# vim:filetype=sh textwidth=0
|