-#
-## check for installation scripts
-#files=$(find .. -name $paket.preinst)
-#files="$files $(find .. -name $paket.postinst)"
-#files="$files $(find .. -name $paket.prerm)"
-#files="$files $(find .. -name $paket.postrm)"
-#for file in $files
-#do
-# ln -sf $file .
-#done
+# pack prepare
+if [ "$target_type" == "DEB" ]
+then
+ if [ ! -f debian/$paket.cp ]
+ then
+ echo "debian/$paket.cp missing for target type DEB"
+ exit 9
+ fi
+ if [ ! -f debian/$paket.control ]
+ then
+ echo "debian/$paket.control missing for target type DEB"
+ exit 10
+ fi
+
+ echo "PACK=binary" >> debian/rules.pre
+ if grep "^Architecture: *all" debian/$paket.control >/dev/null
+ then
+ echo "arch = all" >> debian/rules.pre
+ echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre
+ else
+ echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
+ echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
+ fi
+ if ! [ -f debian/$paket.changelog ]
+ then
+ echo "changelog_source = debian/default.changelog" >> debian/rules.pre
+ if [ -f debian/default.changelog ]
+ then
+ rm debian/default.changelog
+ fi
+ fi
+elif [ "$target_type" == "ZIP" ]
+then
+ echo "PACK=zip" >> debian/rules.pre
+ if [ ! -f debian/$paket.cp ]
+ then
+ echo "debian/$paket.cp missing for target type ZIP"
+ exit 11
+ fi
+elif [ "$target_type" == "FILE" ]
+then
+ echo "PACK=version" >> debian/rules.pre
+ if [ -z "$compile_target" ]
+ then
+ echo "compile_target is needed for target_type FILE"
+ exit 12
+ fi
+ echo "TARGET = $compile_target" >> debian/rules.pre
+
+else
+ echo "Unknown target type: $target_type"
+ exit 13
+fi