From 34eeaf1a6548710a7f9496be2e4ca71acb0c6be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=ADa=20Andrea=20Illanes=20Albornoz?= Date: Tue, 28 Mar 2023 12:47:20 +0200 Subject: Fix printing of package variables in ./pkgtool.sh -i. --- pkgtool.sh | 12 +----------- subr.ex/ex_pkg.subr | 23 +++++++++++++++++++++++ subr.rtl/rtl_platform.subr | 15 --------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/pkgtool.sh b/pkgtool.sh index eca26d9b..9ea8fcbd 100755 --- a/pkgtool.sh +++ b/pkgtool.sh @@ -258,17 +258,7 @@ pkgtoolp_info_single() { else rtl_get_var_unsafe \$_ppis_group_fname -u "PKG_${_ppis_pkg_name}_GROUP_FNAME"; rtl_get_var_unsafe \$_ppis_pkg_version -u "PKG_${_ppis_pkg_name}_VERSION"; - case "${_ppis_pkg_name}" in - *_host) - _ppis_pkg_vars="$(rtl_get_vars_unsafe_fast "^PKG_${_ppis_pkg_name_uc}" | grep -Ev "_(MINIPIX)")"; - ;; - *_minipix) - _ppis_pkg_vars="$(rtl_get_vars_unsafe_fast "^PKG_${_ppis_pkg_name_uc}" | grep -Ev "_(HOST)")"; - ;; - *) - _ppis_pkg_vars="$(rtl_get_vars_unsafe_fast "^PKG_${_ppis_pkg_name_uc}" | grep -Ev "_(HOST|MINIPIX)")"; - ;; - esac; + ex_pkg_get_package_vars \$_ppis_pkg_vars "${DEFAULT_BUILD_VARS}" "${_ppis_pkg_name}"; rtl_log_env_vars "package_vars" "Package variables" ${_ppis_pkg_vars}; rtl_log_msgV "info_build_group" "${MSG_info_build_group}" "${_ppis_group_name}" "${_ppis_group_fname}"; diff --git a/subr.ex/ex_pkg.subr b/subr.ex/ex_pkg.subr index 6f326e1b..c064b408 100644 --- a/subr.ex/ex_pkg.subr +++ b/subr.ex/ex_pkg.subr @@ -157,6 +157,29 @@ ex_pkg_get_packages() { fi; }; +# +# ex_pkg_get_package_vars() - get package variable names +# @_rpkg_vnames: out reference to package variable names variable +# @_build_vars_default: list of default build variables +# @_pkg_name: single package name +# +# Returns: zero (0) on success, non-zero (>0) on failure, list of package names on stdout on success. +# +ex_pkg_get_package_vars() { + local _epgpv_rpkg_vnames="${1#\$}" _epgpv_build_vars_default="${2}" _epgpv_pkg_name="${3}" \ + _epgpv_pkg_name_uc="" _epgpv_vname="" _epgpv_vnames=""; + rtl_toupper2 \$_epgpv_pkg_name \$_epgpv_pkg_name_uc; + + for _epgpv_vname in ${_epgpv_build_vars_default}; do + if eval [ \"\${PKG_${_epgpv_pkg_name_uc}_${_epgpv_vname}:+1}\" = 1 ]; then + rtl_lconcat \$_epgpv_vnames "PKG_${_epgpv_pkg_name_uc}_${_epgpv_vname}"; + fi; + done; + + eval ${_epgpv_rpkg_vnames}='${_epgpv_vnames}'; + return 0; +} + # # ex_pkg_load_vars() - load build variables # @_rstatus: out reference to status string diff --git a/subr.rtl/rtl_platform.subr b/subr.rtl/rtl_platform.subr index d3ba8f56..a58b71a3 100644 --- a/subr.rtl/rtl_platform.subr +++ b/subr.rtl/rtl_platform.subr @@ -111,21 +111,6 @@ rtl_get_var_unsafe() { return 0; }; -# -# rtl_get_vars_unsafe_fast() - get values of multiple variables w/ pattern -# @_pattern: pattern to match against set output -# -# Returns: zero (0) on success, non-zero (>0) on failure, matching variable values on stdout -# N.B.: This function is *unsafe* and impossible to implement otherwise w/o parsing set -# output properly and may produce spurious data. -# -rtl_get_vars_unsafe_fast() { - local _rgvuf_pattern="${1}"; - - set | awk -F= '/'"${_rgvuf_pattern}"'/{print $1}' | sort; - return 0; -}; - # # rtl_kill_tree() - kill tree of processes # @_rpids: inout reference to list of PIDs -- cgit v1.2.3