Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone
Blob Blame History Raw
#
# set +o errexit -o noglob is assumed.
#

pkg_install_rpm() {
	local _pkg_url="" _pkg_version_full="" _pkg_version_rpm="" _rc=0;
	if rtl_lmatch "${ARG_DIST}" "rpm" ","\
	&& [ "${PKG_RPM_DISABLE:-0}" -eq 0 ]\
	&& [ -x "$(which rpmbuild 2>/dev/null)" ]; then
		if [ -n "${PKG_URL}" ]; then
			_pkg_url="${PKG_URL}"; _pkg_version_full="${PKG_VERSION}"; _pkg_version_rpm="${PKG_VERSION%%-*}";
		elif [ -n "${PKG_URLS_GIT}" ]; then
			_pkg_version_rpm="$(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse HEAD)";
			_pkg_version_full="${_pkg_version_rpm} ($(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse --abbrev-ref HEAD))";
			_pkg_url="${PKG_URLS_GIT%% *}"; _pkg_url="${_pkg_url##*=}"; _pkg_url="${_pkg_url%%@*}";
			if [ "${_pkg_url#${DEFAULT_GITROOT_HEAD}}" != "${_pkg_url}" ]; then
				_pkg_url="Unknown";
			fi;
		fi;
		if ! rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/package.spec"					\
				"${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec"; then
			return 1;
		else	while true; do
				rpmbuild									\
					-bb									\
					--define="_tmppath ${BUILD_WORKDIR}"					\
					--define="_topdir ${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}"	\
					--define="pkg_destdir ${PKG_DESTDIR}"					\
					--define="pkg_name ${PKG_NAME}"						\
					--define="pkg_url ${_pkg_url}"						\
					--define="pkg_version_full ${_pkg_version_full}"			\
					--define="pkg_version_rpm ${_pkg_version_rpm}"				\
					--nodeps "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec"; _rc="${?}";
				if [ "${_rc}" -eq 0 ]; then
					break;
				elif [ "${_rc}" -eq 141 ]; then
					continue;
				else
					return "${_rc}";
				fi;
			done;
			if ! find "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}/RPMS"				\
				-iname \*.rpm -exec cp -pP {} "${PREFIX_RPM}/" \;				\
			|| ! rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}"			\
			|| ! rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec" "${PREFIX_RPM}/"; then
				return 1;
			fi;
		fi;
	fi;
};

# vim:filetype=sh