From 34eeaf1a6548710a7f9496be2e4ca71acb0c6be2 Mon Sep 17 00:00:00 2001 From: LucĂ­a Andrea Illanes Albornoz Date: Mar 28 2023 10:47:20 +0000 Subject: Fix printing of package variables in ./pkgtool.sh -i. --- diff --git a/pkgtool.sh b/pkgtool.sh index eca26d9..9ea8fcb 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 6f326e1..c064b40 100644 --- a/subr.ex/ex_pkg.subr +++ b/subr.ex/ex_pkg.subr @@ -158,6 +158,29 @@ ex_pkg_get_packages() { }; # +# 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 # @_rbuild_arch: in reference to build architecture diff --git a/subr.rtl/rtl_platform.subr b/subr.rtl/rtl_platform.subr index d3ba8f5..a58b71a 100644 --- a/subr.rtl/rtl_platform.subr +++ b/subr.rtl/rtl_platform.subr @@ -112,21 +112,6 @@ rtl_get_var_unsafe() { }; # -# 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 # @_pid: top-level PID