debian/rules: Use /bin/sh as POSIX shell regardless of build environment

While working on the “reproducible builds” effort [1], we have noticed
that xz-utils could not be built reproducibly.

When dash is the default shell, the configure script
m4/posix-shell.m4 will select /bin/bash as the “conforming POSIX
shell”. When bash is the default shell, /bin/sh will be selected.

The binary package currently in sid on amd64 uses /bin/bash. As bash
is currently Essential:yes (#103284), this is probably not a problem.
But I wonder if they would not be troubles if the package was built on
an environment were bash is the default shell, but later installed on a
system where /bin/dash is /bin/sh.

So for reproducibility and safety reason, it would be best if the
selected path to the shell would not depend on the build environment.

[jrnieder@gmail.com: imported from uploaded NMU]
diff --git a/debian/changelog b/debian/changelog
index 06a85b5..3649dd4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+xz-utils (5.2.2-1.3) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Force a constant /bin/sh for installed scripts. This helps the build
+    be reproducible; /bin/sh on Debian is always POSIX. (Closes: #806331)
+
+ -- Ximin Luo <infinity0@debian.org>  Wed, 28 Jun 2017 18:39:19 +0200
+
 xz-utils (5.2.2-1.2) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --git a/debian/rules b/debian/rules
index 63bc7c7..6033114 100755
--- a/debian/rules
+++ b/debian/rules
@@ -66,12 +66,14 @@
 
 debian/normal-build/Makefile debian/normal-build/Doxyfile: $(configure_input)
 	dh_auto_configure --builddirectory debian/normal-build -- \
+		$(opt_reproduce) \
 		--enable-threads --disable-static \
 		$(opt_optimize) $(opt_quiet) \
 		--disable-xzdec --disable-lzmadec
 
 debian/static-build/Makefile: $(configure_input)
 	dh_auto_configure --builddirectory debian/static-build -- \
+		$(opt_reproduce) \
 		--disable-threads --disable-shared \
 		--enable-liblzma2-compat \
 		$(opt_optimize) $(opt_quiet) \
@@ -81,6 +83,7 @@
 
 debian/xzdec-build/Makefile: $(configure_input)
 	dh_auto_configure --builddirectory debian/xzdec-build -- \
+		$(opt_reproduce) \
 		--disable-shared --disable-nls --disable-encoders \
 		--enable-small --disable-threads \
 		--disable-liblzma2-compat \
@@ -97,6 +100,7 @@
 flags_cmd = dpkg-buildflags --export=configure
 opt_optimize = $(shell $(flags_cmd))
 opt_optimize_small = $(shell $(small_flags_env) $(flags_cmd))
+opt_reproduce = gl_cv_posix_shell=/bin/sh
 
 opt_no_act =
 opt_quiet =