File displaylink.spec of Package displaylink
#
# spec file for package displaylink
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%bcond_without check
%global debug_package %{nil}
%if 0%{?rhel}
%global kernel_pkg_name kernel-mt
%else
%global kernel_pkg_name kernel
%endif
%define _dllibdirorig /usr/libexec/displaylink
%define _dllibdir %{_libdir}/dl
%define _file_version 5.6.1
%define _release_date 2022-08
%define _release_version 5.6.1-59.184
%define _release_dir displaylink-driver-%{_release_version}
%define _release_bin displaylink-driver-%{_release_version}.run
%if 0%{?suse_version} >= 1550
%bcond_with bundled_evdi
%else
%bcond_without bundled_evdi
%endif
%if %{with bundled_evdi}
%define _evdi_libver 1.12.0
%define _evdi_version 1.12.0
%define _evdi_dir evdi-%{_evdi_version}
%else
%define _evdi_libver 1.12.0
%define _evdi_version 1.12.0
# commit hash or git tag
%define _evdi_commit v1.12.0
%define _evdi_dir evdi-1.12.0
%endif
Name: displaylink
Version: 5.6.1
Release: 0
Summary: DisplayLink VGA/HDMI driver for DL-6xxx, DL-5xxx, DL-41xx and DL-3xxx adapters
License: GPL-2.0 and LGPL-2.1 and Proprietary
Group: Hardware/Other
URL: https://www.displaylink.com/
Source0: https://www.synaptics.com/sites/default/files/exe_files/%{_release_date}/DisplayLink%%20USB%%20Graphics%%20Software%%20for%%20Ubuntu%{_file_version}-EXE.zip#/DisplayLink_%{_release_version}.zip
Source1: %{name}.service
Source2: 99-%{name}.rules
Source3: 20-%{name}.conf
Source4: displaylink-sleep-extractor.sh
%if ! %{with bundled_evdi}
# Support for kernels 5.18
Source10: https://github.com/DisplayLink/evdi/archive/%{_evdi_commit}.tar.gz#/evdi-%{_evdi_version}.tar.gz
%endif
# https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu-5.6?filetype=exe | fold -w 80 -s | sed -E 's/[ ]+$//'
Source99: DISPLAYLINK-EULA
# PATCH-FIX-OPENSUSE adapt the sources for openSUSE 15.3 kernel backports
Patch0: leap153.patch
ExclusiveArch: %ix86 x86_64 %arm aarch64
BuildRequires: chrpath
BuildRequires: dkms
BuildRequires: fdupes
BuildRequires: libdrm-devel
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
BuildRequires: %{kernel_pkg_name}-default > 4.7
BuildRequires: %{kernel_pkg_name}-devel > 4.7
BuildRequires: -post-build-checks
BuildRequires: udev
BuildRequires: unzip
Requires: %{kernel_pkg_name} > 4.7
Requires: %{kernel_pkg_name}-devel > 4.7
Requires: dkms
Requires(preun):dkms
Requires(posttrans):dkms
%description
This adds support for HDMI/VGA adapters built upon the DisplayLink
DL-6xxx, DL-5xxx, DL-41xx and DL-3xxx series of chipsets. This
includes numerous docking stations, USB monitors, and USB adapters.
%prep
%setup -q -c %{name}-%{version}
# This creates a %%{_release_dir} subdirectory
sh ./%{_release_bin} --noexec --keep
%if %{with bundled_evdi}
mkdir -p %{_evdi_dir}
pushd %{_evdi_dir}
tar xvf ../%{_release_dir}/evdi.tar.gz
%if 0%{?sle_version} == 150300 && 0%{?is_opensuse}
%patch0 -p1
%endif
popd
%else
tar xf %{SOURCE10}
%endif
pushd %{_release_dir}
sed -i 's/\r//' LICENSE
chmod -x LICENSE
cp LICENSE 3rd_party_licences.txt ..
popd
cp %{SOURCE99} .
%build
cd %{_evdi_dir}/library/
make %{?_smp_mflags}
%install
mkdir -p %{buildroot}%{_dllibdir} \
%{buildroot}/usr/src/evdi-%{_evdi_version}/ \
%{buildroot}/usr/lib/systemd/system/ \
%{buildroot}/usr/lib/systemd/system-sleep \
%{buildroot}/usr/lib/udev/rules.d/ \
%{buildroot}/etc/X11/xorg.conf.d/ \
%{buildroot}/var/log/displaylink/ \
%{buildroot}/%{_sbindir}
ln -s service %{buildroot}%{_sbindir}/rc%{name}
# Kernel driver sources
pushd %{_evdi_dir}
cp -a module/* %{buildroot}/usr/src/evdi-%{_evdi_version}
# Library
cp library/libevdi.so.%{_evdi_libver} %{buildroot}%{_dllibdir}/
ln -sf libevdi.so.%{_evdi_libver} %{buildroot}%{_dllibdir}/libevdi.so.0
ln -sf libevdi.so.0 %{buildroot}%{_dllibdir}/libevdi.so
# Binaries
# Don't copy libusb-1.0.so.0.1.0 it's already shipped by libusbx
# Don't copy libevdi.so, we compiled it from source
popd
pushd %{_release_dir}
%ifarch x86_64
cp -a x64-ubuntu-1604/DisplayLinkManager %{buildroot}%{_dllibdir}
%endif
%ifarch %ix86
cp -a x86-ubuntu-1604/DisplayLinkManager %{buildroot}%{_dllibdir}
%endif
%ifarch %arm aarch64
cp -a arm-linux-gnueabihf/DisplayLinkManager %{buildroot}%{_dllibdir}
%endif
chrpath -r %{_dllibdir} %{buildroot}%{_dllibdir}/DisplayLinkManager
# Firmwares
cp -a ella-dock-release.spkg firefly-monitor-release.spkg %{buildroot}%{_dllibdir}
# systemd/udev
sed -i "s_%{_dllibdirorig}_%{_dllibdir}_" %{SOURCE1}
cp -a %{SOURCE1} %{buildroot}/usr/lib/systemd/system/
cp -a %{SOURCE2} %{buildroot}/usr/lib/udev/rules.d/
cp -a %{SOURCE3} %{buildroot}/etc/X11/xorg.conf.d/
# pm-util
bash %{SOURCE4} displaylink-installer.sh \
| sed '1{s/env bash/bash/}' \
> %{buildroot}%{_prefix}/lib/systemd/system-sleep/%{name}.sh
chmod +x %{buildroot}%{_prefix}/lib/systemd/system-sleep/%{name}.sh
%fdupes -s %{buildroot}%{_dllibdir}
popd
%check
CHECKDIR=%{_tmppath}/evdi-dkms-check
mkdir -p $CHECKDIR
DKMS_ARGS="--dkmstree $CHECKDIR \
--sourcetree %{buildroot}/usr/src
--installtree $CHECKDIR \
-k `rpm -q -v kernel-default |sed 's/.*[a-z]-\([0-9.lp-]\+\)\.[0-9].*/\1-default/'`"
%if %{with check}
/usr/sbin/dkms $DKMS_ARGS build -m evdi -v %{_evdi_version} || (cat $CHECKDIR/evdi/%{_evdi_version}/build/make.log && exit 10)
%else
/usr/sbin/dkms $DKMS_ARGS build -m evdi -v %{_evdi_version} || cat $CHECKDIR/evdi/%{_evdi_version}/build/make.log
%endif
%pre
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
/usr/bin/systemctl -q is-enabled dkms.service || echo "warning: dkms service not enabled."
%preun
%service_del_preun %{name}.service
/usr/sbin/dkms remove -m evdi -v %{_evdi_version} -q --all || :
%postun
# restart later in posttrans
%service_del_postun_without_restart %{name}.service
%posttrans
# as suggested by https://github.com/dell/dkms/issues/25#issuecomment-360275619
/usr/sbin/dkms add -m evdi -v %{_evdi_version} || :
/usr/sbin/dkms build -m evdi -v %{_evdi_version} -q || :
/usr/sbin/dkms install -m evdi -v %{_evdi_version} -q --force || :
/usr/bin/systemctl restart %{name}.service
%files
%license LICENSE 3rd_party_licences.txt DISPLAYLINK-EULA
%doc %{_evdi_dir}/docs/*
/usr/lib/systemd/system/%{name}.service
/usr/lib/systemd/system-sleep/%{name}.sh
/usr/lib/udev/rules.d/99-%{name}.rules
%config /etc/X11/xorg.conf.d/20-%{name}.conf
%dir /usr/src/evdi-%{_evdi_version}
/usr/src/evdi-%{_evdi_version}/*
%dir %{_dllibdir}
%{_dllibdir}/*
%dir /var/log/displaylink/
%{_sbindir}/rc%{name}
%changelog