pcitool.spec.in 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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
  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. Requires: pcilib-python >= %{version}
  34. Requires: pcilib-dkms >= %{version}
  35. %description -n libpcilib${PCILIB_ABI_VERSION}
  36. pcilib is a user-space library providing structured access to the PCI hardware.
  37. API exposes 4 API layers.
  38. - PCI memory access - allows to map PCI bar memory into the address space of
  39. user application and manipulate it directly.
  40. - Register access - allows to read and write device registers. The register
  41. model is defined using XML. Besides the direct hardware access, the register
  42. values can be filtered using Python scripts. This allows to convert hardware
  43. reading to standard units, make consistency checking, and create meta registers
  44. setting multiple registers from a single parameter.
  45. - DMA engine - allows high-speed reading and writting using DMA. The DMA
  46. engines are implemented in user-space as plugins.
  47. - Event engine - allows polling for hardware events and grabbing the data
  48. associated with the event in multiple supported formats. The event engines
  49. are implemented as plugins and are not part of this package.
  50. %package -n libpcilib-devel
  51. Summary: Development files for pcilib
  52. Group: Development/Libraries
  53. Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}
  54. %description -n libpcilib-devel
  55. Development files for user-space PCI library
  56. %package -n pcilib-test
  57. Summary: Testing files for pcilib
  58. Group: Development/Libraries
  59. Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}
  60. %description -n pcilib-test
  61. Sample XML register model and a few applications for testing pcilib
  62. %package -n pcilib-python
  63. Summary: Python wrapper for pcilib
  64. Group: Development/Libraries
  65. Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}
  66. %description -n pcilib-python
  67. Python wrapper for pcilib. The python wrapper is used
  68. - By register scripts which are used to convert hardware reading to standard
  69. units, make consistency checking, and create meta registers setting multiple
  70. registers from a single parameter.
  71. - pcilib web api which used to provide register and dma access from remote
  72. applications.
  73. %package -n pcilib-dkms
  74. Summary: Kernel module providing low-level PCI access
  75. Group: Development/Libraries
  76. Requires: dkms bash gcc make
  77. %description -n pcilib-dkms
  78. Minimalistic driver used by pcilib to
  79. - Handle interrupts
  80. - Map PCI regions into the user space
  81. - Allocate persistent page-locked memory for DMA operations
  82. and map it into the user-space
  83. - Ensure access syncrhonization between multiple applications
  84. %package -n pcilib-server
  85. Summary: Pcilib Web API
  86. Group: Development/Libraries
  87. Requires: pcilib-python = %{version}
  88. Requires: pcilib-test = %{version}
  89. Requires: python
  90. %if %{defined suse_version}
  91. Prereq: %fillup_prereq
  92. %endif
  93. %description -n pcilib-server
  94. Pcilib Web API and small demo web server.
  95. %prep
  96. %setup -q -n pcitool-%{version}
  97. %build
  98. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \
  99. -DPCILIB_PLUGIN_DIR=%{_libdir}/pcilib${PCILIB_ABI_VERSION}/ -DPCILIB_DATA_DIR=%{_datadir}/pcilib${PCILIB_ABI_VERSION}/ \
  100. -DLIB_INSTALL_DIR=%{_libdir} -DBIN_INSTALL_DIR=%{_bindir} -DDATA_INSTALL_DIR=%{_datadir} -DINCLUDE_INSTALL_DIR=%{_includedir} -DPYTHON_INSTALL_DIR=%{python2_sitearch} .
  101. make
  102. make docs
  103. %install
  104. rm -rf $RPM_BUILD_ROOT
  105. make install DESTDIR=$RPM_BUILD_ROOT
  106. mkdir -p $RPM_BUILD_ROOT/%{_libdir}/pcilib${PCILIB_ABI_VERSION}/
  107. # scripts
  108. install -m 755 tests/reload.sh $RPM_BUILD_ROOT/%{_bindir}/pci-reload
  109. # udev
  110. mkdir -p $RPM_BUILD_ROOT/%{_udevrulesdir}
  111. install -m 644 misc/50-pcidriver.rules $RPM_BUILD_ROOT/%{_udevrulesdir}
  112. # DKMS
  113. mkdir -p $RPM_BUILD_ROOT/%{_includedir}/linux/
  114. install -m 644 driver/ioctl.h $RPM_BUILD_ROOT/%{_includedir}/linux/pcidriver.h
  115. mkdir -p $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/pcilib/
  116. install -m 644 misc/dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/
  117. install -m 644 pcilib/*.h $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/pcilib/
  118. cp -r driver $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/
  119. # Sample model
  120. cp -r xml/test $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/
  121. cp -r xml/devices $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/
  122. # Default configuration
  123. install -m 644 misc/ipedevices.xml $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/
  124. # Servers
  125. mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
  126. install -m 644 misc/pcilib_api.service $RPM_BUILD_ROOT/%{_unitdir}
  127. install -m 644 misc/pcilib_html.service $RPM_BUILD_ROOT/%{_unitdir}
  128. %if %{defined suse_version}
  129. mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates/
  130. install -m 644 misc/pcilib.sysconfig $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.pcilib
  131. %else
  132. mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
  133. install -m 644 misc/pcilib.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/pcilib
  134. %endif
  135. cp -r pyserver $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/
  136. %clean
  137. rm -rf $RPM_BUILD_ROOT
  138. %post -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig
  139. %postun -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig
  140. %post -n pcilib-dkms
  141. if [ -z "`dkms status -m %{modname} -v %{version}`" ]; then
  142. echo "Add module source to dkms"
  143. dkms add -m %{modname} -v %{version} --rpm_safe_upgrade
  144. echo "Build module with dkms"
  145. dkms build -m %{modname} -v %{version}
  146. dkms install -m %{modname} -v %{version}
  147. fi
  148. exit 0
  149. %preun -n pcilib-dkms
  150. /usr/sbin/dkms remove -m %{modname} -v %{version} --all --rpm_safe_upgrade
  151. exit 0
  152. %post -n pcilib-server
  153. %if %{defined suse_version}
  154. %fillup_and_insserv -i
  155. %endif
  156. %files
  157. %defattr(-, root, root)
  158. %{_bindir}/pci
  159. %{_bindir}/pci-reload
  160. %files -n libpcilib${PCILIB_ABI_VERSION}
  161. %defattr(-, root, root)
  162. %doc docs/README
  163. %doc docs/HARDWARE
  164. %dir %{_libdir}/pcilib${PCILIB_ABI_VERSION}/
  165. %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/
  166. %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/
  167. %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/
  168. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/*.xsd
  169. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/*.xsd
  170. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/ipedevices.xml
  171. %{_libdir}/libpcilib.so.*
  172. %files -n libpcilib-devel
  173. %defattr(-, root, root)
  174. %doc docs/html
  175. %{_includedir}/linux/pcidriver.h
  176. %{_includedir}/pcilib.h
  177. %{_includedir}/pcilib/
  178. %{_libdir}/lib*.so
  179. %{_libdir}/pkgconfig/*.pc
  180. %files -n pcilib-test
  181. %defattr(-, root, root)
  182. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/test
  183. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/testdevice.xml
  184. %files -n pcilib-dkms
  185. %defattr(-, root, root)
  186. %{_udevrulesdir}
  187. %{_prefix}/src/%{modname}-%{version}/
  188. %files -n pcilib-python
  189. %defattr(-, root, root)
  190. %{python2_sitearch}/*
  191. %files -n pcilib-server
  192. %defattr(-, root, root)
  193. %if %{defined suse_version}
  194. /var/adm/fillup-templates/sysconfig.*
  195. %else
  196. %{_sysconfdir}/sysconfig/*
  197. %endif
  198. %{_unitdir}/*
  199. %{_datadir}/pcilib${PCILIB_ABI_VERSION}/pyserver
  200. %changelog
  201. * Fri Mar 4 2016 Suren A. Chilingaryan <csa@suren.me> - ${CPACK_PACKAGE_VERSION}
  202. - Added spec file to the sources