Blame subr.pkg/pkg_install_rpm.subr

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
pkg_install_rpm() {
e9fa07
	local	_pir_group_name="${1}" _pir_pkg_name="${2}" _pir_restart_at="${3}"	\
e9fa07
		_pir_pkg_url="" _pir_pkg_version_full="" _pir_pkg_version_rpm=""	\
e9fa07
		_pir_rc=0;
e9fa07
e9fa07
	if rtl_lmatch \$ARG_DIST "rpm" ","\
e9fa07
	&& [ "${PKG_RPM_DISABLE:-0}" -eq 0 ]\
e9fa07
	&& command which rpmbuild >/dev/null 2>&1;
e9fa07
	then
e9fa07
		if [ "${PKG_URL:+1}" = 1 ]; then
e9fa07
			_pir_pkg_url="${PKG_URL%% *}"; _pir_pkg_version_full="${PKG_VERSION}"; _pir_pkg_version_rpm="${PKG_VERSION%%-*}";
e9fa07
		elif [ "${PKG_URLS_GIT:+1}" = 1 ]; then
e9fa07
			_pir_pkg_version_rpm="$(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse HEAD)";
e9fa07
			_pir_pkg_version_full="${_pir_pkg_version_rpm} ($(cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && git rev-parse --abbrev-ref HEAD))";
e9fa07
			_pir_pkg_url="${PKG_URLS_GIT%% *}"; _pir_pkg_url="${_pir_pkg_url##*=}"; _pir_pkg_url="${_pir_pkg_url%%@*}";
e9fa07
e9fa07
			if [ "${_pir_pkg_url#${DEFAULT_GITROOT_HEAD}}" != "${_pir_pkg_url}" ]; then
e9fa07
				_pir_pkg_url="Unknown";
e9fa07
			fi;
e9fa07
		fi;
e9fa07
e9fa07
		if ! rtl_fileop cp "${MIDIPIX_BUILD_PWD}/etc/package.spec"	\
e9fa07
				"${PKG_BASE_DIR}/${PKG_NAME}-${_pir_pkg_version_rpm}.spec";
e9fa07
		then
e9fa07
			return 1;
e9fa07
		else
e9fa07
			while true; do
e9fa07
				rpmbuild									\
e9fa07
					-bb									\
e9fa07
					--define="_tmppath ${BUILD_WORKDIR}"					\
e9fa07
					--define="_topdir ${PREFIX_RPM}/${PKG_NAME}-${_pir_pkg_version_rpm}"	\
e9fa07
					--define="pkg_destdir ${PKG_DESTDIR}"					\
e9fa07
					--define="pkg_name ${PKG_NAME}"						\
e9fa07
					--define="pkg_url ${_pir_pkg_url}"					\
e9fa07
					--define="pkg_version_full ${_pir_pkg_version_full}"			\
e9fa07
					--define="pkg_version_rpm ${_pir_pkg_version_rpm}"			\
e9fa07
					--nodeps "${PKG_BASE_DIR}/${PKG_NAME}-${_pir_pkg_version_rpm}.spec";
e9fa07
				_pir_rc="${?}";
e9fa07
e9fa07
				if [ "${_pir_rc}" -eq 0 ]; then
e9fa07
					break;
e9fa07
				elif [ "${_pir_rc}" -eq 141 ]; then
e9fa07
					continue;
e9fa07
				else
e9fa07
					return "${_pir_rc}";
e9fa07
				fi;
e9fa07
			done;
e9fa07
e9fa07
			if ! find "${PREFIX_RPM}/${PKG_NAME}-${_pir_pkg_version_rpm}/RPMS"	\
e9fa07
				-iname \*.rpm -exec cp -pP {} "${PREFIX_RPM}/" \;		\
e9fa07
			|| ! rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${_pir_pkg_version_rpm}"	\
e9fa07
			|| ! rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${_pir_pkg_version_rpm}.spec" "${PREFIX_RPM}/";
e9fa07
			then
e9fa07
				return 1;
e9fa07
			fi;
e9fa07
		fi;
e9fa07
	fi;
e9fa07
e9fa07
	return 0;
e9fa07
};
e9fa07
64844b
# vim:filetype=sh textwidth=0