From 0e28d6c906f05da92f93cbce32d8abb95e45365b Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Mon, 7 Dec 2015 10:45:46 +0000 Subject: [PATCH] (dali_env) Fix setenv output Problem: Running "dali_env -s" does not output the correct setenv information. Solution: This happened because we were doing a string inequality check using "!=". We should use "ne" instead. Additionally, ensure we only look for "dali-env" as our root dir explicitly, i.e. it should not be dali-env-blah. In that case, a dali-env subdirectory should be used as the root. Also ensuring that we do not create a new dali-env folder if it already exist in the current working directory root path. Change-Id: Ic7b3897996d318439ab3cb6a001917519155ebd7 --- build/scripts/dali_env | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/build/scripts/dali_env b/build/scripts/dali_env index 3230e9e..d3ba046 100755 --- a/build/scripts/dali_env +++ b/build/scripts/dali_env @@ -93,25 +93,40 @@ if($0 !~ m!^/!) $exec_path = dirname($exec_path); my $root_path = getcwd(); + +# Search for the root dali-env directory if($exec_path =~ m!dali-env/opt/bin!) { + # We are using the installed dali_env script + $root_path = $exec_path; - while($root_path !~ m!dali-env$! && $root_path != "") + while(basename($root_path) ne "dali-env" && $root_path ne "") { $root_path = dirname($root_path); } } -elsif($root_path =~ m!dali-env!) +elsif($root_path =~ m!dali-env$! or $root_path =~ m!dali-env/!) { - while($root_path =~ m!dali-env$! && $root_path != "") + # We are NOT using the installed dali_env script + # Find dali-env root from current directory + + while(basename($root_path) ne "dali-env" && $root_path ne "") { $root_path = dirname($root_path); } } else { - $new_env = 1; + # dali-env root dir should be in the current directory + $root_path .= "/dali-env"; + + if(! -e $root_path) + { + # Creating a new dali-env + + $new_env = 1; + } } my $src_path = "$root_path/src-packages"; @@ -527,6 +542,10 @@ if($opt_create) die "Already in a dali-env directory\n"; # Could query if user wants to re-create? } + elsif(-e $root_path) + { + die "$root_path already exists\n"; + } elsif(-e $new_root) { die "A dali-env directory already exists here\n"; -- 2.7.4