Summary: VHBA virtual host bus adapter module
Summary(ja): VHBA（仮想ホストバスアダプタ）モジュール
Name: dkms-vhba
Version: 1.2.1
Release: 1%{?_dist_release}
License: GPLv2+
Group: System Environment/Kernel
URL: http://cdemu.sourceforge.net
Source: http://downloads.sourceforge.net/cdemu/vhba-module-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch
Requires: gcc, make
Requires(post): dkms
Requires(preun): dkms

%description
VHBA kernel module, a virtual SCSI host bus adapter used by CDEmu daemon from
userspace-cdemu suite.

%prep
%setup -n vhba-module-%{version}

%build

%install
%{__rm} -rf %{buildroot}

%define dkms_name vhba
%define dkms_vers %{version}-%{release}
%define quiet -q

# Kernel module sources install for dkms
%{__mkdir_p} %{buildroot}%{_usrsrc}/%{dkms_name}-%{dkms_vers}/
%{__cp} -a * %{buildroot}%{_usrsrc}/%{dkms_name}-%{dkms_vers}/

# Configuration for dkms
%{__cat} > %{buildroot}%{_usrsrc}/%{dkms_name}-%{dkms_vers}/dkms.conf << 'EOF'
PACKAGE_NAME=%{dkms_name}
PACKAGE_VERSION=%{dkms_vers}
MAKE[0]="make"
BUILT_MODULE_NAME[0]=vhba
DEST_MODULE_LOCATION[0]=/kernel/drivers/misc
AUTOINSTALL="YES"
EOF

# Configuration for udev
%{__mkdir_p} %{buildroot}/etc/udev/rules.d
%{__cat} > %{buildroot}/etc/udev/rules.d/60-vhba.rules << 'EOF'
# Make vhba
KERNEL=="vhba_ctl", NAME="%k", MODE="0660", OWNER="root", GROUP="users"
EOF

%clean
%{__rm} -rf %{buildroot}

%post
# Add to DKMS registry
dkms add -m %{dkms_name} -v %{dkms_vers} %{?quiet} || :
# Rebuild and make available for the currenty running kernel
dkms build -m %{dkms_name} -v %{dkms_vers} %{?quiet} || :
dkms install -m %{dkms_name} -v %{dkms_vers} %{?quiet} --force || :

%preun
# Remove all versions from DKMS registry
dkms remove -m %{dkms_name} -v %{dkms_vers} %{?quiet} --all || :

%files
%defattr(-,root,root,-)
#%doc AUTHORS ChangeLog COPYING NEWS README
/etc/udev/rules.d/60-vhba.rules
%{_usrsrc}/%{dkms_name}-%{dkms_vers}/

%changelog
* Sat Sep 26 2009 Toshiharu Kudoh <toshi.kd1@gmail.com> - 1.2.1-1
- initial build for VineSeed

* Sat Jun 28 2008 Rok Mandeljc <rok.mandeljc@email.si> - 1.1.0-1
- Updated to 1.1.0

* Sun Dec 23 2007 Rok Mandeljc <rok.mandeljc@email.si> 1.0.0-2
- Fixed udev rule (it's OWNER, not USER).

* Thu Dec 20 2007 Rok Mandeljc <rok.mandeljc@email.si> 1.0.0-1
- Initial RPM release.
