Add support for Lintian to package builds

- Install lintian into the pbuilder filesystem
- Run lintian with our custom Mendel profile on each package, and fail
if it detects issues.

Change-Id: Idf43f9f184c16dac4b804da0215100de906d5d59
diff --git a/lintian/profiles/mendel/main.profile b/lintian/profiles/mendel/main.profile
new file mode 100644
index 0000000..1d933c3
--- /dev/null
+++ b/lintian/profiles/mendel/main.profile
@@ -0,0 +1,13 @@
+# Default profile for Mendel Linux.
+Profile: mendel/main
+Extends: debian/main
+Disable-Tags: empty-debian-diff,
+ executable-not-elf-or-script,
+ binary-without-manpage,
+ script-with-language-extension,
+ missing-license-paragraph-in-dep5-copyright,
+ source-is-missing, arch-independent-package-contains-binary-or-object,
+ arch-dependent-file-in-usr-share, unstripped-binary-or-object,
+ statically-linked-binary, missing-depends-line,
+ source-nmu-has-incorrect-version-number, changelog-should-mention-nmu,
+ newer-standards-version
diff --git a/lintian/vendors/mendel/main/data/changes-file/known-dists b/lintian/vendors/mendel/main/data/changes-file/known-dists
new file mode 100644
index 0000000..4a5ab8b
--- /dev/null
+++ b/lintian/vendors/mendel/main/data/changes-file/known-dists
@@ -0,0 +1,5 @@
+# List of Mendel distributions
+
+mendel-animal
+mendel-beaker
+mendel-chef
diff --git a/packages.mk b/packages.mk
index f13b768..71afe4e 100644
--- a/packages.mk
+++ b/packages.mk
@@ -31,7 +31,7 @@
 		--mirror http://ftp.debian.org/debian \
 		--distribution stretch \
 		--architecture amd64 \
-		--extrapackages "crossbuild-essential-armhf crossbuild-essential-arm64 debhelper gnupg"
+		--extrapackages "crossbuild-essential-armhf crossbuild-essential-arm64 debhelper gnupg lintian"
 	mkdir -p $(ROOTDIR)/cache/base-tmp
 	cd $(ROOTDIR)/cache/base-tmp; \
 	sudo tar xf $@; \
@@ -96,7 +96,7 @@
 	$(LOG) $1 pbuilder pdebuild
 	cd $(PRODUCT_OUT)/obj/$1; pdebuild \
 		--buildresult $(PRODUCT_OUT)/packages/$(if $6,$6,core) -- \
-		--debbuildopts "--build=$(if $5,$5,full) -sa" \
+		--debbuildopts "--build=$(if $5,$5,full) -sa --check-command=lintian --check-option=--fail-on-warnings --check-option=--profile=mendel" \
 		--basetgz $(ROOTDIR)/cache/base.tgz \
 		--configfile $(ROOTDIR)/build/pbuilderrc \
 		--hookdir $(ROOTDIR)/build/pbuilder-hooks \
diff --git a/pbuilder-hooks/D05deps b/pbuilder-hooks/D05deps
index be35df0..3c53c60 100755
--- a/pbuilder-hooks/D05deps
+++ b/pbuilder-hooks/D05deps
@@ -3,5 +3,6 @@
 echo "deb [trusted=yes] file://$DEPSBASE ./" >> /etc/apt/sources.list
 echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" >> /etc/apt/sources.list
 echo 'Debug::pkgProblemResolver true;' > /etc/apt/apt.conf
+cp -r /rootdir/build/lintian /usr/share/
 cat /rootdir/build/bazel-release.pub.gpg | apt-key add -
 apt-get update