From 0706f54fa83626be370caf9798839d80222f3e22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= <jeremy@asynk.ch>
Date: Wed, 21 Dec 2011 10:01:21 +0100
Subject: easy_e17: find_local_path: keep EXAMPLES dir if it's the only one

---
 easy_e17.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/easy_e17.sh b/easy_e17.sh
index 641be7d..ae4e26e 100755
--- a/easy_e17.sh
+++ b/easy_e17.sh
@@ -60,8 +60,8 @@ packages_full="$efl_basic $efl_extra $bin_basic $e_modules_bin $e_modules_extra
 packages=$packages_basic    # default
 src_mode="packages"
 
-ignore_dirs_re="^(devs|packaging|plugins|src|web|DOCS|E16|EXAMPLES|FORMATTING|MARKETING|THEMES|TEST)/"
-ignore_dirs="devs packaging web DOCS E16 EXAMPLES FORMATTING MARKETING THEMES TEST"
+ignore_dirs_re="^(devs|packaging|plugins|src|web|DOCS|E16|FORMATTING|MARKETING|THEMES|TEST)/"
+ignore_dirs="devs packaging web DOCS E16 FORMATTING MARKETING THEMES TEST"
 package_args=""         # evas:make_only,emotion:clean
 autogen_args=""         # evas:--enable-gl-x11
 linux_distri=""         # if your distribution is wrongly detected, define it here
@@ -1006,8 +1006,14 @@ function find_local_path ()
 {
     name=$1
     re_src_path=$(echo $src_path | sed 's/\//\\\//g')
-    path=$(find $src_path -maxdepth 5 -type d -name $name | sed -e "s/$re_src_path\///" | grep -v -E "^${src_path}$" | grep  -v -E "$ignore_dirs_re" | \
-        while read line; do echo $(echo $line | grep -o '/' | wc -l) $line; done | sort -n | head -n 1 | cut -d " " -f 2)
+    tmpf=$tmp_path/__find_local_path
+    find $src_path -maxdepth 5 -type d -name $name | sed -e "s/$re_src_path\///" | grep -v -E "^${src_path}$" | grep  -v -E "$ignore_dirs_re" > $tmpf
+    if [ $(cat $tmpf | wc -l ) -gt 1 ]; then
+        dirs=$(cat $tmpf | grep -v -E "^EXAMPLES/")
+    else
+        dirs=$(cat $tmpf)
+    fi
+    path=$(echo $dirs | while read line; do echo $(echo $line | grep -o '/' | wc -l) $line; done | sort -n | head -n 1 | cut -d " " -f 2)
     if [ "$path" ]; then echo "$src_path/$path"; fi
 }
 
-- 
cgit v1.1-2-g2b99