Patchwork [15/17] populate_sdk_base: tarball installer: SDK overwrite warning

login
register
mail settings
Submitter Hongxu Jia
Date March 11, 2013, 11:04 a.m.
Message ID <5d7015385718e86cdf212ebacbda9be700fd0274.1362985569.git.hongxu.jia@windriver.com>
Download mbox | patch
Permalink /patch/45909/
State New
Headers show

Comments

Hongxu Jia - March 11, 2013, 11:04 a.m.
This patch contains two fixes:
* if the user wants to install the SDK in a directory that already
  contains a SDK for the same architecture, a warning will be shown;
* when the symbolic links are relocated use -n option. Otherwise,
  symbolic links to existing directories will be created in the
  directory itself;

Cherry-pick commit b751ec137d0228b40a90e9e32b24f5cb5732225b

[YOCTO #3401]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes/populate_sdk_base.bbclass |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Patch

diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
index 6eb6726..3f2926c 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -132,11 +132,20 @@  else
 	target_sdk_dir=$(readlink -m $target_sdk_dir)
 fi
 
-printf "You are about to install the SDK to \"$target_sdk_dir\". Proceed[Y/n]?"
+if [ -e "$target_sdk_dir/environment-setup-${REAL_MULTIMACH_TARGET_SYS}" ]; then
+	echo "The directory \"$target_sdk_dir\" already contains a SDK for this architecture."
+	printf "If you continue, existing files will be overwritten! Proceed[y/N]?"
+
+	default_answer="n"
+else
+	printf "You are about to install the SDK to \"$target_sdk_dir\". Proceed[Y/n]?"
+
+	default_answer="y"
+fi
 read answer
 
 if [ "$answer" = "" ]; then
-	answer="y"
+	answer="$default_answer"
 fi
 
 if [ "$answer" != "Y" -a "$answer" != "y" ]; then
@@ -176,7 +185,7 @@  find $native_sysroot -type f -exec file '{}' \;|grep ":.*ASCII.*text"|cut -d':'
 
 # change all symlinks pointing to ${SDKPATH}
 for l in $(find $native_sysroot -type l); do
-	ln -sf $(readlink $l|sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:") $l
+	ln -sfn $(readlink $l|sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:") $l
 done
 
 echo done