Name:       OpenIPMI
Version:    2.0.31
Release:    1
Summary:    IPMI (Intelligent Platform Management Interface) library and tools
License:    LGPLv2+ and GPLv2+ or BSD
URL:        https://sourceforge.net/projects/openipmi/
Source:     https://downloads.sourceforge.net/openipmi/%{name}-%{version}.tar.gz
Source1:    openipmi.sysconf
Source2:    ipmi.service
Source3:    openipmi-helper

Patch0:     0001-man.patch

BuildRequires:    gdbm-devel swig glib2-devel net-snmp-devel ncurses-devel
BuildRequires:    openssl-devel python3-devel perl-devel perl-generators
BuildRequires:    pkgconfig libedit-devel automake autoconf libtool readline-devel
%{?systemd_requires}
BuildRequires:    systemd

Provides:       %{name}-libs
Obsoletes:      %{name}-libs

Provides:       %{name}-lanserv
Obsoletes:      %{name}-lanserv

%description
This is the OpenIPMI library, a library that makes simplifies building
complex IPMI management software.IPMI is a specification detailing how
to detect and manage sensors in a system.  It also specifies some
chassis-level thing like power control,reset, FRU (Field Replaceable Unit)
information, and watchdogs.

%package perl
Summary:  IPMI Perl language bindings
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
Requires: %{name}%{?_isa} = %{version}-%{release}

%description perl
The OpenIPMI-perl package contains the Perl language bindings for OpenIPMI.

%package -n python3-openipmi
%{?python_provide:%python_provide python3-openipmi}
%{?python_provide:%python_provide python3-OpenIPMI}
Provides:  %{name}-python = %{version}-%{release}
Provides:  %{name}-python%{?_isa} = %{version}-%{release}
Obsoletes: %{name}-python2 < %{version}-%{release}
Summary:   IPMI Python language bindings
Requires:  %{name}%{?_isa} = %{version}-%{release}

%description -n python3-openipmi
The OpenIPMI-python package contains the Python language bindings for OpenIPMI.

%package devel
Summary:  The development environment for the OpenIPMI project
Requires: pkgconfig %{name}%{?_isa} = %{version}-%{release}

%description devel
The OpenIPMI-devel package contains the development libraries and header files
of the OpenIPMI project.

%package_help

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

%build
%configure \
    CFLAGS="-fPIC %{optflags} -z now -fno-strict-aliasing" \
    LDFLAGS="%{__global_ldflags} -Wl,--as-needed" \
    --disable-dependency-tracking \
    --with-pythoninstall=%{python3_sitearch} \
    --with-python=%{__python3} \
    --with-tcl=no \
    --with-tkinter=no
    
%disable_rpath
make

%install
%make_install

mkdir -p %{buildroot}{%{_sysconfdir}/sysconfig,%{_unitdir},%{_libexecdir}}
install -m 644 %SOURCE1 %{buildroot}%{_sysconfdir}/sysconfig/ipmi
install -m 644 %SOURCE2 %{buildroot}%{_unitdir}/ipmi.service
install -m 755 %SOURCE3 %{buildroot}%{_libexecdir}/openipmi-helper
mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d

echo ".so man1/ipmicmd.1" > %{buildroot}%{_mandir}/man1/ipmicmd.1
echo ".so man1/openipmish.1" > %{buildroot}%{_mandir}/man1/ipmish.1

%delete_la

%post
%systemd_post ipmi.service

%preun
%systemd_preun ipmi.service

%postun
%systemd_postun_with_restart ipmi.service

%ldconfig_scriptlets

%triggerun -- OpenIPMI < 2.0.18-14
/usr/bin/systemd-sysv-convert --save ipmi >/dev/null 2>&1 ||:
/bin/systemctl --no-reload enable ipmi.service >/dev/null 2>&1 ||:
/sbin/chkconfig --del ipmi >/dev/null 2>&1 || :
/bin/systemctl try-restart ipmi.service >/dev/null 2>&1 || :

%files
%defattr(-,root,root)
%license COPYING COPYING.BSD COPYING.LIB
%config(noreplace) %{_sysconfdir}/sysconfig/ipmi
%{_libexecdir}/openipmi-helper
%config(noreplace) %{_sysconfdir}/ipmi/*
%{_bindir}/*
%{_libdir}/*.so.*
%{_unitdir}/ipmi.service

%files perl
%defattr(-,root,root)
%{perl_vendorarch}/OpenIPMI.pm
%{perl_vendorarch}/auto/OpenIPMI

%files -n python3-openipmi
%defattr(-,root,root)
%{python3_sitearch}/*OpenIPMI*
%{python3_sitearch}/__pycache__/OpenIPMI.*.pyc

%files devel
%defattr(-,root,root)
%{_includedir}/OpenIPMI
%{_libdir}/*.so
%{_libdir}/*.a
%{_libdir}/pkgconfig/*.pc

%files help
%defattr(-,root,root)
%doc README.MotorolaMXP README.Force README FAQ CONFIGURING_FOR_LAN
%{_mandir}/man*/*
%exclude %{_mandir}/man1/openipmigui.1

%changelog
* Fri Jan 29 2021 xihaochen <xihaochen@huawei.com> - 2.0.31-1
- Type:requirements                                                                                                                                            
- Id:NA
- SUG:NA
- DESC:update OpenIPMI to 2.0.31

* Wed Jul 22 2020 yuboyun<yuboyun@huawei.com> - 2.0.28-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: update to 2.0.28

* Sat Mar 28 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.0.27-6
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: fix openipmi in virt

* Sat Mar 7 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.0.27-5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: change openipmi-helper fileformat

* Mon Mar 2 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.0.27-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: add openipmi-helper file

* Sat Jan 11 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.0.27-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: delete patches

* Sat Dec 28 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.27-2
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:modify the spec

* Wed Sep 18 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.27-1
- Package init
