%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
Summary:        PCI bus related utilities.
Summary(ja):    Linux PCI ユーティリティ
Name:           pciutils
Version:        3.13.0
Release:        1%{?_dist_release}
Group:          admin-tools
Vendor:         Project Vine
Distribution:   Vine Linux

License:        GPLv2+
URL:            https://mj.ucw.cz/sw/pciutils/
Source:         https://mirrors.edge.kernel.org/pub/software/utils/pciutils/pciutils-%{version}.tar.xz

#change pci.ids directory to hwdata, fedora/rhel specific
Patch1:		pciutils-2.2.1-idpath.patch

#add support for directory with another pci.ids, rejected by upstream, rhbz#195327
Patch2:		pciutils-dir-d.patch
Patch3:		pciutils-3.13.0-fixleak.patch

Buildroot: 	%{_tmppath}/%{name}-%{version}-root
BuildRequires:  sed
Requires:	hwdata
Requires:	%{name}-libs = %{version}-%{release}

%global __provides_exclude_from ^%{_libdir}/pkgconfig/.*$

%description
The pciutils package contains various utilities for inspecting and
setting devices connected to the PCI bus. The utilities provided
require kernel version 2.1.82 or newer (which support the
/proc/bus/pci interface).

%description -l ja
このパッケージには PCI バスに接続された各種デバイスの状態を見たり
設定したりする為のユーティリティが収められています.
このパッケージに収められたユーティリティはカーネル 2.1.82 以降
(/proc/bus/pci インタフェースがサポートされているもの) を必要とします.


%package devel
Summary: Linux PCI development library.
Summary(ja): Linux PCI 開発ライブラリ
Group: programming
Requires: %{name}-libs = %{version}-%{release}
Provides: pkgconfig(libpci) = %{version}

%description devel
This package contains a library for inspecting and setting
devices connected to the PCI bus.

%description devel -l ja
このパッケージには PCI バスに接続された各種デバイスの状態を見たり
設定したりするのに必要なライブラリが収められています.


%package libs
Summary: Linux PCI library
Summary(ja): Linux PCI ライブラリ
Group: system

%description libs
This package contains a library for inspecting and setting
devices connected to the PCI bus.


%package static
Summary: Linux PCI satic library
Summary(ja): Linux PCI スタッティックライブラリ
Group: programming
Requires: %{name}-devel = %{version}-%{release}

%description static
This package contains a library for inspecting and setting
devices connected to the PCI bus.


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}-libs
Summary: Linux PCI library.
Group: programming,legacy
Requires: compat32-%{name}-devel = %{version}-%{release}
%description -n compat32-%{name}-libs
This package contains a library for inspecting and setting
devices connected to the PCI bus.


%package -n compat32-%{name}-devel
Summary: Linux PCI development library.
Group: system,legacy
%description -n compat32-%{name}-devel
This package contains a library for inspecting and setting
devices connected to the PCI bus.


%debug_package


%prep
%setup -q -n pciutils-%{version}
%autopatch -p1

sed -i -e 's/^SRC=.*/SRC="http:\/\/pciids.sourceforge.net\/pci.ids"/' update-pciids.sh

%build
make SHARED="no" ZLIB="no" STRIP="" OPT="$RPM_OPT_FLAGS" PREFIX="/usr" IDSDIR="/usr/share/hwdata" PCI_IDS="pci.ids" %{?_smp_mflags}
mv lib/libpci.a lib/libpci.a.toinstall

make clean

make SHARED="yes" ZLIB="no" STRIP="" OPT="$RPM_OPT_FLAGS" PREFIX="/usr" IDSDIR="/usr/share/hwdata" PCI_IDS="pci.ids" %{?_smp_mflags}

#fix lib vs. lib64 in libpci.pc (static Makefile is used)
sed -i -e "s|^libdir=.*$|libdir=%{_libdir}|" lib/libpci.pc


%install
install -d %{buildroot}/{sbin,%{_mandir}/man8,%{_libdir},%{_libdir}/pkgconfig,%{_includedir}/pci}

install -p lspci setpci update-pciids %{buildroot}/sbin
install -p lspci.8 setpci.8 update-pciids.8 %{buildroot}%{_mandir}/man8
install -p  lib/libpci.so.*.*.* %{buildroot}%{_libdir}
ln -s $(basename %{buildroot}%{_libdir}/*.so.*.*.*) %{buildroot}%{_libdir}/libpci.so

mkdir -p %{buildroot}%{_libdir}
mv lib/libpci.a.toinstall %{buildroot}%{_libdir}/libpci.a
ldconfig -N %{buildroot}%{_libdir}
install -p lib/pci.h %{buildroot}%{_includedir}/pci
install -p lib/header.h %{buildroot}%{_includedir}/pci
install -p lib/config.h %{buildroot}%{_includedir}/pci
install -p lib/types.h %{buildroot}%{_includedir}/pci
install -p lib/libpci.pc %{buildroot}%{_libdir}/pkgconfig


%files
%defattr(-,root,root,-)
%{_mandir}/man8/*
%attr(0755, root, root) /sbin/*
%license COPYING
%doc README ChangeLog pciutils.lsm

%files devel
%defattr(-,root,root,-)
%{_libdir}/libpci.so
%{_libdir}/pkgconfig/libpci.pc
%{_includedir}/pci

%files libs
%defattr(-,root,root,-)
%{_libdir}/libpci.so.*

%files static
%defattr(-,root,root,-)
%{_libdir}/libpci.a

%if %{build_compat32}
%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/libpci.so
%{_libdir}/pkgconfig/libpci.pc
%{_includedir}/pci

%files -n compat32-%{name}-libs
%defattr(-,root,root,-)
%{_libdir}/libpci.so.*
%endif


%changelog
* Tue Jul 16 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.13.0-1
- new upstream release.

* Fri Apr 10 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.6.4-1
- new upstream release.
- dropped all patches.
- imported Patch0-2 from rawhide.

* Sun May 15 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.1-1
- new upstream release

* Thu Nov 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.0-1
- new upstream release

* Mon May 04 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.3.1-1
- new upstream release
- update Patch3 (pciutils-havepread.patch)

* Mon Dec 01 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.3.0-1
- new upstream release
- update Patch8 (pciutils-3.3.0-multilib.patch)

* Sun Feb 02 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.1-1
- new upstream release

* Sat Nov 03 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.10-1
- new upstream release

* Sun Oct 09 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.8-1
- new upstream release
- remove Patch1 (pciutils-2.2.4-buf.patch)

* Tue Sep 28 2010 Shu KONNO <owa@bg.wakwak.com> 3.1.2-4
- rebuilt with rpm-4.8.1 for pkg-config

* Sat Jul 03 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.2-3
- add Requires: %{name}-libs = %{version}-%{release} (devel package)

* Sun Jul 05 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.2-2
- removed %%if !%%{build_compat32} case condition

* Tue Apr 28 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.2-1
- new upstream release
- add shared library
- split shared library to -libs
- split static library to -static

* Fri Nov  7 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 3.0.2-1
- new upstream release

* Sat Aug 16 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 3.0.0-1vl5
- new upstream release

* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 2.2.4-1vl5
- applied new versioning policy, spec in utf-8

* Wed Dec 06 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.4-0vl1
- new upstream release

* Sun Feb 19 2006 Shu KONNO <owa@bg.wakwak.com> 2.2.1-1vl2
- rebuilt for x86_64 architecture support
- added compat32-* packages for x86_64 architecture support

* Sun Dec 18 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.1-1vl1
- updated to 2.2.1 based on fedora package
  * Mon Mar 14 2005 Bill Nottingham <notting@redhat.com> - 2.1.99.test8-8
  - add patch for glibc macros (#151032, <redhat-bugzilla@linuxnetz.de>)
  * Tue Jan 25 2005 Bill Nottingham <notting@redhat.com> - 2.1.99.test8-6
  - remove explicit kernel dep (#146153)

* Sat Nov 16 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 2.1.10-4vl1
- use hwdata for pci.ids database.
- merged with rawhide package.
  - update to 2.1.10
  - fix dir perms on /usr/include/pci
  - don't forcibly strip binaries
  - require hwdata now that pci.ids is there
  - man page is now owned by root

* Fri Nov 23 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.1.8-25vl1
- based on 2.1.8-25 from Rawhide and rebuilt for Vine Linux

* Wed Oct 17 2001 Bill Nottingham <notting@redhat.com>
- dump all the patches, ship pci.ids direct out of sourceforge CVS

* Wed Sep 26 2001 Bill Nottingham <notting@redhat.com>
- broadcom bcm5820 id (#53592)

* Fri Aug 10 2001 Bill Nottingham <notting@redhat.com>
- more ids

* Tue Jul 17 2001 Bill Nottingham <notting@redhat.com>
- add newline in printf in PCI-X patch (#49277)

* Mon Jul  9 2001 Bill Nottingham <notting@redhat.com>
- update broadcom patch
- add new ids from 2.4.6

* Mon May 28 2001 Bill Nottingham <notting@redhat.com>
- add a couple of e1000 ids

* Thu Mar 22 2001 Bill Nottingham <notting@redhat.com>
- another megaraid id

* Wed Mar 21 2001 Bill Nottingham <notting@redhat.com>
- another megaraid id

* Wed Mar 14 2001 Preston Brown <pbrown@redhat.com>
- LSI SCSI PCI id

* Wed Feb 21 2001 Nalin Dahyabhai <nalin@redhat.com>
- fix formatting problems

* Wed Feb 21 2001 Preston Brown <pbrown@redhat.com>
- add IBM ServeRAID entries

* Tue Feb 20 2001 Preston Brown <pbrown@redhat.com>
- i860 entries.

* Mon Feb 19 2001 Helge Deller <hdeller@redhat.de>
- added various pci ids 

* Fri Feb  2 2001 Bill Nottingham <notting@redhat.com>
- fix mishap in fixing mishap

* Thu Feb  1 2001 Bill Nottingham <notting@redhat.com>
- fix apparent mishap in pci.ids update from kernel (#25520)

* Tue Jan 23 2001 Bill Nottingham <notting@redhat.com>
- pci.ids updates

* Tue Dec 12 2000 Bill Nottingham <notting@redhat.com>
- big pile of pci.ids updates

* Tue Jul 25 2000 Nalin Dahyabhai <nalin@redhat.com>
- clean up patches to not generate badly-formatted files

* Tue Jul 25 2000 Preston Brown <pbrown@redhat.com>
- Vortex fixes laroche originally applied on kudzu moved here.

* Fri Jul 14 2000 Preston Brown <pbrown@redhat.com>
- pci ids for i815, new ati hardware

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jul 11 2000 Bill Nottingham <notting@redhat.com>
- yet more IDs
- PCI-X support from Matt Domsch

* Fri Jul  7 2000 Bill Nottingham <notting@redhat.com>
- some more QLogic ids

* Mon Jun 26 2000 Bill Nottingham <notting@redhat.com>
- more IDs from Dell

* Sat Jun 10 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.8

* Fri Apr 21 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.7

* Mon Apr 17 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.6

* Fri Mar  3 2000 Bill Nottingham <notting@redhat.com>
- add a couple of ids

* Mon Feb 14 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.5

* Thu Feb  3 2000 Bill Nottingham <notting@redhat.com>
- handle compressed man pages

* Mon Jan 24 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.4

* Thu Jan 20 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.3

* Fri Dec 24 1999 Bill Nottingham <notting@redhat.com>
- update to 2.1.2

* Tue Jun 29 1999 Bill Nottingham <notting@redhat.com>
- add -devel package

* Thu May 20 1999 Bill Nottingham <notting@redhat.com>
- update to 2.0

* Mon Apr 19 1999 Jakub Jelinek  <jj@ultra.linux.cz>
- update to 1.99.5
- fix sparc64 operation

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 2)

* Thu Feb  4 1999 Bill Nottingham <notting@redhat.com>
- initial build