%define modname pciDriver %{!?__python2: %global __python2 /usr/bin/python2} %{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %{?!_udevrulesdir: %global _udevrulesdir %{_prefix}/lib/udev/rules.d/ } %{?!_unitdir: %global _unitdir %{_prefix}/lib/systemd/system/ } %{?!_dkmsdir: %global _dkmsdir /var/lib/dkms } Summary: Universal PCI driver Name: pcitool Version: ${CPACK_PACKAGE_VERSION} Release: csa License: GPL-3.0 Group: Development/Libraries Vendor: Institute for Data Processing and Electronics, KIT Packager: Suren A. Chilingaryan Source: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 URL: http://darksoft.org BuildRequires: libfastwriter-devel libxml2-devel uthash-devel BuildRequires: python python-devel swig BuildRequires: dkms BuildRequires: doxygen BuildRequires: pkg-config libtool cmake BuildRoot: %{_tmppath}/%{name}-%{version}-root Prefix: %{_prefix} Docdir: %{_docdir} %description pcitool is a command line tool to manipulate PCI hardware. It provides ability to get/set registers, read/write data using DMA engine, and debug hardware operation. %package -n libpcilib${PCILIB_ABI_VERSION} Summary: User-space PCI library Group: Development/Libraries Provides: pcilib = %{version} Requires: pcilib-python >= %{version} Requires: pcilib-dkms >= %{version} %description -n libpcilib${PCILIB_ABI_VERSION} pcilib is a user-space library providing structured access to the PCI hardware. API exposes 4 API layers. - PCI memory access - allows to map PCI bar memory into the address space of user application and manipulate it directly. - Register access - allows to read and write device registers. The register model is defined using XML. Besides the direct hardware access, the register values can be filtered using Python scripts. This allows to convert hardware reading to standard units, make consistency checking, and create meta registers setting multiple registers from a single parameter. - DMA engine - allows high-speed reading and writting using DMA. The DMA engines are implemented in user-space as plugins. - Event engine - allows polling for hardware events and grabbing the data associated with the event in multiple supported formats. The event engines are implemented as plugins and are not part of this package. %package -n libpcilib-devel Summary: Development files for pcilib Group: Development/Libraries Requires: libpcilib${PCILIB_ABI_VERSION} = %{version} Requires: uthash-devel %description -n libpcilib-devel Development files for user-space PCI library %package -n pcilib-test Summary: Testing files for pcilib Group: Development/Libraries Requires: libpcilib${PCILIB_ABI_VERSION} = %{version} %description -n pcilib-test Sample XML register model and a few applications for testing pcilib %package -n pcilib-python Summary: Python wrapper for pcilib Group: Development/Libraries Requires: libpcilib${PCILIB_ABI_VERSION} = %{version} %description -n pcilib-python Python wrapper for pcilib. The python wrapper is used - By register scripts which are used to convert hardware reading to standard units, make consistency checking, and create meta registers setting multiple registers from a single parameter. - pcilib web api which used to provide register and dma access from remote applications. %package -n pcilib-dkms Summary: Kernel module providing low-level PCI access Group: Development/Libraries Requires: dkms bash gcc make %description -n pcilib-dkms Minimalistic driver used by pcilib to - Handle interrupts - Map PCI regions into the user space - Allocate persistent page-locked memory for DMA operations and map it into the user-space - Ensure access syncrhonization between multiple applications %package -n pcilib-server Summary: Pcilib Web API Group: Development/Libraries Requires: pcilib-python = %{version} Requires: pcilib-test = %{version} Requires: python %if %{defined suse_version} Prereq: %fillup_prereq %endif %description -n pcilib-server Pcilib Web API and small demo web server. %prep %setup -q -n pcitool-%{version} %build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DPCILIB_DYNAMIC_HEADERS_INC="" \ -DPCILIB_PLUGIN_DIR=%{_libdir}/pcilib${PCILIB_ABI_VERSION}/ -DPCILIB_DATA_DIR=%{_datadir}/pcilib${PCILIB_ABI_VERSION}/ \ -DPCILIB_PYTHON_SITEDIR=%{python2_sitearch} \ -DCMAKE_INSTALL_LIBDIR=%{_libdir} -DCMAKE_INSTALL_BINDIR=%{_bindir} -DCMAKE_INSTALL_DATADIR=%{_datadir} -DCMAKE_INSTALL_DATAROOTDIR=%{_datadir} -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} . make make docs %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{_libdir}/pcilib${PCILIB_ABI_VERSION}/ # scripts install -m 755 tests/reload.sh $RPM_BUILD_ROOT/%{_bindir}/pci-reload # udev mkdir -p $RPM_BUILD_ROOT/%{_udevrulesdir} install -m 644 misc/50-pcidriver.rules $RPM_BUILD_ROOT/%{_udevrulesdir} # DKMS mkdir -p $RPM_BUILD_ROOT/%{_includedir}/linux/ install -m 644 driver/ioctl.h $RPM_BUILD_ROOT/%{_includedir}/linux/pcidriver.h mkdir -p $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/pcilib/ install -m 644 misc/dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/ install -m 755 misc/dkms-postbuild.sh $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/ install -m 644 pcilib/*.h $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/pcilib/ cp -r driver $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/ # Sample model cp -r xml/test $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/ cp -r xml/devices $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/ # Default configuration install -m 644 misc/ipedevices.xml $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/ # Servers mkdir -p $RPM_BUILD_ROOT/%{_unitdir} install -m 644 misc/pcilib_api.service $RPM_BUILD_ROOT/%{_unitdir} install -m 644 misc/pcilib_html.service $RPM_BUILD_ROOT/%{_unitdir} %if %{defined suse_version} mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates/ install -m 644 misc/pcilib.sysconfig $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.pcilib %else mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig install -m 644 misc/pcilib.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/pcilib %endif cp -r pyserver $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/ %clean rm -rf $RPM_BUILD_ROOT %post -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig %postun -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig %post -n pcilib-dkms if [ -z "`dkms status -m %{modname} -v %{version}`" ]; then echo "Add module source to dkms" dkms add -m %{modname} -v %{version} --rpm_safe_upgrade echo "Build module with dkms" dkms build -m %{modname} -v %{version} dkms install -m %{modname} -v %{version} fi exit 0 %preun -n pcilib-dkms /usr/sbin/dkms remove -m %{modname} -v %{version} --all --rpm_safe_upgrade exit 0 %post -n pcilib-server %if %{defined suse_version} %fillup_and_insserv -i %endif %files %defattr(-, root, root) %{_bindir}/pci %{_bindir}/pci-reload %files -n libpcilib${PCILIB_ABI_VERSION} %defattr(-, root, root) %doc docs/README %doc docs/HARDWARE %dir %{_libdir}/pcilib${PCILIB_ABI_VERSION}/ %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/ %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/ %dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/ %{_datadir}/pcilib${PCILIB_ABI_VERSION}/*.xsd %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/*.xsd %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/ipedevices.xml %{_libdir}/libpcilib.so.* %files -n libpcilib-devel %defattr(-, root, root) %doc docs/html %{_includedir}/linux/pcidriver.h %{_includedir}/pcilib.h %{_includedir}/pcilib/ %{_libdir}/lib*.so %{_libdir}/pkgconfig/*.pc %files -n pcilib-test %defattr(-, root, root) %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/test %{_datadir}/pcilib${PCILIB_ABI_VERSION}/devices/testdevice.xml %files -n pcilib-dkms %defattr(-, root, root) %{_udevrulesdir} %{_prefix}/src/%{modname}-%{version}/ %files -n pcilib-python %defattr(-, root, root) %{python2_sitearch}/* %files -n pcilib-server %defattr(-, root, root) %if %{defined suse_version} /var/adm/fillup-templates/sysconfig.* %else %config %{_sysconfdir}/sysconfig/* %endif %{_unitdir}/* %{_datadir}/pcilib${PCILIB_ABI_VERSION}/pyserver %changelog * Fri Mar 4 2016 Suren A. Chilingaryan - ${CPACK_PACKAGE_VERSION} - Added spec file to the sources