Name: setroubleshoot
Version: 3.3.32
Release: 2
Summary: SELinux Trouble Shooting Tool
License: GPLv2+
URL: https://gitlab.com/setroubleshoot/setroubleshoot

Source0: https://gitlab.com/setroubleshoot/setroubleshoot/-/archive/%{version}/%{name}-%{version}.tar.gz
Source1: %{name}.tmpfiles

Patch9000: Fix-config-file-to-deny-noraml-user-to-stop-Setroubleshootd.patch

BuildRequires: gcc libcap-ng-devel intltool gettext python3 python3-devel python3-setuptools python3-wheel 
BuildRequires: desktop-file-utils dbus-glib-devel gtk2-devel libnotify-devel audit-libs-devel libselinux-devel polkit-devel
BuildRequires: python3-libselinux python3-dasbus python3-gobject gtk3-devel xdg-utils python3-pip

Requires: %{name}-server = %{version}-%{release} 
Requires: gtk3, libnotify libreport python3-libreport python3-gobject python3-dasbus xdg-utils
Requires(post): desktop-file-utils
Requires(post): dbus
Requires(postun): desktop-file-utils
Requires(postun): dbus

%description
SELinux Trouble Shooting Tool

%package server
Summary: SELinux troubleshoot server

Requires: %{name}-plugins >= 3.3.8
Requires: audit >= 2.8.5
Requires: python3-audit
Requires: python3-libxml2
Requires: python3-rpm
Requires: python3-libselinux
Requires: policycoreutils-python-utils
BuildRequires: intltool gettext python3
BuildRequires: python3-devel
Requires: python3-slip python3-systemd
Requires: python3-gobject >= 3.11
Requires: dbus
Requires: python3-dbus python3-dasbus
Requires: polkit
Requires(pre): /usr/sbin/useradd /usr/sbin/groupadd

%description server
Provides tools to help diagnose SELinux problems. When AVC messages
are generated an alert can be generated that will give information
about the problem and help track its resolution. Alerts can be configured
to user preference. The same tools can be run on existing log files.

%package legacy
Summary: SELinux troubleshoot legacy applet

Requires: gtk2
Requires: %{name} = %{version}-%{release}

%description legacy
SELinux troubleshoot legacy applet

%package_help

%prep
%autosetup -n %{name}-%{version} -p1

%build
./autogen.sh
%global _python_bytecompile_extra 0
%configure PYTHON=%{__python3} --enable-seappletlegacy=yes --with-auditpluginsdir=/etc/audit/plugins.d
%make_build V=1

%install
%make_install PREFIX=%{_prefix}
desktop-file-install --vendor="" --dir=%{buildroot}%{_datadir}/applications %{buildroot}/%{_datadir}/applications/%{name}.desktop
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}
mkdir -p %{buildroot}%{_rundir}/setroubleshoot
touch %{buildroot}%{_localstatedir}/lib/%{name}/setroubleshoot_database.xml
touch %{buildroot}%{_localstatedir}/lib/%{name}/email_alert_recipients
# create /run/setroubleshoot on boot
install -m644 -D %{SOURCE1} $RPM_BUILD_ROOT%{_tmpfilesdir}/%{name}.conf

%find_lang %{name}

%post
dbus-send --system /com/redhat/setroubleshootd com.redhat.SEtroubleshootdIface.restart string:'rpm install' >/dev/null 2>&1 || :
/sbin/service auditd reload >/dev/null 2>&1 || :

%postun
/sbin/service auditd reload >/dev/null 2>&1 || :

%pre server
getent passwd setroubleshoot >/dev/null || useradd -r -U -s /sbin/nologin -d %{_localstatedir}/lib/%{name} setroubleshoot

%post server
/sbin/service auditd reload >/dev/null 2>&1 || :

%postun server
/sbin/service auditd reload >/dev/null 2>&1 || :

%triggerun server -- %{name}-server < 3.2.24-4
chown -R setroubleshoot:setroubleshoot %{_localstatedir}/lib/%{name}

%files
%license COPYING
%{_bindir}/seapplet
%config(noreplace) %{_sysconfdir}/xdg/autostart/*
%{_datadir}/%{name}/gui
%{_datadir}/applications/*.desktop
%{_datadir}/metainfo/*.appdata.xml
%{_datadir}/dbus-1/services/org.fedoraproject.sealert.service
%{_datadir}/icons/hicolor/*/*/*
%dir %attr(0755,root,root) %{python3_sitelib}/%{name}
%{python3_sitelib}/%{name}/browser.py
%{python3_sitelib}/%{name}/gui_utils.py
%{python3_sitelib}/%{name}/__pycache__/browser.cpython*
%{python3_sitelib}/%{name}/__pycache__/gui_utils.cpython*

%files server -f %{name}.lang
%{_bindir}/sealert
%{_sbindir}/sedispatch
%{_sbindir}/setroubleshootd
%{python3_sitelib}/setroubleshoot*.dist-info
%dir %attr(0755,root,root) %{_sysconfdir}/%{name}
%dir %{python3_sitelib}/%{name}
%dir %{python3_sitelib}/%{name}/__pycache__
%{python3_sitelib}/%{name}/*.py
%exclude %{python3_sitelib}/%{name}/browser.py
%exclude %{python3_sitelib}/%{name}/gui_utils.py
%{python3_sitelib}/%{name}/__pycache__/*.cpython*
%exclude %{python3_sitelib}/%{name}/__pycache__/browser.cpython*
%exclude %{python3_sitelib}/%{name}/__pycache__/gui_utils.cpython*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/SetroubleshootFixit.py
%{_datadir}/%{name}/SetroubleshootPrivileged.py
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.fedoraproject.Setroubleshootd.conf
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.fedoraproject.SetroubleshootPrivileged.conf
%attr(0700,setroubleshoot,setroubleshoot) %dir %{_localstatedir}/lib/%{name}
%ghost %attr(0600,setroubleshoot,setroubleshoot) %{_localstatedir}/lib/%{name}/setroubleshoot_database.xml
%ghost %attr(0644,setroubleshoot,setroubleshoot) %{_localstatedir}/lib/%{name}/email_alert_recipients
%config /etc/audit/plugins.d/sedispatch.conf
%{_unitdir}/setroubleshootd.service
%{_datadir}/dbus-1/system-services/org.fedoraproject.Setroubleshootd.service
%{_datadir}/dbus-1/system-services/org.fedoraproject.SetroubleshootPrivileged.service
%{_datadir}/polkit-1/actions/org.fedoraproject.setroubleshootfixit.policy
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.fedoraproject.SetroubleshootFixit.conf
%{_datadir}/dbus-1/system-services/org.fedoraproject.SetroubleshootFixit.service
%attr(0644,root,root) %{_tmpfilesdir}/%{name}.conf
%attr(0711,setroubleshoot,setroubleshoot) %dir %{_rundir}/setroubleshoot
%doc AUTHORS COPYING ChangeLog DBUS.md NEWS README TODO

%files legacy
%{_bindir}/seappletlegacy

%files help
%{_docdir}/%{name}*
%{_mandir}/man8/sealert.8.gz
%{_mandir}/man8/sedispatch.8.gz
%{_mandir}/man8/setroubleshootd.8.gz
%{_mandir}/man1/seapplet.1.gz

%changelog
* Wed Dec 4 2024 xuce <xuce10@h-partners.com> - 3.3.32-2
- add BuildRequires: python3-setuptools and python3-wheel

* Thu Jul 20 2023 zhangguangzhi <zhangguangzhi3@huawei.com> - 3.3.32-1
- update version to 3.3.32

* Mon Jan 30 2023 wangyunjia <yunjia.wang@huawei.com> - 3.3.26-1
- update version to 3.3.26

* Thu Nov 17 2022 shenxiangwei <shenxiangwei1@huawei.com> - 3.3.24-5
- Fix the dependency on the formatter class of python-3.10.

* Mon Dec 27 2021 Hugel <gengqihu1@huawei.com> - 3.3.24-4
- Fix the problem when setroubleshoot is installed, or updated.

* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 3.3.24-3
- DESC: delete -S git from %autosetup, and delete BuildRequires git

* Tue Mar 16 2021 yixiangzhike <zhangxingliang3@huawei.com> - 3.3.24-2
- add "Requires: python3-pydbus" for subpackage setroubleshoot-server

* Fri Jan 22 2021 yixiangzhike <zhangxingliang3@huawei.com> - 3.3.24-1
- update to 3.3.24

* Tue Dec 15 2020 panxiaohe <panxiaohe@huawei.com> - 3.3.20-4
- Fix config file to deny noraml user to stop Setroubleshootd.

* Thu Aug 20 2020 wangchen <wangchen137@huawei.com> - 3.3.20-3
- fix the failure of building for audit downgrade

* Thu Oct 10 2019 openEuler Buildteam <buildteam@openeuler.org> - 3.3.20-2
- add COPYING to license directory

* Tue Aug 27 2019 openEuler Buildteam <buildteam@openeuler.org> - 3.3.20-1
- Package init
