e9fa07
#
8d7a8a
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
e9fa07
# set +o errexit -o noglob -o nounset is assumed.
e9fa07
#
e9fa07
e9fa07
pkg_configure_patch() {
e9fa07
	local	_pcp_group_name="${1}" _pcp_pkg_name="${2}" _pcp_restart_at="${3}"	\
e9fa07
		_pcp_patch_cwd="" _pcp_patch_dir="${MIDIPIX_BUILD_PWD}/patches"		\
e9fa07
		_pcp_patch_fname="" _pcp_patches_done="" _pcp_pkg_name_full=""		\
e9fa07
		_pcp_strip_count=0;
e9fa07
	_pcp_pkg_name_full="${_pcp_pkg_name}${PKG_VERSION:+-${PKG_VERSION}}";
e9fa07
e9fa07
	if [ "${PKG_FNAME:+1}" = 1 ]\
e9fa07
	&& [ "${PKG_URLS_GIT:+1}" = 1 ];
e9fa07
	then
e9fa07
		_pcp_patch_cwd="${PKG_BASE_DIR}";
e9fa07
		_pcp_strip_count=0;
e9fa07
	else
e9fa07
		_pcp_patch_cwd="${PKG_BASE_DIR}/${PKG_SUBDIR}";
e9fa07
		_pcp_strip_count=1;
e9fa07
	fi;
e9fa07
e9fa07
	set +o noglob;
e9fa07
	for _pcp_patch_fname in 								\
e9fa07
			"${_pcp_patch_dir}/${PKG_NAME}/"*.patch					\
e9fa07
			"${_pcp_patch_dir}/${_pcp_pkg_name_full}.local.patch"			\
e9fa07
			"${_pcp_patch_dir}/${_pcp_pkg_name_full}.local@${BUILD_HNAME}.patch"	\
e9fa07
			${PKG_PATCHES_EXTRA:-};
e9fa07
	do
e9fa07
		if [ -r "${_pcp_patch_fname}" ]\
e9fa07
		&& ! rtl_lmatch \$_pcp_patches_done "${_pcp_patch_fname}";
e9fa07
		then
e9fa07
			if ! patch -b -d "${_pcp_patch_cwd}" "-p${_pcp_strip_count}" < "${_pcp_patch_fname}"; then
e9fa07
				set -o noglob; return 1;
e9fa07
			else
e9fa07
				rtl_lconcat \$_pcp_patches_done "${_pcp_patch_fname}";
e9fa07
			fi;
e9fa07
		fi;
e9fa07
	done;
e9fa07
	set -o noglob;
e9fa07
e9fa07
	return 0;
e9fa07
};
e9fa07
64844b
# vim:filetype=sh textwidth=0