ovirt-imageio/ovirt-imageio.spec

147 lines
4.0 KiB
RPMSpec

# SPDX-FileCopyrightText: Red Hat, Inc.
# SPDX-License-Identifier: GPL-2.0-or-later
Name: ovirt-imageio
Version: 2.5.0~git0.83401ef
Release: 0
Summary: oVirt imageio
License: GPL-2.0-or-later
Url: https://github.com/oVirt/%{name}
Source0: https://github.com/oVirt/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz
BuildRequires: fdupes
%global ovirtimg_user ovirtimg
%global srcname ovirt_imageio
%global logdir %{_localstatedir}/log/%{name}
%global admin_confdir %{_sysconfdir}/%{name}
%global vendor_confdir %{_prefix}/lib/%{name}
%description
Transfer disk images on oVirt system.
%prep
%setup -q
%build
%py3_build
%install
%py3_install
install -D -m 0755 --directory %{buildroot}%{logdir}
# Create a dummy log file to make rpm happy during build
touch %{buildroot}%{logdir}/daemon.log
install -D -m 0755 --directory %{buildroot}%{vendor_confdir}/conf.d
install -D -m 0755 --directory %{buildroot}%{admin_confdir}/conf.d
install -D -m 0644 data/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%fdupes %buildroot%{python3_sitearch}
%package common
Summary: oVirt imageio common resources
# NOTE: keep in sync with docs/development.md
BuildRequires: gcc
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: python3
%description common
Common resources used by oVirt imageio server and client
%files common
%license LICENSES/GPL-2.0-or-later.txt
%{python3_sitearch}/%{srcname}
%{python3_sitearch}/%{srcname}-*.egg-info
%exclude %{python3_sitearch}/%{srcname}/client
%exclude %{python3_sitearch}/%{srcname}/admin
%package client
Summary: oVirt imageio client library
Requires: %{name}-common = %{version}-%{release}
%if 0%{?rhel}
# RHEL 8.4 version. Some features require qemu-nbd 5.2.0 and are disabled when
# using older qemu-nbd.
Requires: qemu-img >= 15:4.2.0
Requires: python3-ovirt-engine-sdk4
%else
# Fedora.
Requires: qemu-img
%endif
%description client
Python client library for accessing imageio server on oVirt hosts.
%files client
%{python3_sitearch}/%{srcname}/client
%{_bindir}/ovirt-img
%package daemon
Summary: oVirt imageio daemon
# NOTE: keep in sync with docs/development.md
BuildRequires: systemd
Requires: python3-systemd
Requires: %{name}-common = %{version}-%{release}
Requires(pre): user(ovirtimg)
%description daemon
Daemon providing image transfer service on oVirt hosts.
%files daemon
%doc data/README
%{python3_sitearch}/%{srcname}/admin
%{_bindir}/%{name}
%{_bindir}/%{name}ctl
%{_unitdir}/%{name}.service
%dir %{admin_confdir}
%dir %{admin_confdir}/conf.d
%dir %{vendor_confdir}
%dir %{vendor_confdir}/conf.d
# The log directory should belong to the daemon so it can create log files.
# http://rpm.org/max-rpm-snapshot/s1-rpm-inside-files-list-directives.html#S3-RPM-INSIDE-FLIST-ATTR-DIRECTIVE
%dir %attr(755, %{ovirtimg_user}, %{ovirtimg_user}) %{logdir}
# The log files belongs to the package, so they will be removed with the package.
# http://rpm.org/max-rpm-snapshot/s1-rpm-inside-files-list-directives.html#S3-RPM-INSIDE-FLIST-GHOST-DIRECTIVE
%ghost %attr(644, %{ovirtimg_user}, %{ovirtimg_user}) %{logdir}/daemon.log*
# For more information about the systemd macros, see:
# https://fedoraproject.org/wiki/Packaging:Scriptlets#New_Packages
# For info on ordering of the scriplets, see:
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering
%pre daemon
%systemd_pre %{name}.service
%post daemon
# After installation, synchronize service state with preset files.
%systemd_post %{name}.service
%preun daemon
# Before uninstalling, stop and disable the service.
%systemd_preun %{name}.service
%postun daemon
# After upgrading, restart the service.
%systemd_postun_with_restart %{name}.service
%posttrans daemon
# At the end of the transaction, stop stale ovirt-imageio-daemon service.
# Needed only when upgrading from ovirt-imageio-daemon < 2.
if systemctl is-active ovirt-imageio-daemon.service >/dev/null; then
echo "Stopping ovirt-imageio-daemon.service";
systemctl stop ovirt-imageio-daemon.service
fi
%changelog