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