File scsi_ep_front.spec of Package scsi_ep_front

# needssslcertforbuild
Name: scsi_ep_front
Summary: Huawei SCSI driver for virtual cinder block storage on OTC BMS (SD100)
Version: 1.0.2
Release: 0
#Source:  %{name}.zip
Source:  %{name}.tar.bz2
Source1: preamble
Source2: open_source_software_Copyright_notice.html.gz
#Source3: README.md
Patch1: fix-411.diff
Patch2: Makefile-kbuild.diff
Patch3: Mod-Supp-Ext.diff
Patch4: fix-412.diff
Vendor: Huawei Technologies Co., Ltd.
URL: https://github.com/Huawei-SDI/SD100_Card_Driver
License: GPL-2.0
ExclusiveOS: linux
Group: System Environment/Kernel
BuildRequires: unzip binutils
#Provides: %{name}
#URL: http://developer.huawei.com
ExclusiveArch: x86_64 %ix86

BuildRoot: %{_tmppath}/%{name}-%{version}-root
# do not generate debugging packages by default - newer versions of rpmbuild
# may instead need:
#%define debug_package %{nil}
%debug_package %{nil}

Requires: kernel, fileutils, findutils, gawk, bash
BuildRequires: %kernel_module_package_buildreqs
%if 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700
#BuildRequires: kabi-whitelists
%endif
#ExclusiveArch: %{ix86} x86_64

%if 0%{?suse_version} > 0
#Recommends: scsi_ep_front-kmp-default
%kernel_module_package -p %_sourcedir/preamble -x ec2 -x vmi -x xen
%else
#Recommends: kmod-scsi_ep_front = %{version}
Requires: kmod-scsi_ep_front = %{version}
%kernel_module_package -p %_sourcedir/preamble default
%endif


%description
This SCSI device driver exposes the SCSI (metadata.hw:passthrough=true) cinder
volumes on Bare Metal (Ironic) servers in Open Telekom Cloud.  The device
driver supports specific Huawei SDI add-in cards (SD100EP - 19e5:1610).


%prep
#%setup -n %{name}
%setup -n SD100_Card_Driver
cp -p %{S:2} .
#mv open\ source\ software\ Copyright\ notice.docx open_source_software_Copyright_notice.docx
chmod 0644 open_source_software_Copyright_notice.*
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
#chmod -x README ixgbevf.7
set -- %{name}/*
mkdir source
mv "$@" source/
mkdir obj

%build
#make -C src clean
#make -C src
echo Build kernel modules for kernel flavors %flavors_to_build ...
for flavor in %flavors_to_build; do
    rm -rf obj/$flavor
    cp -r source obj/$flavor
    MOD=$PWD/obj/$flavor
    export CFLAGS_MODULE
    make -C %{kernel_source $flavor} modules %{?_smp_mflags} M=$MOD KSRC=%{kernel_source $flavor} #CFLAGS_MODULE="$CFLAGS_MODULE"
done


%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
# Following line works for SUSE 11+ and RHEL 6.1+ only, must set INSTALL_MOD_DIR manually for other targets
%if 0%{?suse_version} > 0
export INSTALL_MOD_DIR=%{kernel_module_package_moddir %{name}}
%else
%if 0%{?centos_version} > 600 || 0%{?rhel_version} > 600
export INSTALL_MOD_DIR=%{kernel_module_package_moddir %{name}}/%{name}
%else
export INSTALL_MOD_DIR=extra/%{name}
%endif
%endif
export INSTALL_MOD_STRIP=1
for flavor in %flavors_to_build; do
    make -C %{kernel_source $flavor} modules_install M=$PWD/obj/$flavor
done
%if 0%{?suse_version} == 0
rm -f $RPM_BUILD_ROOT/lib/modules/*/modules.*
%endif
#%if 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700
#mkdir -p $RPM_BUILD_ROOT/etc/depmod.d/
#cp -p %{S:2} $RPM_BUILD_ROOT/etc/depmod.d/
#%endif

%clean
rm -rf %{buildroot}

%files 
%defattr(-,root,root)
%doc README.md LICENSE open_source_software_Copyright_notice.html.gz
#%if 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700
#%config /etc/depmod.d/kmod-ixgbevf.conf
#%endif

%post
uname -r | grep BOOT || /sbin/depmod -a > /dev/null 2>&1 || true


%postun
uname -r | grep BOOT || /sbin/depmod -a > /dev/null 2>&1 || true