Description: Fix FTBFS due to LD_LIBRARY_PATH in test script wrappers
 Since we use the system sqlite3, the system library path gets added to
 temp_rpath/LD_LIBRARY_PATH. On Ubuntu, libldap-2.4-2 =>
 libgssapi3-heimdal => libhcrypto4-heimdal (as well as in the buildd
 schroots, apt-transport-https is installed by default which also pulls
 in libldap-2.4-2), and so libhcrypto4-heimdal (the current example, but
 other heimdal libraries could also trigger this) is installed when we
 run the build-time tests.
 .
 We therefore encounter a bug when the system libhcrypto.so gets found
 in the search path before the build-local version. The ABI may have
 changed, but more importantly, we want to test the build-local version.
 Fix temp_rpath like the other rpath variables to not insert the system
 search path.
Author: Nishanth Aravamudan <nish.aravamudan@canonical.com>
Bug: https://github.com/heimdal/heimdal/issues/241
Bug-Ubuntu: https://launchpad.net/bugs/1655839
Last-Update: 2017-02-16

--- heimdal-7.1.0+dfsg.orig/ltmain.sh
+++ heimdal-7.1.0+dfsg/ltmain.sh
@@ -8092,9 +8092,16 @@ func_mode_link ()
 	    # We need to hardcode the library path
 	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case $temp_rpath: in
-	      *"$absdir:"*) ;;
-	      *) func_append temp_rpath "$absdir:" ;;
+	      # Skip directories that are in the system default run-time
+	      # search path.
+	      case " $sys_lib_dlsearch_path " in
+	      *" $absdir "*) ;;
+	      *)
+		case $temp_rpath: in
+		*"$absdir:"*) ;;
+		*) func_append temp_rpath "$absdir:" ;;
+		esac
+		;;
 	      esac
 	    fi
 
