Make it possible to build SCST as an RPM (merge r5137 from trunk)

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@5193 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2014-01-10 08:45:32 +00:00
parent 16def0fe3d
commit 7ab3d52047
4 changed files with 193 additions and 5 deletions

View File

@@ -52,6 +52,12 @@ FCST_DIR=fcst
ISCSI_DIR=iscsi-scst
#ISCSI_DESTDIR=../../../iscsi_scst_inst
VERSION = $(shell echo -n "$$(sed -n 's/^\#define[[:blank:]]SCST_VERSION_NAME[[:blank:]]*\"\([^-]*\).*\"/\1/p' scst/include/scst_const.h)."; \
if svn info >/dev/null 2>&1; \
then svn info | sed -n 's/^Revision:[[:blank:]]*/r/p';\
else git show | sed -n 's/^commit[[:blank:]]*\(.......\).*/\1/p'; \
fi)
help:
@echo " all : make all"
@echo " clean : clean files"
@@ -365,6 +371,40 @@ fcst_clean:
fcst_extraclean:
cd $(FCST_DIR) && $(MAKE) extraclean
scst-dist-gzip:
name=scst && \
mkdir $${name}-$(VERSION) && \
{ scripts/list-source-files | \
grep -E '^doc/|^fcst/|^iscsi-scst/|^Makefile|^qla2x00t/|^scst.spec|^scst/|^scst_local/|^srpt/'|\
tar -T- -cf- | \
tar -C $${name}-$(VERSION) -xf-; } && \
rm -f $${name}-$(VERSION).tar.bz2 && \
tar -cjf $${name}-$(VERSION).tar.bz2 $${name}-$(VERSION) && \
rm -rf $${name}-$(VERSION)
scst-rpm:
name=scst && \
rpmtopdir="$$(if [ $$(id -u) = 0 ]; then echo /usr/src/packages;\
else echo $$PWD/rpmbuilddir; fi)" && \
$(MAKE) scst-dist-gzip && \
rm -rf $${rpmtopdir} && \
for d in BUILD RPMS SOURCES SPECS SRPMS; do \
mkdir -p $${rpmtopdir}/$$d; \
done && \
cp $${name}-$(VERSION).tar.bz2 $${rpmtopdir}/SOURCES && \
sed "s/@rpm_version@/$(VERSION)/g" \
<$${name}.spec.in >$${name}.spec; \
MAKE="$(MAKE)" \
rpmbuild --define="%_topdir $${rpmtopdir}" -ba $${name}.spec && \
rm -f $${name}-$(VERSION).tar.bz2
rpm:
$(MAKE) scst-rpm
$(MAKE) -C scstadmin rpm
@echo
@echo "The following RPMs have been built:"
@find -name '*.rpm'
debug2perf: extraclean
cd $(SCST_DIR) && $(MAKE) $@
@if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi

View File

@@ -5,19 +5,23 @@
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (not a .c file).
ifndef PREFIX
PREFIX=/usr/local
endif
SHELL=/bin/bash
SUBDIRS := $(shell pwd)
SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \
then echo "$$PWD/../scst/include"; \
else echo "/usr/local/include/scst"; fi)
else echo "$(PREFIX)/include/scst"; fi)
SCST_DIR := $(shell if [ -e "$$PWD/../scst" ]; then echo "$$PWD/../scst/src"; \
else echo "/usr/local/include/scst"; fi)
SBINDIR := /usr/local/sbin
else echo "$(PREFIX)/include/scst"; fi)
SBINDIR := $(PREFIX)/sbin
INITDIR := /etc/init.d
RCDIR := /etc/rc.d
MANDIR := /usr/local/man
MANDIR ?= $(PREFIX)/man
KMOD := $(shell pwd)/kernel
INCDIR := $(shell pwd)/include

136
scst.spec.in Normal file
View File

@@ -0,0 +1,136 @@
%define kmod_name scst
%define kver %{expand:%%(echo ${KVER:-$(uname -r)})}
%define kernel_rpm %{expand:%%( \
krpm="$(rpm -qf /boot/vmlinuz-%{kver} 2>/dev/null | \
grep -v 'is not owned by any package' | head -n 1)"; \
if [ -n "$krpm" ]; then \
echo "/boot/vmlinuz-%{kver}"; \
else \
echo "%{nil}"; \
fi \
)}
%define rpm_version @rpm_version@
%define make %{expand:%%(echo ${MAKE:-make})}
Name: %{kmod_name}-%{kver}
Version: %{rpm_version}
Release: 1
Summary: SCST mid-layer kernel driver
Group: System/Kernel
License: GPLv2
Vendor: http://scst.sourceforge.net/
URL: http://scst.sourceforge.net/
Source: %{kmod_name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: no
%description
A generic SCSI target subsystem for Linux that allows to convert any Linux
server into a sophisticated storage server. The three layers in SCST are the
target driver layer; the SCSI target core and the device handler layer. SCST
target drivers realize communication with an initiator and implement a storage
protocol like iSCSI, FC or SRP. SCST device handlers implement a SCSI
interface on top of local storage. Examples of such local storage are SCSI
RAID controller (dev_disk handler), block device (vdisk_blockio handler), file
(vdisk_fileio handler) or custom block device behavior implemented in user
space (scst_user).
Authors:
--------
Vladislav Bolkhovitin, Bart Van Assche and others
%package devel
Summary: SCST mid-layer kernel driver development package
Group: Development/Kernel
AutoReqProv: no
%description devel
A generic SCSI target subsystem for Linux (SCST) that allows to convert
any Linux server into a sophisticated storage server. SCST target drivers
implement protocols like iSCSI, FC or SRP. SCST device handlers either
provide access to a local SCSI RAID controller (dev_disk), block device
(vdisk_blockio), file (vdisk_fileio) or custom block device behavior
implemented in user space (scst_user).
Authors:
--------
Vladislav Bolkhovitin, Bart Van Assche and others
%prep
%setup -q -n %{kmod_name}-%{version}
%build
export KVER=%{kver} PREFIX=%{_prefix}
export BUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y
for d in scst fcst iscsi-scst qla2x00t/qla2x00-target scst_local srpt; do
%{make} -C $d
done
%install
export KVER=%{kver} PREFIX=%{_prefix} MANDIR=%{_mandir}
export BUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y
for d in scst iscsi-scst srpt; do
DESTDIR=%{buildroot} %{make} -C $d install
done
for d in fcst qla2x00t/qla2x00-target scst_local; do
INSTALL_MOD_PATH=%{buildroot} %{make} -C $d install
done
rm -f %{buildroot}/lib/modules/%{kver}/[Mm]odule*
%clean
rm -rf %{buildroot}
%pre
# Remove files installed by "make install"
rm -f /usr/local/man/man5/iscsi-scstd.conf.5
rm -f /usr/local/man/man8/iscsi-scst-adm.8
rm -f /usr/local/man/man8/iscsi-scstd.8
rm -f /usr/local/sbin/iscsi-scst-adm
rm -f /usr/local/sbin/iscsi-scstd
rm -rf /usr/local/include/scst
%post
/sbin/depmod -a %{kver}
%files
%defattr(-,root,root)
%dir /lib/modules/%{kver}/extra
/lib/modules/%{kver}/extra/fcst.ko
/lib/modules/%{kver}/extra/ib_srpt.ko
/lib/modules/%{kver}/extra/iscsi-scst.ko
/lib/modules/%{kver}/extra/qla2x00tgt.ko
/lib/modules/%{kver}/extra/qla2xxx_scst.ko
/lib/modules/%{kver}/extra/scst.ko
/lib/modules/%{kver}/extra/scst_local.ko
%dir /lib/modules/%{kver}/extra/dev_handlers
/lib/modules/%{kver}/extra/dev_handlers/scst_cdrom.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_changer.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_disk.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_modisk.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_processor.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_raid.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_tape.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_user.ko
/lib/modules/%{kver}/extra/dev_handlers/scst_vdisk.ko
%{_mandir}/man5/iscsi-scstd.conf.5.gz
%{_mandir}/man8/iscsi-scst-adm.8.gz
%{_mandir}/man8/iscsi-scstd.8.gz
%{_sbindir}/iscsi-scst-adm
%{_sbindir}/iscsi-scstd
%dir /var/lib/scst
%files devel
%defattr(-,root,root)
%dir /usr/include/scst
/usr/include/scst/Module.symvers
/usr/include/scst/scst.h
/usr/include/scst/scst_const.h
/usr/include/scst/scst_debug.h
/usr/include/scst/scst_sgv.h
/usr/include/scst/scst_user.h
%changelog
* Fri Nov 22 2013 Bart Van Assche <bvanassche@acm.org>
- Initial spec file.

View File

@@ -28,6 +28,10 @@
# - install and uninstall must be made as root
#
ifndef PREFIX
PREFIX=/usr/local
endif
SHELL=/bin/bash
DEV_HANDLERS_DIR = dev_handlers
@@ -71,6 +75,10 @@ MODS_VERS := $(shell ls Modules.symvers 2>/dev/null)
MOD_VERS := $(shell ls Module.symvers 2>/dev/null)
install: all
@if [ -z "$(DESTDIR)" ] && \
{ rpm -q scst || rpm -q scst-devel; } >/dev/null 2>&1; then \
echo Error: the scst and/or scst-devel RPMs must be uninstalled first; \
false; fi
-rm -f $(INSTALL_DIR)/scsi_tgt.ko
install -d $(INSTALL_DIR)
install -d $(INSTALL_DIR)/dev_handlers
@@ -118,7 +126,7 @@ INSTALL_DIR := $(DESTDIR)/lib/modules/$(shell uname -r)/extra
else
INSTALL_DIR := $(DESTDIR)/lib/modules/$(KVER)/extra
endif
INSTALL_DIR_H := $(DESTDIR)/usr/local/include/scst
INSTALL_DIR_H := $(DESTDIR)$(PREFIX)/include/scst
enable-Wextra = $(shell uname_r="$$(uname -r)"; if [ "$${uname_r%.el5}" = "$${uname_r}" ]; then echo "$(1)"; fi)