midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_install_libs.subr

Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
pkgp_install_lib_check() {
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
	local _so_path="${1}" _so_ver="${1##*.so}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -z "${_so_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	else while [ -n "${_so_ver}" ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) d7eaa6
		if [ "${_so_ver#[0-9.]}" = "${_so_ver}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
			return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 412fec
			_so_ver="${_so_ver#[0-9.]}";
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	done; return 0; fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
};
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkgp_install_lib_link() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	local _so_path="${1}" _so_dir="${2}" _lib_name="${3}"					\
Lucio Andrés Illanes Albornoz 907bd3
		_lib_link_tgt="" _lib_link_path="";
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	_lib_link_path="${_so_path%.so*}.lib.a";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	_lib_link_tgt="$(find "${_so_dir}"							\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			-name "${_lib_name%%.*}.*.lib.a"					|\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			sort | tail -1)";
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	if [ -n "${_lib_link_tgt}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	&& [ "${_lib_link_tgt}" != "${_lib_link_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_fileop rm "${_lib_link_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_fileop ln_symbolic "$(ex_rtl_basename "${_lib_link_tgt}")"		\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			"${_lib_link_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkg_install_libs() {
Lucio Andrés Illanes Albornoz 907bd3
	local _so_src_path="" _so_dst_dir="" _lib_src_path="" _lib_name="" _lib_dst_path="";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	if [ "${PKG_BUILD_TYPE}" != "host" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		for _so_src_path in								\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			$(find	"${PKG_DESTDIR}"						\
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
				\(  -name "*.so" -or -name "*.so.*" \) -print);
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		do	if ! pkgp_install_lib_check "${_so_src_path}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
			|| [ "$(readlink -f "${_so_src_path}")" = "/dev/null" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				continue;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			else	_so_dst_dir="${_so_src_path%/*}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				case "${_so_src_path}" in
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				*.so)	_lib_src_path="${_so_src_path%%.so}.lib.a"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				*.so.*)	_lib_src_path="${_so_src_path%%.so.*}.${_so_src_path##*.so.}.lib.a"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				esac;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				_lib_name="$(ex_rtl_basename "${_lib_src_path}")";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				_lib_dst_path="${_so_dst_dir}/${_lib_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			if [ ! -L "${_lib_src_path}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			&& [ ! -e "${_lib_dst_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				(ex_rtl_fileop cd "$(ex_rtl_dirname "${_so_src_path}")";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				perk -e "$(ex_rtl_basename "${_so_src_path}")"			|\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					"${PKG_TARGET}-mdso"					\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
						-i "$(ex_rtl_basename "${_lib_dst_path}")"	\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
						-n "$(ex_rtl_basename "${_so_src_path}")" -);
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			pkgp_install_lib_link "${_so_src_path}" "${_so_dst_dir}" "${_lib_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# vim:filetype=sh