18971c
From d76ccd07bc7d2d30ab2df38e9ae444766662c639 Mon Sep 17 00:00:00 2001
18971c
From: Ondrej Dubaj <odubaj@redhat.com>
18971c
Date: Tue, 5 Feb 2019 15:18:08 +0100
18971c
Subject: [PATCH] added make rpm/srpm options
18971c
18971c
---
18971c
 Makefile | 14 ++++++++++++--
18971c
 1 file changed, 12 insertions(+), 2 deletions(-)
18971c
18971c
diff --git a/Makefile b/Makefile
18971c
index 2977d187..43390405 100644
18971c
--- a/Makefile
18971c
+++ b/Makefile
18971c
@@ -1,6 +1,6 @@
18971c
 -include dracut-version.sh
18971c
 
18971c
-VERSION = $(shell [ -d .git ] && git describe --abbrev=0 --tags 2>/dev/null || echo $(DRACUT_VERSION))
18971c
+VERSION = $(shell [ -d .git ] && git describe --abbrev=0 2>/dev/null || echo $(DRACUT_VERSION))
18971c
 GITVERSION = $(shell [ -d .git ] && { v=$$(git describe --tags 2>/dev/null); [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } )
18971c
 
18971c
 -include Makefile.inc
18971c
@@ -39,7 +39,7 @@ man8pages = dracut.8 \
18971c
 
18971c
 manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
18971c
 
18971c
-.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
18971c
+.PHONY: install clean archive rpm srpm testimage test all check AUTHORS doc dracut-version.sh
18971c
 
18971c
 all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio
18971c
 
18971c
@@ -202,6 +202,16 @@ rpm: dracut-$(VERSION).tar.bz2 syncheck
18971c
 		--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
18971c
 	( mv "$$rpmbuild"/$$(arch)/*.rpm $(DESTDIR).; mv "$$rpmbuild"/*.src.rpm $(DESTDIR).;rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
18971c
 
18971c
+srpm: dracut-$(VERSION).tar.bz2 syncheck
18971c
+	rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
18971c
+	cp dracut-$(VERSION).tar.bz2 "$$rpmbuild"; \
18971c
+	LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
18971c
+	(cd "$$rpmbuild"; \
18971c
+	rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
18971c
+	        --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
18971c
+		--define "_rpmdir $$PWD" -bs dracut.spec; ) && \
18971c
+	( mv "$$rpmbuild"/*.src.rpm $(DESTDIR).; rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
18971c
+
18971c
 syncheck:
18971c
 	@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \
18971c
                 [ "$${i##*/}" = "module-setup.sh" ] && continue; \