rrs/tools.py: Create standalone get_recipe_pv_without_srcpv function.

Copied get_recipe_pv_without_srcpv from oe-core/recipeutils library
to avoid import errors caused by have imported twice oe-core from poky
and from tinfoil.

rrs/tools/rrs_upgrade_history.py: Update to use get_recipe_pv_without_srcpv
from common.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
Aníbal Limón 2015-07-07 12:00:05 -05:00
parent d75b296349
commit 488a2351ad
2 changed files with 28 additions and 8 deletions

View File

@ -128,3 +128,27 @@ def load_recipes(layerbranch, bitbakepath, fetchdir, settings, logger,
continue
return (tinfoil, d, recipes)
# XXX: Copied from oe-core recipeutils to avoid import errors.
def get_recipe_pv_without_srcpv(pv, uri_type):
"""
Get PV without SRCPV common in SCM's for now only
support git.
Returns tuple with pv, prefix and suffix.
"""
import re
pfx = ''
sfx = ''
if uri_type == 'git':
git_regex = re.compile("(?P<pfx>(v|))(?P<ver>((\d+[\.\-_]*)+))(?P<sfx>(\+|)(git|)(r|)(AUTOINC|)(\+|))(?P<rev>.*)")
m = git_regex.match(pv)
if m:
pv = m.group('ver')
pfx = m.group('pfx')
sfx = m.group('sfx')
return (pv, pfx, sfx)

View File

@ -40,14 +40,6 @@ sys.path.insert(0, os.path.join(bitbakepath, 'lib'))
from bb import BBHandledException
from bb.utils import vercmp_string
# setup poky/oecore
pokypath = update_repo(settings.LAYER_FETCH_DIR, 'poky', settings.POKY_REPO_URL,
True, logger)
# XXX: To use oe-core libraries from poky because the layer oe-core
# is checkout an old revision.
sys.path.insert(0, os.path.join(pokypath, 'meta', 'lib'))
from oe.recipeutils import get_recipe_pv_without_srcpv
"""
Store upgrade into RecipeUpgrade model.
"""
@ -102,6 +94,8 @@ def _create_upgrade(recipe_data, layerbranch, ct, title, info, logger, initial=F
logger.debug("%s: Initial upgrade ( -> %s)." % (recipe.pn, pv))
_save_upgrade(recipe, pv, ct, title, info, logger)
else:
from common import get_recipe_pv_without_srcpv
(ppv, _, _) = get_recipe_pv_without_srcpv(prev_pv,
get_pv_type(prev_pv))
(npv, _, _) = get_recipe_pv_without_srcpv(pv,
@ -189,6 +183,7 @@ def upgrade_history(options, logger):
ct = commit_list.pop(0)
utils.runcmd("git checkout %s -b %s -f" % (ct, branch_name_tmp),
repodir, logger=logger)
utils.runcmd("git clean -dfx", repodir, logger=logger)
(tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath,
fetchdir, settings, logger, nocheckout=True)
@ -208,6 +203,7 @@ def upgrade_history(options, logger):
utils.runcmd("git checkout %s -b %s -f" % (ct, branch_name_tmp),
repodir, logger=logger)
utils.runcmd("git clean -dfx", repodir, logger=logger)
fns = _get_recipes_filenames(ct, repodir, layerdir, logger)
if not fns: