[stgt] [PATCH 3/3] Top-level Makefile: add facility to conveniently create an RPM spec file from a template
Florian Haas
florian.haas at linbit.com
Wed Sep 30 13:36:41 CEST 2009
Add a "spec" target to create an RPM spec file from a template. Also
include this spec file in the "tarball" target, so the tarball can
conveniently be transformed into an RPM by running "rpmbuild -tb".
Signed-off-by: Florian Haas <florian.haas at linbit.com>
---
Makefile | 30 +++++++++++++++++-
tgt.spec.in | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+), 2 deletions(-)
create mode 100644 tgt.spec.in
diff --git a/Makefile b/Makefile
index 1a443ee..aaa718a 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,9 @@
# VERSION variable defined on the command line.
include version-stamp
+# This spec is generated from a template with "make spec", see below
+SPECFILE = tgt.spec
+
# This tarball is generated by "make tarball", see below
TARBALL = tgt-$(VERSION).tar.bz2
@@ -92,7 +95,22 @@ clean-version-stamp:
.PHONY: install
install: install-programs install-doc install-conf install-scripts
-$(TARBALL): clean version-stamp all
+# Our spec file is created from a template where VERSION is set to the
+# version-stamp magic.
+$(SPECFILE): $(SPECFILE).in
+ sed -e 's/@VERSION@/$(VERSION)/' $< > $@
+
+.PHONY: spec
+spec: $(SPECFILE)
+
+.PHONY: clean-spec
+clean-spec:
+ rm -f $(SPECFILE)
+
+# The tarball contains the version stamp and the autogenerated spec
+# file. Thus it supports both the regular make/make install
+# installation, and "rpmbuild -tb".
+$(TARBALL): clean version-stamp all $(SPECFILE)
tar -cjf $@ \
--transform 's,^,tgt-$(VERSION)/,' \
--exclude=*~ \
@@ -106,9 +124,17 @@ tarball: $(TARBALL)
clean-tarball:
rm -f $(TARBALL)
+# This is just a convenience target that will roll a binary RPM out of
+# the tarball. Note that the RPM is not necessary built within your
+# checkout or expanded tarball; instead your settings apply as set in
+# your ~/.rpmmacros configuration.
+.PHONY: rpm
+rpm: $(TARBALL)
+ rpmbuild -tb $(TARBALL)
+
# clean-version-stamp is intentionally not included in
# clean. Otherwise, when clean is invoked in an expanded tarball, you
# would afterwards have to specify VERSION explicitly on your next
# build, or your build would fail.
.PHONY: clean
-clean: clean-programs clean-doc clean-conf clean-scripts clean-tarball
+clean: clean-programs clean-doc clean-conf clean-scripts clean-spec clean-tarball
diff --git a/tgt.spec.in b/tgt.spec.in
new file mode 100644
index 0000000..140275d
--- /dev/null
+++ b/tgt.spec.in
@@ -0,0 +1,97 @@
+Name: tgt
+Version: @VERSION@
+Release: 1
+Summary: The SCSI target daemon and utility programs
+
+Group: System Environment/Daemons
+License: GPLv2
+URL: http://stgt.berlios.de
+Source0: http://stgt.berlios.de/releases/%{name}-%{version}.tar.bz2
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires: openssl-devel pkgconfig libibverbs-devel librdmacm-devel
+Requires: /sbin/chkconfig /sbin/service
+Obsoletes: scsi-target-utils
+Conflicts: scsi-target-utils
+ExcludeArch: s390 s390x
+
+%description
+The SCSI target package contains the daemon and tools to setup a SCSI targets.
+Currently, software iSCSI targets are supported.
+
+%prep
+%setup -q
+
+%build
+if pkg-config openssl ; then
+ CPPFLAGS=$(pkg-config --cflags openssl) ; export CPPFLAGS
+ LDFLAGS=$(pkg-config --libs openssl) ; export LDFLAGS
+fi
+%{__make} %{?_smp_mflags} ISCSI=1 ISCSI_RDMA=1 VERSION=%{version}
+
+%install
+%{__rm} -rf %{buildroot}
+%{__make} install DESTDIR=%{buildroot}
+
+%post
+/sbin/chkconfig --add tgtd
+
+%postun
+if [ "$1" = "1" ] ; then
+ /sbin/service tgtd condrestart > /dev/null 2>&1
+fi
+
+%preun
+if [ "$1" = "0" ] ; then
+ /sbin/chkconfig tgtd stop > /dev/null 2>&1
+ /sbin/chkconfig --del tgtd
+fi
+
+%clean
+%{__rm} -rf %{buildroot}
+
+%files
+%defattr(-, root, root, -)
+%doc doc/TODO doc/README.fcoe doc/README.ibmvstgt doc/README.iscsi doc/README.iser doc/README.lu_configuration doc/README.mmc doc/targets.conf.example doc/tmf.txt
+%{_sbindir}/tgtd
+%{_sbindir}/tgtadm
+%{_sbindir}/tgtimg
+%{_sbindir}/tgt-admin
+%{_sbindir}/tgt-setup-lun
+%{_mandir}/man8/*
+%{_sysconfdir}/init.d/tgtd
+%attr(0600,root,root) %config(noreplace) /etc/sysconfig/tgtd
+%attr(0600,root,root) %config(noreplace) /etc/tgt/targets.conf
+
+%changelog
+* Tue Sep 8 2009 Florian Haas <florian.haas at linbit.com> - 0.9.8-1
+- Add spec file, sysconfig file, and init script originally only found
+ in Red Hat packages.
+
+* Mon Aug 4 2008 Mike Christie <mchristie at redhat.com> - 0.0-5.20080917snap
+- Rebase to latest upstream snapshot to include tgt-admin and static config.
+- When doing a "tgtd stop" kill running targets if run level indicates
+system is shutting down or restarting.
+
+* Sun Feb 10 2008 Terje Rosten <terje.rosten at ntnu.no> - 0.0-4.20071227snap
+- update to 20071227 snapshot
+- add patch to compile with newer glibc
+
+* Sat Feb 9 2008 Terje Rosten <terje.rosten at ntnu.no> - 0.0-3.20070803snap
+- rebuild
+
+* Sun Dec 07 2007 Alex Lancaster <alexlan[AT]fedoraproject.org> - 0.0-2.20070803snap
+- Rebuild for new openssl soname bump
+
+* Wed Sep 26 2007 Terje Rosten <terje.rosten at ntnu.no> - 0.0-1.20070803snap
+- random cleanup
+
+* Wed Sep 26 2007 Terje Rosten <terje.rosten at ntnu.no> - 0.0-0.20070803snap
+- update to 20070803
+- fix license tag
+- use date macro
+- build with correct flags (%%optflags)
+
+* Tue Jul 10 2007 Mike Christie <mchristie at redhat.com> - 0.0-0.20070620snap
+- first build
--
1.6.0.4
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list