From bfebfb0fa0e89f37f3be58f2ab1f1c939de164cf Mon Sep 17 00:00:00 2001
From: Andy Whitcroft <apw@canonical.com>
Date: Thu, 10 May 2018 12:32:20 +0100
Subject: [PATCH 05/21] UBUNTU: [Packaging] ABI -- accumulate abi information
 at the end of the build

BugLink: http://bugs.launchpad.net/bugs/1764792
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 debian/rules.d/2-binary-arch.mk | 22 ++++++++++++++++++++--
 debian/rules.d/4-checks.mk      | 20 +++-----------------
 2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index fe17742ba70d..6f9e713e94e9 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -118,7 +118,7 @@ install-%: splopts += INSTALL_MOD_PATH=$(pkgdir)/
 install-%: splopts += INSTALL_MOD_DIR=kernel/zfs
 install-%: splopts += $(conc_level)
 install-%: zfsopts  = $(splopts)
-install-%: checks-%
+install-%: $(stampdir)/stamp-build-%
 	@echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
 	dh_testdir
 	dh_testroot
@@ -404,6 +404,24 @@ ifeq ($(do_tools_hyperv),true)
 endif
 endif
 
+	# Build the final ABI information.
+	install -d $(abidir)
+	sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/'	\
+		$(builddir)/build-$*/Module.symvers | sort > $(abidir)/$*
+
+	# Build the final ABI modules information.
+	find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
+		sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > $(abidir)/$*.modules
+
+	# Build the final ABI retpoline information.
+	if grep -q CONFIG_RETPOLINE=y $(builddir)/build-$*/.config; then \
+		echo "# retpoline v1.0" >$(abidir)/$*.retpoline; \
+		$(SHELL) $(DROOT)/scripts/retpoline-extract $(builddir)/build-$* $(CURDIR) | \
+			sort >>$(abidir)/$*.retpoline; \
+	else \
+		echo "# RETPOLINE NOT ENABLED" >$(abidir)/$*.retpoline; \
+	fi
+
 headers_tmp := $(CURDIR)/debian/tmp-headers
 headers_dir := $(CURDIR)/debian/linux-libc-dev
 
@@ -482,7 +500,7 @@ binary-%: pkgtools = $(tools_flavour_pkg_name)-$*
 binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
 binary-%: rprovides = $(if $(filter true,$(call custom_override,do_zfs,$*)),spl-modules$(comma) spl-dkms$(comma) zfs-modules$(comma) zfs-dkms$(comma))
 binary-%: target_flavour = $*
-binary-%: install-%
+binary-%: checks-%
 	@echo Debug: $@
 	dh_testdir
 	dh_testroot
diff --git a/debian/rules.d/4-checks.mk b/debian/rules.d/4-checks.mk
index da9a1c8a1016..3ce7e6e6f8e2 100644
--- a/debian/rules.d/4-checks.mk
+++ b/debian/rules.d/4-checks.mk
@@ -1,32 +1,18 @@
 # Check ABI for package against last release (if not same abinum)
-abi-check-%: $(stampdir)/stamp-build-%
+abi-check-%: install-%
 	@echo Debug: $@
-	install -d $(abidir)
-	sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/'	\
-		$(builddir)/build-$*/Module.symvers | sort > $(abidir)/$*
 	@perl -f $(DROOT)/scripts/abi-check "$*" "$(prev_abinum)" "$(abinum)" \
 		"$(prev_abidir)" "$(abidir)" "$(skipabi)"
 
 # Check the module list against the last release (always)
-module-check-%: $(stampdir)/stamp-build-%
+module-check-%: install-%
 	@echo Debug: $@
-	install -d $(abidir)
-	find $(builddir)/build-$*/ -name \*.ko | \
-		sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > $(abidir)/$*.modules
 	@perl -f $(DROOT)/scripts/module-check "$*" \
 		"$(prev_abidir)" "$(abidir)" $(skipmodule)
 
 # Check the reptoline jmp/call functions against the last release.
-retpoline-check-%: $(stampdir)/stamp-build-%
+retpoline-check-%: install-%
 	@echo Debug: $@
-	install -d $(abidir)
-	if grep -q CONFIG_RETPOLINE=y $(builddir)/build-$*/.config; then \
-		echo "# retpoline v1.0" >$(abidir)/$*.retpoline; \
-		$(SHELL) $(DROOT)/scripts/retpoline-extract $(builddir)/build-$* $(CURDIR) | \
-			sort >>$(abidir)/$*.retpoline; \
-	else \
-		echo "# RETPOLINE NOT ENABLED" >$(abidir)/$*.retpoline; \
-	fi
 	$(SHELL) $(DROOT)/scripts/retpoline-check "$*" \
 		"$(prev_abidir)" "$(abidir)" "$(skipretpoline)" "$(builddir)/build-$*"
 
-- 
2.19.1

