summaryrefslogtreecommitdiffhomepage
path: root/subr.pkg/pkg_configure_patch.subr
blob: 62c4f382c75f4e91db7b30445f87ca4ae31b7ad8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
# 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.
#

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_type="${4:-patches}"	\
		_pcp_patch_cwd="" _pcp_strip_count=0;

	if [ -x "${PKG_BASE_DIR}/${PKG_SUBDIR}/srcprep.sh" ]; then
		return 0;
	fi;

	if [ "${PKG_FNAME:+1}" = 1 ]\
	&& [ "${PKG_URLS_GIT:+1}" = 1 ];
	then
		_pcp_patch_cwd="${PKG_BASE_DIR}";
		_pcp_strip_count=0;
	else
		_pcp_patch_cwd="${PKG_BASE_DIR}/${PKG_SUBDIR}";
		_pcp_strip_count=1;
	fi;

	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;
};

# vim:filetype=sh textwidth=0