Commit Graph

17 Commits

Author SHA1 Message Date
Joshua Lock c4e2c59088 meta: remove True option to getVar calls
getVar() now defaults to expanding by default, thus remove the True
option from getVar() calls with a regex search and replace.

Search made with the following regex: getVar ?\(( ?[^,()]*), True\)

(From OE-Core rev: 7c552996597faaee2fbee185b250c0ee30ea3b5f)

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-16 10:23:23 +00:00
Peter Kjellerstedt 88d5f563c9 metadata_scm.bbclass: Do not assume ${COREBASE} is a Git repo
The functions base_detect_revision() and base_detect_branch() try to
extract SCM meta information from the path returned by
base_get_scmbasepath(), which currently returns ${COREBASE}. However,
making the assumption that ${COREBASE} contains SCM meta information
can be false. It is true for Poky, but not necessarily other
environments. A better option is to look for the SCM meta information
based on the meta layer.

Since this works as expected for Git but not SVN, the call to
base_get_metadata_svn_revision() from base_detect_revision() was also
removed. This is not expected to affect anyone (partly based on the
comment in base_get_metadata_svn_revision()).

(From OE-Core rev: 53fd0a4a37023642a770a9fbf3cd5511d3c82af7)

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-11 10:33:42 +01:00
Paul Eggleton 43c8867b63 classes/metadata_scm: fix git errors showing up on non-git repositories
Fixes the following error showing up for layers that aren't a git repo
(or aren't parented by one):

fatal: Not a git repository (or any of the parent directories): .git

This was because we weren't intercepting stderr. We might as well just
use bb.process.run() here which does that and returns stdout and stderr
separately.

(This was a regression that came in with OE-Core revision
3aac11076e).

Fixes [YOCTO #8661].

(From OE-Core rev: f533c1bf4c6edbecc67f9e2c62fd475d64668e86)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-11-24 15:50:26 +00:00
Ross Burton 3aac11076e metadata_scm: rewrite git hash logic
The code to get the git and branch hash for the current commit in a specific
repository was quite complex and prone to breakage, replace it with subprocess
and git rev-parse.

(From OE-Core rev: bd8ff33cf2439536c6e41cf0ee9dd8fb3b64770a)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-10-19 17:57:58 +01:00
Merten Sach 97d5b997cf metadata_scm: Fix crash due to uncaught python exception
Function base_get_metadata_svn_revision was crashing due to an uncaught
IndexError exception.

The except notation without parentheses is legacy syntax. It is the equivalent
to 'except IOError as IndexError' which is not what we want here.

The change catches both exceptions.

(From OE-Core rev: 33bea949bae54ddc89aa83cf07d7b1ee62e2b393)

Signed-off-by: Merten Sach <msach@mailbox.tu-berlin.de>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-12-03 12:23:59 +00:00
Richard Purdie b62bdbd135 metadata_scm: Avoid crashing on new svn version layouts
This avoids crashing on newer svn layouts where the entries files
don't contain three lines. If someone wants to fix this to
get the right version on newer subversion checkouts, patches
welcome but this at least stops things crashing.

[YOCTO #5363]

(From OE-Core rev: e850c53d4d8cb877a704a23f9ce02d6185ba3ffa)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-11-24 12:25:36 +00:00
Richard Purdie 566628d8cd class/lib: Fix up various file access methods
There are various bits of cruft that have built up around our file accesses. This patch
cleans some of them up, specifically:

 * Remove pointless "from __builtin__ import file"
 * Use open(), not file()
 * Wrap file usage in a with container to ensure files are closed
 * Add missing .close() calls in some cases

(From OE-Core rev: a43e0a8ecd0441131e929daf998c3cd454d9c8f3)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09 22:28:04 +01:00
Richard Purdie caa8b29c77 metadata_scm: Replace deprecated operator
The <> operator is deprecated, use != instead which is equivalent.

(From OE-Core rev: dde7af5f6c769eae721b1ee18462b841c8ea3277)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09 14:06:51 +01:00
Richard Purdie bfd279de32 Convert tab indentation in python functions into four-space
(From OE-Core rev: 604d46c686d06d62d5a07b9c7f4fa170f99307d8)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-19 10:24:50 +01:00
Richard Purdie 0d9e893711 Revert "meta: replace os.popen with subprocess.Popen"
This reverts commit e83d8e58a6b107eea87df0ec233a1bc932b2c6e as the conversion
is not correct. Its replacing readlines() calls which generate an array with
what are effectively strings. There are split("\n") calls missing in many
cases so this needs to be reverted until it gets fixed.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-05-30 14:21:29 +01:00
Robert Yang 5996b2b58e meta: replace os.popen with subprocess.Popen
Replace os.popen with subprocess.Popen since the older function would
fail (more or less) silently if the executed program cannot be found

There are both bb.process.run() and bb.process.Popen() which wraps the
subprocess module, use it for simplifying the code.

Note: We don't need the "2>/dev/null" or "2>&1" since bb.process.run()
can handle it, it will raise exception when error occurs, we should
handle the exception ourselves if we want to ignore the error.

More info:
http://docs.python.org/library/subprocess.html#subprocess-replacements

[YOCTO #2454]

(From OE-Core rev: e83d8e58a6b107eea87df0ec233a1bc932b2c6ea)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-05-30 12:04:45 +01:00
Richard Purdie 06f2f8ce0a meta: Convert getVar/getVarFlag(xxx, 1) -> (xxx, True)
Using "1" with getVar is bad coding style and "True" is preferred.
This patch is a sed over the meta directory of the form:

sed \
 -e 's:\(\.getVar([^,()]*, \)1 *):\1True):g' \
 -e 's:\(\.getVarFlag([^,()]*, [^,()]*, \)1 *):\1True):g' \
 -i `grep -ril getVar *`

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-05 10:22:56 -08:00
Richard Purdie c8dee9b92d Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:

sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`

(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-10 11:51:19 +00:00
Khem Raj f21b091e34 metadata_scm.bbclass: Use COREBASE to grok for SCM operations
(From OE-Core rev: 17c8c41b837d66bd3cc02c4c60e62dcfc13b80a8)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-11 15:38:33 +01:00
Richard Purdie d5504a4275 metadata_scm: Ensure that if an SCM isn't present, we dont print a revision of 'fatal:' as it looks bad
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-10-21 23:26:40 +01:00
Joe Sauer 47e5d86aad metadata_scm.bbclass: Make errors quiet if we're not in a git based scm
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-06-08 20:54:26 +01:00
Richard Purdie 9c5386c1fd base.bbclass: Split up as per the patch in OE.dev by Chris Larson making code more readable and modularised
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-19 23:12:06 +00:00