From 8b075bf0a9e81fcc0536eff9aa18313c42915d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=ADa=20Andrea=20Illanes=20Albornoz?= Date: Wed, 24 Apr 2024 20:24:57 +0200 Subject: groups.d/dev_packages.group: copy all group variables from native_packages. subr.ex/ex_pkg.subr:ex_pkg_copy_group_vars(): initial implementation. etc/README.md: updated. --- etc/README.md | 9 ++++++++- groups.d/dev_packages.group | 11 +---------- subr.ex/ex_pkg.subr | 30 ++++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/etc/README.md b/etc/README.md index 98f1d35b..38206285 100644 --- a/etc/README.md +++ b/etc/README.md @@ -342,7 +342,14 @@ build groups without taking ownership thereof, if ``owner`` is specified, the de group owns all of its packages. If ``noauto`` is specified, the build group will not be added to the list of build groups to build by default, if ``auto`` is specified, the build group will be added to the list of build groups to build by default. - + +If a build group that specifies ``copy`` should copy all of its build group variables from another +build group, use the following code: + +```shell +ex_pkg_copy_group_vars "" ""; +``` + Additionally, single package files may be added beneath ``groups.d/[0-9][0-9][0-9]..d/``, named ``.package`` containing the package's variables, with the following epilogue, the parameters enclosed in square brackets being optional: diff --git a/groups.d/dev_packages.group b/groups.d/dev_packages.group index c596224f..ec853c6d 100644 --- a/groups.d/dev_packages.group +++ b/groups.d/dev_packages.group @@ -1,20 +1,11 @@ # # Build group dev_packages # -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}"; -DEV_PACKAGES_CONFIGURE_ARGS="-C --disable-nls --host=${DEFAULT_TARGET} --prefix= --program-prefix= --target=${DEFAULT_TARGET}"; -DEV_PACKAGES_GROUP_DEPENDS="host_deps host_deps_rpm cross_toolchain host_toolchain host_tools native_toolchain native_tools"; -DEV_PACKAGES_LDFLAGS_CONFIGURE="--sysroot=${PREFIX_NATIVE}"; -DEV_PACKAGES_MAKEFLAGS_INSTALL="PREFIX= prefix="; DEV_PACKAGES_PACKAGES=" ncurses ncursesw libiconv coreutils bash libz git make sed grep findutils m4 flex bison diffutils patch patchutils gzip tar dos2unix nano vim"; -DEV_PACKAGES_PKG_CONFIG_LIBDIR="${PREFIX_NATIVE}/lib/pkgconfig"; -DEV_PACKAGES_PREFIX="${PREFIX_NATIVE}"; -DEV_PACKAGES_PYTHON="${PREFIX}/bin/python2"; +ex_pkg_copy_group_vars "native_packages" "dev_packages"; ex_pkg_register_group "dev_packages" "${RTL_FILEOP_SOURCE_FNAME}" "copy" "noauto"; # vim:filetype=sh textwidth=0 diff --git a/subr.ex/ex_pkg.subr b/subr.ex/ex_pkg.subr index c90515fb..2e86c319 100644 --- a/subr.ex/ex_pkg.subr +++ b/subr.ex/ex_pkg.subr @@ -49,6 +49,32 @@ ex_pkg_check_depends() { return "${_epcd_dependfl}"; }; +# +# ex_pkg_copy_group_vars() - copy build group variables into build group +# @_group_name_src: single source build group name +# @_group_name_dst: single destination build group name +# @[_build_vars_default]: optional list of default build variables, defaults to ${DEFAULT_BUILD_VARS} +# +# Returns: zero (0) on success, non-zero (>0) on failure. +# +ex_pkg_copy_group_vars() { + local _epcgv_group_name_src="${1#\$}" _epcgv_group_name_dst="${2#\$}" \ + _epcgv_build_vars_default="${3:-${DEFAULT_BUILD_VARS}}" \ + _epcgv_group_name_dst_uc="" _epcgv_group_name_src_uc="" \ + _epcgv_vname="" _epcgv_vval=""; + rtl_toupper2 \$_epcgv_group_name_dst \$_epcgv_group_name_dst_uc; + rtl_toupper2 \$_epcgv_group_name_src \$_epcgv_group_name_src_uc; + + for _epcgv_vname in ${_epcgv_build_vars_default}; do + if rtl_get_var_unsafe \$_epcgv_vval "${_epcgv_group_name_src_uc}_${_epcgv_vname}"\ + && [ "${_epcgv_vval:+1}" = 1 ]; then + rtl_set_var_unsafe "${_epcgv_group_name_dst_uc}_${_epcgv_vname}" "${_epcgv_vval}"; + fi; + done; + + return 0; +}; + # # ex_pkg_find_package() - find build group a single named package belongs to # @_rgroup_name: out reference to variable of build group name @@ -181,7 +207,7 @@ ex_pkg_get_package_vars() { eval ${_epgpv_rpkg_vnames}='${_epgpv_vnames}'; return 0; -} +}; # # ex_pkg_load_vars() - load build variables @@ -304,7 +330,7 @@ ex_pkg_register() { # ${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. +# Returns: zero (0) on success, non-zero (>0) on failure. # ex_pkg_register_group() { local _eprg_group_name="${1}" _eprg_fname="${2}" \ -- cgit v1.2.3