summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-03-13 14:18:14 +0100
committerLucía Andrea Illanes Albornoz <lucia@luciaillanes.de>2023-03-13 14:18:14 +0100
commit1380599ef36e89818d74a5e8ee8edd75846a4b7c (patch)
treeb6493f80d2c4784b55ab5bad8c57467b872b98a5
parente94dc6d0cadb6703baced36ed82709146e80285b (diff)
downloadmidipix_build-1380599ef36e89818d74a5e8ee8edd75846a4b7c.tar.bz2
midipix_build-1380599ef36e89818d74a5e8ee8edd75846a4b7c.tar.xz
Followup to <fd38dc025f5d31890abbf3d48c597114203b1421>.
-rwxr-xr-xpkgtool.sh10
-rw-r--r--subr.ex/ex_pkg.subr18
-rw-r--r--subr.ex/ex_pkg_env.subr7
-rw-r--r--subr.pkg/pkg_configure_patch.subr36
l---------[-rw-r--r--]subr.pkg/pkg_configure_patch_pre.subr56
-rw-r--r--subr.rtl/rtl_filepath.subr25
6 files changed, 54 insertions, 98 deletions
diff --git a/pkgtool.sh b/pkgtool.sh
index 185bc303..bb10fcd6 100755
--- a/pkgtool.sh
+++ b/pkgtool.sh
@@ -234,11 +234,11 @@ pkgtoolp_info() {
fi;
_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}" \
+ while ex_pkg_get_default \
+ \$_ppi_fname "${_ppi_patch_idx}" \
+ "${_ppi_pkg_name}" \
+ "${_ppi_pkg_version}" \
+ "vars_file patches_pre patches" \
&& [ "${_ppi_fname:+1}" = 1 ];
do
: $((_ppi_patch_idx += 1));
diff --git a/subr.ex/ex_pkg.subr b/subr.ex/ex_pkg.subr
index 2babb92a..6e33f9be 100644
--- a/subr.ex/ex_pkg.subr
+++ b/subr.ex/ex_pkg.subr
@@ -80,16 +80,16 @@ 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
+# @_default_idx: one-based single default value index
# @_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
+# @_ldefault: SP-separated list of default value names (any of: patches, patches_pre, vars_file)
#
# 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}" \
+ local _epgd_rdefault="${1#\$}" _epgd_default_idx="${2}" _epgd_pkg_name="${3}" \
+ _epgd_pkg_version="${4}" _epgd_ldefault="${5}" \
_epgd_default="" _epgd_patch_fname="" _epgd_pkg_name_full="" \
_epgd_pkg_patches_extra="" _epgd_rc=0;
@@ -100,7 +100,7 @@ ex_pkg_get_default() {
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";
+ rtl_get_var_unsafe \$_epgd_pkg_patches_extra -u "PKG_${_epgd_pkg_name}_PATCHES_EXTRA";
set +o noglob;
set -- \
"${@}" \
@@ -111,14 +111,6 @@ ex_pkg_get_default() {
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 -- \
"${@}" \
diff --git a/subr.ex/ex_pkg_env.subr b/subr.ex/ex_pkg_env.subr
index d6e8b803..f7ed3552 100644
--- a/subr.ex/ex_pkg_env.subr
+++ b/subr.ex/ex_pkg_env.subr
@@ -137,9 +137,10 @@ ex_pkg_env() {
if [ "${_epe_vars_file:+1}" != 1 ]; then
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 \
+ ex_pkg_get_default \
+ \$_epe_vars_file 1 \
+ "${_epe_pkg_name}" "${_epe_pkg_version}" \
+ "vars_file" \
|| return 1;
fi;
diff --git a/subr.pkg/pkg_configure_patch.subr b/subr.pkg/pkg_configure_patch.subr
index 07fb644d..572ea10a 100644
--- a/subr.pkg/pkg_configure_patch.subr
+++ b/subr.pkg/pkg_configure_patch.subr
@@ -3,11 +3,14 @@
# set +o errexit -o noglob -o nounset is assumed.
#
+pkg_configure_patch_pre() {
+ pkg_configure_patch "${@}" "patches_pre";
+};
+
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_patch_idx=0 _pcp_patches_done="" \
- _pcp_strip_count=0;
+ local _pcp_group_name="${1}" _pcp_pkg_name="${2}" \
+ _pcp_restart_at="${3}" _pcp_type="${4:-patches}" \
+ _pcp_patch_cwd="" _pcp_strip_count=0;
if [ "${PKG_FNAME:+1}" = 1 ]\
&& [ "${PKG_URLS_GIT:+1}" = 1 ];
@@ -19,24 +22,13 @@ pkg_configure_patch() {
_pcp_strip_count=1;
fi;
- _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
- return 1;
- else
- rtl_lconcat \$_pcp_patches_done "${_pcp_patch_fname}";
- fi;
- fi;
- done;
-
+ if ! rtl_patch_files \
+ "${_pcp_patch_cwd}" "${_pcp_strip_count}" \
+ ex_pkg_get_default -- -- \
+ "${_pcp_pkg_name}" "${PKG_VERSION:-}" "${_pcp_type}";
+ then
+ return 1;
+ fi;
return 0;
};
diff --git a/subr.pkg/pkg_configure_patch_pre.subr b/subr.pkg/pkg_configure_patch_pre.subr
index 5f3c8fff..f26702c8 100644..120000
--- a/subr.pkg/pkg_configure_patch_pre.subr
+++ b/subr.pkg/pkg_configure_patch_pre.subr
@@ -1,55 +1 @@
-#
-# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de>
-# set +o errexit -o noglob -o nounset is assumed.
-#
-
-pkgp_configure_patch_pre() {
- local _ppcpp_patch_fname="" _ppcpp_patch_idx=0;
-
- _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
- : $((_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;
- done;
- return 0;
-};
-
-pkgp_configure_patch_pre_chainport() {
- local _ppcppc_patch_dname="" _ppcppc_patch_fname="";
-
- 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;
- fi;
- fi;
- return 0;
-};
-
-pkg_configure_patch_pre() {
- local _pcpp_group_name="${1}" _pcpp_pkg_name="${2}" _pcpp_restart_at="${3}";
-
- if ! pkgp_configure_patch_pre_chainport\
- || ! pkgp_configure_patch_pre;
- then
- return 1;
- fi;
- return 0;
-};
-
-# vim:filetype=sh textwidth=0
+pkg_configure_patch.subr \ No newline at end of file
diff --git a/subr.rtl/rtl_filepath.subr b/subr.rtl/rtl_filepath.subr
index 7588b7ef..7d4ec553 100644
--- a/subr.rtl/rtl_filepath.subr
+++ b/subr.rtl/rtl_filepath.subr
@@ -141,4 +141,29 @@ rtl_is_newer() {
fi;
};
+rtl_patch_files() {
+ local _rpf_patch_cwd="${1}" _rpf_strip_count="${2}" _rpf_fn="${3}" \
+ _rpf_patch_fname="" _rpf_patch_idx=0;
+ shift $((3 + 2));
+
+ _rpf_patch_idx=1;
+ while "${_rpf_fn}" \
+ \$_rpf_patch_fname "${_rpf_patch_idx}" \
+ "${@}" \
+ && [ "${_rpf_patch_fname:+1}" = 1 ];
+ do
+ : $((_rpf_patch_idx += 1));
+ if [ -r "${_rpf_patch_fname}" ]\
+ && ! patch \
+ -b \
+ -d "${_rpf_patch_cwd}" \
+ "-p${_rpf_strip_count}" \
+ < "${_rpf_patch_fname}";
+ then
+ return 1;
+ fi;
+ done;
+ return 0;
+};
+
# vim:filetype=sh textwidth=0