[oe-commits] Laurentiu Palcu : SDK: trap any IO errors in the relocate script

git at git.openembedded.org git at git.openembedded.org
Wed Sep 26 14:04:47 UTC 2012


Module: openembedded-core.git
Branch: master
Commit: 26daec758b2eaeb208356d5aa8a9a191bd366751
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=26daec758b2eaeb208356d5aa8a9a191bd366751

Author: Laurentiu Palcu <laurentiu.palcu at intel.com>
Date:   Tue Sep 25 19:35:46 2012 +0300

SDK: trap any IO errors in the relocate script

If the files being relocated are already used by other processes the
relocate script will fail with a traceback. This patch will trap any IO
errors when opening such a file and gracefully report them to the user.

Also change the exit code from 1 to -1 for a better adt-installer user
experience (like pointing the user to the adt_installer.log).

[YOCTO #3164]

Signed-off-by: Laurentiu Palcu <laurentiu.palcu at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 scripts/relocate_sdk.py |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py
index b247e65..637ffe9 100755
--- a/scripts/relocate_sdk.py
+++ b/scripts/relocate_sdk.py
@@ -29,6 +29,7 @@ import sys
 import stat
 import os
 import re
+import errno
 
 old_prefix = re.compile("##DEFAULT_INSTALL_DIR##")
 
@@ -171,7 +172,7 @@ def change_dl_sysdirs():
 
 # MAIN
 if len(sys.argv) < 4:
-    exit(1)
+    exit(-1)
 
 new_prefix = sys.argv[1]
 new_dl_path = sys.argv[2]
@@ -184,7 +185,16 @@ for e in executables_list:
     else:
         os.chmod(e, perms|stat.S_IRWXU)
 
-    f = open(e, "r+b")
+    try:
+        f = open(e, "r+b")
+    except IOError as ioex:
+        if ioex.errno == errno.ETXTBSY:
+            print("Could not open %s. File used by another process.\nPlease "\
+                  "make sure you exit all processes that might use any SDK "\
+                  "binaries." % e)
+        else:
+            print("Could not open %s: %s(%d)" % (e, ioex.strerror, ioex.errno))
+        exit(-1)
 
     arch = get_arch()
     if arch:





More information about the Openembedded-commits mailing list