Skip to contentSkip to conversation

image.py: Avoid creating empty .env file in _write_wic_env

PATCH Superseded Mike Crowe 2 participants 2 messages Nov 19, 2015 – Nov 23, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mike Crowe

author
#0 lore raw

PATCH 2/2 image.py: Avoid creating empty .env file in _write_wic_env

Creating a file for every image containing a few variables isn't necessary if wic is not being used, so don't write the file if WICVARS is empty.

---
 meta/lib/oe/image.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/lib/oe/image.py +5 -1
index 8c797ec..ceaade7 100644
@@ -336,6 +336,10 @@ class Image(ImageDepGraph):
         Write environment variables used by wic
         to tmp/sysroots/<machine>/imgdata/<image>.env
         """
+        wicvars = self.d.getVar('WICVARS', True)
+        if not wicvars:
+            return
+
         stdir = self.d.getVar('STAGING_DIR_TARGET', True)
         outdir = os.path.join(stdir, 'imgdata')
         try:
@@ -350,7 +354,7 @@ class Image(ImageDepGraph):
                 raise
         basename = self.d.getVar('IMAGE_BASENAME', True)
         with open(os.path.join(outdir, basename) + '.env', 'w') as envf:
-            for var in self.d.getVar('WICVARS', True).split():
+            for var in wicvars.split():
                 value = self.d.getVar(var, True)
                 if value:
                     envf.write('%s="%s"\n' % (var, value.strip()))
Signature · 1 line
2.1.4
Acked-by on v1 2/2
#1 lore raw

Looks good to me.

Quoted 41 lines · Mike Crowe

Creating a file for every image containing a few variables isn't necessary if wic is not being used, so don't write the file if WICVARS is empty.

---
 meta/lib/oe/image.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/lib/oe/image.py +5 -1
index 8c797ec..ceaade7 100644
@@ -336,6 +336,10 @@ class Image(ImageDepGraph):
         Write environment variables used by wic
         to tmp/sysroots/<machine>/imgdata/<image>.env
         """
+        wicvars = self.d.getVar('WICVARS', True)
+        if not wicvars:
+            return
+
         stdir = self.d.getVar('STAGING_DIR_TARGET', True)
         outdir = os.path.join(stdir, 'imgdata')
         try:
@@ -350,7 +354,7 @@ class Image(ImageDepGraph):
                 raise
         basename = self.d.getVar('IMAGE_BASENAME', True)
         with open(os.path.join(outdir, basename) + '.env', 'w') as envf:
-            for var in self.d.getVar('WICVARS', True).split():
+            for var in wicvars.split():
                 value = self.d.getVar(var, True)
                 if value:
                     envf.write('%s="%s"\n' % (var, value.strip()))
Signature · 7 lines
2.1.4

-- 
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 3 lines
--
Regards,
Ed