From 874146a1ea7edca2564152e8de17c9e2361ac092 Mon Sep 17 00:00:00 2001 From: LucĂ­a Andrea Illanes Albornoz Date: Apr 24 2024 14:14:20 +0000 Subject: Register groups w/ ex_pkg_register_group(). --- diff --git a/groups.d/000.host_tools.group b/groups.d/000.host_tools.group index 31fe06c..b00996a 100644 --- a/groups.d/000.host_tools.group +++ b/groups.d/000.host_tools.group @@ -7,4 +7,6 @@ HOST_TOOLS_MAKEFLAGS_INSTALL="prefix= PREFIX="; HOST_TOOLS_PREFIX="${PREFIX}"; HOST_TOOLS_RPM_DISABLE=1; +ex_pkg_register_group "host_tools" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/010.host_deps.group b/groups.d/010.host_deps.group index 1f188df..6c7c828 100644 --- a/groups.d/010.host_deps.group +++ b/groups.d/010.host_deps.group @@ -13,4 +13,6 @@ HOST_DEPS_PKG_CONFIG="${PREFIX}/bin/pkgconf"; HOST_DEPS_PREFIX="${PREFIX}"; HOST_DEPS_TOOLS_RPM_DISABLE=1; +ex_pkg_register_group "host_deps" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/020.host_deps_rpm.group b/groups.d/020.host_deps_rpm.group index c3ebf57..6376d24 100644 --- a/groups.d/020.host_deps_rpm.group +++ b/groups.d/020.host_deps_rpm.group @@ -13,4 +13,6 @@ HOST_DEPS_RPM_PKG_CONFIG="${PREFIX}/bin/pkgconf"; HOST_DEPS_RPM_PREFIX="${PREFIX}"; HOST_DEPS_RPM_RPM_DISABLE=1; +ex_pkg_register_group "host_deps_rpm" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/030.cross_toolchain.group b/groups.d/030.cross_toolchain.group index 111e388..148f93d 100644 --- a/groups.d/030.cross_toolchain.group +++ b/groups.d/030.cross_toolchain.group @@ -9,4 +9,6 @@ CROSS_TOOLCHAIN_PKG_CONFIG="${PREFIX}/bin/pkgconf"; CROSS_TOOLCHAIN_PREFIX="${PREFIX_LOCAL}"; CROSS_TOOLCHAIN_RPM_DISABLE=1; +ex_pkg_register_group "cross_toolchain" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/040.host_toolchain.group b/groups.d/040.host_toolchain.group index c7657dc..649feba 100644 --- a/groups.d/040.host_toolchain.group +++ b/groups.d/040.host_toolchain.group @@ -9,4 +9,6 @@ HOST_TOOLCHAIN_PKG_CONFIG="${PREFIX}/bin/pkgconf"; HOST_TOOLCHAIN_PREFIX="${PREFIX_CROSS}"; HOST_TOOLCHAIN_RPM_DISABLE=1; +ex_pkg_register_group "host_toolchain" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/100.native_tools.group b/groups.d/100.native_tools.group index 70e5df5..eea03fe 100644 --- a/groups.d/100.native_tools.group +++ b/groups.d/100.native_tools.group @@ -7,4 +7,6 @@ NATIVE_TOOLS_MAKEFLAGS_INSTALL="PREFIX= prefix="; NATIVE_TOOLS_PKG_CONFIG_LIBDIR="${PREFIX_NATIVE}/lib/pkgconfig"; NATIVE_TOOLS_PREFIX="${PREFIX_NATIVE}"; +ex_pkg_register_group "native_tools" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/110.native_toolchain.group b/groups.d/110.native_toolchain.group index 014ed80..bc19764 100644 --- a/groups.d/110.native_toolchain.group +++ b/groups.d/110.native_toolchain.group @@ -5,4 +5,6 @@ NATIVE_TOOLCHAIN_CONFIGURE_ARGS="--disable-nls --host=${DEFAULT_TARGET} --progra NATIVE_TOOLCHAIN_GROUP_DEPENDS="host_deps host_deps_rpm cross_toolchain host_toolchain host_tools native_tools"; NATIVE_TOOLCHAIN_PREFIX="${PREFIX_NATIVE}"; +ex_pkg_register_group "native_toolchain" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/120.native_runtime.group b/groups.d/120.native_runtime.group index 153a40f..89986cd 100644 --- a/groups.d/120.native_runtime.group +++ b/groups.d/120.native_runtime.group @@ -9,4 +9,6 @@ NATIVE_RUNTIME_ENV_VARS_EXTRA="CFLAGS_PATH=-I${PREFIX_NATIVE}/include:LDFLAGS_PA NATIVE_RUNTIME_GROUP_DEPENDS="host_deps host_deps_rpm cross_toolchain host_toolchain host_tools native_toolchain native_tools"; NATIVE_RUNTIME_PREFIX="${PREFIX_NATIVE}"; +ex_pkg_register_group "native_runtime" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/200.native_packages.group b/groups.d/200.native_packages.group index 845117c..f64b924 100644 --- a/groups.d/200.native_packages.group +++ b/groups.d/200.native_packages.group @@ -14,4 +14,6 @@ NATIVE_PACKAGES_PKG_CONFIG_LIBDIR="${PREFIX_NATIVE}/lib/pkgconfig"; NATIVE_PACKAGES_PREFIX="${PREFIX_NATIVE}"; NATIVE_PACKAGES_PYTHON="${PREFIX}/bin/python2"; +ex_pkg_register_group "native_packages" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/800.minipix.group b/groups.d/800.minipix.group index b24c863..5a11ec0 100644 --- a/groups.d/800.minipix.group +++ b/groups.d/800.minipix.group @@ -15,4 +15,6 @@ MINIPIX_PKGLIST_DISABLE=1; MINIPIX_PREFIX="${PREFIX}/minipix_dist"; MINIPIX_RPM_DISABLE=1; +ex_pkg_register_group "minipix" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/999.dist.group b/groups.d/999.dist.group index c980cf4..27ac86b 100644 --- a/groups.d/999.dist.group +++ b/groups.d/999.dist.group @@ -4,6 +4,9 @@ DIST_FORCE=1; DIST_NO_LOG_VARS=1; DIST_PACKAGES="dist_gitref dist_minipix dist_zipdist"; + : ${PKG_DIST_ZIPDIST_DEPENDS:="dist_minipix"}; +ex_pkg_register_group "dist" "${RTL_FILEOP_SOURCE_FNAME}"; + # vim:filetype=sh textwidth=0 diff --git a/groups.d/dev_packages.group b/groups.d/dev_packages.group index e4cbd8f..cb2fbca 100644 --- a/groups.d/dev_packages.group +++ b/groups.d/dev_packages.group @@ -1,7 +1,6 @@ # # Build group dev_packages # -GROUP_AUTO=0; rtl_lconcat2 \$DEV_PACKAGES_CFLAGS_CONFIGURE \$DEFAULT_CFLAGS "--sysroot=${PREFIX_NATIVE}"; rtl_lconcat2 \$DEV_PACKAGES_CXXFLAGS_CONFIGURE \$DEFAULT_CXXFLAGS "--sysroot=${PREFIX_NATIVE}"; DEV_PACKAGES_CONFIG_CACHE_LOCAL="${CONFIG_CACHE_GNULIB}"; @@ -16,4 +15,6 @@ DEV_PACKAGES_PKG_CONFIG_LIBDIR="${PREFIX_NATIVE}/lib/pkgconfig"; DEV_PACKAGES_PREFIX="${PREFIX_NATIVE}"; DEV_PACKAGES_PYTHON="${PREFIX}/bin/python2"; +ex_pkg_register_group "dev_packages" "${RTL_FILEOP_SOURCE_FNAME}" "noauto"; + # vim:filetype=sh textwidth=0 diff --git a/subr.ex/ex_pkg.subr b/subr.ex/ex_pkg.subr index 6c02070..94dbf6c 100644 --- a/subr.ex/ex_pkg.subr +++ b/subr.ex/ex_pkg.subr @@ -3,6 +3,7 @@ # set +o errexit -o noglob -o nounset is assumed. # + # # ex_pkg_check_depends() - check single named package for unsatisfied dependencies # @_checkfl: enable (1) or inhibit (0) dependency expansion @@ -249,74 +250,21 @@ ex_pkg_load_vars() { # Returns: zero (0) on success, non-zero (>0) on failure. # ex_pkg_load_groups() { - local _eplg_rgroups="${1#\$}" _eplg_rgroups_noauto="${2#\$}" \ - _eplg_build_groups="" _eplg_build_groups_noauto="" \ - _eplg_fname="" _eplg_group="" _eplg_group_noautofl=0 \ - _eplg_group_target="" _eplg_group_target_uc="" \ - _eplg_group_target_appendfl=0 _eplg_groups="" _eplg_pkg_name="" \ - _eplg_pkg_names=""; + local _eplg_rgroups="${1#\$}" _eplg_rgroups_noauto="${2#\$}" \ + _eplg_build_groups="" _eplg_build_groups_noauto="" _eplg_fname=""; + EXP_PKG_REGISTER_GROUP_RGROUPS="${_eplg_rgroups}"; + EXP_PKG_REGISTER_GROUP_RGROUPS_NOAUTO="${_eplg_rgroups_noauto}"; for _eplg_fname in $(find ./groups.d -name *.group | sort); do - rtl_fileop source "${_eplg_fname}"; - - _eplg_group="${_eplg_fname##*/}"; - _eplg_group="${_eplg_group%.group}"; - _eplg_group="${_eplg_group#*.}"; - - if [ "${GROUP_TARGET_APPEND:+1}" = 1 ]; then - _eplg_group_target="${GROUP_TARGET_APPEND}"; - _eplg_group_target_appendfl=1; - unset GROUP_TARGET_APPEND; - else - _eplg_group_target="${_eplg_group}"; - _eplg_group_target_appendfl=0; - fi; - - _eplg_group_noautofl=0; - if ! rtl_lmatch \$_eplg_groups "${_eplg_group_target}"; then - rtl_lconcat \$_eplg_groups "${_eplg_group_target}"; - if eval [ \"\${GROUP_AUTO:+1}\" = 1 ]; then - if eval [ \"\${GROUP_AUTO:-0}\" -ne 0 ]; then - _eplg_group_noautofl=0; - rtl_lconcat \$_eplg_build_groups "${_eplg_group_target}"; - else - _eplg_group_noautofl=1; - rtl_lconcat \$_eplg_build_groups_noauto "${_eplg_group_target}"; - fi; - unset GROUP_AUTO; - else - rtl_lconcat \$_eplg_build_groups "${_eplg_group_target}"; - fi; - fi; - - if rtl_get_var_unsafe \$_eplg_pkg_names -u "${_eplg_group}_PACKAGES"\ - && [ "${_eplg_pkg_names:+1}" = 1 ]; then - if [ "${_eplg_group_target_appendfl}" -eq 1 ]; then - rtl_toupper2 \$_eplg_group_target \$_eplg_group_target_uc; - rtl_lconcat "\$${_eplg_group_target_uc}_PACKAGES" "${_eplg_pkg_names}"; - fi; - - if [ "${_eplg_group_noautofl}" -eq 0 ]; then - for _eplg_pkg_name in ${_eplg_pkg_names}; do - rtl_set_var_unsafe -u "PKG_${_eplg_pkg_name}_GROUP" "${_eplg_group}"; - rtl_set_var_unsafe -u "PKG_${_eplg_pkg_name}_GROUP_FNAME" "${_eplg_fname}"; - done; - fi; - fi; + rtl_fileop source_with_fnamevar "${_eplg_fname}"; done; + unset EXP_PKG_REGISTER_GROUP_RGROUPS; + unset EXP_PKG_REGISTER_GROUP_RGROUPS_NOAUTO; for _eplg_fname in $(find ./groups.d -mindepth 2 -name *.package | sort); do rtl_fileop source_with_fnamevar "${_eplg_fname}"; done; - _eplg_build_groups="$(rtl_uniq "${_eplg_build_groups}")"; - eval ${_eplg_rgroups}=\"${_eplg_build_groups}\"; - - if [ "${_eplg_rgroups_noauto:+1}" = 1 ]; then - _eplg_build_groups_noauto="$(rtl_uniq "${_eplg_build_groups_noauto}")"; - eval ${_eplg_rgroups_noauto}=\"${_eplg_build_groups_noauto}\"; - fi; - return 0; }; @@ -348,6 +296,44 @@ ex_pkg_register() { }; # +# ex_pkg_register_group() - register single group +# @_group_name: single group name +# @_fname: pathname to file group is defined in, relative to midipix_build root +# @[_autofl]: "auto" for groups to build by default, "noauto" for optional groups only built when requested +# ${EXP_PKG_REGISTER_GROUP_RGROUPS}: inout reference to variable of build groups +# ${EXP_PKG_REGISTER_GROUP_RGROUPS_NOAUTO}: inout reference to variable of build groups only built when requested +# +# Returns: zero (0) on success, non-zero (>0) on failure. +# +ex_pkg_register_group() { + local _eprg_group_name="${1}" _eprg_fname="${2}" _eprg_autofl="${3:-auto}" \ + _eprg_pkg_name="" _eprg_pkg_names="" _eprg_rgroups=""; + + case "${_eprg_autofl}" in + auto) _eprg_rgroups="${EXP_PKG_REGISTER_GROUP_RGROUPS}"; ;; + noauto) _eprg_rgroups="${EXP_PKG_REGISTER_GROUP_RGROUPS_NOAUTO}"; ;; + *) ;; + esac; + if ! rtl_lmatch "${_eprg_rgroups}" "${_eprg_group_name}"; then + rtl_lconcat "${_eprg_rgroups}" "${_eprg_group_name}"; + fi; + + if rtl_get_var_unsafe \$_eprg_pkg_names -u "${_eprg_group_name}_PACKAGES"\ + && [ "${_eprg_pkg_names:+1}" = 1 ]; then + case "${_eprg_autofl}" in + noauto) + for _eprg_pkg_name in ${_eprg_pkg_names}; do + rtl_set_var_unsafe -u "PKG_${_eprg_pkg_name}_GROUP" "${_eprg_group_name}"; + rtl_set_var_unsafe -u "PKG_${_eprg_pkg_name}_GROUP_FNAME" "${_eprg_fname}"; + done; + ;; + esac; + fi; + + return 0; +}; + +# # ex_pkg_unfold_depends() - unfold list of package names into dependency-expanded set of complete, disabled, finished, and outstanding package names # @_rdisabled: in reference toout variable of disabled packages # @_rfinished: in reference toout variable of finished packages