Description: dpkg-buildpackage is very picky with changes in the source tree during clean
Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>

--- a/Makefile
+++ b/Makefile
@@ -92,7 +92,7 @@
 # The front end binary
 export CYMAKE       = $(BINDIR)/$(CURRYSYSTEM)-frontend
 # The cleancurry binary
-export CLEANCURRY   = $(BINDIR)/cleancurry
+export CLEANCURRY   = debian/bin/cleancurry
 
 # Logfile for make:
 MAKELOG=make.log
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -4,7 +4,7 @@
 
 # the scripts to be installed
 BINS = $(BINDIR)/pakcs $(BINDIR)/pakcs-makecgi \
-       $(BINDIR)/cleancurry \
+       ../debian/bin/cleancurry \
        $(BINDIR)/pakcs-fcypp
 
 
@@ -20,6 +20,14 @@
 	 sed "s|^PAKCSINSTALLDIR=.*$$|PAKCSINSTALLDIR=$(PAKCSINSTALLDIR)|" > $@
 	chmod 755 $@
 
+# the cleancurry script must be run from inside debian/ subfolder
+# to keep the original source tree clean while running upstream's
+# make clean
+../debian/bin/%: %.sh
+	mkdir -p $(@D)
+	sed "s|^PAKCSHOME=.*$$|PAKCSHOME=$(ROOT)|" < $< > $@
+	chmod 755 $@
+
 .PHONY: clean
 clean:
 	rm -f $(BINS)
--- a/testsuite2/test.sh
+++ b/testsuite2/test.sh
@@ -34,7 +34,7 @@
 export PATH
 
 # clean up before
-$CURRYBIN/cleancurry
+../debian/bin/cleancurry
 
 LOGFILE=xxx$$
 
