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