From 34d764426a162f42ef4511d7c5efb42c7c76ab4f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 3 Dec 2013 12:04:35 +0000 Subject: [PATCH] scst: Make it possible to build an RPM Make it possible to build an SCST RPM via the command "make rpm". The contents of the two RPMs built by this command is as follows: $ rpm -qlp rpmbuilddir/RPMS/x86_64/scst-3.11.8+-3.0.0.*-1.x86_64.rpm /lib/modules/3.11.8+/extra /lib/modules/3.11.8+/extra/dev_handlers /lib/modules/3.11.8+/extra/dev_handlers/scst_cdrom.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_changer.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_disk.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_modisk.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_processor.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_raid.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_tape.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_user.ko /lib/modules/3.11.8+/extra/dev_handlers/scst_vdisk.ko /lib/modules/3.11.8+/extra/fcst.ko /lib/modules/3.11.8+/extra/ib_srpt.ko /lib/modules/3.11.8+/extra/iscsi-scst.ko /lib/modules/3.11.8+/extra/qla2x00tgt.ko /lib/modules/3.11.8+/extra/qla2xxx_scst.ko /lib/modules/3.11.8+/extra/scst.ko /lib/modules/3.11.8+/extra/scst_local.ko /usr/sbin/iscsi-scst-adm /usr/sbin/iscsi-scstd /usr/share/man/man5/iscsi-scstd.conf.5.gz /usr/share/man/man8/iscsi-scst-adm.8.gz /usr/share/man/man8/iscsi-scstd.8.gz /var/lib/scst $ rpm -qlp rpmbuilddir/RPMS/x86_64/scst-3.11.8+-devel-3.0.0.*-1.x86_64.rpm /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 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5137 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- Makefile | 40 +++++++++++++ iscsi-scst/Makefile | 2 +- scst.spec.in | 136 ++++++++++++++++++++++++++++++++++++++++++++ scst/src/Makefile | 4 ++ 4 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 scst.spec.in diff --git a/Makefile b/Makefile index 05732e99d..d31a00c23 100644 --- a/Makefile +++ b/Makefile @@ -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" @@ -367,6 +373,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' + 2perf: extraclean cd $(SCST_DIR) && $(MAKE) $@ @if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index 4290334e2..25cc62e0b 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -21,7 +21,7 @@ SCST_DIR := $(shell if [ -e "$$PWD/../scst" ]; then echo "$$PWD/../scst/src"; \ SBINDIR := $(PREFIX)/sbin INITDIR := /etc/init.d RCDIR := /etc/rc.d -MANDIR := $(PREFIX)/man +MANDIR ?= $(PREFIX)/man KMOD := $(shell pwd)/kernel INCDIR := $(shell pwd)/include diff --git a/scst.spec.in b/scst.spec.in new file mode 100644 index 000000000..8c73adac1 --- /dev/null +++ b/scst.spec.in @@ -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 +- Initial spec file. diff --git a/scst/src/Makefile b/scst/src/Makefile index ddfa3ee6f..6fb934eca 100644 --- a/scst/src/Makefile +++ b/scst/src/Makefile @@ -75,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