don't copy mic code on host pc to mic-bootstap if mic in bootstrap is py3 23/303023/1 sandbox/xuhy/opensuse421 accepted/tools/devbase/tools/legacy/20240422.110739 accepted/tools/devbase/tools/legacy/20240423.040631 accepted/tools/devbase/tools/legacy/20240424.050612
authorwangbiao <biao716.wang@samsung.com>
Tue, 19 Dec 2023 05:28:25 +0000 (14:28 +0900)
committerwangbiao <biao716.wang@samsung.com>
Tue, 19 Dec 2023 05:28:25 +0000 (14:28 +0900)
Change-Id: I38f212811f0b3fd78d95f29d51c96790df155e32
Signed-off-by: wangbiao <biao716.wang@samsung.com>
mic/rt_util.py

index b79e8005a7d0a52fe8004b5161c7c637b15fc7a5..db8427f202a9ed0e81f2667c2b3f9d27f7b3028c 100644 (file)
@@ -64,6 +64,19 @@ def inbootstrap():
         return True
     return (os.stat("/").st_ino != 2)
 
+# check python version in mic-bootstrap
+def mic_py2_in_mic_bootstrap(binpth_in_micbootstrap):
+    #Check /usr/bin/mic file in mic bootstrap, if there is #!/usr/bin/python2 -tt, mean it is python2.x version.
+    #For python2.x version, the first line of /usr/bin/mic in mic-bootstrap is: #!/bin/python -tt
+    #For python3.x version, the first line of /usr/bin/mic in mic-bootstrap is: #!/bin/python3 -tt
+    with open(binpth_in_micbootstrap, 'r') as mic_bin:
+        first_line = mic_bin.readline()
+
+    msger.debug("first line of /usr/bin/mic in mic bootstrap: %s" % first_line)
+    if (first_line.find('python3') == -1):
+        return True
+    return False
+
 def bootstrap_mic(argv=None):
     def mychroot():
         os.chroot(rootdir)
@@ -103,7 +116,8 @@ def bootstrap_mic(argv=None):
             rootdir = os.path.join(rootdir, "bootstrap")
 
         bsenv.dirsetup(rootdir)
-        if cropts['use_mic_in_bootstrap']:
+        #when mic in mic-bootstrap is py3, use mic version in mic-bootstrap.
+        if cropts['use_mic_in_bootstrap'] | (mic_py2_in_mic_bootstrap(os.path.join(rootdir, '/usr/bin/mic'.lstrip('/'))) == False):
             msger.info("No copy host mic")
         else:
             msger.info("Copy host mic to bootstrap")