Blame subr/pkg_install_files.subr

Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz 2b85d0
pkgp_install_files() {
Lucio Andrés Illanes Albornoz e1d469
	if [ -n "${PKG_INSTALL_FILES:-}" ]; then
Lucio Andrés Illanes Albornoz bf9edf
		if ! rtl_install -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES}; then
Lucio Andrés Illanes Albornoz bf9edf
			return 1;
Lucio Andrés Illanes Albornoz bf9edf
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 611492
pkgp_install_files_v2() {
Lucio Andrés Illanes Albornoz 611492
	local _vflag=""; _status="";
Lucio Andrés Illanes Albornoz 611492
Lucio Andrés Illanes Albornoz 611492
	if [ -n "${PKG_INSTALL_FILES_V2:-}" ]; then
Lucio Andrés Illanes Albornoz b1d432
		if rtl_lmatch "${ARG_VERBOSE_TAGS}" "install" ","; then
Lucio Andrés Illanes Albornoz 30cdf7
			_vflag="-v";
Lucio Andrés Illanes Albornoz 30cdf7
		fi;
Lucio Andrés Illanes Albornoz 611492
		if ! rtl_install_v2							\
Lucio Andrés Illanes Albornoz 611492
				-p "_builddir=${PKG_BUILD_DIR}"				\
Lucio Andrés Illanes Albornoz 611492
				-p "_destdir=${PKG_BASE_DIR}/${PKG_DESTDIR}"		\
Lucio Andrés Illanes Albornoz 611492
				-p "_destdir_host=${PKG_BASE_DIR}/${PKG_DESTDIR_HOST}"	\
Lucio Andrés Illanes Albornoz 611492
				-p "_files=${MIDIPIX_BUILD_PWD}/files/${PKG_NAME}"	\
Lucio Andrés Illanes Albornoz 611492
				-p "_name=${PKG_NAME}"					\
Lucio Andrés Illanes Albornoz 611492
				-p "_prefix=${PKG_PREFIX}"				\
Lucio Andrés Illanes Albornoz 611492
				-p "_prefix_host=${PREFIX}"				\
Lucio Andrés Illanes Albornoz 611492
				-p "_prefix_native=${PREFIX_NATIVE}"			\
Lucio Andrés Illanes Albornoz 611492
				-p "_subdir=${PKG_BASE_DIR}/${PKG_SUBDIR}"		\
Lucio Andrés Illanes Albornoz 611492
				-p "_target=${PKG_TARGET}"				\
Lucio Andrés Illanes Albornoz 611492
				-p "_version=${PKG_VERSION:-}"				\
Lucio Andrés Illanes Albornoz 611492
				-p "_workdir=${BUILD_WORKDIR}"				\
Lucio Andrés Illanes Albornoz 611492
				${_vflag} -- "${PKG_DESTDIR}"				\
Lucio Andrés Illanes Albornoz 611492
				"${PKG_INSTALL_FILES_V2}"; then
Lucio Andrés Illanes Albornoz 611492
			return 1;
Lucio Andrés Illanes Albornoz 611492
		fi;
Lucio Andrés Illanes Albornoz 611492
	fi;
Lucio Andrés Illanes Albornoz 611492
};
Lucio Andrés Illanes Albornoz 611492
Lucio Andrés Illanes Albornoz 8e39bd
pkgp_install_files_perms() {
Lucio Andrés Illanes Albornoz 8e39bd
	local _destdir="" _fname="" IFS;
Lucio Andrés Illanes Albornoz 8e39bd
	for _destdir in "${PKG_DESTDIR}" "${PKG_DESTDIR_HOST}"; do
Lucio Andrés Illanes Albornoz 8e39bd
		if [ -e "${_destdir}" ]; then
Lucio Andrés Illanes Albornoz 8e39bd
			rtl_set_IFS_nl;
Lucio Andrés Illanes Albornoz 8e39bd
			for _fname in $(find "${_destdir}" -type d); do
Lucio Andrés Illanes Albornoz 8e39bd
				if ! rtl_fileop chmod 0755 "${_fname}"; then
Lucio Andrés Illanes Albornoz 8e39bd
					return 1;
Lucio Andrés Illanes Albornoz 8e39bd
				fi;
Lucio Andrés Illanes Albornoz 8e39bd
			done;
Lucio Andrés Illanes Albornoz 8e39bd
			for _fname in $(find "${_destdir}" \( -not -perm /0111 \) -type f); do
Lucio Andrés Illanes Albornoz 8e39bd
				if ! rtl_fileop chmod 0644 "${_fname}"; then
Lucio Andrés Illanes Albornoz 8e39bd
					return 1;
Lucio Andrés Illanes Albornoz 8e39bd
				fi;
Lucio Andrés Illanes Albornoz 8e39bd
			done;
Lucio Andrés Illanes Albornoz 8e39bd
			for _fname in $(find "${_destdir}" -perm /0111 -type f); do
Lucio Andrés Illanes Albornoz 8e39bd
				if ! rtl_fileop chmod 0755 "${_fname}"; then
Lucio Andrés Illanes Albornoz 8e39bd
					return 1;
Lucio Andrés Illanes Albornoz 8e39bd
				fi;
Lucio Andrés Illanes Albornoz 8e39bd
			done;
Lucio Andrés Illanes Albornoz 8e39bd
		fi;
Lucio Andrés Illanes Albornoz 8e39bd
	done;
Lucio Andrés Illanes Albornoz 8e39bd
};
Lucio Andrés Illanes Albornoz 8e39bd
Lucio Andrés Illanes Albornoz 2b85d0
pkgp_install_files_pkgconfig() {
Lucio Andrés Illanes Albornoz 2b85d0
	local _pc_path="";
Lucio Andrés Illanes Albornoz 2b85d0
	for _pc_path in $(find "${PKG_DESTDIR}" -name \*.pc); do
Lucio Andrés Illanes Albornoz 0d1c4f
		if [ -n "$(sed -ne '/^libdir=[^$]*$/p' "${_pc_path}")" ]			\
Lucio Andrés Illanes Albornoz 0d1c4f
		&& ! sed -i""	-e '/^libdir=[^$]*$/s/^libdir=\(.*\)$/libdir=${exec_prefix}\1/'	\
Lucio Andrés Illanes Albornoz 0d1c4f
				-e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/'		\
Lucio Andrés Illanes Albornoz bf9edf
				"${_pc_path}"; then
Lucio Andrés Illanes Albornoz bf9edf
			return 1;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
786c74
		if [ -n "$(sed -ne '/^includedir=[^$]*$/p' "${_pc_path}")" ]				\
786c74
		&& ! sed -i""	-e '/^includedir=[^$]*$/s/^includedir=\(.*\)$/includedir=${prefix}\1/'	\
786c74
				"${_pc_path}"; then
786c74
			return 1;
786c74
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
	done;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 2b85d0
pkgp_install_files_strip() {
Lucio Andrés Illanes Albornoz 00ef8a
	local _bin_path="" _stripfl=0 _tree_root="${PKG_DESTDIR}";
Lucio Andrés Illanes Albornoz 00ef8a
	if [ -e "${_tree_root}" ]; then
Lucio Andrés Illanes Albornoz 00ef8a
		if rtl_match "${PKG_NAME}" "*_minipix"; then
Lucio Andrés Illanes Albornoz 00ef8a
			: $((_stripfl=(${ARG_DEBUG_MINIPIX:-0} ? 0 : 1)));
Lucio Andrés Illanes Albornoz 00ef8a
		elif [ "${BUILD_KIND}" = release ]\
Lucio Andrés Illanes Albornoz 00ef8a
		&&   [ "${PKG_BUILD_TYPE}" = native ]; then
Lucio Andrés Illanes Albornoz 00ef8a
			_stripfl=1;
Lucio Andrés Illanes Albornoz 00ef8a
		else
Lucio Andrés Illanes Albornoz 00ef8a
			_stripfl=0;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz 00ef8a
		if [ "${_stripfl:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz 00ef8a
			for _bin_path in $(find "${_tree_root}" -perm /a=x -type f); do
Lucio Andrés Illanes Albornoz 00ef8a
				if objdump -sj .debug_frame -j .debug_info "${_bin_path}" >/dev/null 2>&1; then
Lucio Andrés Illanes Albornoz e493dc
					rtl_log_msg "pkg_strip" "${MSG_pkg_strip}" "${_bin_path}";
Lucio Andrés Illanes Albornoz 00ef8a
					if ! "${PKG_TARGET}-strip" "${_bin_path}"; then
Lucio Andrés Illanes Albornoz 00ef8a
						return 1;
Lucio Andrés Illanes Albornoz 00ef8a
					fi;
Lucio Andrés Illanes Albornoz bf9edf
				fi;
Lucio Andrés Illanes Albornoz 00ef8a
			done;
Lucio Andrés Illanes Albornoz 00ef8a
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 2b85d0
pkg_install_files() {
Lucio Andrés Illanes Albornoz 2b85d0
	if ! pkgp_install_files\
Lucio Andrés Illanes Albornoz 611492
	|| ! pkgp_install_files_v2\
Lucio Andrés Illanes Albornoz 8e39bd
	|| ! pkgp_install_files_perms\
Lucio Andrés Illanes Albornoz 2b85d0
	|| ! pkgp_install_files_pkgconfig\
Lucio Andrés Illanes Albornoz 2b85d0
	|| ! pkgp_install_files_strip; then
Lucio Andrés Illanes Albornoz bf9edf
		return 1;
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