public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] Skip over event handler calls with incomplete environment
@ 2018-02-07 15:59 Jan Kiszka
  2018-02-07 16:12 ` Alexander Smirnov
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2018-02-07 15:59 UTC (permalink / raw)
  To: isar-users

From: Jan Kiszka <jan.kiszka@siemens.com>

The cleanup handler is called a couple of times per shutdown and,
depending on the setup, some may not have a complete config. Avoid that
we stumble and fall over any of the environment variables being
undefined.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/isar-events.bbclass | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index ae0f791..4b5e97e 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -15,15 +15,16 @@ python isar_handler () {
         distro = d.getVar('DISTRO', True)
         arch = d.getVar('DISTRO_ARCH', True)
 
-        w = tmpdir + '/work/' + distro + '-' + arch
+        if tmpdir and distro and arch:
+            w = tmpdir + '/work/' + distro + '-' + arch
 
-        # '/proc/mounts' contains all the active mounts, so knowing 'w' we
-        # could get the list of mounts for the specific multiconfig and
-        # clean them.
-        with open('/proc/mounts', 'rU') as f:
-            for line in f:
-                if w in line:
-                    subprocess.call('sudo umount -f ' + line.split()[1], stdout=devnull, stderr=devnull, shell=True)
+            # '/proc/mounts' contains all the active mounts, so knowing 'w' we
+            # could get the list of mounts for the specific multiconfig and
+            # clean them.
+            with open('/proc/mounts', 'rU') as f:
+                for line in f:
+                    if w in line:
+                        subprocess.call('sudo umount -f ' + line.split()[1], stdout=devnull, stderr=devnull, shell=True)
 
     devnull.close()
 }
-- 
2.13.6

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-08  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-07 15:59 [PATCH] Skip over event handler calls with incomplete environment Jan Kiszka
2018-02-07 16:12 ` Alexander Smirnov
2018-02-08  7:27   ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox