e83cdd
From d8386b5d8fae2e45a27635c48ecab63abba10e39 Mon Sep 17 00:00:00 2001
e83cdd
From: Harald Hoyer <harald@redhat.com>
e83cdd
Date: Wed, 24 Oct 2018 15:14:03 +0200
e83cdd
Subject: [PATCH] Makefile: add srpm target
e83cdd
e83cdd
---
e83cdd
 Makefile | 13 ++++++++++++-
e83cdd
 1 file changed, 12 insertions(+), 1 deletion(-)
e83cdd
e83cdd
diff --git a/Makefile b/Makefile
e83cdd
index 80623437..503d069f 100644
e83cdd
--- a/Makefile
e83cdd
+++ b/Makefile
e83cdd
@@ -40,7 +40,7 @@ man8pages = dracut.8 \
e83cdd
 
e83cdd
 manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
e83cdd
 
e83cdd
-.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
e83cdd
+.PHONY: install clean archive rpm srpm testimage test all check AUTHORS doc dracut-version.sh
e83cdd
 
e83cdd
 all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio
e83cdd
 
e83cdd
@@ -216,6 +216,17 @@ rpm: dracut-$(VERSION).tar.xz syncheck
e83cdd
 		--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
e83cdd
 	( mv "$$rpmbuild"/{,$$(arch)/}*.rpm $(DESTDIR).; rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
e83cdd
 
e83cdd
+srpm: dracut-$(VERSION).tar.xz syncheck
e83cdd
+	rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
e83cdd
+	cp dracut-$(VERSION).tar.xz "$$rpmbuild"; \
e83cdd
+	LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
e83cdd
+	(cd "$$rpmbuild"; \
e83cdd
+	[ -f $$src/lgpl-2.1.txt ] && cp $$src/lgpl-2.1.txt . || wget https://www.gnu.org/licenses/lgpl-2.1.txt; \
e83cdd
+	rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
e83cdd
+	        --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
e83cdd
+		--define "_rpmdir $$PWD" -bs dracut.spec; ) && \
e83cdd
+	( mv "$$rpmbuild"/*.src.rpm $(DESTDIR).; rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
e83cdd
+
e83cdd
 syncheck:
e83cdd
 	@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \
e83cdd
                 [ "$${i##*/}" = "module-setup.sh" ] && continue; \
e83cdd