# build conditions
# have to be called with "--with docs", "--with python3" to activate them
%bcond_with docs
%bcond_with python3
%global _hardened_build 1
%global kversion %((rpm -q --qf '%%{EVR}.%%{ARCH}\\n' kernel-devel | tail -1))
%global ksrcdir %{_usrsrc}/kernels/%{kversion}
Name: linux-gpib
Version: 4.3.7
Release: 1%{?dist}
Summary: Linux GPIB (IEEE-488) userspace library and programs
License: GPLv2+
URL: http://linux-gpib.sourceforge.net/
Source0: %{name}-%{version}.tar.gz
Source1: 60-%{name}-adapter.rules
Source2: %{name}-config@.service.in
Source3: dkms-%{name}.conf.in
Source4: %{name}-config-systemd
# We don't need to mknod since we can let the driver and systemd take care of it
Patch0: %{name}-nodevnodes.patch
# We package our own udev rules and firmware loader
Patch1: %{name}-remove-usb-autotools.patch
# EPEL needs the compatible kernel headers altered
Patch2: %{name}-compat-timer.patch
# The GPIB driver is scheduled to be in the mainline in 6.18
# prior to this version the dkms kernel module is required
Requires: dkms-%{name}
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: autoconf >= 2.50
BuildRequires: automake
BuildRequires: libtool
BuildRequires: sed
BuildRequires: gcc
BuildRequires: flex
BuildRequires: bison
BuildRequires: libxslt
BuildRequires: python3-setuptools
BuildRequires: perl
BuildRequires: docbook5-style-xsl
BuildRequires: docbook5-schemas
BuildRequires: docbook-dtds
BuildRequires: opensp
%{?systemd_requires}
BuildRequires: systemd
BuildRequires: kernel-devel
# As of release 4.2, the driver has changed the configuation system and no
# longer needs the default packages to work
Provides: %{name}-defaults-agilent-82357a = %{version}-%{release}
Obsoletes: %{name}-defaults-agilent-82357a < %{version}-%{release}
Provides: %{name}-defaults-ni-gpib-usb = %{version}-%{release}
Obsoletes: %{name}-defaults-ni-gpib-usb < %{version}-%{release}
%description
The Linux GPIB package provides support for GPIB (IEEE-488) hardware.
This packages contains the userspace libraries and programs.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
Development files for %{name}.
%package -n dkms-%{name}
Summary: Linux GPIB (IEEE-488) driver
# since the package just distributes the source for
# compilation by dkms, this package can be noarch
BuildArch: noarch
# TODO: do we need to limit the archs this will run on?
#ExclusiveArch: ????
Requires: dkms
Requires: kernel-headers
Requires: kernel-devel
Requires: gcc
Requires: make
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: kernel-devel
BuildRequires: kmod
BuildRequires: elfutils-libelf-devel
%description -n dkms-%{name}
The Linux GPIB package provides support for GPIB (IEEE-488) hardware.
This packages contains the kernel drivers for adapters compatible with:
- Agilent/Keysight 82350B
- Agilent/Keysight 82357A/B
- CB7210
- Capital Equipment Corporation GPIB cards
- FMH GPIB HDL core
- HP 82335
- HP 82341
- INES PCI cards
- LPVO USB GPIB
- NEC7210
- NI GPIB-USB-B/HS/HS+
- TMS9914
- TNT4882
%if %{with python3}
%package -n python%{python3_pkgversion}-%{name}
Summary: Python 3 %{name} module
%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}}
Requires: %{name}%{?_isa} = %{version}-%{release}
BuildRequires: python%{python3_pkgversion}-devel
%description -n python%{python3_pkgversion}-%{name}
Python 3 bindings for %{name}.
%endif
%prep
%setup -q -n %{name}-%{version}
tar xzvf %{name}-kernel-%{version}.tar.gz
mv %{name}-kernel-%{version} %{name}-kernel
tar xzvf %{name}-user-%{version}.tar.gz
mv %{name}-user-%{version} %{name}-user
%patch0 -p1
%patch1 -p1
%{?el9:%patch2 -p1}
pushd %{name}-kernel
sed -e 's/__VERSION_STRING/%{version}/g' %{SOURCE3} > dkms.conf
popd
%build
pushd %{name}-user
touch ChangeLog
autoreconf -vif
# we make the docs, and the Perl and Python bindings in the spec,
# not the library's Makefile
%configure \
--disable-guile18-binding \
--disable-php-binding \
--disable-tcl-binding \
--disable-documentation \
--disable-python-binding \
--disable-perl-binding \
--disable-static \
--sbindir=%{_sbindir} YACC=bison
%make_build
pushd language
pushd python
%{?with_python3:%py3_build}
popd
popd # language
popd # %%{name}-user
%install
# build directory tree
install -d %{buildroot}%{_docdir}/%{name}
install -d %{buildroot}%{_mandir}/{man1,man3,man5,man8,mann}
# dkms package
pushd %{name}-kernel
install -d %{buildroot}%{_usrsrc}/%{name}-%{version}-%{release}
cp -Rfp . %{buildroot}%{_usrsrc}/%{name}-%{version}-%{release}
install -p -m 0644 dkms.conf %{buildroot}%{_usrsrc}/%{name}-%{version}-%{release}
popd
# userspace
pushd %{name}-user
%make_install
pushd language
pushd python
%{?with_python3:%py3_install}
popd
popd # language
pushd doc
echo '%{version}' > %{name}-version.xml
echo %{version} > gpib_version.txt;
osx -x no-expand-internal -x no-internal-decl -x preserve-case %{name}.sgml > %{name}.xml
xsltproc --param man.authors.section.enabled 0 \
--param man.output.in.separate.dir 1 \
--xinclude \
%{_datadir}/sgml/docbook/xsl-ns-stylesheets/manpages/docbook.xsl \
%{name}.xml
for mandir in man1 man3 man5 man8 ; do
install -p -m 0644 man/$mandir/* %{buildroot}%{_mandir}/$mandir
done
popd # doc
# udev rules
install -d %{buildroot}%{_udevrulesdir}
install -p -m 0644 %{SOURCE1} %{buildroot}%{_udevrulesdir}
# systemd config unit
install -d %{buildroot}%{_unitdir}
sed -e 's|@libexecdir@|%{_libexecdir}|g' %{SOURCE2} > %{name}-config@.service
install -p -m 0644 %{name}-config@.service %{buildroot}%{_unitdir}
# systemd config script
install -d %{buildroot}%{_libexecdir}
install -p -m 0755 %{SOURCE4} %{buildroot}%{_libexecdir}
popd # %%{name}-user
# Cleanup
# remove libtool stuff
find %{buildroot} -name '*.la' -delete
# remove .gitignore
find %{buildroot} -name '.gitignore' -delete
find %{buildroot} -name '.gitignore~' -delete
find %{buildroot} -name '.ibterm_hist_07' -delete
# ... and automake caches `make dist` didn't get rid of
find %{buildroot} -name '.cache.mk' -delete
%check
# Sanity check to make sure the kernel modules compile
%define kkversion %((rpm -q --qf '%%{EVR}.%%{ARCH}\\n' kernel-devel | tail -1))
%define kksrcdir %{_usrsrc}/kernels/%{kversion}
pushd %{name}-kernel
%make_build LINUX_SRCDIR=%{kksrcdir}
popd
# Post-install stuff
# systemd stuff
%post
%systemd_post %{name}-config@.service
%{?ldconfig}
%preun
%systemd_preun %{name}-config@.service
%postun
%systemd_postun %{name}-config@.service
%{?ldconfig}
# and ldconfig
%ldconfig_scriptlets devel
# dkms
# Adapted from https://github.com/openzfs/zfs/blob/master/rpm/generic/zfs-dkms.spec.in
%pre -n dkms-%{name}
echo "Running pre installation script: $0. Parameters: $*"
# We don't want any other versions lingering around in dkms.
# Tests with 'dnf' showed that in case of reinstall, or upgrade
# the preun scriptlet removed the version we are trying to install.
# Because of this, find all zfs dkms sources in /var/lib/dkms and
# remove them, if we find a matching version in dkms.
dkms_root=/var/lib/dkms
if [ -d ${dkms_root}/%{name} ]; then
cd ${dkms_root}/%{name}
for x in [[:digit:]]*; do
[ -d "$x" ] || continue
otherver="$x"
opath="${dkms_root}/%{name}/${otherver}"
if [ "$otherver" != %{version}-%{release} ]; then
# This is a workaround for a broken 'dkms status', we caused in a previous version.
# One day it might be not needed anymore, but it does not hurt to keep it.
if dkms status -m %{name} -v "$otherver" 2>&1 | grep "${opath}/source/dkms.conf does not exist"
then
echo "ERROR: dkms status is broken!" >&2
if [ -L "${opath}/source" -a ! -d "${opath}/source" ]
then
echo "Trying to fix it by removing the symlink: ${opath}/source" >&2
echo "You should manually remove ${opath}" >&2
rm -f "${opath}/source" || echo "Removal failed!" >&2
fi
fi
if [ `dkms status -m %{name} -v "$otherver" | grep -c %{name}` -gt 0 ]; then
echo "Removing old %{name} dkms modules version $otherver from all kernels."
dkms remove -m %{name} -v "$otherver" --all ||:
fi
fi
done
cd ${dkms_root}
fi
# Uninstall this version of dkms-linux-gpib dkms modules before installation of the package.
if [ `dkms status -m %{name} -v %{version} | grep -c %{name}` -gt 0 ]; then
echo "Removing %{name} dkms modules version %{version}-%{release} from all kernels."
dkms remove -m %{name} -v %{version}-%{release} --all ||:
fi
%post -n dkms-%{name}
dkms add -m %{name} -v %{version}-%{release} -q --rpm_safe_upgrade || :
# Rebuild and make available for the currently running kernel
dkms build -m %{name} -v %{version}-%{release} -q || :
dkms install -m %{name} -v %{version}-%{release} -q --force || :
%{?ldconfig}
udevadm control --reload > /dev/null 2>&1 || :
%preun -n dkms-%{name}
dkms_root="/var/lib/dkms/%{name}/%{version}-%{release}"
echo "Running pre uninstall script: $0. Parameters: $*"
# In case of upgrade we do nothing. See above comment in pre hook.
if [ "$1" = "1" -o "$1" = "upgrade" ] ; then
echo "This is an upgrade. Skipping pre uninstall action."
exit 0
fi
# Check if we uninstall the package. In that case remove the dkms modules.
# '0' is the value for the first parameter for rpm packages.
# 'remove' or 'purge' are the possible names for deb packages.
if [ "$1" = "0" -o "$1" = "remove" -o "$1" = "purge" ] ; then
if [ `dkms status -m %{name} -v %{version}-%{release} | grep -c %{name}` -gt 0 ]; then
echo "Removing %{name} dkms modules version %{version}-%{release} from all kernels."
dkms remove -m %{name} -v %{version}-%{release} --all --rpm_safe_upgrade && exit 0
fi
# If removing the modules failed, it might be because of the broken 'dkms status'.
if dkms status -m %{name} -v %{version} 2>&1 | grep "${dkms_root}/source/dkms.conf does not exist"
then
echo "ERROR: dkms status is broken!" >&2
echo "You should manually remove ${dkms_root}" >&2
echo "WARNING: installed modules in /lib/modules/`uname -r`/extra could not be removed automatically!" >&2
fi
%{?ldconfig}
udevadm control --reload > /dev/null 2>&1 || :
else
echo "Script parameter $1 did not match any removal condition."
fi
%files
%defattr(644,root,root,755)
%license %{name}-user/COPYING
%doc %{name}-user/README
%attr(755,root,root) %{_bindir}/ibterm
%attr(755,root,root) %{_bindir}/findlisteners
%attr(755,root,root) %{_bindir}/ibtest
%attr(755,root,root) %{_sbindir}/gpib_config
%attr(755,root,root) %{_libexecdir}/linux-gpib-config-systemd
%{_mandir}/man1/*
%{_mandir}/man3/*
%{_mandir}/man5/*
%{_mandir}/man8/*
%{_libdir}/libgpib.so.*
%config(noreplace) %{_sysconfdir}/gpib.conf
%{_unitdir}/*.service
%{_udevrulesdir}/*.rules
%files -n dkms-%{name}
%doc %{name}-kernel/README %{name}-kernel/AUTHORS %{name}-kernel/INSTALL
%license %{name}-kernel/COPYING
%dir %{_usrsrc}/%{name}-%{version}-%{release}
%{_usrsrc}/%{name}-%{version}-%{release}/*
%exclude %{_usrsrc}/%{name}-%{version}-%{release}/NEWS
%files devel
%defattr(644,root,root,755)
%doc %{name}-user/README
%license %{name}-user/COPYING
%dir %{_includedir}/gpib
%{_includedir}/gpib/gpib_user.h
%{_includedir}/gpib/ib.h
%{_includedir}/gpib/gpib.h
%{_includedir}/gpib/gpib_version.h
%{_libdir}/pkgconfig/libgpib.pc
%{_libdir}/libgpib.so
%{_mandir}/man3/*.3*
%if %{with python3}
%files -n python%{python3_pkgversion}-%{name}
%defattr(644,root,root,755)
%doc %{name}-user/language/python/README
%license %{name}-user/COPYING
%{python3_sitearch}/*
%endif
%if %{with docs}
%files doc
%defattr(644,root,root,755)
%license %{name}-user/doc/fdl.xml
%{_docdir}/%{name}
%endif
%changelog
* Sat Dec 20 2025 GA
- New upstream version 4.3.7
- Package for el9
* Fri Jun 28 2024 GA
- remove guil, perl, tcl
* Sun Jun 09 2024 Michael Katzmann - git.9813ff8f
- 9813ff8f Add ready responses for NI GPIB-USB-HS bona fide genuine board
* Sat Jun 08 2024 Michael Katzmann - git.4c5ef2e6
- 4c5ef2e6 Optionally suppress stderr output from ibdev()
* Sat Apr 27 2024 Michael Katzmann - svnr2103
- r2103 sleep/resume for NI-USB-HS & Agilent 82357a
* Fri Apr 12 2024 Michael Katzmann - svnr2096
- r2096 sleep/resume for NI-USB-HS
* Fri Apr 05 2024 Michael Katzmann - svnr2093
- r2093 sleep/resume for NI-USB-HS
* Fri Apr 05 2024 Michael Katzmann - svnr2091
- r2090 sleep/resume for Agilent 82357a
* Sat Mar 30 2024 Michael Katzmann - svnr2090
- r2090 patch 6 incorporated upstream
* Wed Mar 27 2024 Michael Katzmann - svnr2088
- r2088 Fix for Fedora 40
* Sat Mar 02 2024 Michael Katzmann - svnr2085
- r2085 Fix ibonl(ud,1) for ud a board descriptor
* Tue Feb 20 2024 Michael Katzmann - svnr2079
- r2084
* Tue Jan 16 2024 Michael Katzmann - svnr2079
- Preliminary fix for CMPL being set incorrectly bug #87
* Sat Jan 13 2024 Michael Katzmann - svnr2079
- fix for timeout on async reads/writes (ticket #87)
* Fri Dec 15 2023 Michael Katzmann - 4.3.6-11.20231215svnr2075
- Upstream fix for SRQ problem with NEC7210 (ticket #86)
* Mon Dec 11 2023 Michael Katzmann - 4.3.6-10.20231211svnr2073
- Upstream fix for SRQ problem with Agilent 82357B (ticket #86)
* Sat Dec 9 2023 Michael Katzmann - 4.3.6-9.20231130svnr2070
- Fix removal of old modules which sometimes cause installation failures
* Sun Feb 24 2019 Colin Samples - 4.2.0-2.20190107svn1809
- Fix Agilent adapter configuation
* Sun Feb 24 2019 Colin Samples - 4.2.0-1.20190107svn1809
- Bump linux-gbib version, and update udev rules and systemd unit file to
account for changes in upstream. Add support for RHEL8 beta.
* Fri Feb 1 2019 Colin Samples - 4.1.0-2.20180529svn1753
- Increment release number to fix F29 copr
* Sat Jun 16 2018 Colin Samples - 4.1.0-1.20180529svn1753
- Initial release