diff options
-rwxr-xr-x | pkgtool.sh | 23 | ||||
-rw-r--r-- | subr.ex/ex_pkg.subr | 67 | ||||
-rw-r--r-- | subr.ex/ex_pkg_env.subr | 14 | ||||
-rw-r--r-- | subr.pkg/pkg_configure_patch.subr | 19 | ||||
-rw-r--r-- | subr.pkg/pkg_configure_patch_pre.subr | 30 |
5 files changed, 114 insertions, 39 deletions
@@ -185,8 +185,8 @@ pkgtoolp_init_getopts_fn() { pkgtoolp_info() { local _ppi_rstatus="${1}" _ppi_pkg_name="${2}" \ _ppi_fname="" _ppi_group_name="" _ppi_groups="" _ppi_groups_noauto="" \ - _ppi_pkg_disabled="" _ppi_pkg_finished="" _ppi_pkg_name_uc="" \ - _ppi_pkg_names="" _ppi_rc=0; + _ppi_patch_idx=0 _ppi_pkg_disabled="" _ppi_pkg_finished="" \ + _ppi_pkg_name_uc="" _ppi_pkg_names="" _ppi_rc=0; rtl_toupper2 \$_ppi_pkg_name \$_ppi_pkg_name_uc; if ! ex_pkg_load_groups \$_ppi_groups \$_ppi_groups_noauto \$GROUP_AUTO \$GROUP_TARGET; then @@ -233,22 +233,19 @@ pkgtoolp_info() { fi; fi; - set +o noglob; - for _ppi_fname in \ - "vars/${_ppi_pkg_name}.vars" \ - "patches/${_ppi_pkg_name}/"*.patch \ - "patches/${_ppi_pkg_name}${_ppi_pkg_version:+-${_ppi_pkg_version}}.local.patch" \ - "patches/${_ppi_pkg_name}${_ppi_pkg_version:+-${_ppi_pkg_version}}.local@${BUILD_HNAME}.patch" \ - "patches/${_ppi_pkg_name}${_ppi_pkg_version:+-${_ppi_pkg_version}}_pre.local.patch" \ - "patches/${_ppi_pkg_name}${_ppi_pkg_version:+-${_ppi_pkg_version}}_pre.local@${BUILD_HNAME}.patch" \ - "${BUILD_WORKDIR}/chainport/patches/${_ppi_pkg_name%%_ppi_*}/${_ppi_pkg_name%%_ppi_*}-${_ppi_pkg_version}.midipix.patch"; + _ppi_patch_idx=1; + while ex_pkg_get_default \ + \$_ppi_fname "${_ppi_pkg_name}" \ + "${_ppi_pkg_version}" \ + "vars_file patches_chainport patches_pre patches" \ + "${_ppi_patch_idx}" \ + && [ "${_ppi_fname:+1}" = 1 ]; do + : $((_ppi_patch_idx += 1)); if [ -e "${_ppi_fname}" ]; then sha256sum "${_ppi_fname}"; fi; done; - set -o noglob; - fi; return "${_ppi_rc}"; diff --git a/subr.ex/ex_pkg.subr b/subr.ex/ex_pkg.subr index e3e90574..2babb92a 100644 --- a/subr.ex/ex_pkg.subr +++ b/subr.ex/ex_pkg.subr @@ -78,6 +78,73 @@ ex_pkg_find_package() { }; # +# ex_pkg_get_default() - get single package default value +# @_rdefault: reference to out variable of default value or "" on end of list +# @_pkg_name: single package name +# @_pkg_version: single package version +# @_ldefault: SP-separated list of default value names (any of: patches, patches_chainport, patches_pre, vars_file) +# @_default_idx: one-based single default value index +# +# Return: zero (0) on success, non-zero (>0) on invalid default value name or unknown package. +# +ex_pkg_get_default() { + local _epgd_rdefault="${1#\$}" _epgd_pkg_name="${2}" _epgd_pkg_version="${3}" \ + _epgd_ldefault="${4}" _epgd_default_idx="${5}" \ + _epgd_default="" _epgd_patch_fname="" _epgd_pkg_name_full="" \ + _epgd_pkg_patches_extra="" _epgd_rc=0; + + set --; + _epgd_pkg_name_full="${_epgd_pkg_name}${_epgd_pkg_version:+-${_epgd_pkg_version}}"; + _epgd_rc=0; + + for _epgd_default in ${_epgd_ldefault}; do + case "${_epgd_default}" in + patches) + rtl_get_var_unsafe \$_epgd_pkg_patches_extra -u "${_epgd_pkg_name}_PATCHES_EXTRA"; + set +o noglob; + set -- \ + "${@}" \ + "${MIDIPIX_BUILD_PWD}/patches/${_epgd_pkg_name_full}/"*.patch \ + "${MIDIPIX_BUILD_PWD}/patches/${_epgd_pkg_name_full}.local.patch" \ + "${MIDIPIX_BUILD_PWD}/patches/${_epgd_pkg_name_full}.local@${BUILD_HNAME}.patch" \ + ${_epgd_pkg_patches_extra}; + set -o noglob; + ;; + + patches_chainport) + if [ "${_epgd_pkg_version:+1}" = 1 ]; then + set -- \ + "${@}" \ + "${BUILD_WORKDIR}/chainport/patches/${_epgd_pkg_name%%_*}/${_epgd_pkg_name%%_*}-${_epgd_pkg_version}.midipix.patch"; + fi; + ;; + + patches_pre) + set -- \ + "${@}" \ + "${MIDIPIX_BUILD_PWD}/patches/${_epgd_pkg_name_full}_pre.local.patch" \ + "${MIDIPIX_BUILD_PWD}/patches/${_epgd_pkg_name_full}_pre.local@${BUILD_HNAME}.patch"; + ;; + + vars_file) + set -- \ + "vars/${_epgd_pkg_name}.vars"; + ;; + + *) + _epgd_rc=1; break; + ;; + esac; + done; + + if [ "${_epgd_rc}" = 0 ]; then + eval ${_epgd_rdefault}="\${${_epgd_default_idx}:-}"; + fi; + + return "${_epgd_rc}"; +}; + +# # ex_pkg_get_packages() - get list of packages belonging to single named build group # @_rpkg_names: reference to out variable of package names # @_group_name: build group name diff --git a/subr.ex/ex_pkg_env.subr b/subr.ex/ex_pkg_env.subr index f8966ad3..d6e8b803 100644 --- a/subr.ex/ex_pkg_env.subr +++ b/subr.ex/ex_pkg_env.subr @@ -118,9 +118,11 @@ exp_pkg_env_set() { # Return: zero (0) on success, non-zero (>0) on failure # ex_pkg_env() { - local _epe_build_steps_default="${1}" _epe_build_vars_default="${2}" _epe_group_name="${3}" \ - _epe_pkg_name="${4}" _epe_restart_at="${5}" _epe_workdir="${6}" \ - _epe_inherit_from="" _epe_vars_file="" _epe_vars_file_parent="" _epe_vname=""; + local _epe_build_steps_default="${1}" _epe_build_vars_default="${2}" \ + _epe_group_name="${3}" _epe_pkg_name="${4}" _epe_restart_at="${5}" \ + _epe_workdir="${6}" \ + _epe_inherit_from="" _epe_pkg_version="" _epe_vars_file="" \ + _epe_vars_file_parent="" _epe_vname=""; if rtl_get_var_unsafe \$_epe_inherit_from -u "PKG_${_epe_pkg_name}_INHERIT_FROM"\ && [ "${_epe_inherit_from:+1}" = 1 ]; then @@ -134,7 +136,11 @@ ex_pkg_env() { fi; if [ "${_epe_vars_file:+1}" != 1 ]; then - _epe_vars_file="vars/${_epe_pkg_name}.vars"; + rtl_get_var_unsafe \$_epe_pkg_version -u "PKG_${_epe_pkg_name}_VERSION"; + ex_pkg_get_default \ + \$_epe_vars_file "${_epe_pkg_name}" \ + "${_epe_pkg_version}" "vars_file" 1 \ + || return 1; fi; rtl_fileop source_opt "${_epe_vars_file}" "${_epe_group_name}/${_epe_pkg_name}.${_epe_group_name}"; diff --git a/subr.pkg/pkg_configure_patch.subr b/subr.pkg/pkg_configure_patch.subr index c616fde2..8ed0ad33 100644 --- a/subr.pkg/pkg_configure_patch.subr +++ b/subr.pkg/pkg_configure_patch.subr @@ -6,8 +6,8 @@ pkg_configure_patch() { local _pcp_group_name="${1}" _pcp_pkg_name="${2}" _pcp_restart_at="${3}" \ _pcp_patch_cwd="" _pcp_patch_dir="${MIDIPIX_BUILD_PWD}/patches" \ - _pcp_patch_fname="" _pcp_patches_done="" _pcp_pkg_name_full="" \ - _pcp_strip_count=0; + _pcp_patch_fname="" _pcp_patch_idx=0 _pcp_patches_done="" \ + _pcp_pkg_name_full="" _pcp_strip_count=0; _pcp_pkg_name_full="${_pcp_pkg_name}${PKG_VERSION:+-${PKG_VERSION}}"; if [ "${PKG_FNAME:+1}" = 1 ]\ @@ -20,24 +20,23 @@ pkg_configure_patch() { _pcp_strip_count=1; fi; - set +o noglob; - for _pcp_patch_fname in \ - "${_pcp_patch_dir}/${PKG_NAME}/"*.patch \ - "${_pcp_patch_dir}/${_pcp_pkg_name_full}.local.patch" \ - "${_pcp_patch_dir}/${_pcp_pkg_name_full}.local@${BUILD_HNAME}.patch" \ - ${PKG_PATCHES_EXTRA:-}; + _pcp_patch_idx=1; + while ex_pkg_get_default \ + \$_pcp_patch_fname "${_pcp_pkg_name}" \ + "${PKG_VERSION}" "patches" "${_pcp_patch_idx}" \ + && [ "${_pcp_patch_fname:+1}" = 1 ]; do + : $((_pcp_patch_idx += 1)); if [ -r "${_pcp_patch_fname}" ]\ && ! rtl_lmatch \$_pcp_patches_done "${_pcp_patch_fname}"; then if ! patch -b -d "${_pcp_patch_cwd}" "-p${_pcp_strip_count}" < "${_pcp_patch_fname}"; then - set -o noglob; return 1; + return 1; else rtl_lconcat \$_pcp_patches_done "${_pcp_patch_fname}"; fi; fi; done; - set -o noglob; return 0; }; diff --git a/subr.pkg/pkg_configure_patch_pre.subr b/subr.pkg/pkg_configure_patch_pre.subr index 3a0c461e..d315fb49 100644 --- a/subr.pkg/pkg_configure_patch_pre.subr +++ b/subr.pkg/pkg_configure_patch_pre.subr @@ -4,14 +4,17 @@ # pkgp_configure_patch_pre() { - local _ppcpp_patch_path=""; + local _ppcpp_patch_fname="" _ppcpp_patch_idx=0; - for _ppcpp_patch_path in \ - "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}${PKG_VERSION:+-${PKG_VERSION}}_pre.local.patch" \ - "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}${PKG_VERSION:+-${PKG_VERSION}}_pre.local@${BUILD_HNAME}.patch"; + _ppcpp_patch_idx=1; + while ex_pkg_get_default \ + \$_ppcpp_patch_fname "${PKG_NAME}" \ + "${PKG_VERSION}" "patches_pre" "${_ppcpp_patch_idx}" \ + && [ "${_pcp_patch_fname:+1}" = 1 ]; do - if [ -r "${_ppcpp_patch_path}" ]\ - && ! patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_ppcpp_patch_path}"; + : $((_ppcpp_patch_idx += 1)); + if [ -r "${_ppcpp_patch_fname}" ]\ + && ! patch -b -d "${PKG_BASE_DIR}/${PKG_SUBDIR}" -p1 < "${_ppcpp_patch_fname}"; then return 1; fi; @@ -20,13 +23,16 @@ pkgp_configure_patch_pre() { }; pkgp_configure_patch_pre_chainport() { - local _ppcppc_patch_dname="" _ppcppc_patch_fname="" _ppcppc_oldpwd=""; - _ppcppc_patch_dname="${PKG_BASE_DIR}/${PKG_SUBDIR}/patches/${PKG_NAME%%_*}"; + local _ppcppc_patch_dname="" _ppcppc_patch_fname=""; - if [ "${PKG_VERSION:+1}" = 1 ]; then - _ppcppc_patch_fname="${BUILD_WORKDIR}/chainport/patches/${PKG_NAME%%_*}/${PKG_NAME%%_*}-${PKG_VERSION}.midipix.patch"; - fi; - if [ -e "${_ppcppc_patch_fname}" ]; then + ex_pkg_get_default \ + \$_ppcppc_patch_fname "${PKG_NAME}" \ + "${PKG_VERSION}" "patches_chainport" 1 \ + || return 1; + + if [ "${_ppcppc_patch_fname:+1}" = 1 ]\ + && [ -e "${_ppcppc_patch_fname}" ]; then + _ppcppc_patch_dname="${PKG_BASE_DIR}/${PKG_SUBDIR}/patches/${PKG_NAME%%_*}"; if ! rtl_fileop mkdir "${_ppcppc_patch_dname}"\ || ! rtl_fileop cp "${_ppcppc_patch_fname}" "${_ppcppc_patch_dname}"; then return 1; |