Skip to contentSkip to conversation

cookerdata: print an error if layer dir does not exist

PATCH Superseded Markus Lehtonen 3 participants 4 messages May 24, 2016 – May 25, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cookerdata: print an error if layer dir does not exist

Makes it easier for user to identify problems, e.g. typos, in BBLAYERS.

[YOCTO #9507]

---
 lib/bb/cookerdata.py | 4 ++++
 1 file changed, 4 insertions(+)
lib/bb/cookerdata.py +4 -0
index 1615db5..7dfe7b5 100644
@@ -292,6 +292,10 @@ class CookerDataBuilder(object):
             data = bb.data.createCopy(data)
             approved = bb.utils.approved_variables()
             for layer in layers:
+                if not os.path.isdir(layer):
+                    parselog.critical("Layer directory '%s' does not to exist! "
+                                      "Please check BBLAYERS in %s" % (layer, layerconf))
+                    sys.exit(1)
                 parselog.debug(2, "Adding layer %s", layer)
                 if 'HOME' in approved and '~' in layer:
                     layer = os.path.expanduser(layer)
Signature · 1 line
2.6.6
#1 lore raw
Quoted 14 lines · Markus Lehtonen

Makes it easier for user to identify problems, e.g. typos, in BBLAYERS.

[YOCTO #9507]

---
  lib/bb/cookerdata.py | 4 ++++
  1 file changed, 4 insertions(+)
lib/bb/cookerdata.py +0 -0
index 1615db5..7dfe7b5 100644

lib/bb/cookerdata.py class CookerDataBuilder(object): · line 298

Quoted 7 lines
lib/bb/cookerdata.py +4 -0
@@ -292,6 +292,10 @@ class CookerDataBuilder(object):
              data = bb.data.createCopy(data)
              approved = bb.utils.approved_variables()
              for layer in layers:
+                if not os.path.isdir(layer):
+                    parselog.critical("Layer directory '%s' does not to exist! "
+                                      "Please check BBLAYERS in %s" % (layer, layerconf))
+                    sys.exit(1)

Markus, I am not familiar with this code, but instead of a sys.exit(1), would it be better to raise a exception instead (raise SystemExit(msg))?

Quoted 3 lines
lib/bb/cookerdata.py +0 -0
                  parselog.debug(2, "Adding layer %s", layer)
                  if 'HOME' in approved and '~' in layer:
                      layer = os.path.expanduser(layer)
#2 lore raw

Hi Leonardo,

Quoted 23 lines · Leonardo Sandoval
Quoted 21 lines · Markus Lehtonen

Makes it easier for user to identify problems, e.g. typos, in BBLAYERS.

[YOCTO #9507]

---
  lib/bb/cookerdata.py | 4 ++++
  1 file changed, 4 insertions(+)
lib/bb/cookerdata.py +2 -0
index 1615db5..7dfe7b5 100644
@@ -292,6 +292,10 @@ class CookerDataBuilder(object):
              data = bb.data.createCopy(data)
              approved = bb.utils.approved_variables()
              for layer in layers:
+                if not os.path.isdir(layer):
+                    parselog.critical("Layer directory '%s' does

not to exist! "

Quoted 13 lines
Quoted 3 lines

+ "Please check BBLAYERS in
%s" % (layer, layerconf))
+ sys.exit(1)

Markus, I am not familiar with this code, but instead of a sys.exit(1),
would it be better to raise a exception instead (raise SystemExit(msg))?

Quoted 3 lines

parselog.debug(2, "Adding layer %s", layer) if 'HOME' in approved and '~' in layer:
layer = os.path.expanduser(layer)

The reason for this is that with SystemExit() the output will be much uglier. Bitbake will not only print the error message but also all logging debug messages and I think that this may confuse the user. The output would look something like:
--- SNIP ----------------------------------------------------- Layer directory '#' does not to exist! Please check BBLAYERS in /home/marquiz/yocto/openembedded-core/build-9507/conf/bblayers.conf
DEBUG: Removed the following variables from the environment: _, LS_COLORS, EMAIL, JAVA_ROOT, LESS, G_BROKEN_FILENAMES, MINICOM, CSHEDIT, HOSTTYPE, LESSOPEN, QT_SYSTEM_DIR, PYTHONSTARTUP, CVS_RSH, GPG_AGENT_INFO, INPUTRC, XDG_VTNR, SOCKS_PROXY, CPU, QT_IM_SWITCHER, XSESSION_IS_UP, AUDIODRIVER, LESSKEY, XDG_DATA_DIRS, XNLSPATH, TERMINATOR_UUID, ALSA_CONFIG_PATH, HISTSIZE, SDL_AUDIODRIVER, WINDOWID, LESS_ADVANCED_PREPROCESSOR, gopher_proxy, MANPATH, XMODIFIERS, WINDOWPATH, JAVA_HOME, PROFILEREAD, XKEYSYMDB, VDPAU_DRIVER, GIT_CEILING_DIRECTORIES, JAVA_BINDIR, XDG_RUNTIME_DIR, DISPLAY, PYTHONPATH, COMP_WORDBREAKS, NNTPSERVER, XCURSOR_THEME, DBUS_SESSION_BUS_PID, G_FILENAME_ENCODING, OSTYPE, HOST, FROM_HEADER, LESSCLOSE, JRE_HOME, socks_proxy, LS_OPTIONS, GPG_TTY, XDG_SESSION_ID, DBUS_SESSION_BUS_ADDRESS, ORBIT_SOCKETDIR, LANG, GTK_IM_MODULE, CONFIG_SITE, XDG_CONFIG_DIRS, GTK_MODULES, SOCKS5_SERVER, XDG_SEAT, OLDPWD, HOSTNAME, WINDOWMANAGER, INPUT_METHOD, SHLVL, QT_IM_MODULE, COLORTERM, BUILDDIR, QEMU_AUDIO_DRV, MAIL, MACHTYPE, PAGER, XAUTHLOCALHOSTNAME, MORE
DEBUG: Found bblayers.conf (/home/marquiz/yocto/openembedded-core/build -9507/conf/bblayers.conf)
DEBUG: Adding layer /home/marquiz/yocto/openembedded-core/meta --- SNIP -----------------------------------------------------

The reason for this behavior is that bitbake will spit out all log messages (even debug messages) if it exits at this early stage and there are no non-debug messages in the logger.

Thanks,
Markus

#3 lore raw
In reply to Markus Lehtonen
Quoted 22 lines

-----Original Message-----
From: [email protected] [mailto:bitbake- [email protected]] On Behalf Of Markus Lehtonen
Sent: den 24 maj 2016 09:26
To: [email protected]
Subject: [bitbake-devel] [PATCH] cookerdata: print an error if layer dir does not exist

Makes it easier for user to identify problems, e.g. typos, in BBLAYERS.

[YOCTO #9507]

---
 lib/bb/cookerdata.py | 4 ++++
 1 file changed, 4 insertions(+)
lib/bb/cookerdata.py +0 -0
index 1615db5..7dfe7b5 100644

lib/bb/cookerdata.py class CookerDataBuilder(object): · line 296

Quoted 5 lines
lib/bb/cookerdata.py +2 -0
@@ -292,6 +292,10 @@ class CookerDataBuilder(object):
             data = bb.data.createCopy(data)
             approved = bb.utils.approved_variables()
             for layer in layers:
+                if not os.path.isdir(layer):
+                    parselog.critical("Layer directory '%s' does not to exist! "
                                                                        ^^

Change "not to exist" to "not exist".

Quoted 7 lines
lib/bb/cookerdata.py +2 -1
+                                      "Please check BBLAYERS in %s" % (layer, layerconf))
+                    sys.exit(1)
                 parselog.debug(2, "Adding layer %s", layer)
                 if 'HOME' in approved and '~' in layer:
                     layer = os.path.expanduser(layer)
--

2.6.6

//Peter