[OE-core] [PATCH 7/8] populate_sdk_ext.bbclass: remove the try...finally

Robert Yang liezhi.yang at windriver.com
Wed Mar 14 03:18:02 UTC 2018


On 03/13/2018 10:57 PM, Richard Purdie wrote:
> On Tue, 2018-03-13 at 11:24 +0800, Robert Yang wrote:
>> The "sdkbasepath + '/conf/local.conf.bak" doesn't exist when
>> "oe.copy_buildsystem.check_sstate_task_list()" fails, then
>> os.replace() would
>> raise FileNotFoundError, which overcomes the real error. Keep the
>> error status
>> makes debug easier, so remove the try..finally.
> 
> I don't think this patch is quite right. If there is a failure we
> *must* make sure local.conf is restored, that is important. The code
> should probably keep the try/finally but make the replace conditional
> on the file existing.

Thanks, updated in the repo:

Author: Robert Yang <liezhi.yang at windriver.com>
Date:   Wed Mar 14 10:01:51 2018 +0800

     populate_sdk_ext.bbclass: only replace local.conf when local.conf.bak exists

     The "sdkbasepath + '/conf/local.conf.bak'" doesn't exist when
     "oe.copy_buildsystem.check_sstate_task_list()" fails since the sdkbasepath had
     been renamed to temp_sdkbasepath, but can't rename back when
     oe.copy_buildsystem.check_sstate_task_list() fails, then os.replace() would
     raise FileNotFoundError, which overcomes the real error. Only replace
     local.conf when local_conf.bak exists can make the debug easier.

     Signed-off-by: Robert Yang <liezhi.yang at windriver.com>

diff --git a/meta/classes/populate_sdk_ext.bbclass 
b/meta/classes/populate_sdk_ext.bbclass
index 057c495..fa24fc4 100644
--- a/meta/classes/populate_sdk_ext.bbclass
+++ b/meta/classes/populate_sdk_ext.bbclass
@@ -141,9 +141,11 @@ def create_filtered_tasklist(d, sdkbasepath, tasklistfile, 
conf_initpath):
      import oe.copy_buildsystem

      # Create a temporary build directory that we can pass to the env setup script
-    shutil.copyfile(sdkbasepath + '/conf/local.conf', sdkbasepath + 
'/conf/local.conf.bak')
+    local_conf = sdkbasepath + '/conf/local.conf'
+    local_conf_bak = local_conf + '.bak'
+    shutil.copyfile(local_conf, local_conf_bak)
      try:
-        with open(sdkbasepath + '/conf/local.conf', 'a') as f:
+        with open(local_conf, 'a') as f:
              # Force the use of sstate from the build system
              f.write('\nSSTATE_DIR_forcevariable = "%s"\n' % 
d.getVar('SSTATE_DIR'))
              f.write('SSTATE_MIRRORS_forcevariable = "file://universal/(.*) 
file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n')
@@ -178,7 +180,8 @@ def create_filtered_tasklist(d, sdkbasepath, tasklistfile, 
conf_initpath):
          # will effectively do
          clean_esdk_builddir(d, sdkbasepath)
      finally:
-        os.replace(sdkbasepath + '/conf/local.conf.bak', sdkbasepath + 
'/conf/local.conf')
+        if os.path.exists(local_conf_bak):
+            os.replace(local_conf_bak, local_conf)

  python copy_buildsystem () {
      import re

// Robert


> 
> Cheers,
> 
> Richard
> 



More information about the Openembedded-core mailing list