Name: libsmbios
Version: 2.4.3
Release: 2%{?_dist_release}
Summary: Libsmbios C/C++ shared libraries
Summary(ja): Libsmbios C/C++ 共有ライブラリ
Group: system
Vendor: Project Vine
Distribution: Vine Linux
Packager: shaolin, daisuke

License: GPLv2+ or OSL 2.1
URL: https://github.com/dell/libsmbios
Source: https://github.com/dell/libsmbios/archive/v%{version}.tar.gz#/libsmbios-%{version}.tar.gz
Source100: ChangeLog.fedora
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: strace libxml2-devel gcc-c++ gettext doxygen cppunit-devel pkgconfig python-devel
Obsoletes: python-smbios < %{version}-%{release}

# libsmbios only ever makes sense on intel compatible arches
# no DMI tables on ppc, s390, etc.
ExclusiveArch: x86_64 ia64 %{ix86}

# these are all substituted by autoconf
%define pot_file  libsmbios
%define lang_dom  libsmbios-2.4-x86_64

%define major %(echo %{version} | sed -e 's/^\\([0-9]*\\)\..*$/\\1/')
%define minor %(echo %{version} | sed -e 's/^[0-9]*\\.\\([0-9]*\\).*$/\\1/')
%define micro %(echo %{version} | sed -e 's/^[0-9]*\\.[0-9]*\\.\\([0-9]*\\).*$/\\1/')
%define extra %{nil}

%description
Libsmbios is a library and utilities that can be used by client programs to get
information from standard BIOS tables, such as the SMBIOS table.

This package provides the C-based libsmbios library, with a C interface.

This package also has a C++-based library, with a C++ interface. It is not
actively maintained, but provided for backwards compatibility. New programs
should use the libsmbios C interface.


%package -n python3-smbios
Summary: Python interface to Libsmbios C library
Summary(ja): libsmbios C ライブラリへの Python インターフェース
Group: programming
BuildRequires: python3-devel python3-setuptools python3-rpm-macros
Requires: %{name} = %{version}-%{release}
Requires: python3

%description -n python3-smbios
This package provides a Python interface to libsmbios


%package -n smbios-utils
Summary: Meta-package that pulls in all smbios binaries and python scripts
Summary(ja): すべての smbios プログラムと python スクリプトをインストールするための仮想パッケージ
Group: admin-tools
Requires: smbios-utils-bin = %{version}-%{release}
Requires: smbios-utils-python3 = %{version}-%{release}

%description -n smbios-utils
This is a meta-package that pulls in the binary libsmbios executables as well
as the python executables.


%package -n smbios-utils-bin
Summary: Binary utilities that use libsmbios
Summary(ja): libsmbios を用いたユーティリティ集
Group: admin-tools
Requires: %{name} = %{version}-%{release}

%description -n smbios-utils-bin
Get BIOS information, such as System product name, product id, service tag and
asset tag.


%package -n smbios-utils-python3
Summary: Python executables that use libsmbios
Summary(ja): libsmbios を用いた Python スクリプト集
Group: admin-tools
Requires: python3-smbios = %{version}-%{release}
Obsoletes: smbios-utils-python < %{version}-%{release}
Provides: smbios-utils-python = %{version}-%{release}

%description -n smbios-utils-python3
Get BIOS information, such as System product name, product id, service tag and
asset tag. Set service and asset tags on Dell machines. Manipulate wireless
cards/bluetooth on Dell laptops. Set BIOS password on select Dell systems.
Update BIOS on select Dell systems. Set LCD brightness on select Dell laptops.


# name the devel package libsmbios-devel regardless of package name, per suse/fedora convention
%package -n libsmbios-devel
Summary: Development headers and archives
Summary(ja): libsmbios の開発用ヘッダファイルとライブラリ
Group: programming
Requires: %{name} = %{version}-%{release}

%description -n libsmbios-devel
Libsmbios is a library and utilities that can be used by client programs to get
information from standard BIOS tables, such as the SMBIOS table.

This package contains the headers and .a files necessary to compile new client
programs against libsmbios.


%prep
%setup -q -n libsmbios-%{version}
find . -type d -exec chmod -f 755 {} \;
find doc src -type f -exec chmod -f 644 {} \;
chmod 755 src/cppunit/*.sh


%build
# this line lets us build an RPM directly from a git tarball
# and retains any customized version information we might have
[ -e ./configure ] || ./autogen.sh --no-configure

mkdir _build
cd _build
echo '../configure "$@"' > configure
chmod +x ./configure

export PYTHON=%{__python3}
%configure

mkdir -p out/libsmbios_c
mkdir -p out/libsmbios_c++
make %{?_smp_mflags} 2>&1 | tee build-%{_arch}.log

echo \%doc _build/build-%{_arch}.log > buildlogs.txt


%install
rm -rf %{buildroot}
mkdir %{buildroot}

cd _build
TOPDIR=..
make install DESTDIR=%{buildroot} INSTALL="%{__install} -p"
mkdir -p %{buildroot}/%{_includedir}
mkdir -p %{buildroot}/%{_bindir}
cp -a $TOPDIR/src/include/*  %{buildroot}/%{_includedir}/
cp -a out/public-include/*  %{buildroot}/%{_includedir}/
rm -f %{buildroot}/%{_libdir}/lib*.{la,a}
rm -f %{buildroot}/%{_includedir}/Makefile.am
find %{buildroot}/%{_includedir} out/libsmbios_c++ out/libsmbios_c -exec touch -r $TOPDIR/configure.ac {} \;

mv out/libsmbios_c++  out/libsmbios_c++-%{_arch}
mv out/libsmbios_c    out/libsmbios_c-%{_arch}

rename %{pot_file}.mo %{lang_dom}.mo $(find %{buildroot}/%{_datadir} -name %{pot_file}.mo)
%find_lang %{lang_dom}

touch files-yum-dellsysid
touch files-smbios-utils-python3
touch files-python3-smbios

cat > files-python3-smbios <<-EOF
	%{python3_sitearch}/*
EOF

cat > files-smbios-utils-python3 <<-EOF
	%dir %{_sysconfdir}/libsmbios
	%config(noreplace) %{_sysconfdir}/libsmbios/*
	
	# python utilities
	%{_sbindir}/smbios-sys-info
	%{_sbindir}/smbios-token-ctl
	%{_sbindir}/smbios-passwd
	%{_sbindir}/smbios-wakeup-ctl
	%{_sbindir}/smbios-wireless-ctl
	%{_sbindir}/smbios-lcd-brightness
	%{_sbindir}/smbios-keyboard-ctl
	%{_sbindir}/smbios-thermal-ctl
	%{_sbindir}/smbios-battery-ctl

	# data files
	%{_datadir}/smbios-utils
EOF


%clean
rm -rf %{buildroot}


%post   -p /sbin/ldconfig
%postun -p /sbin/ldconfig


%files -f _build/%{lang_dom}.lang
%defattr(-,root,root,-)
%license COPYING* src/bin/getopts_LICENSE.txt src/include/smbios_c/config/boost_LICENSE_1_0_txt
%doc README*
%{_libdir}/libsmbios_c.so.*

%files -n libsmbios-devel -f _build/buildlogs.txt
%defattr(-,root,root,-)
%{_includedir}/smbios
%{_includedir}/smbios_c
%{_libdir}/libsmbios_c.so
%{_libdir}/pkgconfig/*.pc
%doc _build/out/libsmbios_c++-%{_arch}
%doc _build/out/libsmbios_c-%{_arch}

%files -n smbios-utils
# opensuse 11.1 enforces non-empty file list :(
%defattr(-,root,root,-)
%license COPYING-GPL COPYING-OSL
%doc README*
# no other files.

%files -n smbios-utils-bin
%defattr(-,root,root,-)
%license COPYING-GPL COPYING-OSL
%license src/bin/getopts_LICENSE.txt src/include/smbios_c/config/boost_LICENSE_1_0_txt
%doc README*
#
# new C utilities
%{_sbindir}/smbios-state-byte-ctl
%{_sbindir}/smbios-get-ut-data
%{_sbindir}/smbios-upflag-ctl
%{_sbindir}/smbios-sys-info-lite

%files -n python3-smbios -f _build/files-python3-smbios
%defattr(-,root,root,-)
%license COPYING-GPL COPYING-OSL
%doc README*

%files -n smbios-utils-python3 -f _build/files-smbios-utils-python3
%defattr(-,root,root,-)
%license COPYING-GPL COPYING-OSL
%license src/bin/getopts_LICENSE.txt src/include/smbios_c/config/boost_LICENSE_1_0_txt
%doc README*


%changelog
* Tue Aug 18 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.3-2
- rebuilt with python3.8.

* Sat Apr 11 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.3-1
- new upstream release.
- dropped python2 support.
- added python3 support.
- truncated %%changelog: old logs are ChangeLog.fedora.

* Sat Jul  2 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.3.0-1
- new upstream release.

* Tue Feb 24 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 2.2.28-2
- rebuilt on current VineSeed
- added Japanese summary

* Thu Feb 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.2.28-1
- update to 2.2.28

* Sun Apr 24 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.26-1
- merged with upstream package
  * Sat May 24 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.0.1-3
  - initial build for Vine Linux
