Blame subr.ex/ex_rtl.subr

938c5c
#
938c5c
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
938c5c
# set +o errexit -o noglob -o nounset is assumed.
938c5c
#
938c5c
#
938c5c
938c5c
#
938c5c
# ex_rtl_fixup_pkgconfig_paths() - fixup pathname prefixes in pkg-config(1) files
938c5c
# @_dname_base:		base directory pathname
938c5c
#
938c5c
# Returns:		zero (0) on success, non-zero (>0) on failure
938c5c
#
938c5c
ex_rtl_fixup_pkgconfig_paths() {
938c5c
	local	_erfpp_dname_base="${1}"	\
938c5c
		_erfpp_pc_path="";
938c5c
938c5c
	for _erfpp_pc_path in $(find "${_erfpp_dname_base=}" -name \*.pc); do
938c5c
		if [ -n "$(sed -ne '/^libdir=[^$]*$/p' "${_erfpp_pc_path}")" ]			\
938c5c
		&& ! sed -i""	-e '/^libdir=[^$]*$/s/^libdir=\(.*\)$/libdir=${exec_prefix}\1/'	\
938c5c
				-e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/'		\
938c5c
				"${_erfpp_pc_path}";
938c5c
		then
938c5c
			return 1;
938c5c
		fi;
938c5c
938c5c
		if [ -n "$(sed -ne '/^includedir=[^$]*$/p' "${_erfpp_pc_path}")" ]			\
938c5c
		&& ! sed -i""	-e '/^includedir=[^$]*$/s/^includedir=\(.*\)$/includedir=${prefix}\1/'	\
938c5c
				"${_erfpp_pc_path}";
938c5c
		then
938c5c
			return 1;
938c5c
		fi;
938c5c
	done;
938c5c
938c5c
	return 0;
938c5c
};
938c5c
938c5c
#
938c5c
# ex_rtl_purge_la_files() - purge .la files in tree
938c5c
# @_dname_base:		base directory pathname
938c5c
#
938c5c
# Returns:		zero (0) on success, non-zero (>0) on failure
938c5c
#
938c5c
ex_rtl_purge_la_files() {
938c5c
	local	_erplf_dname_base="${1}"	\
938c5c
		_erplf_la_path="";
938c5c
938c5c
	for _erplf_la_path in $(find		\
938c5c
			"${_erplf_dname_base}"	\
938c5c
			-type f			\
938c5c
			-name \*.la);
938c5c
	do
938c5c
		if ! rtl_fileop rm "${_erplf_la_path}"; then
938c5c
			return 1;
938c5c
		fi;
938c5c
	done;
938c5c
	return 0;
938c5c
};
938c5c
938c5c
#
938c5c
# ex_rtl_strip_files() - strip files of debugging information
938c5c
# @_strip_cmd:		strip(1) command name
938c5c
# @_tree_root:		pathname to tree root
938c5c
# @--:			(ignored)
938c5c
# @_log_fn:		logging function name; called with @... and pathname of each file stripped
938c5c
# @...:			@_fn initial arguments list as positional parameters
938c5c
#
938c5c
# Returns:		zero (0) on success, non-zero (>0) on failure
938c5c
#
938c5c
ex_rtl_strip_files() {
938c5c
	local	_ersf_strip_cmd="${1}" _ersf_tree_root="${2}"	\
938c5c
		_ersf_ignored="${3}" _ersf_log_fn="${4}"	\
938c5c
		_ersf_bin_path="";
938c5c
	shift 4;
938c5c
938c5c
	if [ -e "${_ersf_tree_root}" ]; then
938c5c
		for _ersf_bin_path in $(find		\
938c5c
				"${_ersf_tree_root}"	\
938c5c
				-perm /a=x		\
938c5c
				-type f);
938c5c
		do
938c5c
			if objdump				\
938c5c
					-sj .debug_frame	\
938c5c
					-j .debug_info		\
938c5c
					"${_ersf_bin_path}"	\
938c5c
					>/dev/null 2>&1;
938c5c
			then
938c5c
				if ! "${_ersf_strip_cmd}" "${_ersf_bin_path}"; then
938c5c
					return 1;
938c5c
				else
938c5c
					"${_ersf_log_fn}" "${@}" "${_ersf_bin_path}";
938c5c
				fi;
938c5c
			fi;
938c5c
		done;
938c5c
	fi;
938c5c
938c5c
	return 0;
938c5c
};
938c5c
938c5c
# vim:filetype=sh textwidth=0