aboutsummaryrefslogtreecommitdiffstats
path: root/rrs/tools/common.py
blob: ee72d97297e90e04268e8ad08e97a2fbfcd9afd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Common functionality for RRS tools. 
#
# Copyright (C) 2015 Intel Corporation
# Author: Anibal Limon <anibal.limon@linux.intel.com>
#
# Licensed under the MIT license, see COPYING.MIT for details

def common_setup():
    import sys, os
    sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '../../')))

def update_repo(fetchdir, repo_name, repo_url, pull, logger):
    import os
    from layerindex import utils, recipeparse

    path = os.path.join(fetchdir, repo_name)

    logger.info("Fetching %s from remote repository %s"
                    % (repo_name, repo_url))
    if not os.path.exists(path):
        out = utils.runcmd("git clone %s %s" % (repo_url, repo_name),
                fetchdir, logger = logger)
    elif pull == True:
        out = utils.runcmd("git pull", path, logger = logger)
    else:
        out = utils.runcmd("git fetch", path, logger = logger)

    return path

def get_pv_type(pv):
    pv_type = ''
    if '+git' in pv:
        pv_type = 'git'
    elif '+svn' in pv:
        pv_type = 'svn'
    elif '+hg' in pv:
        pv_type = 'hg'

    return pv_type