Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for gclient fetcher, support for comments that appended to a line #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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".
2 changes: 2 additions & 0 deletions lib/bb/fetch2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -1536,3 +1537,4 @@ def clean(self, urls = []):
methods.append(hg.Hg())
methods.append(osc.Osc())
methods.append(repo.Repo())
methods.append(gclient.Gclient())
78 changes: 78 additions & 0 deletions lib/bb/fetch2/gclient.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions lib/bb/parse/parse_py/ConfHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down