Blame SOURCES/0013-Add-coverity-makefile-bits.patch

453bef
From d27930abbc6af501d8375b1a28001691b91fc952 Mon Sep 17 00:00:00 2001
453bef
From: Peter Jones <pjones@redhat.com>
453bef
Date: Tue, 9 May 2017 11:35:17 -0400
453bef
Subject: [PATCH 13/13] Add coverity makefile bits
453bef
453bef
This lets us do semi-automated coverity uploads directly from the repo
453bef
checkout.
453bef
453bef
Signed-off-by: Peter Jones <pjones@redhat.com>
453bef
---
453bef
 .gitignore |  1 +
453bef
 Make.rules |  6 ++++++
453bef
 Makefile   | 38 +++++++++++++++++++++++++++++++++++++-
453bef
 3 files changed, 44 insertions(+), 1 deletion(-)
453bef
 create mode 100644 Make.rules
453bef
453bef
diff --git a/.gitignore b/.gitignore
453bef
index 25be91f..91c3ae6 100644
453bef
--- a/.gitignore
453bef
+++ b/.gitignore
453bef
@@ -10,3 +10,4 @@
453bef
 *.tar.*
453bef
 .*.sw?
453bef
 linux/include/fwup-version.h
453bef
+cov-int
453bef
diff --git a/Make.rules b/Make.rules
453bef
new file mode 100644
453bef
index 0000000..b7cd9e8
453bef
--- /dev/null
453bef
+++ b/Make.rules
453bef
@@ -0,0 +1,6 @@
453bef
+
453bef
+include $(TOPDIR)/Make.version
453bef
+
453bef
+define get-config
453bef
+$(shell git config --local --get "fwupdate.$(1)")
453bef
+endef
453bef
diff --git a/Makefile b/Makefile
453bef
index 6d6511b..14c3ad6 100644
453bef
--- a/Makefile
453bef
+++ b/Makefile
453bef
@@ -2,10 +2,11 @@ default : all
453bef
 
453bef
 TOPDIR=$(shell pwd)
453bef
 include $(TOPDIR)/Make.version
453bef
+include $(TOPDIR)/Make.rules
453bef
 include $(TOPDIR)/Make.defaults
453bef
 SUBDIRS ?= efi linux docs include
453bef
 
453bef
-all clean install : | check_efidir_error
453bef
+all install : | check_efidir_error
453bef
 	@set -e ; for x in $(SUBDIRS) ; do \
453bef
 		$(MAKE) DESTDIR=$(DESTDIR) TOPDIR=$(TOPDIR) VERSION=$(VERSION) \
453bef
 			LIBDIR=$(LIBDIR) bindir=$(bindir) mandir=$(mandir) \
453bef
@@ -15,6 +16,39 @@ all clean install : | check_efidir_error
453bef
 fwupdate.spec : fwupdate.spec.in Makefile
453bef
 	@sed -e "s,@@VERSION@@,$(VERSION),g" $< > $@
453bef
 
453bef
+COV_EMAIL=$(call get-config,coverity.email)
453bef
+COV_TOKEN=$(call get-config,coverity.token)
453bef
+COV_URL=$(call get-config,coverity.url)
453bef
+COV_FILE=fwupdate-coverity-$(VERSION)-$(COMMIT_ID).tar.bz2
453bef
+COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master)
453bef
+
453bef
+clean :
453bef
+	@set -e ; for x in $(SUBDIRS) ; do \
453bef
+		$(MAKE) DESTDIR=$(DESTDIR) TOPDIR=$(TOPDIR) VERSION=$(VERSION) \
453bef
+			LIBDIR=$(LIBDIR) bindir=$(bindir) mandir=$(mandir) \
453bef
+			-C $$x $@ ; \
453bef
+	done
453bef
+	@rm -vrf cov-int fwupdate-coverity-*.tar.*
453bef
+
453bef
+cov-int : clean
453bef
+	cov-build --dir cov-int make all
453bef
+
453bef
+$(COV_FILE) : cov-int
453bef
+	tar caf $@ cov-int
453bef
+
453bef
+cov-upload :
453bef
+	@if [[ -n "$(COV_URL)" ]] &&					\
453bef
+	    [[ -n "$(COV_TOKEN)" ]] &&					\
453bef
+	    [[ -n "$(COV_EMAIL)" ]] ;					\
453bef
+	then								\
453bef
+		echo curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \
453bef
+		curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \
453bef
+	else								\
453bef
+		echo Coverity output is in $(COV_FILE) ;		\
453bef
+	fi
453bef
+
453bef
+coverity : $(COV_FILE) cov-upload
453bef
+
453bef
 GITTAG = $(VERSION)
453bef
 
453bef
 test-archive: fwupdate.spec
453bef
@@ -40,3 +74,5 @@ archive: tag fwupdate.spec
453bef
 	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/fwupdate-$(VERSION).tar.bz2 fwupdate-$(VERSION)
453bef
 	@rm -rf /tmp/fwupdate-$(VERSION)
453bef
 	@echo "The archive is in fwupdate-$(VERSION).tar.bz2"
453bef
+
453bef
+.PHONY: $(SUBDIRS) coverity cov-upload
453bef
-- 
453bef
2.12.2
453bef