[apparmor] [PATCH v2.1 4/5] Makefile: Add coverity target

Tyler Hicks tyhicks at canonical.com
Fri Jan 8 15:51:44 UTC 2016


Add a target that uses cov-build, which must be found in $PATH, to
generate an intermediate Coverity directory called cov-int. The
intermediate Coverity directory will be based on a clean snapshot of the
last commit in the bzr tree. Finally, the intermediate directory is
converted to a compressed tarball, stored in
apparmor-<SNAPSHOT_VERSION>-cov-int.tar.gz, and is suitable for
uploading to scan.coverity.com.

Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
---

* Changes since v2:
  - The scan service wants to uncompress and untar our upload and then find
    everything in the cov-int/ directory. This revision moves away from using
    the snapshot name as a prefix in the cov-int/ directory name.
  - Ignore the utils, profiles, and tests directories in the coverity target.
    The first two contain no compiled code so Coverity is of no use. The tests
    directory was causing the build from being rejected on scans.coverity.com
    due to no new object files being detected. It was easier to disable
    building the tests directory for now so that we can get our first build
    analyzed.
    + I think what the cov-build tool ideally wants is to wrap a make target
      that builds the entire project rather than what this patch set is
      currently doing where it is iteratively invoked on each dir (libapparmor,
      binutils, parser, etc.) of the project. What we have now will work but we
      may want to make a top level build target and wrap that with the coverity
      target in the future.

 Makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index b3f5130..9478a10 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ REPO_URL?=https://code.launchpad.net/~apparmor-dev/apparmor/master
 #REPO_URL=.
 #REPO_URL="bzr+ssh://bazaar.launchpad.net/~sbeattie/+junk/apparmor-dev/"
 
+COVERITY_DIR=cov-int
 RELEASE_DIR=apparmor-${VERSION}
 __SETUP_DIR?=.
 
@@ -44,13 +45,20 @@ tarball: clean
 	tar ${TAR_EXCLUSIONS} -cvzf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR}
 
 .PHONY: snapshot
-snapshot: REPO_VERSION:=$(shell $(value REPO_VERSION_CMD))
-snapshot: SNAPSHOT_NAME=apparmor-$(VERSION)~$(REPO_VERSION)
+snapshot coverity: REPO_VERSION:=$(shell $(value REPO_VERSION_CMD))
+snapshot coverity: SNAPSHOT_NAME=apparmor-$(VERSION)~$(REPO_VERSION)
 snapshot: clean
 	make export_dir __EXPORT_DIR=${SNAPSHOT_NAME} __REPO_VERSION=${REPO_VERSION} ; \
 	make setup __SETUP_DIR=${SNAPSHOT_NAME} ; \
 	tar ${TAR_EXCLUSIONS} -cvzf ${SNAPSHOT_NAME}.tar.gz ${SNAPSHOT_NAME} ;
 
+.PHONY: coverity
+coverity: IGNORED_DIRS=utils profiles tests
+coverity: DIRS:=$(filter-out $(IGNORED_DIRS), $(DIRS))
+coverity: snapshot
+	cd $(SNAPSHOT_NAME)/libraries/libapparmor && ./configure --with-python
+	$(foreach dir, $(DIRS), cov-build --dir $(COVERITY_DIR) -- make -C $(SNAPSHOT_NAME)/$(dir);)
+	tar -cvzf $(SNAPSHOT_NAME)-$(COVERITY_DIR).tar.gz $(COVERITY_DIR)
 
 .PHONY: export_dir
 export_dir:
@@ -60,7 +68,7 @@ export_dir:
 
 .PHONY: clean
 clean:
-	-rm -rf ${RELEASE_DIR} ./apparmor-${VERSION}~*
+	-rm -rf ${RELEASE_DIR} ./apparmor-${VERSION}~* ${COVERITY_DIR}
 	for dir in $(DIRS); do \
 		make -C $$dir clean; \
 	done
-- 
2.5.0




More information about the AppArmor mailing list