+
+# Copy private code and data from the currently installed profile
+pushd "$CURRENT_PROFILE_PATH"
+
+find . -maxdepth 1 -type d ! -name "tests" -printf "%P\n" |
+ while read -r dir;
+ do
+ [ -d "$dir" ] && cp -r "$dir" "${PROFILE_DEST_DIR}/"
+ done
+
+find . -maxdepth 1 -type f ! -name "*.info.yml" -printf "%P\n" |
+ while read -r original_file;
+ do
+ DESTINATION_FILE="${PROFILE_DEST_DIR}/${original_file/#${CURRENT_PROFILE}/${PROFILE_MACHINE_NAME}}"
+ cp "${original_file}" "$DESTINATION_FILE"
+ if file "$original_file" | grep -q PHP;
+ then
+ sed -i \
+ -e "s/^function ${CURRENT_PROFILE}_/function ${PROFILE_MACHINE_NAME}_/g" \
+ -e "s/\$form\['#submit'\]\[\] = '${CURRENT_PROFILE}_/\$form\['#submit'\]\[\] = '${PROFILE_MACHINE_NAME}_/g" \
+ "$DESTINATION_FILE"
+ fi
+ done
+
+popd