midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_install_rpm.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
#
Lucio Andrés Illanes Albornoz 2b85d0
# set +o errexit -o noglob is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
#
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
pkg_install_rpm() {
Lucio Andrés Illanes Albornoz 2b85d0
	local _pkg_url="" _pkg_version_full="" _pkg_version_rpm="" _rc=0;
Lucio Andrés Illanes Albornoz 2b85d0
	if ex_rtl_lmatch "${ARG_DIST}" "rpm" ","\
Lucio Andrés Illanes Albornoz 2b85d0
	&& [ "${PKG_RPM_DISABLE:-0}" -eq 0 ]\
Lucio Andrés Illanes Albornoz 0eaee4
	&& [ -x "$(which rpmbuild 2>/dev/null)" ]; then
Lucio Andrés Illanes Albornoz 0eaee4
		if [ -n "${PKG_URL}" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
			_pkg_url="${PKG_URL}"; _pkg_version_full="${PKG_VERSION}"; _pkg_version_rpm="${PKG_VERSION%%-*}";
Lucio Andrés Illanes Albornoz 0eaee4
		elif [ -n "${PKG_URLS_GIT}" ]; then
Lucio Andrés Illanes Albornoz 0eaee4
			_pkg_version_rpm="$(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse HEAD)";
Lucio Andrés Illanes Albornoz 0eaee4
			_pkg_version_full="${_pkg_version_rpm} ($(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse --abbrev-ref HEAD))";
Lucio Andrés Illanes Albornoz 2b85d0
			_pkg_url="${PKG_URLS_GIT%% *}"; _pkg_url="${_pkg_url##*=}"; _pkg_url="${_pkg_url%%@*}";
Lucio Andrés Illanes Albornoz 0eaee4
			if [ "${_pkg_url#${DEFAULT_GITROOT_HEAD}}" != "${_pkg_url}" ]; then
Lucio Andrés Illanes Albornoz 0eaee4
				_pkg_url="Unknown";
Lucio Andrés Illanes Albornoz 0eaee4
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
		if ! ex_rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/package.spec"					\
Lucio Andrés Illanes Albornoz 2b85d0
				"${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec"; then
Lucio Andrés Illanes Albornoz 2b85d0
			return 1;
Lucio Andrés Illanes Albornoz 2b85d0
		else	while true; do
Lucio Andrés Illanes Albornoz 2b85d0
				rpmbuild									\
Lucio Andrés Illanes Albornoz 2b85d0
					-bb									\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="_tmppath ${BUILD_WORKDIR}"					\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="_topdir ${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}"	\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="pkg_destdir ${PKG_DESTDIR}"					\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="pkg_name ${PKG_NAME}"						\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="pkg_url ${_pkg_url}"						\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="pkg_version_full ${_pkg_version_full}"			\
Lucio Andrés Illanes Albornoz 2b85d0
					--define="pkg_version_rpm ${_pkg_version_rpm}"				\
Lucio Andrés Illanes Albornoz 2b85d0
					--nodeps "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec"; _rc="${?}";
Lucio Andrés Illanes Albornoz 2b85d0
				if [ "${_rc}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz dc935b
					break;
Lucio Andrés Illanes Albornoz 2b85d0
				elif [ "${_rc}" -eq 141 ]; then
Lucio Andrés Illanes Albornoz 2b85d0
					continue;
Lucio Andrés Illanes Albornoz 2b85d0
				else
Lucio Andrés Illanes Albornoz 2b85d0
					return "${?}";
Lucio Andrés Illanes Albornoz dc935b
				fi;
Lucio Andrés Illanes Albornoz 2b85d0
			done;
Lucio Andrés Illanes Albornoz 2b85d0
			if ! find "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}/RPMS"				\
Lucio Andrés Illanes Albornoz 2b85d0
				-iname \*.rpm -exec cp -pP {} "${PREFIX_RPM}/" \;				\
Lucio Andrés Illanes Albornoz 2b85d0
			|| ! ex_rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${_pkg_version_rpm}"			\
Lucio Andrés Illanes Albornoz 2b85d0
			|| ! ex_rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${_pkg_version_rpm}.spec" "${PREFIX_RPM}/"; then
Lucio Andrés Illanes Albornoz 2b85d0
				return "${?}";
Lucio Andrés Illanes Albornoz dc935b
			fi;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz 0eaee4
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
};
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
Lucio Andrés Illanes Albornoz (arab, vxp) 729be5
# vim:filetype=sh