From d9fa5df30f56b7cfdad50f874ba46a966bfc16df Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Mon, 19 Oct 2015 11:40:14 -0600 Subject: [PATCH] Provide rpm build target Makes creating an RPM package easy. Signed-off-by: Keith Busch --- Makefile | 22 ++++++++++++++++++++-- NVME-VERSION-GEN | 2 +- nvme.spec.in | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 nvme.spec.in diff --git a/Makefile b/Makefile index bbb65ab3..b89ad7fd 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,11 @@ DESTDIR = PREFIX := /usr/local SBINDIR = $(PREFIX)/sbin LIBUDEV:=$(shell ld -ludev > /dev/null 2>&1 ; echo $$?) + +RPMBUILD = rpmbuild +TAR = tar +RM = rm -f + ifeq ($(LIBUDEV),0) LDFLAGS += -ludev CFLAGS += -DLIBUDEV_EXISTS @@ -44,7 +49,7 @@ doc: $(NVME) all: doc clean: - rm -f $(NVME) *.o *~ a.out NVME-VERSION-FILE + rm -f $(NVME) *.o *~ a.out NVME-VERSION-FILE *.tar* nvme.spec version $(MAKE) -C Documentation clean clobber: clean @@ -59,4 +64,17 @@ install-bin: default install: install-bin install-man -.PHONY: default all doc clean clobber install install-bin install-man FORCE +nvme.spec: nvme.spec.in NVME-VERSION-FILE + sed -e 's/@@VERSION@@/$(NVME_VERSION)/g' < $< > $@+ + mv $@+ $@ + +dist: nvme.spec + git archive --format=tar --prefix=nvme-$(NVME_VERSION)/ HEAD > nvme-$(NVME_VERSION).tar + @echo $(NVME_VERSION) > version + $(TAR) rf nvme-$(NVME_VERSION).tar nvme.spec version + gzip -f -9 nvme-$(NVME_VERSION).tar + +rpm: dist + $(RPMBUILD) -ta nvme-$(NVME_VERSION).tar.gz + +.PHONY: default all doc clean clobber install install-bin install-man rpm FORCE diff --git a/NVME-VERSION-GEN b/NVME-VERSION-GEN index dd97433c..adaa1f47 100755 --- a/NVME-VERSION-GEN +++ b/NVME-VERSION-GEN @@ -21,7 +21,7 @@ elif test -d .git -o -f .git && VN="$VN-dirty" ;; esac then - VN=$VN + VN=$(echo "$VN" | sed -e 's/-/./g'); else VN="$DEF_VER" fi diff --git a/nvme.spec.in b/nvme.spec.in new file mode 100644 index 00000000..3a4f488f --- /dev/null +++ b/nvme.spec.in @@ -0,0 +1,37 @@ +Name: nvme +Version: @@VERSION@@ +Release: 1%{?dist} +Summary: Core nvme tools +License: GPL +Group: Development/Tools +URL: https://github.com/linux-nvme/nvme-cli/ +Source: nvme-@@VERSION@@.tar.gz +Provides: nvme +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +NVMe is a fast, scalable, direct attached storage interface. The nvme +cli rpm installs core management tools with minimal dependencies. + +%prep +%setup + +%build +make + +%install +rm -rf $RPM_BUILD_ROOT +make install PREFIX=%{buildroot}/usr + +%files +%defattr(-,root,root) +%doc Documentation/nvme*.1 +%{_sbindir}/nvme +%{_mandir}/man1/nvme*.1* + +%clean +rm -rf $RPM_BUILD_ROOT + +%changelog +* Thu Oct 15 2015 Keith Busch +- Initial RPM spec -- 2.50.1