From 31c2120edda4921f658a74a618096e5690f17b12 Mon Sep 17 00:00:00 2001 From: Aníbal Limón Date: Wed, 1 Jul 2015 10:27:57 -0500 Subject: rrs/tools/common.py: Add library with common functionality. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aníbal Limón --- rrs/tools/common.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 rrs/tools/common.py (limited to 'rrs/tools/common.py') diff --git a/rrs/tools/common.py b/rrs/tools/common.py new file mode 100644 index 0000000000..5922ce9ee9 --- /dev/null +++ b/rrs/tools/common.py @@ -0,0 +1,28 @@ +# Common functionality for RRS tools. +# +# Copyright (C) 2015 Intel Corporation +# Author: Anibal Limon +# +# 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 -- cgit 1.2.3-korg