diff -u ghc6-6.10.1+dfsg1/debian/rules ghc6-6.10.1+dfsg1/debian/rules
--- ghc6-6.10.1+dfsg1/debian/rules
+++ ghc6-6.10.1+dfsg1/debian/rules
@@ -130,41 +130,54 @@
 	# Sort out the package.conf files
 	mv debian/tmp/usr/lib/ghc-$(ProjectVersion)/package.conf \
 	   debian/tmp/usr/lib/ghc-$(ProjectVersion)/package.conf.shipped
-	PACKAGE=`utils/ghc-pkg/ghc-pkg-inplace list -f debian/tmp/usr/lib/ghc-$(ProjectVersion)/package.conf.shipped | perl -ne 'print if $$foo; $$foo = 1 if /^debian/' | tr '\n,A-Z' '  a-z' | sed -e "s/([^)]*)//g" -e "s/-[0-9]\+\(\.[0-9]\+\)*//g" -e "s/^ *//" -e "s/ *$$//" -e "s/  */, /g"`; \
+	set -e; \
+	  { utils/ghc-pkg/install-inplace/bin/ghc-pkg list -f \
+		debian/tmp/usr/lib/ghc-$(ProjectVersion)/package.conf.shipped |\
+	    perl -ne 'print if $$foo; $$foo = 1 if /^debian/' | \
+	    tr '\n,A-Z' '  a-z' | \
+	    sed -e "s/([^)]*)//g" -e "s/-[0-9]\+\(\.[0-9]\+\)*//g" \
+		-e "s/^ *//" -e "s/ *$$//" -e "s/  */, /g"; \
+	    echo; \
+	  } | \
+	  { read PACKAGE; \
 	    { echo -n "provided-devs="; \
-	      echo "$$PACKAGE" | sed -e "s/\([a-z0-9.-]\+\)/libghc6-\1-dev/g"; } \
-	          >> debian/ghc6.substvars; \
+	      echo "$$PACKAGE" | \
+	      sed -e "s/\([a-z0-9.-]\+\)/libghc6-\1-dev/g"; \
+	    } >> debian/ghc6.substvars; \
 	    { echo -n "provided-profs="; \
-	      echo "$$PACKAGE" | sed -e "s/\([a-z0-9.-]\+\)/libghc6-\1-prof/g"; } \
-	          >> debian/ghc6-prof.substvars; \
+	      echo "$$PACKAGE" | \
+	      sed -e "s/\([a-z0-9.-]\+\)/libghc6-\1-prof/g"; \
+	    } >> debian/ghc6-prof.substvars; \
 	    { echo -n "provided-docs="; \
-	      echo "$$PACKAGE" | sed -e "s/\([a-z0-9.-]\+\)/libghc6-\1-doc/g"; } \
-	          >> debian/ghc6-doc.substvars
+	      echo "$$PACKAGE" | \
+	      sed -e "s/\([a-z0-9.-]\+\)/libghc6-\1-doc/g"; \
+	    } >> debian/ghc6-doc.substvars; \
+	  }
 
	# Sort out the binaries
 	mkdir debian/tmp/usr/bin
-	cd debian/tmp/usr/lib/ghc-$(ProjectVersion)/bin && \
+	set -e; cd debian/tmp/usr/lib/ghc-$(ProjectVersion)/bin && \
 	    for f in *-$(ProjectVersion); \
 	    do ln -s /usr/lib/ghc-$(ProjectVersion)/bin/$$f \
 	             ../../../bin/; \
 	    done
-	cd debian/tmp/usr/lib/ghc-$(ProjectVersion)/bin && \
+	set -e; cd debian/tmp/usr/lib/ghc-$(ProjectVersion)/bin && \
 	    for f in *; \
 	    do ln -s /usr/lib/ghc-$(ProjectVersion)/bin/$$f \
 	             ../../../bin/$${f}6; \
 	    done
 	rm -f debian/tmp/usr/bin/*-$(ProjectVersion)6
 	rm -f debian/tmp/usr/bin/runhaskell6
	# gen_contents_index is a script, so move it into /usr/lib
 	mkdir debian/tmp/usr/lib/ghc6-doc
 ifeq ($(BUILD_HADDOCK_DOCS),YES)
 	mv debian/tmp/usr/share/doc/ghc6-doc/libraries/gen_contents_index \
 	   debian/tmp/usr/lib/ghc6-doc
 endif
 
	# manpages
 	ProjectVersion=$(ProjectVersion) $(MAKE) -f debian/scripts.mk all
-	for m in ghci6 ghc-$(ProjectVersion) ghci-$(ProjectVersion); do echo ".so man1/ghc6.1" > debian/$$m.1; done
+	set -e; for m in ghci6 ghc-$(ProjectVersion) ghci-$(ProjectVersion); do echo ".so man1/ghc6.1" > debian/$$m.1; done
 	mv debian/tmp/usr/share/man/man1/ghc.1 debian/ghc6.1
 	cp utils/hp2ps/hp2ps.1 debian/hp2ps-ghc6.1
 	echo debian/*.1 > debian/ghc6.manpages