From f267dc0391dc0e496847db91a07ca707cfbfff61 Mon Sep 17 00:00:00 2001 From: karfield chen Date: Mon, 22 Jul 2013 11:37:12 +0800 Subject: [PATCH 1/4] add lib/bb/fectcher2/gclient.py Signed-off-by: karfield chen --- lib/bb/fetch2/__init__.py | 2 + lib/bb/fetch2/gclient.py | 78 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 lib/bb/fetch2/gclient.py diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index 6211cd7f5dc..c16e07bb038 100644 --- a/lib/bb/fetch2/__init__.py +++ b/lib/bb/fetch2/__init__.py @@ -1521,6 +1521,7 @@ def clean(self, urls = []): from . import hg from . import osc from . import repo +from . import gclient methods.append(local.Local()) methods.append(wget.Wget()) @@ -1536,3 +1537,4 @@ def clean(self, urls = []): methods.append(hg.Hg()) methods.append(osc.Osc()) methods.append(repo.Repo()) +methods.append(gclient.Gclient()) diff --git a/lib/bb/fetch2/gclient.py b/lib/bb/fetch2/gclient.py new file mode 100644 index 00000000000..e969d48035b --- /dev/null +++ b/lib/bb/fetch2/gclient.py @@ -0,0 +1,78 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +""" +BitBake 'Fetch' gclient implementation + +Copyright (C) 2013, Karfield Chen. All rights reserved. + +""" + +import os +import bb +from bb import data +from bb.fetch2 import FetchMethod +from bb.fetch2 import runfetchcmd +from bb.fetch2 import logger + +class Gclient(FetchMethod): + """Class for sync code from depot-based repositories""" + def init(self, d): + pass + + def supports(self, url, ud, d): + """ + Check to see if a given url starts with "depot" or "gclient". + """ + return ud.type in ["depot", "gclient"] + + def supports_checksum(self, urldata): + """ + checksum? needn't. + """ + return False + + def urldata_init(self, ud, d): + """ + supported options: + name: package name + """ + ud.name = ud.parm.get('name', '') + ud.njobs = ud.parm.get('jobs', '1') + ud.packname = "gclient_%s%s_%s" % (ud.host, ud.path.replace("/", "."), ud.name) + ud.localfile = data.expand("%s.tar.gz" % ud.packname, d) + + def download(self, loc, ud, d): + """ + do fetch + """ + # if the package has been downloaded, just return + if os.access(os.path.join(data.getVar("DL_DIR", d, True), ud.localfile), os.R_OK): + logger.debug(1, "%s already exists (or was stashed). Skipping gclient sync.", ud.localpath) + return + + depot_dir = data.getVar("DEPOTDIR", d, True) or os.path.join(data.getVar("DL_DIR", d, True), "depot") + sync_dir = os.path.join(depot_dir, ud.packname) + + bb.utils.mkdirhier(sync_dir) + os.chdir(sync_dir) + + if not os.path.exists(os.path.join(sync_dir, ".gclient")): + logger.info('This is the first time to sync this depot, config it as htttp://%s%s' + % (ud.host, ud.path)) + runfetchcmd('gclient config http://%s%s' % (ud.host, ud.path), d) + + logger.info('Start to sync source code..') + runfetchcmd('gclient fetch --jobs %s' % ud.njobs, d) + + logger.info('Creating tarball %s.' % ud.localfile) + runfetchcmd('tar --exclude .svn --exclude .git -czf %s ./' % + os.path.join(data.getVar("DL_DIR", d, True), ud.localfile), d) + + def supports_srcrev(self): + return False + + def _build_revision(self, url, ud, d): + return None + + def _want_sortable_revision(self, url, ud, d): + return False From 7b5e0b188e5bc51fa7e5e762101636055127dee3 Mon Sep 17 00:00:00 2001 From: Karfield Date: Mon, 22 Jul 2013 11:41:44 +0800 Subject: [PATCH 2/4] Create README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000000..916c6b5634f --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +BitBake +======= + +BitBake is a simple tool for the execution of tasks. It is derived from Portage, which is the package management system used by the Gentoo Linux distribution. It is most commonly used to build packages, and is used as the basis of the OpenEmbedded project. + +BitBake is now managed using the Git source control system which can be obtained from git://git.openembedded.org/bitbake.git. Releases can be downloaded from http://downloads.yoctoproject.org/releases/bitbake/ and the developer mailing list, bitbake-devel can be found at http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/bitbake-devel. + +The user manual is found in the docmentation directory within the source code. + +Karfield's addition +=================== + +1. add gclient fetcher. So the bitbake can support to sync chromium-based project such as chromium, libjingle etc. + To use this, the SRC_URI for example, could write like this + SRC_URI = "gclient://libjingle.googlecode.com/svn/trunk;name=libjingle;jobs=8". From d302fb77bab6758de5eb15cc4dfb327dc0044917 Mon Sep 17 00:00:00 2001 From: Karfield Date: Mon, 22 Jul 2013 13:17:55 +0800 Subject: [PATCH 3/4] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 916c6b5634f..df9f3dff1b4 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,5 @@ Karfield's addition 1. add gclient fetcher. So the bitbake can support to sync chromium-based project such as chromium, libjingle etc. To use this, the SRC_URI for example, could write like this + SRC_URI = "gclient://libjingle.googlecode.com/svn/trunk;name=libjingle;jobs=8". From 3c99b30525d5d2bd2212596fbf9461c1aceb50d3 Mon Sep 17 00:00:00 2001 From: karfield chen Date: Wed, 24 Jul 2013 17:07:19 +0800 Subject: [PATCH 4/4] fix parse bug: bitbake did not support to append comments to a line Signed-off-by: karfield chen --- lib/bb/parse/parse_py/ConfHandler.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/bb/parse/parse_py/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py index 7d4a5b14a71..3692f4202b1 100644 --- a/lib/bb/parse/parse_py/ConfHandler.py +++ b/lib/bb/parse/parse_py/ConfHandler.py @@ -128,6 +128,21 @@ def handle(fn, data, include): if not w: continue s = s.rstrip() + if s[0] == '#': continue # skip comments + def strip_comments(_s): + c1 = re.findall('\".*\"', _s) # used for check + v = _s.split('#') + if len(v) > 1: # we found some comments + _v = v[-1] + del v[-1] + _s = '#'.join(v).rstrip('#') + if re.findall('\".*\"', _s) != c1: + # we remove the expr, roll back + return '%s#%s' % (_s, _v.rstrip()) + return strip_comments(_s) + else: + return '#'.join(v).rstrip('[# ]') + s = strip_comments(s) while s[-1] == '\\': s2 = f.readline().strip() lineno = lineno + 1