#
# CUSTOMIZATION-BEGIN
#
# ovirt_build_extra_flags
# ovirt_build_ut
%if 0%{?ovirt_build_quick}
%global _ovirt_build_ut 0
%global ovirt_build_gwt 0
%endif
%if 0%{?ovirt_build_minimal}
%global _ovirt_build_ut 0
%global ovirt_build_all_user_agents 0
%global ovirt_build_locales 0
%global _ovirt_build_extra_flags -D gwt.userAgent=gecko1_8
%endif
%if 0%{?ovirt_build_draft}
%global _ovirt_build_ut 0
%global ovirt_build_all_user_agents 0
%global ovirt_build_locales 0
%global _ovirt_build_extra_flags -D gwt.userAgent=gecko1_8 -P gwtdraft
%endif
%if 0%{!?ovirt_build_ut:1}
%if 0%{?_ovirt_build_ut:1}
%global ovirt_build_ut %{_ovirt_build_ut}
%else
%global ovirt_build_ut 1
%endif
%endif
%if 0%{!?ovirt_build_gwt:1}
%global ovirt_build_gwt 1
%endif
%if 0%{!?ovirt_build_locales:1}
%global ovirt_build_locales 1
%endif
%if 0%{!?ovirt_build_all_user_agents:1}
%global ovirt_build_all_user_agents 1
%endif
%global ovirt_provides_jboss 1
#
# CUSTOMIZATION-END
#

#raw

# Do not repack .jar files, as it takes a long time and doesn't have a
# real benefit:
%global __jar_repack 0

%if !%{ovirt_provides_jboss}
#
# unsign all provided jars
# see rhbz#1019637
#
%global _jarsign_opts --unsign=/usr/share/ovirt-engine
%endif

#
# rpm does not support override
# nor modify of variables
#
%if %{?_ovirt_build_extra_flags:1}%{?ovirt_build_extra_flags:1}0
%global EXTRA_BUILD_FLAGS %{?_ovirt_build_extra_flags:%{_ovirt_build_extra_flags}}%{?ovirt_build_extra_flags: %{ovirt_build_extra_flags}}
%endif

#
# Supported distributions:
# Fedora >= 30
# EL >= 7
#

%global ovirt_install_poms 1

%global ovirt_product_name oVirt Engine
%global ovirt_product_name_short oVirt Engine
%global ovirt_product_group Virtualization/Management
%global ovirt_user_description oVirt Manager


%global engine_cache %{_localstatedir}/cache/%{engine_name}
%global engine_data %{_datadir}/%{engine_name}
%global engine_doc %{_docdir}/%{engine_name}
%global engine_ear %{engine_data}/engine.ear
%global engine_etc %{_sysconfdir}/%{engine_name}
%global engine_java %{_javadir}/%{engine_name}
%global engine_jboss_modules %{engine_data}/modules
%global engine_log %{_localstatedir}/log/%{engine_name}
%global engine_name ovirt-engine
%global engine_pki %{_sysconfdir}/pki/%{engine_name}
%global engine_restapi_war %{engine_data}/restapi.war
%global engine_apidoc_war %{engine_data}/apidoc.war
%global engine_run %{_localstatedir}/run/%{engine_name}
%global engine_state %{_localstatedir}/lib/%{engine_name}
%global engine_tmp %{_localstatedir}/tmp/%{engine_name}
%global engine_backup_default_dir  %{_localstatedir}/lib/%{engine_name}-backup
%global engine_backup_log_default_dir  %{_localstatedir}/log/%{engine_name}-backup
%global engine_rpm_state_dir  %{_localstatedir}/lib/rpm-state/%{name}
%global engine_setup_rpm_state_flag_file %{engine_rpm_state_dir}/need-engine-setup

%global engine_gid 108
%global engine_group ovirt
%global engine_uid 108
%global engine_user ovirt
%global vdsm_description Node Virtualization Manager
%global vdsm_gid 36
%global vdsm_group kvm
%global vdsm_uid 36
%global vdsm_user vdsm

%global openstack_java_version 3.2.9

# Macro to create an user:
#
# %1 user name
# %2 user id
# %3 primary group name
# %4 primary group id
# %5 description
# %6 home directory
#
%global _ovirt_create_user() \
getent group %3 >/dev/null || groupadd -r -g %4 %3; \
getent passwd %1 >/dev/null || useradd -r -u %2 -g %3 -c %5 -s /sbin/nologin -d %6 %1

%global ovirt_create_user_engine \
%_ovirt_create_user %{engine_user} %{engine_uid} %{engine_group} %{engine_gid} "%%{ovirt_user_description}" %{engine_state}

%global ovirt_create_user_vdsm \
%_ovirt_create_user %{vdsm_user} %{vdsm_uid} %{vdsm_group} %{vdsm_gid} "%%{vdsm_description}" /var/lib/vdsm

%global wildfly_overlay_modules "/usr/share/ovirt-engine-wildfly-overlay/modules"

%global make_common_opts \\\
	-j1 \\\
	BUILD_GWT=%{ovirt_build_gwt} \\\
	BUILD_ALL_USER_AGENTS=%{ovirt_build_all_user_agents} \\\
	BUILD_LOCALES=%{ovirt_build_locales} \\\
	BUILD_UT=%{ovirt_build_ut} \\\
	BUILD_VALIDATION=0 \\\
	PACKAGE_NAME=%{name} \\\
	RPM_VERSION=%{version} \\\
	RPM_RELEASE=%{release} \\\
	DISPLAY_VERSION=%{version}-%{release} \\\
	ENGINE_NAME=%{engine_name} \\\
	LOCALSTATE_DIR=%{_localstatedir} \\\
	PREFIX=%{_prefix} \\\
	SYSCONF_DIR=%{_sysconfdir} \\\
	BIN_DIR=%{_bindir} \\\
	PID_DIR=%{_localstatedir}/run \\\
	DATAROOT_DIR=%{_datadir} \\\
	MAN_DIR=%{_mandir} \\\
	DOC_DIR=%{_docdir} \\\
	PYTHON_DIR=%{python3_sitelib} \\\
	PYTHON=%{__python3} \\\
	PY_VERSION=3 \\\
	JAVA_DIR=%{_javadir} \\\
	MAVENPOM_DIR=%{_mavenpomdir} \\\
	PKG_SYSCONF_DIR=%{engine_etc} \\\
	PKG_DOC_DIR=%{engine_doc} \\\
	PKG_EAR_DIR=%{engine_ear} \\\
	PKG_PKI_DIR=%{engine_pki} \\\
	PKG_JBOSS_MODULES=%{engine_jboss_modules} \\\
	PKG_CACHE_DIR=%{engine_cache} \\\
	PKG_LOG_DIR=%{engine_log} \\\
	PKG_BACKUP_DEFAULT_DIR=%{engine_backup_default_dir} \\\
	PKG_BACKUP_LOG_DEFAULT_DIR=%{engine_backup_log_default_dir} \\\
	PKG_TMP_DIR=%{engine_tmp} \\\
	PKG_STATE_DIR=%{engine_state} \\\
	PKG_USER=%{engine_user} \\\
	PKG_GROUP=%{engine_group} \\\
	POSTGRESQL_SYSTEMD_SERVICE=postgresql.service \\\
	WILDFLY_OVERLAY_MODULES=%{wildfly_overlay_modules} \\\
	%{?EXTRA_BUILD_FLAGS:EXTRA_BUILD_FLAGS="%{EXTRA_BUILD_FLAGS}"} \\\
	%{?extra_common_opts}

%global ovirt_dependencies ovirt-dependencies/4.4

Name:		ovirt-engine
Version:	4.4.4.1
Release:	6
Summary:	Management server for Open Virtualization
Group:		%{ovirt_product_group}
License:	Apache 2.0
URL:		http://www.ovirt.org
Source0:	http://resources.ovirt.org/pub/ovirt-master-snapshot/src/ovirt-engine/ovirt-engine-4.4.4.1.tar.gz
Source1:        xalan-2.7.1.jbossorg-2.jar
# wget https://repo1.maven.org/maven2/com/github/warmuuh/libsass-maven-plugin/0.2.8-libsass_3.4.4/libsass-maven-plugin-0.2.8-libsass_3.4.4.pom
# version=`grep jsass libsass-maven-plugin-0.2.8-libsass_3.4.4.pom` -A 1| grep "version"|awk -F ">" '{print $2}' | awk -F "<" '{print $1}'`
# sed -i "s/$version/5.10.3/g" libsass-maven-plugin-0.2.8-libsass_3.4.4.pom
Source2:        libsass-maven-plugin-0.2.8-libsass_3.4.4.pom
Source3:        https://github.com/oVirt/ovirt-engine-api-model/archive/refs/tags/4.4.20.tar.gz
Source4:        0006-add-arm-biostype-in-front-end-api.patch

Patch1:         0001-add-dependent-package-to-lib.patch
Patch2:         0002-add-support-running-on-kunpeng-platform.patch
Patch3:         0003-add-virt-chipset-support.patch
Patch4:         0004-fit-cluster-can-not-find-error-under-aarch64-platform.patch
Patch5:         0005-fix-interface-report-an-error-when-emulatedMachine-is-null.patch
Patch6:         0007-add-config-item-for-openeuler.patch
Patch7:         CVE-2020-10775.patch
Patch8:         0008-modify-sshd-core-version.patch
Patch9:         0009-fix-host-installation-failure.patch
Patch10:        0010-get-vdsm-id-from-dmidecode-system-uuid-on-aarch64.patch
BuildArch:	noarch

BuildRequires:	assertj-core >= 2.2.0
BuildRequires:	maven >= 3.5.0
BuildRequires:  maven-enforcer-plugin
BuildRequires:	java-11-openjdk-devel >= 11.0.4
BuildRequires:	javapackages-tools
BuildRequires:	make
BuildRequires:	python3-devel
BuildRequires:	systemd
BuildRequires:	unzip
BuildRequires:	ovirt-jboss-modules-maven-plugin >= 2.0.1
BuildRequires:	javapackages-local

Requires(pre):	shadow-utils

Requires:	ovirt-engine-wildfly-overlay = 19.1.0
Requires:	ansible-2.9 
Requires:       sudo >= 1.9.2

Requires:	%{name}-backend = %{version}-%{release}
Requires:	%{name}-dbscripts = %{version}-%{release}
Requires:	%{name}-restapi = %{version}-%{release}
Requires:	%{name}-tools = %{version}-%{release}
Requires:	%{name}-webadmin-portal = %{version}-%{release}
Requires:	%{name}-websocket-proxy >= %{version}-%{release}
Requires:	%{name}-vmconsole-proxy-helper >= %{version}-%{release}
Requires:	%{name}-ui-extensions >= 1.0.4
Requires:	ansible-runner-service >= 1.0.6
Requires:	apache-commons-compress
Requires:	apache-commons-configuration
Requires:	apache-commons-jxpath
Requires:	java-11-openjdk-headless >= 11.0.4
Requires:	javapackages-tools
Requires:	ovirt-imageio-daemon >= 2.0.10-1
Requires:	python3-mod_wsgi >= 4.6.4
Requires:	slf4j >= 1.7.0
Requires:	ws-commons-util
Requires:	xmlrpc-client
Requires:	ovirt-ansible-collection >= 1.2.0
Requires:	ovirt-web-ui
Requires:	ovirt-cockpit-sso
Obsoletes:	ovirt-engine-api-explorer

# This is required for OpenJDK keytool to work properly, when engine machine
# is running in FIPS mode. More info at https://bugzilla.redhat.com/1894083
Requires:	nss

# Metrics stuff
Requires:	collectd
Requires:	collectd-postgresql
Requires:	collectd-disk
Requires:	collectd-write_http
Requires:	collectd-write_syslog


# Requirements for ovirt-engine-metrics
Requires:	rsyslog
Requires:	rsyslog-elasticsearch
Requires:	rsyslog-mmjsonparse
Requires:	rsyslog-mmnormalize
Requires:	libfastjson
Requires:	liblognorm
Requires:	libestr

Requires:	postgresql-jdbc >= 42.2.3

Requires:	postgresql-13-server
Requires:	postgresql-13-contrib

Requires:	openstack-java-cinder-client >= %{openstack_java_version}
Requires:	openstack-java-cinder-model >= %{openstack_java_version}
Requires:	openstack-java-client >= %{openstack_java_version}
Requires:	openstack-java-glance-client >= %{openstack_java_version}
Requires:	openstack-java-glance-model >= %{openstack_java_version}
Requires:	openstack-java-keystone-client >= %{openstack_java_version}
Requires:	openstack-java-keystone-model >= %{openstack_java_version}
Requires:	openstack-java-quantum-client >= %{openstack_java_version}
Requires:	openstack-java-quantum-model >= %{openstack_java_version}
Requires:	openstack-java-resteasy-connector >= %{openstack_java_version}
Requires:	python3-dnf-plugin-versionlock
Requires:	apache-sshd >= 2.5.0
Requires:	slf4j-jdk14 >= 1.7.0
Requires:	jcl-over-slf4j >= 1.7.0
Requires:	snmp4j >= 2.4.1
Requires:	ovirt-dependencies >= 4.4.2
%{?extra_main_requires}

# We can't require exactly the same version and release of the
# setup package because it needs to be updated independently as part
# of the update process implemented in the engine-upgrade script:
Requires:	%{name}-setup >= %{version}-%{release}

# We can drop these conflicts when
# we drop Requires: mod_ssl
Conflicts:	freeipa-server
Conflicts:	ipa-server
Conflicts:	python2-ipaserver
Conflicts:	python3-ipaserver

# Userportal is retired
Obsoletes:	%{name}-userportal

#JavaScript and CSS libraries are currently bundled
Provides:	bundled(js-jquery) = 3.4.1
Provides:	bundled(js-jquery-ui) = 1.12.1
Provides:	bundled(js-bootstrap) = 3.4.1
Provides:	bundled(js-patternfly) = 3.59.3
Provides:	bundled(js-patternfly-next) = 2.26.1

%description
%{ovirt_product_name} is a feature-rich server virtualization management
system that provides advanced capabilities for managing the Open
virtualization infrastructure for Servers and Desktops.

%if !%{ovirt_provides_jboss}
%package -n rhvm
Summary:    Red Hat Virtualization Manager
Group:      %{ovirt_product_group}
Requires:   ovirt-engine = %{version}-%{release}
Requires:   ovirt-log-collector >= 4.3.0
Requires:   rhv-log-collector-analyzer
# misc packages
Requires:   spice-client-win-x64 >= %{spice_version}
Requires:   spice-client-win-x86 >= %{spice_version}

%description -n rhvm
Red Hat Virtualization is a feature-rich server virtualization management
system that provides advanced capabilities for managing Red Hat
virtualization infrastructure for Servers and Desktops.
%endif

%package -n python%{python3_pkgversion}-%{name}-lib
Summary:	%{ovirt_product_name_short} library
Group:		%{ovirt_product_group}
Requires:	python3-m2crypto >= 0.28
Requires:	python3-dateutil
Requires:	python3-daemon >= 2.1.2

%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}-lib}

%description -n python%{python3_pkgversion}-%{name}-lib
%{ovirt_product_name_short} library for python3

%package backend
Summary:	Engine core of %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
License:	ASL 2.0 and LGPLv3 and GPLv3
Requires:	%{name} = %{version}-%{release}
Requires:	%{name}-extensions-api >= 1.0.0
Requires:	aopalliance >= 1.0
Requires:	curl
Requires:	httpd
Requires:	java-11-openjdk-headless
Requires:	logrotate
Requires:	mailcap
Requires:	mod_ssl
Requires:	novnc >= 1.0.0
Requires:	python3-%{name}-lib >= %{version}-%{release}
Requires:	openssh >= 8.2p1
Requires:	vdsm-jsonrpc-java >= 1.5.4
Conflicts:  vdsm-jsonrpc-java >= 1.6
Requires:	java-client-kubevirt >= 0.5.0
Requires:	openssl
Requires:	ovirt-engine-extension-aaa-jdbc >= 1.2.0
Requires:	python3-jinja2
%{?extra_backend_requires}
Requires(pre):	shadow-utils
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd

%pre backend
%ovirt_create_user_engine

%post backend
%systemd_post ovirt-engine.service

%preun backend
%systemd_preun ovirt-engine.service

%postun backend
%systemd_postun ovirt-engine.service

%description backend
The backend engine of %{ovirt_product_name_short}

%package restapi
Summary:	RESTful API for %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
Requires:	%{name} = %{version}-%{release}

%description restapi
The RESTful API for %{ovirt_product_name_short}

%package setup-base
Summary:	%{ovirt_product_name_short} suite base setup components.
Group:		%{ovirt_product_group}
Requires:	python3-%{name}-lib >= %{version}-%{release}
Requires:	python3-ovirt-setup-lib >= 1.1.1
Requires:	bind-utils
Requires:	iproute
Requires:	python3-libxml2
Requires:	logrotate
Requires:	python3-otopi >= 1.9.0
Requires:	python3-paramiko
Requires(pre):	shadow-utils
Conflicts:	%{name}-dwh < 4.4.0
Conflicts:	%{name}-dwh-setup < 4.4.0

%description setup-base
%{ovirt_product_name_short} suite base setup components.

%pre setup-base
%ovirt_create_user_engine

%package setup
Summary:	Setup and upgrade scripts for %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
Requires:	%{name}-setup-plugin-ovirt-engine = %{version}-%{release}
%{?extra_setup_requires}

%description setup
Setup and upgrade scripts for %{ovirt_product_name_short}

%post setup
# If this is an update, tell the users they need to run engine-setup
if [ $1 -gt 1 -a -e "%{_sysconfdir}/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf" ]; then
  touch %{engine_setup_rpm_state_flag_file}
  echo "Updating ovirt-engine-setup. To update the engine, you need to run: engine-setup"
fi

%posttrans setup
if [ -e %{engine_setup_rpm_state_flag_file} -a -e "%{_sysconfdir}/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf" ]; then
  echo "Updated ovirt-engine-setup. To update the engine, you need to run: engine-setup"
fi
rm -f %{engine_setup_rpm_state_flag_file}

%package setup-plugin-ovirt-engine
Summary:	Setup and upgrade specific plugins for %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
Requires:	%{name} >= 4.4.0
Requires:	%{name}-setup-plugin-ovirt-engine-common = %{version}-%{release}
Requires:	%{name}-setup-plugin-vmconsole-proxy-helper = %{version}-%{release}
Requires:	%{name}-setup-plugin-cinderlib = %{version}-%{release}
Requires:	%{name}-setup-plugin-imageio = %{version}-%{release}
Requires:	%{name}-dwh-setup >= 4.4.1.2
Requires:	ovirt-engine-extension-aaa-jdbc >= 1.2.0
Requires:	openssh >= 8.2p1
Requires:       postgresql-13-server
Requires:       postgresql-13-contrib
Conflicts:	%{name} < 4.4.0
# See rhbz# 1676461
Requires:	ovirt-vmconsole >= 1.0.7

%description setup-plugin-ovirt-engine
Setup and upgrade specific plugins for %{ovirt_product_name_short}

%pre setup-plugin-ovirt-engine
%ovirt_create_user_vdsm

%package setup-plugin-ovirt-engine-common
Summary:	Setup and upgrade common plugins for %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
Requires:	%{name}-setup-base = %{version}-%{release}
Requires:	python3-libselinux
Requires:	policycoreutils-python-utils
Requires:	python3-psycopg2
Requires(pre):	shadow-utils
Requires:	java-11-openjdk-headless >= 11.0.4
Requires:	python3-pwquality
Requires:	python3-m2crypto >= 0.28
Requires:	python3-dnf

# We can drop these conflicts when
# we drop Requires: mod_ssl
# conflict here so we can avoid upgrade
# of setup at this environment, this
# will produce early error.
Conflicts:	ipa-server
Conflicts:	freeipa-server

%description setup-plugin-ovirt-engine-common
Setup and upgrade common plugins for %{ovirt_product_name_short}

%package dbscripts
Summary:	Database scripts for %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
Requires:	%{name} = %{version}-%{release}

%description dbscripts
Database scripts for %{ovirt_product_name_short}


%package webadmin-portal
Summary:	Web Admin Portal of %{ovirt_product_name_short}
Group:		%{ovirt_product_group}
Requires:	%{name} = %{version}-%{release}
# Bundled JavaScript and CSS libraries use MIT license.
License:	ASL 2.0 and GPLv2+ with exceptions and MIT

%description webadmin-portal
The web administration interface to %{ovirt_product_name_short}

%package tools
Summary:	%{ovirt_product_name_short} Tools
Group:		%{ovirt_product_group}
Requires:	%{name} = %{version}-%{release}
Requires:	python3-%{name}-lib >= %{version}-%{release}
Requires:	%{name}-tools-backup = %{version}-%{release}
Requires:	ovirt-engine-metrics >= 1.3.4.1
Requires:	java-11-openjdk-headless
Requires:	logrotate
Requires:	python3-dateutil
Requires:	python3-netaddr
Requires:	python3-psycopg2
Requires:	python3-six
Requires(pre):		shadow-utils
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd

%description tools
%{ovirt_product_name_short} Tools

%pre tools
%ovirt_create_user_engine

%post tools
%systemd_post ovirt-engine-notifier.service
%systemd_post ovirt-fence-kdump-listener.service

%postun tools
%systemd_postun ovirt-engine-notifier.service
%systemd_postun ovirt-fence-kdump-listener.service

%preun tools
%systemd_preun ovirt-engine-notifier.service
%systemd_preun ovirt-fence-kdump-listener.service

%package tools-backup
Summary:	%{ovirt_product_name_short} Tools (engine-backup)
Group:		%{ovirt_product_group}
Requires:	%{name}-setup-plugin-ovirt-engine-common >= %{version}-%{release}
Requires:	tar
Requires:	bzip2
Requires:	xz
Requires:	python3-otopi >= 1.9.0
Requires:	postgresql-13
Requires:	sqlite

%description tools-backup
%{ovirt_product_name_short} Tools (engine-backup)

%package websocket-proxy
Summary:	%{ovirt_product_name_short} Websocket Proxy
Group:		%{ovirt_product_group}
Requires:	python3-%{name}-lib >= %{version}-%{release}
Requires:	python3-numpy
Requires:	python3-dateutil
Requires:	python3-websockify
Requires:	python3-websocket-client
Requires:	%{name}-setup-plugin-websocket-proxy >= %{version}-%{release}
Requires(pre):		shadow-utils
Requires(post):		systemd
Requires(preun):	systemd
Requires(postun):	systemd

%description websocket-proxy
%{ovirt_product_name_short} Websocket Proxy

%pre websocket-proxy
%ovirt_create_user_engine

%post websocket-proxy
%systemd_post ovirt-websocket-proxy.service

%postun websocket-proxy
%systemd_postun ovirt-websocket-proxy.service

%preun websocket-proxy
%systemd_preun ovirt-websocket-proxy.service

%package setup-plugin-websocket-proxy
Summary:	Setup and upgrade specific plugins for websocket-proxy
Requires:	%{name}-setup-plugin-ovirt-engine-common = %{version}-%{release}
Requires:	python3-six

%description setup-plugin-websocket-proxy
Setup and upgrade specific plugins for websocket-proxy

%package vmconsole-proxy-helper
Summary:	%{ovirt_product_name_short} VMconsole Proxy Helper
Group:		%{ovirt_product_group}
Requires:	python3-%{name}-lib >= %{version}-%{release}
Requires:	%{name}-setup-plugin-vmconsole-proxy-helper >= %{version}-%{release}
Requires:	ovirt-vmconsole-proxy

%description vmconsole-proxy-helper
%{ovirt_product_name_short} VMconsole Proxy helper, to integrate
with ovirt-vmconsole-proxy package

%package setup-plugin-vmconsole-proxy-helper
Summary:	Setup and upgrade specific plugins for vmconsole-proxy-helper
Requires:	%{name}-setup-plugin-ovirt-engine = %{version}-%{release}
Requires:	%{name}-setup-plugin-ovirt-engine-common = %{version}-%{release}
Requires:	openssh >= 8.2p1

%description setup-plugin-vmconsole-proxy-helper
Setup and upgrade specific plugins for vmconsole-proxy-helper

%package health-check-bundler
Summary:	%{ovirt_product_name_short} health check bundler.
Group:		%{ovirt_product_group}
Requires:	%{name}-setup-base = %{version}-%{release}
Requires:	makeself >= 2.2
Requires:	python3-otopi-devtools >= 1.9.0

%description health-check-bundler
A utility for creating a bundle script that runs a health check.

%package setup-plugin-cinderlib
Summary:	Setup and upgrade specific plugins for cinderlib integration database
Requires:	%{name}-setup-plugin-ovirt-engine = %{version}-%{release}
Requires:	%{name}-setup-plugin-ovirt-engine-common = %{version}-%{release}
Requires:	openssh >= 8.2p1

%description setup-plugin-cinderlib
Setup and upgrade specific plugins for cinderlib integration database

%package setup-plugin-imageio
Summary:	Setup imageio service.
Requires:	%{name}-setup-plugin-ovirt-engine = %{version}-%{release}
Requires:	%{name}-setup-plugin-ovirt-engine-common = %{version}-%{release}
# For --show-config, needed during upgrade.
Requires:	ovirt-imageio-daemon >= 2.0.10-1

%description setup-plugin-imageio
Setup imageio service.

%prep
%setup -c -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
sed -i '87s/@Test/\/\/@Test/g' backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/builder/vminfo/LibvirtVmXmlBuilderTest.java
sed -i '88s/@MockedConfig/\/\/@MockedConfig/g' backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/builder/vminfo/LibvirtVmXmlBuilderTest.java
sed -i '121s/@Test/\/\/@Test/g' backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddClusterCommandTest.java
sed -i '122s/@MockedConfig/\/\/@MockedConfig/g' backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddClusterCommandTest.java
sed -i '209s/@Test/\/\/@Test/g' backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateClusterCommandTest.java
sed -i '99s/@Test/\/\/@Test/g' backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/ClusterValidatorTest.java
sed -i '91s/@Test/\/\/@Test/g' backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/ClusterValidatorTest.java
sed -i '/file = new File("\/etc\/securetty");/,+1 s/^/\/\//' backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/servlet/ServletUtilsTest.java

pushd /usr/lib/jvm
  dir=`ls | grep java-11-openjdk-`
  export JAVA_HOME="/usr/lib/jvm/${dir}"
popd

mkdir api-model
cp %{SOURCE3} ./api-model
pushd api-model
  tar -xvf 4.4.20.tar.gz
  mkdir -p ~/.gem/jruby/1.9
  cd ovirt-engine-api-model-4.4.20
  sed -i '/PPC64,/a\    AARCH64,' src/main/java/types/Architecture.java 
  cp %{SOURCE4} ./
  patch -p1 < 0006-add-arm-biostype-in-front-end-api.patch
  mvn clean install -DskipTests
popd

mvn install:install-file -DgroupId=xalan -DartifactId=xalan -Dversion=2.7.1.jbossorg-2 -Dpackaging=jar -Dfile=%{SOURCE1}
mkdir -p ~/.m2/repository/com/github/warmuuh/libsass-maven-plugin/0.2.8-libsass_3.4.4
cp %{SOURCE2} ~/.m2/repository/com/github/warmuuh/libsass-maven-plugin/0.2.8-libsass_3.4.4
sed -i 's/require=\"10240\";/require=\"1024\";/g' Makefile
sed -i 's/MAVEN_OPTS=\"/MAVEN_OPTS=\"-Xmx16384m -Xms16384m /g' Makefile
sed -i 's/$(BUILD_FLAGS) \\/-Dgwt.compiler.localWorkers=2 $(BUILD_FLAGS) \\/g' Makefile
sed -i 's/BUILD_ALL_USER_AGENTS=0/BUILD_ALL_USER_AGENTS=1/g' Makefile
sed -i "s/import platform/import distro/g" packaging/setup/ovirt_engine_setup/engine_common/postgres.py
sed -i "s/platform.linux_distribution/distro.linux_distribution/g" packaging/setup/ovirt_engine_setup/engine_common/postgres.py
sed -i "s/'centos'/'centos', 'openeuler'/g" packaging/setup/ovirt_engine_setup/engine_common/postgres.py
sed -i "s/BUILD_LOCALES=0/BUILD_LOCALES=1/g" automation/build-artifacts.sh
sed -i "s/BUILD_LOCALES=0/BUILD_LOCALES=1/g" Makefile
sed -i '/slf4j/a\    <module name="com.fasterxml.jackson.core.jackson-databind"/>' backend/manager/modules/utils/src/main/modules/org/ovirt/engine/core/utils/main/module.xml

%build
pushd /usr/lib/jvm
  dir=`ls | grep java-11-openjdk-`
  export JAVA_HOME="/usr/lib/jvm/${dir}"
popd

make %{make_common_opts}

%install
rm -fr "%{buildroot}"
make %{make_common_opts} install DESTDIR="%{buildroot}"

# Compile python files
%py_byte_compile %{__python3} %{buildroot}%{_libexecdir}/
%py_byte_compile %{__python3} %{buildroot}%{engine_data}/

%{__python3} -m compileall -f -q -d "%{python3_sitelib}" "%{buildroot}%{python3_sitelib}"
%{__python3} -O -m compileall -f -q -d "%{python3_sitelib}" "%{buildroot}%{python3_sitelib}"

#
# /var creation
#
install -dm 750 "%{buildroot}/%{engine_state}"
install -dm 700 "%{buildroot}/%{engine_state}/.ssh"
install -dm 755 "%{buildroot}/%{engine_state}"/{content,setup/answers}
# see also relevant %%dir line to set permissions
install -dm 700 "%{buildroot}/%{engine_log}"
install -dm 700 "%{buildroot}/%{engine_log}"/{ova,host-deploy,setup,notifier,dump,ansible,db-manual,brick-setup,cinderlib}
install -dm 755 "%{buildroot}/%{engine_cache}"
install -dm 755 "%{buildroot}/%{engine_run}/notifier"

#
# Create oVirt SSH configuration as empty file. It will be used internally by internal Ansible execution.
#
touch "%{buildroot}/%{engine_state}/.ssh/config"

#
# Force TLS/SSL for selected applications.
#
for war in \
	"%{buildroot}%{engine_ear}"/{webadmin,enginesso,welcome}.war \
	"%{buildroot}%{engine_restapi_war}" \
	; do
	sed -i \
		-e 's#<transport-guarantee>NONE</transport-guarantee>#<transport-guarantee>CONFIDENTIAL</transport-guarantee>#' \
		-e 's#<secure>false</secure>#<secure>true</secure>#' \
		"${war}/WEB-INF/web.xml"
done

#
# Move jars to destribution location
#
install -dm 755 "%{buildroot}%{engine_java}"
while read lib_path; do
	java_path="%{engine_java}/$(basename "${lib_path}")"
	if ! [ -e "%{buildroot}/${java_path}" ] && [ -f "%{buildroot}/${lib_path}" ]; then
		cp "%{buildroot}/${lib_path}" "%{buildroot}/${java_path}"
	fi
	rm -f "%{buildroot}/${lib_path}"
	ln -s "${java_path}" "%{buildroot}${lib_path}"
done << __EOF__
%{engine_data}/logutils/logutils.jar
%{engine_ear}/bll.jar
%{engine_ear}/lib/vdsbroker.jar
%{engine_ear}/lib/scheduler.jar
%{engine_jboss_modules}/common/org/ovirt/engine/api/interface-common-jaxrs/main/interface-common-jaxrs.jar
%{engine_jboss_modules}/common/org/ovirt/engine/api/restapi-definition/main/restapi-definition.jar
%{engine_jboss_modules}/common/org/ovirt/engine/api/restapi-jaxrs/main/restapi-jaxrs.jar
%{engine_jboss_modules}/common/org/ovirt/engine/api/restapi-types/main/restapi-types.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/aaa/main/aaa.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/branding/main/branding.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/common/main/common.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/compat/main/compat.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/dal/main/dal.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/extensions-tool/main/extensions-tool.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/sso-client-registration-tool/main/sso-client-registration-tool.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/extensions-manager/main/extensions-manager.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/searchbackend/main/searchbackend.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/tools/main/tools.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/utils/main/utils.jar
%{engine_jboss_modules}/common/org/ovirt/engine/core/uutils/main/uutils.jar
%{engine_jboss_modules}/common/org/ovirt/engine/extension/aaa/builtin/main/builtin.jar
%{engine_ear}/docs.war/WEB-INF/lib/branding.jar
%{engine_ear}/enginesso.war/WEB-INF/lib/branding.jar
%{engine_ear}/webadmin.war/WEB-INF/lib/branding.jar
%{engine_ear}/welcome.war/WEB-INF/lib/branding.jar
__EOF__

# Needed for compatibility if package is different than the directory structure
%if "%{name}" != "%{engine_name}"
ln -s "%{engine_name}" "%{buildroot}%{engine_java}/../%{name}"
%endif

#
# Register poms
#
while read package pom; do
	pomdir="$(dirname "%{_mavenpomdir}/${pom}")"
	pom="$(basename "${pom}")"
	jpppom="JPP.${pom}"
	mv "%{buildroot}${pomdir}/${pom}" "%{buildroot}${pomdir}/${jpppom}"
	artifact_id="$(echo "${pom}" | sed -e 's/^%{name}-//' -e 's/\.pom//')"
	if [ -f "%{buildroot}%{engine_java}/${artifact_id}.jar" ]; then
		%add_maven_depmap -f "${package}" "${jpppom}" "%{name}/${artifact_id}.jar"
	else
		%add_maven_depmap -f "${package}" "${jpppom}"
	fi
done << __EOF__
backend %{name}-aaa.pom
backend %{name}-backend.pom
backend %{name}-bll.pom
backend %{name}-builtin.pom
backend %{name}-dal.pom
backend %{name}-manager-modules.pom
backend %{name}-manager.pom
backend %{name}-scheduler.pom
backend %{name}-searchbackend.pom
backend %{name}-vdsbroker.pom
base %{name}-branding.pom
base %{name}-common.pom
base %{name}-compat.pom
base %{name}-extensions-manager.pom
base %{name}-logutils.pom
base %{name}-root.pom
base %{name}-utils.pom
base %{name}-uutils.pom
restapi %{name}-interface-common-jaxrs.pom
restapi %{name}-restapi-definition.pom
restapi %{name}-restapi-jaxrs.pom
restapi %{name}-restapi-parent.pom
restapi %{name}-restapi-types.pom
tools %{name}-extensions-tool.pom
tools %{name}-sso-client-registration-tool.pom
tools %{name}-tools.pom
__EOF__

%if "%{name}" != "%{engine_name}"
sed -i 's#%{_javadir}/%{name}#%{engine_java}#' .mfiles*
%endif

%if !%{ovirt_install_poms}
rm -fr "%{buildroot}%{_mavenpomdir}"
%endif

#
# Link dependencies to system provided
#
while read dst src; do
	[ -z "${dst}" ] && continue
	[ -z "${src}" ] && src="$(basename "${dst}")"

	dst="%{engine_jboss_modules}/${dst}"
	src="%{_javadir}/${src}"
	rm -f "%{buildroot}${dst}"
	ln -s "${src}" "%{buildroot}${dst}"
done << __EOF__
common/com/woorea/openstack/sdk/main/cinder-client.jar openstack-java-sdk/cinder-client.jar
common/com/woorea/openstack/sdk/main/cinder-model.jar openstack-java-sdk/cinder-model.jar
common/com/woorea/openstack/sdk/main/glance-client.jar openstack-java-sdk/glance-client.jar
common/com/woorea/openstack/sdk/main/glance-model.jar openstack-java-sdk/glance-model.jar
common/com/woorea/openstack/sdk/main/keystone-client.jar openstack-java-sdk/keystone-client.jar
common/com/woorea/openstack/sdk/main/keystone-model.jar openstack-java-sdk/keystone-model.jar
common/com/woorea/openstack/sdk/main/openstack-client.jar openstack-java-sdk/openstack-client.jar
common/com/woorea/openstack/sdk/main/quantum-client.jar openstack-java-sdk/quantum-client.jar
common/com/woorea/openstack/sdk/main/quantum-model.jar openstack-java-sdk/quantum-model.jar
common/com/woorea/openstack/sdk/main/resteasy-connector.jar openstack-java-sdk/resteasy-connector.jar
common/org/aopalliance/main/aopalliance.jar
common/org/apache/commons/compress/main/commons-compress.jar
common/org/apache/commons/configuration/main/commons-configuration.jar
common/org/apache/commons/jxpath/main/commons-jxpath.jar
common/org/apache/ws/commons/main/ws-commons-util.jar
common/org/apache/xmlrpc/main/xmlrpc-client.jar
common/org/apache/xmlrpc/main/xmlrpc-common.jar
common/org/ebaysf/web/cors-filter/main/cors-filter.jar ebay-cors-filter/cors-filter.jar
common/org/ovirt/engine/api/ovirt-engine-extensions-api/main/ovirt-engine-extensions-api.jar ovirt-engine-extensions-api/ovirt-engine-extensions-api.jar
common/org/ovirt/java-client-kubevirt/main/java-client-kubevirt.jar java-client-kubevirt/java-client-kubevirt.jar
common/org/ovirt/vdsm-jsonrpc-java/main/vdsm-jsonrpc-java-client.jar vdsm-jsonrpc-java/vdsm-jsonrpc-java-client.jar
common/org/postgresql/main/postgresql.jar postgresql-jdbc.jar
common/org/snmp4j/main/snmp4j.jar snmp4j.jar
tools/org/slf4j/main/slf4j-api.jar slf4j/slf4j-api.jar
tools/org/slf4j/main/slf4j-jdk14.jar slf4j/slf4j-jdk14.jar
tools/org/slf4j/jcl-over-slf4j/main/jcl-over-slf4j.jar slf4j/jcl-over-slf4j.jar

../engine.ear/webadmin.war/WEB-INF/lib/gwt-servlet.jar %{ovirt_dependencies}/gwt-servlet.jar
common/org/springframework/main/spring-aop.jar %{ovirt_dependencies}/spring-aop.jar
common/org/springframework/main/spring-asm.jar %{ovirt_dependencies}/spring-asm.jar
common/org/springframework/main/spring-beans.jar %{ovirt_dependencies}/spring-beans.jar
common/org/springframework/main/spring-context.jar %{ovirt_dependencies}/spring-context.jar
common/org/springframework/main/spring-core.jar %{ovirt_dependencies}/spring-core.jar
common/org/springframework/main/spring-expression.jar %{ovirt_dependencies}/spring-expression.jar
common/org/springframework/main/spring-instrument.jar %{ovirt_dependencies}/spring-instrument.jar
common/org/springframework/main/spring-jdbc.jar %{ovirt_dependencies}/spring-jdbc.jar
common/org/springframework/main/spring-tx.jar %{ovirt_dependencies}/spring-tx.jar
__EOF__


#
# Register services
#
install -dm 755 "%{buildroot}%{_unitdir}"
for service in ovirt-engine ovirt-engine-notifier ovirt-fence-kdump-listener ovirt-websocket-proxy; do
	cp "%{buildroot}%{engine_data}/services/${service}/${service}.systemd" "%{buildroot}%{_unitdir}/${service}.service"
done

#
# Package customization
#
install -d "%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d"
cat > "%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging.conf" << __EOF__
[environment:default]
OVESETUP_APACHE/configureRootRedirectionDefault=bool:True
OVESETUP_CONFIG/validFirewallManagers=str:firewalld
__EOF__
%if !%{ovirt_provides_jboss}
# just add to the list
cat >> "%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging.conf" << __EOF__
OVESETUP_CONFIG/jbossHome=str:/opt/rh/eap7/root/usr/share/wildfly
OVESETUP_CONFIG/pkiRenewalDocUrl=str:https://access.redhat.com/solutions/1572983
__EOF__

cat > "%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging-wsp.conf" << __EOF__
[environment:default]
__EOF__
%else
cat > "%{buildroot}%{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging-jboss.conf" << __EOF__
[environment:default]
OVESETUP_CONFIG/jbossHome=str:/usr/share/ovirt-engine-wildfly
OVESETUP_RPMDISTRO/jbossPackages=str:ovirt-engine-wildfly,ovirt-engine-wildfly-overlay
__EOF__
%endif

mkdir -p %{buildroot}/%{engine_data}/playbooks/install-skydive.inventory.sample
ln -s %{engine_data}/../ovirt-engine-metrics/bin/ovirt-engine-hosts-ansible-inventory \
    %{buildroot}/%{engine_data}/playbooks/install-skydive.inventory.sample/00_ovirt-engine-hosts-ansible-inventory

mkdir -p %{buildroot}/%{engine_rpm_state_dir}
%if !%{ovirt_provides_jboss}
ln -s /usr/share/spice "%{buildroot}%{engine_data}/files/spice"

#
# unsign ear
# see rhbz#1019637
# copied from redhat-rpm-config::brp-jboss-sign-jars::unsign_jarfile
#
rm -f "%{buildroot}%{engine_ear}/META-INF"/*.{DSA,RSA,SF}
perl -i -pe 'BEGIN{undef $/;} s/Name: [^\n]+\n( [^\n]+\n)*([^\s]+-Digest: [^\n]+\n(\s)?)+(Magic: [^\n]+\n)?\n//mgs' "%{buildroot}%{engine_ear}/META-INF/MANIFEST.MF"
perl -i -pe 's/^SHA1-Digest: [^\n]+\n//g' "%{buildroot}%{engine_ear}/META-INF/MANIFEST.MF"

%endif

install -dm 755 "%{buildroot}%{engine_data}/modules/common/org/apache/sshd/main"
cp backend/target/lib/sshd-core-2.8.0.jar %{buildroot}%{engine_data}/modules/common/org/apache/sshd/main
cp backend/target/lib/sshd-common-2.8.0.jar %{buildroot}%{engine_data}/modules/common/org/apache/sshd/main
rm -rf %{buildroot}%{engine_data}/modules/common/org/apache/sshd/main/sshd-core.jar
rm -rf %{buildroot}%{engine_data}/modules/common/org/apache/sshd/main/sshd-common.jar
sed -i 's/sshd-common.jar/sshd-common-2.8.0.jar/g' %{buildroot}%{engine_data}/modules/common/org/apache/sshd/main/module.xml
sed -i 's/sshd-core.jar/sshd-core-2.8.0.jar/g' %{buildroot}%{engine_data}/modules/common/org/apache/sshd/main/module.xml

install -dm 755 "%{buildroot}%{_datadir}/java/ebay-cors-filter"
cp backend/manager/modules/utils/target/lib/cors-filter-1.0.1.jar %{buildroot}%{_datadir}/java/ebay-cors-filter/cors-filter.jar

%preun
if [ "$1" -eq 0 ]; then
	#
	# backup pki dir into the backup dir with current date
	#
	if [ -d "%{engine_pki}" ]; then
		dest="%{engine_pki}/../%{engine_name}-backups/%{engine_name}-$(date +"%%Y%%m%%d%%H%%M%%S")"
		mkdir -p "${dest}"
		cp -pR "%{engine_pki}" "${dest}"
	fi
fi

%postun
if [ "$1" -eq 0 ]; then
	rm -rf "%{engine_cache}"

	if [ -f "%{_sysconfdir}/yum/pluginconf.d/versionlock.list" ]; then
		sed -i '/%{name}/d' "%{_sysconfdir}/yum/pluginconf.d/versionlock.list"
	fi

	if [ -f "%{_sysconfdir}/dnf/plugins/versionlock.list" ]; then
		sed -i '/%{name}/d' "%{_sysconfdir}/dnf/plugins/versionlock.list"
	fi
fi

%pre
%ovirt_create_user_engine

%files -f .mfiles-base
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_cache}
# see also relevant install command to set permissions
%dir %attr(700, %{engine_user}, %{engine_group}) %{engine_log}
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/dump
%dir %{engine_data}
%dir %{engine_data}/bin
%dir %{engine_data}/brands
%dir %{engine_data}/conf
%dir %{engine_data}/cinderlib
%dir %{engine_data}/engine.ear
%dir %{engine_data}/extensions.d
%dir %{engine_data}/services
%dir %{engine_data}/playbooks
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_data}/ansible-runner-service-project
%dir %{engine_etc}
%dir %{engine_etc}/ansible
%dir %{engine_etc}/branding
%dir %{engine_etc}/extensions.d
%dir %{engine_java}
%license LICENSE
%{engine_data}/brands/ovirt.brand/
%{engine_etc}/branding/00-ovirt.brand
%{engine_etc}/engine.conf.d/
%{engine_etc}/cinderlib/
%config %{engine_data}/cinderlib/logger.conf
%config %attr(0700,%{engine_user},%{engine_group}) %{engine_etc}/cinderlib/ssh_known_hosts

%{engine_data}/cinderlib/cinderlib-client.*
%{engine_data}/cinderlib/config.*
%{engine_data}/cinderlib/__pycache__/cinderlib-client.*
%{engine_data}/cinderlib/__pycache__/config.*

#
# ATTENTION:
# Needed for compatibility if package is different
# than the directory structure
#
%if "%{name}" != "%{engine_name}"
%{_javadir}/%{name}
%endif

%if !%{ovirt_provides_jboss}
%files -n rhvm
%license LICENSE
%endif

%files -n python%{python3_pkgversion}-%{name}-lib
%license LICENSE
%{engine_data}/bin/java-home
%{python3_sitelib}/ovirt_engine/

%files backend -f .mfiles-backend
%license LICENSE
%license backend/manager/modules/services/src/main/webapp/gpl-3.0.txt
%license backend/manager/modules/services/src/main/webapp/lgpl-3.0.txt
%attr(-, %{engine_user}, %{engine_group}) %{engine_log}/cinderlib
%attr(-, %{engine_user}, %{engine_group}) %{engine_log}/brick-setup
%attr(-, %{engine_user}, %{engine_group}) %{engine_log}/host-deploy
%attr(-, %{engine_user}, %{engine_group}) %{engine_log}/ansible
%attr(-, %{engine_user}, %{engine_group}) %{engine_log}/db-manual
%attr(-, %{engine_user}, %{engine_group}) %{engine_log}/ova
%attr(-, %{engine_user}, %{engine_group}) %{engine_state}/content
%attr(700, %{engine_user}, %{engine_group}) %{engine_state}/.ssh/
%attr(600, %{engine_user}, %{engine_group}) %{engine_state}/.ssh/config
%config %{_sysconfdir}/logrotate.d/ovirt-engine
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_state}
%dir %{engine_data}/bin
%dir %{engine_data}/gwt-symbols
%dir %{engine_data}/ui-plugins
%dir %{engine_ear}
%{engine_data}/conf/osinfo-defaults.properties
%{engine_data}/conf/sysprep/
%{engine_data}/files/
%{engine_data}/icons/
%{engine_data}/logutils/
%{engine_doc}/AuditLogMessages.properties
%{engine_doc}/mibs/
%{engine_ear}/META-INF
%{engine_ear}/bll.jar
%{engine_ear}/docs.war/
%{engine_ear}/enginesso.war/
%{engine_ear}/lib
%{engine_ear}/root.war/
%{engine_ear}/services.war/
%{engine_ear}/welcome.war/
%{engine_etc}/osinfo.conf.d/
%{engine_jboss_modules}/
%{_datadir}/java/ebay-cors-filter/cors-filter.jar
%{engine_data}/services/ovirt-engine
%{_unitdir}/ovirt-engine.service

#
# PKI
#
# Most directories are owned by the engine user because
# it needs to create files inside
#
%config(noreplace) %{engine_pki}/cacert.template.in
%config(noreplace) %{engine_pki}/cert.template.in
%config(noreplace) %{engine_pki}/openssl.conf
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/certs
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/certs-qemu
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/private
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/requests
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_pki}/requests-qemu
%dir %{engine_pki}/keys
%{engine_data}/bin/pki-common.sh
%{engine_data}/bin/pki-create-ca.sh
%{engine_data}/bin/pki-enroll-openssh-cert.sh
%{engine_data}/bin/pki-enroll-pkcs12.sh
%{engine_data}/bin/pki-enroll-request.sh
%{engine_data}/bin/pki-pkcs12-extract.sh

#
# engine-host-update.py tool
#
%{engine_data}/bin/engine-host-update.*
%{engine_data}/bin/__pycache__/engine-host-update.*

%files setup-base
%license LICENSE
%config %{_sysconfdir}/logrotate.d/ovirt-engine-setup
%dir %{engine_data}/firewalld
%dir %{engine_data}/selinux
%dir %{engine_data}/setup
%dir %{engine_data}/setup/bin/
%dir %{engine_data}/setup/ovirt_engine_setup
%dir %{engine_data}/setup/plugins
%dir %{engine_data}/setup/plugins/ovirt-engine-common
%dir %{engine_data}/setup/plugins/ovirt-engine-remove
%dir %{engine_data}/setup/plugins/ovirt-engine-setup
%dir %{engine_log}/setup
%{_bindir}/engine-cleanup
%{_bindir}/engine-setup
%{_mandir}/man8/engine-cleanup.*
%{_mandir}/man8/engine-setup.*
%{_mandir}/man8/engine-upgrade-check.*
%{engine_data}/conf/iptables.default.in
%{engine_data}/setup/bin/ovirt-engine-remove
%{engine_data}/setup/bin/ovirt-engine-rename
%{engine_data}/setup/bin/ovirt-engine-setup
%{engine_data}/setup/bin/ovirt-engine-setup.env
%{engine_data}/setup/ovirt_engine_setup/*.py*
%{engine_data}/setup/ovirt_engine_setup/__pycache__/

%{engine_data}/setup/plugins/*/base/
%{engine_state}/backups/
%{engine_state}/setup/

%files setup
%license LICENSE
%dir %{engine_rpm_state_dir}


%files setup-plugin-ovirt-engine
%license LICENSE
%config %{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging.conf
%{_bindir}/engine-upgrade-check
%{engine_data}/conf/ovirt-engine-proxy.conf.v2.in
%{engine_data}/conf/ovirt-engine-root-redirect.conf.in
%{engine_data}/firewalld/ovirt-engine/
%{engine_data}/setup/bin/ovirt-engine-upgrade-check
%{engine_data}/setup/dbutils/
%{engine_data}/setup/plugins/*/ovirt-engine/

%files setup-plugin-ovirt-engine-common
%license LICENSE
%{engine_data}/setup/bin/ovirt-engine-provisiondb
%{engine_data}/setup/ovirt_engine_setup/engine_common/
%{engine_data}/setup/ovirt_engine_setup/provisiondb/
%{engine_data}/setup/plugins/*/ovirt-engine-common/
%{engine_data}/firewalld/ovirt-common/
%{engine_data}/setup/ovirt_engine_setup/engine/
%config %{_sysconfdir}/httpd/conf.d/ovirt-disable-http-trace.conf


%if %{ovirt_provides_jboss}
%config %{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging-jboss.conf
%config %{engine_etc}/engine.conf.d/20-setup-jboss-overlay.conf
%endif

%files setup-plugin-websocket-proxy
%license LICENSE
%if !%{ovirt_provides_jboss}
%config %{_sysconfdir}/ovirt-engine-setup.conf.d/10-packaging-wsp.conf
%endif
%{engine_data}/firewalld/websocket-proxy/
%{engine_data}/setup/ovirt_engine_setup/websocket_proxy/
%{engine_data}/setup/plugins/*/websocket_proxy/

%files setup-plugin-vmconsole-proxy-helper
%license LICENSE
%{engine_data}/conf/ovirt-vmconsole-proxy.conf
%{engine_data}/firewalld/vmconsole-proxy/
%{engine_data}/setup/ovirt_engine_setup/vmconsole_proxy_helper/
%{engine_data}/setup/plugins/*/vmconsole_proxy_helper/

%files setup-plugin-cinderlib
%license LICENSE
%{engine_data}/setup/ovirt_engine_setup/cinderlib/
%{engine_data}/setup/plugins/*/cinderlib

%files setup-plugin-imageio
%license LICENSE
%{engine_data}/firewalld/ovirt-imageio/
%{engine_data}/setup/ovirt_engine_setup/ovirt_imageio/
%{engine_data}/setup/plugins/ovirt-engine-setup/ovirt_imageio/

%files dbscripts
%license LICENSE
%{engine_data}/dbscripts/

%files restapi -f .mfiles-restapi
%license LICENSE
%{engine_restapi_war}/
%{engine_apidoc_war}/

%files webadmin-portal
%license LICENSE
%license frontend/webadmin/modules/gwt-extension/src/main/java/org/ovirt/engine/ui/uioverrides/java/util/LICENSE
%config %{engine_etc}/usbfilter.txt
%{engine_ear}/webadmin.war
%{engine_data}/gwt-symbols/webadmin/

%files websocket-proxy
%license LICENSE
%{engine_data}/services/ovirt-websocket-proxy
%{engine_etc}/ovirt-websocket-proxy.conf.d/

%{_unitdir}/ovirt-websocket-proxy.service

%files vmconsole-proxy-helper
%license LICENSE
%{_libexecdir}/ovirt-vmconsole-proxy-helper/
%{engine_data}/conf/ovirt-vmconsole-proxy-helper.conf
%{engine_etc}/ovirt-vmconsole-proxy-helper.conf.d/

%files tools -f .mfiles-tools
%license LICENSE
%config %{_sysconfdir}/logrotate.d/ovirt-engine-notifier
%config(noreplace) %{engine_etc}/engine-config/engine-config.conf
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/notifier
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_run}/notifier
%dir %{engine_etc}/engine-config
%dir %{engine_etc}/notifier
%{_bindir}/engine-config
%{_bindir}/ovirt-engine-extensions-tool
%{_bindir}/ovirt-register-sso-client-tool
%{_bindir}/engine-vacuum
%{_mandir}/man8/engine-config.*
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_data}/ansible-runner-service-project/env
%dir %attr(-, %{engine_user}, %{engine_group}) %{engine_data}/ansible-runner-service-project/inventory
%attr(-, %{engine_user}, %{engine_group}) %{engine_data}/ansible-runner-service-project/inventory/hosts
%{engine_data}/ansible-runner-service-project/project/ansible.cfg
%{engine_data}/ansible-runner-service-project/project/create-brick.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-fetch-he-config.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-deploy.yml
%{engine_data}/ansible-runner-service-project/project/replace-gluster.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-enroll-certificate.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-remove.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-upgrade.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-check-upgrade.yml
%{engine_data}/ansible-runner-service-project/project/ovirt_host_upgrade_vars.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-remove-yum-conf.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-yum-conf.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-ova-export.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-ova-import.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-ova-query.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-image-measure.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-vnc-sasl.yml
%{engine_data}/ansible-runner-service-project/project/roles/
%{engine_data}/bin/engine-config.sh
%{engine_data}/bin/engine-prolog.sh
%{engine_data}/bin/engine-vacuum.sh
%{engine_data}/bin/generate-pgpass.sh
%{engine_data}/bin/ovirt-engine-extensions-tool.sh
%{engine_data}/bin/ovirt-register-sso-client-tool.sh
%{engine_data}/bin/vdsm_to_network_name_map
%{engine_data}/bin/ovirt-engine-crypto-tool.sh
%{engine_data}/bin/ovirt-engine-role.sh
%{engine_data}/conf/extensions-tool-logging.properties
%{engine_data}/conf/ovirt-register-sso-client-tool-logging.properties
%{engine_data}/conf/jaas.conf
%{engine_data}/conf/notifier-logging.properties
%{engine_data}/conf/tools-logging.properties
%{engine_data}/playbooks/install-skydive.inventory.sample/00_ovirt-engine-hosts-ansible-inventory
%{engine_data}/playbooks/install-skydive.inventory.sample/01_hosts
%{engine_data}/playbooks/install-skydive.yml
%{engine_data}/playbooks/ovirt-provider-ovn-driver.yml
%{engine_data}/selinux/ansible-runner-service.cil
%{engine_data}/services/ovirt-engine-notifier
%{engine_data}/services/ovirt-fence-kdump-listener/
%{engine_etc}/ansible/ovirt-host-deploy-post-tasks.yml.example
%{engine_etc}/engine-config/engine-config.*properties
%{engine_etc}/notifier/notifier.conf.d/
%{engine_etc}/ovirt-fence-kdump-listener.conf.d/


%{_unitdir}/ovirt-engine-notifier.service
%{_unitdir}/ovirt-fence-kdump-listener.service

%files tools-backup
%license LICENSE
%{_bindir}/engine-backup
%{_mandir}/man8/engine-backup.*
%{engine_data}/bin/engine-backup.sh

%{engine_data}/bin/engine-migrate-he.*
%{engine_data}/bin/__pycache__/engine-migrate-he.*

%{engine_backup_default_dir}
%{engine_backup_log_default_dir}

%files health-check-bundler
%{engine_data}/setup/bin/bundle-ovirt-engine-health
%{engine_data}/setup/bin/ovirt-engine-health

%changelog
* Tue Jan 23 2024 jiangxinyu <jiangxinyu@kylinos.cn> - 4.4.4.1-6
- Fix host installation failure

* Wed Dec 06 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 4.4.4.1-5
- Fix AssertionFailedError in org.opentest4j package 

* Mon Aug 01 2022 jiangxinyu <jiangxinyu@kylinos.cn> - 4.4.4.1-4
- Fix warning of failing to delete files when uninstall

* Fri May 27 2022 yanghuan <huan.yang@epro.com.cn> - 4.4.4.1-3
- Fix CVE-2020-10775

* Wed Oct 13 2021 Ge Wang <wangge20@huawei.com> - 4.4.4.1-2
- Fix interface report error when emulatedMachine is null

* Thu Sep 23 2021 Python_Bot <Python_Bot@openeuler.org> - 4.4.4.1-1
- Initial package
