pcitool.spec.in 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. %define modname pciDriver
  2. %{!?__python2: %global __python2 /usr/bin/python2}
  3. %{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
  4. %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
  5. %{?!_udevrulesdir: %global _udevrulesdir %{_prefix}/lib/udev/rules.d/ }
  6. %{?!_unitdir: %global _unitdir %{_prefix}/lib/systemd/system/ }
  7. %{?!_dkmsdir: %global _dkmsdir /var/lib/dkms }
  8. Summary: Universal PCI driver
  9. Name: pcitool
  10. Version: ${CPACK_PACKAGE_VERSION}
  11. Release: csa
  12. License: GPL-3.0
  13. Group: Development/Libraries
  14. Vendor: Institute for Data Processing and Electronics, KIT
  15. Packager: Suren A. Chilingaryan <csa@suren.me>
  16. Source: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
  17. URL: http://darksoft.org
  18. BuildRequires: libfastwriter-devel libxml2-devel uthash-devel
  19. BuildRequires: python python-devel swig
  20. BuildRequires: dkms
  21. BuildRequires: doxygen
  22. BuildRequires: pkg-config libtool cmake
  23. BuildRoot: %{_tmppath}/%{name}-%{version}-root
  24. Prefix: %{_prefix}
  25. Docdir: %{_docdir}
  26. %description
  27. pcitool is a command line tool to manipulate PCI hardware. It provides ability
  28. to get/set registers, read/write data using DMA engine, and debug hardware
  29. operation.
  30. %package -n libpcilib${PCILIB_ABI_VERSION}
  31. Summary: User-space PCI library
  32. Group: Development/Libraries
  33. Provides: pcilib = %{version}
  34. Requires: pcilib-python >= %{version}
  35. Requires: pcilib-dkms >= %{version}
  36. %description -n libpcilib${PCILIB_ABI_VERSION}
  37. pcilib is a user-space library providing structured access to the PCI hardware.
  38. API exposes 4 API layers.
  39. - PCI memory access - allows to map PCI bar memory into the address space of
  40. user application and manipulate it directly.
  41. - Register access - allows to read and write device registers. The register
  42. model is defined using XML. Besides the direct hardware access, the register
  43. values can be filtered using Python scripts. This allows to convert hardware
  44. reading to standard units, make consistency checking, and create meta registers
  45. setting multiple registers from a single parameter.
  46. - DMA engine - allows high-speed reading and writting using DMA. The DMA
  47. engines are implemented in user-space as plugins.
  48. - Event engine - allows polling for hardware events and grabbing the data
  49. associated with the event in multiple supported formats. The event engines
  50. are implemented as plugins and are not part of this package.
  51. %package -n libpcilib-devel
  52. Summary: Development files for pcilib
  53. Group: Development/Libraries
  54. Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}
  55. Requires: uthash-devel
  56. %description -n libpcilib-devel
  57. Development files for user-space PCI library
  58. %package -n pcilib-test
  59. Summary: Testing files for pcilib
  60. Group: Development/Libraries
  61. Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}
  62. %description -n pcilib-test
  63. Sample XML register model and a few applications for testing pcilib
  64. %package -n pcilib-python
  65. Summary: Python wrapper for pcilib
  66. Group: Development/Libraries
  67. Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}
  68. %description -n pcilib-python
  69. Python wrapper for pcilib. The python wrapper is used
  70. - By register scripts which are used to convert hardware reading to standard
  71. units, make consistency checking, and create meta registers setting multiple
  72. registers from a single parameter.
  73. - pcilib web api which used to provide register and dma access from remote
  74. applications.
  75. %package -n pcilib-dkms
  76. Summary: Kernel module providing low-level PCI access
  77. Group: Development/Libraries
  78. Requires: dkms bash gcc make
  79. %description -n pcilib-dkms
  80. Minimalistic driver used by pcilib to
  81. - Handle interrupts
  82. - Map PCI regions into the user space
  83. - Allocate persistent page-locked memory for DMA operations
  84. and map it into the user-space
  85. - Ensure access syncrhonization between multiple applications
  86. %package -n pcilib-server
  87. Summary: Pcilib Web API
  88. Group: Development/Libraries
  89. Requires: pcilib-python = %{version}
  90. Requires: pcilib-test = %{version}
  91. Requires: python
  92. %if %{defined suse_version}
  93. Prereq: %fillup_prereq
  94. %endif
  95. %description -n pcilib-server
  96. Pcilib Web API and small demo web server.
  97. %prep
  98. %setup -q -n pcitool-%{version}
  99. %build
  100. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DPCILIB_DYNAMIC_HEADERS_INC="" \
  101. -DPCILIB_PLUGIN_DIR=%{_libdir}/pcilib${PCILIB_ABI_VERSION}/ -DPCILIB_DATA_DIR=%{_datadir}/pcilib${PCILIB_ABI_VERSION}/ \
  102. -DPCILIB_PYTHON_SITEDIR=%{python2_sitearch} \
  103. -DCMAKE_INSTALL_LIBDIR=%{_libdir} -DCMAKE_INSTALL_BINDIR=%{_bindir} -DCMAKE_INSTALL_DATADIR=%{_datadir} -DCMAKE_INSTALL_DATAROOTDIR=%{_datadir} -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} .
  104. make
  105. make docs
  106. %install
  107. rm -rf $RPM_BUILD_ROOT
  108. make install DESTDIR=$RPM_BUILD_ROOT
  109. mkdir -p $RPM_BUILD_ROOT/%{_libdir}/pcilib${PCILIB_ABI_VERSION}/
  110. # scripts
  111. install -m 755 tests/reload.sh $RPM_BUILD_ROOT/%{_bindir}/pci-reload
  112. # udev
  113. mkdir -p $RPM_BUILD_ROOT/%{_udevrulesdir}
  114. install -m 644 misc/50-pcidriver.rules $RPM_BUILD_ROOT/%{_udevrulesdir}
  115. # DKMS
  116. mkdir -p $RPM_BUILD_ROOT/%{_includedir}/linux/
  117. install -m 644 driver/ioctl.h $RPM_BUILD_ROOT/%{_includedir}/linux/pcidriver.h
  118. mkdir -p $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/pcilib/
  119. install -m 644 misc/dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/
  120. install -m 755 misc/dkms-postbuild.sh $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/
  121. install -m 644 pcilib/*.h $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/pcilib/
  122. cp -r driver $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/
  123. # Sample model
  124. cp -r xml/test $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/
  125. cp -r xml/devices $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/
  126. # Default configuration
  127. install -m 644 misc/ipedevices.xml $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/
  128. # Servers
  129. mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
  130. install -m 644 misc/pcilib_api.service $RPM_BUILD_ROOT/%{_unitdir}
  131. install -m 644 misc/pcilib_html.service $RPM_BUILD_ROOT/%{_unitdir}
  132. %if %{defined suse_version}
  133. mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates/
  134. install -m 644 misc/pcilib.sysconfig $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.pcilib
  135. %else
  136. mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
  137. install -m 644 misc/pcilib.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/pcilib
  138. %endif
  139. cp -r pyserver $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/
  140. %clean
  141. rm -rf $RPM_BUILD_ROOT
  142. %post -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig
  143. %postun -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig
  144. %post -n pcilib-dkms
  145. if [ -z "`dkms status -m %{modname} -v %{version}`" ]; then
  146. echo "Add module source to dkms"
  147. dkms add -m %{modname} -v %{version} --rpm_safe_upgrade
  148. echo "Build module with dkms"
  149. dkms build -m %{modname} -v %{version}
  150. dkms install -m %{modname} -v %{version}
  151. fi
  152. exit 0
  153. %preun -n pcilib-dkms
  154. /usr/sbin/dkms remove -m %{modname} -v %{version} --all --rpm_safe_upgrade
  155. exit 0
  156. %post -n pcilib-server
  157. %if %{defined suse_version}
  158. %fillup_and_insserv -i
  159. %endif
  160. %files
  161. %defattr(-, root, root)
  162. %{_bindir}/pci
  163. %{_bindir}/pci-reload
  164. %files -n libpcilib${PCILIB_ABI_VERSION}
  165. %defattr(-, root, root)
  166. %doc docs/README
  167. %doc docs/HARDWARE
  168. %dir %{_libdir}/pcilib${PCILIB_ABI_VERSION}/
  169. %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/
  170. %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/
  171. %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/
  172. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/*.xsd
  173. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/*.xsd
  174. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/ipedevices.xml
  175. %{_libdir}/libpcilib.so.*
  176. %files -n libpcilib-devel
  177. %defattr(-, root, root)
  178. %doc docs/html
  179. %{_includedir}/linux/pcidriver.h
  180. %{_includedir}/pcilib.h
  181. %{_includedir}/pcilib/
  182. %{_libdir}/lib*.so
  183. %{_libdir}/pkgconfig/*.pc
  184. %files -n pcilib-test
  185. %defattr(-, root, root)
  186. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/test
  187. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/testdevice.xml
  188. %files -n pcilib-dkms
  189. %defattr(-, root, root)
  190. %{_udevrulesdir}
  191. %{_prefix}/src/%{modname}-%{version}/
  192. %files -n pcilib-python
  193. %defattr(-, root, root)
  194. %{python2_sitearch}/*
  195. %files -n pcilib-server
  196. %defattr(-, root, root)
  197. %if %{defined suse_version}
  198. /var/adm/fillup-templates/sysconfig.*
  199. %else
  200. %config %{_sysconfdir}/sysconfig/*
  201. %endif
  202. %{_unitdir}/*
  203. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/pyserver
  204. %changelog
  205. * Fri Mar 4 2016 Suren A. Chilingaryan <csa@suren.me> - ${CPACK_PACKAGE_VERSION}
  206. - Added spec file to the sources