diff --git a/debian/rules b/debian/rules
index b80d56cfdb..5bc19ace77 100755
--- a/debian/rules
+++ b/debian/rules
@@ -151,7 +151,11 @@ install-arch-stamp:
# Remove READM.txt files from output directories
find $(INSTALL_DIR)/usr/lib/lazarus/${DEB_UPSTREAM_MAIN_VERSION} '(' -name '*.or' -or -wholename '*/lib/README.txt' ')' -delete
# Mark package as manually compilable and install them
- find -name '*.lpk' -exec sed -e 's@\(\W*\)<\bAddToProjectUsesSection\b.*@&\n\1@' '{}' > '$(INSTALL_DIR)/usr/lib/lazarus/${DEB_UPSTREAM_MAIN_VERSION}/{}' ';'
+ for package in `find -name '*.lpk'` ; \
+ do \
+ ${MKDIR} `dirname "$(INSTALL_DIR)/usr/lib/lazarus/${DEB_UPSTREAM_MAIN_VERSION}/$${package}"` ; \
+ sed -e 's@\(\W*\)<\bAddToProjectUsesSection\b.*@&\n\1@' "$${package}" > "$(INSTALL_DIR)/usr/lib/lazarus/${DEB_UPSTREAM_MAIN_VERSION}/$${package}" ; \
+ done
# copy icons and menu entries for the GNOME menu
install -d $(INSTALL_DIR)/usr/share/pixmaps
install -d $(INSTALL_DIR)/usr/share/applications