File lio-utils.spec of Package lio-utils.216

#
# spec file for package lio-utils
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Summary:        Linux-iSCSI.org Target Userspace utils
License:        GPL-2.0+
Group:          System/Kernel

Name:           lio-utils
Version:        4.1
Release:        0
Url:            http://linux-iscsi.org/index.php/Lio-utils
Source:         lio-utils-4.1.tar.bz2
Source1:        target.service
BuildRequires:  net-snmp-devel
BuildRequires:  python-devel
%{?systemd_requires}
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%endif

# Patches from upstream
Patch101:       0101-Remove-tcm_snap.py-from-package-scripts.patch
Patch102:       0102-Add-additional-rc.target-run_fabric_cfs_ops-exclusio.patch
Patch104:       0104-lio-utils-Fix-tools-build-breakage-with-dpkg-buildpa.patch
Patch105:       0105-lio-utils-Remove-target-stop-start-from-debian-prerm.patch
Patch106:       0106-lio-utils-Convert-direct-unlink-call-to-os.unlink.patch
Patch107:       0107-lio_dump-Add-TPG-auth-attribute-check-for-lio_target.patch
Patch108:       0108-Handle-exception-in-cases-where-the-path-is-not-avai.patch
Patch109:       0109-tighter-checks.patch
Patch110:       0110-Handle-exception-during-non-existent-files.patch
Patch111:       0111-tcm_node-Remove-target_core_stgt-shutdown-warning.patch
Patch112:       0112-lio-utils-Add-init-script-for-SUSE.patch
Patch113:       0113-lio_node-Unload-iscsi_target_mod-correctly.patch
Patch114:       0114-tcm_node-Unload-tcm-modules-recursively.patch
Patch115:       0115-lio-utils-Use-the-proper-conditional-inversion-in-sh.patch
Patch116:       0116-lio-utils-Change-rc.target.suse-shutdown_lio_mod-to-.patch
Patch117:       0117-tcm_node-Fix-typo-in-tcm_create_pscsibyudev.patch
Patch118:       0118-tcm-file-Set-fd_buffered_io-1-based-upon-active-FILE.patch
Patch119:       0119-tcm_node-Fix-typo-in-tcm_create_pscsibyudev-again.patch
Patch120:       0120-lio-node-Add-iser-network-portal-attribute-ib_isert-.patch
Patch121:       0121-lio-dump-Add-iser-network-portal-attribute-support.patch
Patch122:       0122-Create-COPYING.patch
Patch123:       0123-Update-COPYING.patch
Patch124:       0124-Create-README.patch
Patch125:       0125-Update-README.patch
Patch126:       0126-Update-README.patch
# SuSE-specific patches
Patch8:         0008-Add-lio-utils-HOWTO.patch
Patch9:         0009-lio_node-listendpoints-crashes-if-config-dir-is-not-.patch
Patch13:        0013-lio_node-Silence-output.patch
Patch14:        0014-Add-shell-header-when-dumping-configuration.patch
Patch15:        0015-lio_node-Check-for-iscsi_target_mod.patch
Patch16:        0016-tcm_node-Check-for-target_core_mod.patch
Patch17:        0017-rc.target.suse-Clean-up-startup-sequence.patch
Patch18:        0018-lio_node-Make-add-idempotent.patch
Patch19:        0019-rc.target.suse-Separate-tcm_-.sh-and-lio_-.sh-during.patch
Patch20:        0020-tcm_dump-Error-checking-in-startup-script.patch
Patch21:        0021-lio_dump-Error-checking-in-startup-script.patch
Patch22:        0022-rc.target.suse-Save-configuration-during-shutdown.patch
Patch23:        0023-Use-OPTFLAGS-when-compiling.patch
Patch24:        0024-lio_node-do-not-fail-if-target-port-is-already-disab.patch
Patch25:        0025-target.service-Add-systemd-service-file.patch
Patch26:        0026-iscsiMib.c-fixes-for-strict-aliasing.patch
Patch27:        0027-Compile-tools-with-OPTFLAGS.patch
Patch28:        0028-lio_dump-Implement-file-option.patch
Patch29:        0029-tcm_dump-Implement-file-option.patch
Patch30:        0030-target.service-Fixup-service-file.patch
Patch31:        0031-lio_node-create-sys-kernel-config-target-iscsi-on-st.patch
Patch32:        0032-lio-utils-remove-systemd-default-dependies.patch
Patch33:        0033-lio-utils-dont-dump-RO-attributes.patch
Patch34:        lio-utils-allow-clearing-discovery-auth.patch
Patch35:        lio-utils-fix-systemd-service-start.patch
Patch36:        lio-utils-fix-empty-attribute-string-writes

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
lio-utils provide a simple low-level configuration tool set for LIO.

lio-utils use the configFS kernel API that is available with LIO, which
provides a clean interface for controlling the kernel level Target
engine and its fabric module subsystems. lio-utils require LIO 3 or
higher, and provide iSCSI target functionality on a number of Linux
baremetal and virtualized systems.

The lio-utils HOWTO gives a good idea of how lio-utils (tcm_node and
lio_node) CLI operations look like. The LIO User's Reference Manual
contains detailed operating instructions. It also describes how to
setup a number of different subsystem storage object backstores for
LIO LUN endpoints.


Authors:
--------
    Nicholas Bellinger <nab@linux-iscsi.org>

%package -n lio-mibs
Summary:        Linux-iSCSI.org Target Userspace utils
Group:          System/Kernel
Requires:       %{name} = %{version}
Requires:       net-snmp

%description -n lio-mibs
lio-utils provide a simple low-level configuration tool
set for LIO.

lio-utils use the configFS kernel API that is available with LIO, which
provides a clean interface for controlling the kernel level Target
engine and its fabric module subsystems. lio-utils require LIO 3 or
higher, and provide iSCSI target functionality on a number of Linux
baremetal and virtualized systems.

The lio-utils HOWTO gives a good idea of how lio-utils (tcm_node and
lio_node) CLI operations look like. It is based on the lio-core-2.6.git
tree for Linux kernel v2.6.30. The LIO User's Reference Manual contains
detailed operating instructions. It also describes how to setup a
number of different subsystem storage object backstores for LIO LUN
endpoints.


Authors:
--------
    Nicholas Bellinger <nab@linux-iscsi.org>

%prep
%setup
%patch101 -p1
%patch102 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p1
%patch108 -p1
%patch109 -p1
%patch110 -p1
%patch111 -p1
%patch112 -p1
%patch113 -p1
%patch114 -p1
%patch115 -p1
%patch116 -p1
%patch117 -p1
%patch118 -p1
%patch119 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1

%patch8 -p1
%patch9 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1

%build
make %{?_smp_mflags} OPTFLAGS="$RPM_OPT_FLAGS"

%install
%define _vardir /var/target

install -vD %{S:1} ${RPM_BUILD_ROOT}/etc/sysconfig/SuSEfirewall2.d/services/target
mkdir -p $RPM_BUILD_ROOT%{_vardir}
mkdir $RPM_BUILD_ROOT%{_vardir}/pr
mkdir $RPM_BUILD_ROOT%{_vardir}/alua
mkdir $RPM_BUILD_ROOT%{_vardir}/fabric
mkdir $RPM_BUILD_ROOT%{_vardir}/policy

mkdir -p $RPM_BUILD_ROOT/etc/target
echo "#!/bin/bash" > $RPM_BUILD_ROOT/etc/target/tcm_start.sh
for mod in target_core_mod target_core_file target_core_iblock target_core_pscsi ; do
  echo "modprobe $mod" >> $RPM_BUILD_ROOT/etc/target/tcm_start.sh
done
chmod 755 $RPM_BUILD_ROOT/etc/target/tcm_start.sh
echo "#!/bin/bash" > $RPM_BUILD_ROOT/etc/target/lio_start.sh
echo "modprobe iscsi_target_mod" >> $RPM_BUILD_ROOT/etc/target/lio_start.sh
echo "udevadm settle -t 3 -E /sys/kernel/config/target" >> $RPM_BUILD_ROOT/etc/target/lio_start.sh
chmod 755 $RPM_BUILD_ROOT/etc/target/lio_start.sh
(cd tcm-py; python setup.py install --prefix=%{_prefix} --root=%{buildroot})
(cd lio-py; python setup.py install --prefix=%{_prefix} --root=%{buildroot})
mkdir $RPM_BUILD_ROOT/usr/sbin
make DESTDIR=$RPM_BUILD_ROOT -C tools install
make DESTDIR=$RPM_BUILD_ROOT DLMODDIR=%{_prefix}/lib/net-snmp -C mib-modules install
install -m 755 mib-modules/setup_snmpd $RPM_BUILD_ROOT/etc/target/setup_snmpd
for p in tcm_node tcm_dump tcm_fabric tcm_iblock tcm_fileio tcm_pscsi tcm_ramdisk tcm_loop lio_node lio_dump ; do 
    chmod 755 $RPM_BUILD_ROOT/%{python_sitelib}/$p.py
    ln -sf ../../%{python_sitelib}/$p.py $RPM_BUILD_ROOT/usr/sbin/$p
done
%if %{?suse_version} > 1220
install -D -m 0644 scripts/target.service $RPM_BUILD_ROOT%{_unitdir}/target.service
ln -sf service $RPM_BUILD_ROOT/usr/sbin/rctarget
%else
if [ ! -d $RPM_BUILD_ROOT/etc/init.d ] ; then
    mkdir -p $RPM_BUILD_ROOT/etc/init.d
fi
install -m 755 scripts/rc.target.suse $RPM_BUILD_ROOT/etc/init.d/target
ln -sf ../../etc/init.d/target $RPM_BUILD_ROOT/usr/sbin/rctarget
%endif

%preun
%if %{?suse_version} > 1220
%service_del_preun target.service
%else
%stop_on_removal target
%endif

%postun
%if %{?suse_version} > 1220
%service_del_postun target.service
%else
%insserv_cleanup target
%endif

%pre
%if 0%{?suse_version} > 1220
  %service_add_pre target.service
%endif

%post
%if 0%{?suse_version} > 1220
  %service_add_post target.service
%endif

%files
%defattr(-,root,root,-)
%if %{?suse_version} > 1220
%{_unitdir}/target.service
%else
/etc/init.d/target
%endif
%dir /etc/target
%config /etc/target/lio_start.sh
%config /etc/target/tcm_start.sh
%config %attr(0644,root,root) /etc/sysconfig/SuSEfirewall2.d/services/target
%dir %{_vardir}
%dir %{_vardir}/pr
%dir %{_vardir}/alua
%dir %{_vardir}/fabric
%dir %{_vardir}/policy
/usr/sbin/iscsi-name
/usr/sbin/tcm_*
/usr/sbin/lio_node
/usr/sbin/lio_dump
/usr/sbin/rctarget
%{python_sitelib}/*
%doc lio-utils.HOWTO

%files -n lio-mibs
%defattr(-,root,root,-)
/etc/target/setup_snmpd
/usr/share/snmp/mibs/LIO-ISCSI-MIB.txt
/usr/share/snmp/mibs/LIO-SCSI-MIB.txt
/usr/share/snmp/mibs/LIO-IPS-AUTH-MIB.txt
%{_prefix}/lib/net-snmp/iscsiTargetMib.so

%changelog
openSUSE Build Service is sponsored by