dkms/dkms.spec
liyunfei 3d552b93e0 Add clang compile support
Backport commit 6ddb09145930b03c88e63f5930e718a33501024d Support CC=clang and LD=ld.lld & add clang llvm lld requires
2023-09-19 20:04:04 +08:00

144 lines
4.3 KiB
RPMSpec

Summary: Dynamic Kernel Module Support Framework
Name: dkms
Version: 2.6.1
Release: 8
License: GPLv2+
BuildArch: noarch
URL: https://github.com/dell/dkms
Source0: https://github.com/dell/dkms/archive/v%{version}.tar.gz#/dkms-%{version}.tar.gz
# because Mandriva calls this package dkms-minimal
Patch0: change-deprecated-egrep-for-grep-E.patch
Patch1: Support-CC-clang-and-LD-ld.lld.patch
Provides: dkms-minimal = %{version}
Requires: coreutils
Requires: cpio
Requires: findutils
Requires: gawk
Requires: gcc
Requires: clang llvm lld
Requires: grep
Requires: gzip
Requires: kernel-devel
Requires: sed
Requires: tar
Requires: which
Requires: bash > 1.99
Requires: kmod
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Requires: kernel-devel
%description
This package contains the framework for the Dynamic Kernel Module Support (DKMS)
method for installing module RPMS as originally developed by Dell.
%prep
%autosetup -p1
%build
%triggerpostun -- %{name} < 1.90.00-1
for dir in `find %{_localstatedir}/%{name} -type d -maxdepth 1 -mindepth 1`; do
mv -f $dir %{_localstatedir}/lib/%{name}
done
[ -e %{_sysconfdir}/dkms_framework.conf ] && ! [ -e %{_sysconfdir}/%{name}/framework.conf ] && mkdir %{_sysconfdir}/%{name} && cp -a %{_sysconfdir}/dkms_framework.conf %{_sysconfdir}/%{name}/framework.conf
arch_used=""
[ `uname -m` == "x86_64" ] && [ `cat /proc/cpuinfo | grep -c "Intel"` -gt 0 ] && arch_used="ia32e" || arch_used=`uname -m`
echo ""
echo "ALERT! ALERT! ALERT!"
echo ""
echo "You are using a version of DKMS which does not support multiple system"
echo "architectures. Your DKMS tree will now be modified to add this support."
echo ""
echo "The upgrade will assume all built modules are for arch: $arch_used"
current_kernel=`uname -r`
dkms_tree="%{_localstatedir}/lib/%{name}"
source_tree="%{_prefix}/src"
tmp_location="/tmp"
dkms_frameworkconf="%{_sysconfdir}/%{name}/framework.conf"
. $dkms_frameworkconf 2>/dev/null
echo ""
echo "Fixing directories."
for directory in `find $dkms_tree -type d -name "module" -mindepth 3 -maxdepth 4`; do
dir_to_fix=`echo $directory | sed 's#/module$##'`
echo "Creating $dir_to_fix/$arch_used..."
mkdir $dir_to_fix/$arch_used
mv -f $dir_to_fix/* $dir_to_fix/$arch_used 2>/dev/null
done
echo ""
echo "Fixing symlinks."
for symlink in `find $dkms_tree -type l -name "kernel*" -mindepth 2 -maxdepth 2`; do
symlink_kernelname=`echo $symlink | sed 's#.*/kernel-##'`
dir_of_symlink=`echo $symlink | sed 's#/kernel-.*$##'`
cd $dir_of_symlink
read_link="$symlink"
while [ -L "$read_link" ]; do
read_link=`ls -l $read_link | sed 's/.*-> //'`
done
if [ `echo $read_link | sed 's#/# #g' | wc -w | awk {'print $1'}` -lt 3 ]; then
echo "Updating $symlink..."
ln -sf $read_link/$arch_used kernel-$symlink_kernelname-$arch_used
rm -f $symlink
fi
cd -
done
echo ""
%install
rm -rf $RPM_BUILD_ROOT
make install-redhat-systemd DESTDIR=$RPM_BUILD_ROOT \
SBIN=$RPM_BUILD_ROOT%{_sbindir} \
VAR=$RPM_BUILD_ROOT%{_localstatedir}/lib/%{name} \
MAN=$RPM_BUILD_ROOT%{_mandir}/man8 \
ETC=$RPM_BUILD_ROOT%{_sysconfdir}/%{name} \
BASHDIR=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d \
LIBDIR=$RPM_BUILD_ROOT%{_prefix}/lib/%{name}
%clean
rm -rf $RPM_BUILD_ROOT
%post
systemctl enable %{name}.service>/dev/null 2>&1
%preun
if [ $1 -eq 0 ]; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
fi
%systemd_preun %{name}.service
%postun
%systemd_postun %{name}.service
%files
%defattr(-,root,root)
%doc sample.spec sample.conf AUTHORS COPYING README.md
%{_unitdir}/%{name}.service
%{_prefix}/lib/%{name}
%{_mandir}/*/*
%{_sbindir}/%{name}
%{_localstatedir}/lib/%{name}
%config(noreplace) %{_sysconfdir}/%{name}
# these dirs are for plugins - owned by other packages
%{_sysconfdir}/kernel/postinst.d/%{name}
%{_sysconfdir}/kernel/prerm.d/%{name}
%{_sysconfdir}/bash_completion.d/%{name}
%changelog
* Tue Sep 19 2023 liyunfei <liyunfei@huawei.com> - 2.6.1-8
- Add clang compile support
* Mon Mar 27 2023 wangkai <wangkai385@h-partners.com> - 2.6.1-7
- Change deprecated egrep for grep -E
* Mon Sep 7 2020 Ge Wang <wangge20@huawei.com> - 2.6.1-6
- Modify the Source0 Url
* Fri Feb 14 2020 Tianfei <tianfei16@huawei.com> - 2.6.1-5
- Package init