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
pkgp_install_libs_purge_la() {
e9fa07
	local _ppilpl_la_path="";
e9fa07
e9fa07
	for _ppilpl_la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do
e9fa07
		if ! rtl_fileop rm "${_ppilpl_la_path}"; then
e9fa07
			return 1;
e9fa07
		fi;
e9fa07
	done;
e9fa07
	return 0;
e9fa07
};
e9fa07
e9fa07
pkgp_install_libs_shared_link() {
e9fa07
	local	_ppilsl_lib_name="${1}" _ppilsl_so_dir="${2}" _ppilsl_so_path="${3}"	\
e9fa07
		_ppilsl_lib_link_path="${3%.so*}.lib.a" _ppilsl_fname="" _ppilsl_lib_link_tgt="";
e9fa07
e9fa07
	if _ppilsl_lib_link_tgt="$(find "${_ppilsl_so_dir}" -name "${_ppilsl_lib_name%%.*}.*.lib.a" | sort | tail -1)"\
e9fa07
	&& [ "${_ppilsl_lib_link_tgt:+1}" = 1 ]\
e9fa07
	&& [ "${_ppilsl_lib_link_tgt}" != "${_ppilsl_lib_link_path}" ];
e9fa07
	then
e9fa07
		rtl_basename2 \$_ppilsl_lib_link_tgt \$_ppilsl_fname;
e9fa07
e9fa07
		if ! rtl_fileop rm "${_ppilsl_lib_link_path}"\
e9fa07
		|| ! rtl_fileop ln_symbolic "${_ppilsl_fname}" "${_ppilsl_lib_link_path}"; then
e9fa07
			return 1;
e9fa07
		fi;
e9fa07
	fi;
e9fa07
	return 0;
e9fa07
};
e9fa07
e9fa07
pkgp_install_libs_shared() {
e9fa07
	local	_ppils_head="" _ppils_lib_dst_path="" _ppils_lib_name=""	\
e9fa07
		_ppils_lib_src_path="" _ppils_so_dst_dir="" _ppils_so_src_path="";
e9fa07
e9fa07
	if [ "${PKG_BUILD_TYPE}" != "host" ]; then
e9fa07
		for _ppils_so_src_path in 		\
e9fa07
			$(find	"${PKG_DESTDIR}"	\
e9fa07
				\(  -name "*.so" -or -name "*.so.*" \) -print);
e9fa07
		do
e9fa07
			if [ "$(readlink -f "${_ppils_so_src_path}")" != "/dev/null" ]\
e9fa07
			&& rtl_head "[0-9.]" "${_ppils_so_src_path##*.so}" \$_ppils_head\
e9fa07
			&& [ "${_ppils_head:+1}" != 1 ]; then
e9fa07
				case "${_ppils_so_src_path}" in
e9fa07
				*.so)	_ppils_lib_src_path="${_ppils_so_src_path%%.so}.lib.a"; ;;
e9fa07
				*.so.*)	_ppils_lib_src_path="${_ppils_so_src_path%%.so.*}.${_ppils_so_src_path##*.so.}.lib.a"; ;;
e9fa07
				esac;
e9fa07
e9fa07
				_ppils_so_dst_dir="${_ppils_so_src_path%/*}";
e9fa07
				rtl_basename2 \$_ppils_lib_src_path \$_ppils_lib_name;
e9fa07
				_ppils_lib_dst_path="${_ppils_so_dst_dir}/${_ppils_lib_name}";
e9fa07
e9fa07
				if [ ! -L "${_ppils_lib_src_path}" ]\
e9fa07
				&& [ ! -e "${_ppils_lib_dst_path}" ]; then
e9fa07
					if ! (rtl_basename2 \$_ppils_so_src_path \$_ppils_fname;	\
e9fa07
					      rtl_basename2 \$_ppils_lib_dst_path \$_ppils_fname_dst;	\
e9fa07
					      rtl_dirname2 \$_ppils_so_src_path \$_ppils_dname;		\
e9fa07
					      rtl_fileop cd "${_ppils_dname}" &&			\
e9fa07
							perk -e "${_ppils_fname}"			|\
e9fa07
								"${PKG_TARGET}-mdso"			\
e9fa07
									-i "${_ppils_fname_dst}"	\
e9fa07
									-n "${_ppils_fname}" -);
e9fa07
					then
e9fa07
						return 1;
e9fa07
					fi;
e9fa07
				fi;
e9fa07
e9fa07
				if ! pkgp_install_libs_shared_link				\
e9fa07
						"${_ppils_lib_name}" "${_ppils_so_dst_dir}"	\
e9fa07
						"${_ppils_so_src_path}";
e9fa07
				then
e9fa07
					return 1;
e9fa07
				fi;
e9fa07
			fi;
e9fa07
		done;
e9fa07
	fi;
e9fa07
e9fa07
	return 0;
e9fa07
};
e9fa07
e9fa07
pkg_install_libs() {
e9fa07
	local _pil_group_name="${1}" _pil_pkg_name="${2}" _pil_restart_at="${3}";
e9fa07
e9fa07
	if ! pkgp_install_libs_purge_la\
e9fa07
	|| ! pkgp_install_libs_shared;
e9fa07
	then
e9fa07
		return 1;
e9fa07
	fi;
e9fa07
	return 0;
e9fa07
};
e9fa07
64844b
# vim:filetype=sh textwidth=0