2011-01-10 14:23:36 +00:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
"""
|
|
|
|
BitBake 'Fetch' git implementation
|
|
|
|
|
2011-05-24 06:22:52 +00:00
|
|
|
git fetcher support the SRC_URI with format of:
|
|
|
|
SRC_URI = "git://some.host/somepath;OptionA=xxx;OptionB=xxx;..."
|
|
|
|
|
|
|
|
Supported SRC_URI options are:
|
|
|
|
|
|
|
|
- branch
|
|
|
|
The git branch to retrieve from. The default is "master"
|
|
|
|
|
2012-12-13 16:06:29 +00:00
|
|
|
This option also supports multiple branch fetching, with branches
|
|
|
|
separated by commas. In multiple branches case, the name option
|
2011-05-24 06:22:52 +00:00
|
|
|
must have the same number of names to match the branches, which is
|
|
|
|
used to specify the SRC_REV for the branch
|
|
|
|
e.g:
|
|
|
|
SRC_URI="git://some.host/somepath;branch=branchX,branchY;name=nameX,nameY"
|
|
|
|
SRCREV_nameX = "xxxxxxxxxxxxxxxxxxxx"
|
|
|
|
SRCREV_nameY = "YYYYYYYYYYYYYYYYYYYY"
|
|
|
|
|
|
|
|
- tag
|
|
|
|
The git tag to retrieve. The default is "master"
|
|
|
|
|
|
|
|
- protocol
|
|
|
|
The method to use to access the repository. Common options are "git",
|
2012-12-13 16:06:29 +00:00
|
|
|
"http", "https", "file", "ssh" and "rsync". The default is "git".
|
2011-05-24 06:22:52 +00:00
|
|
|
|
|
|
|
- rebaseable
|
|
|
|
rebaseable indicates that the upstream git repo may rebase in the future,
|
|
|
|
and current revision may disappear from upstream repo. This option will
|
2012-12-13 16:06:29 +00:00
|
|
|
remind fetcher to preserve local cache carefully for future use.
|
|
|
|
The default value is "0", set rebaseable=1 for rebaseable git repo.
|
2011-05-24 06:22:52 +00:00
|
|
|
|
|
|
|
- nocheckout
|
|
|
|
Don't checkout source code when unpacking. set this option for the recipe
|
|
|
|
who has its own routine to checkout code.
|
|
|
|
The default is "0", set nocheckout=1 if needed.
|
|
|
|
|
2012-02-23 21:08:42 +00:00
|
|
|
- bareclone
|
|
|
|
Create a bare clone of the source code and don't checkout the source code
|
|
|
|
when unpacking. Set this option for the recipe who has its own routine to
|
|
|
|
checkout code and tracking branch requirements.
|
|
|
|
The default is "0", set bareclone=1 if needed.
|
|
|
|
|
2014-01-08 10:17:08 +00:00
|
|
|
- nobranch
|
|
|
|
Don't check the SHA validation for branch. set this option for the recipe
|
|
|
|
referring to commit which is valid in tag instead of branch.
|
|
|
|
The default is "0", set nobranch=1 if needed.
|
|
|
|
|
2016-08-18 16:12:01 +00:00
|
|
|
- usehead
|
2017-02-13 11:38:47 +00:00
|
|
|
For local git:// urls to use the current branch HEAD as the revision for use with
|
2016-08-18 16:12:01 +00:00
|
|
|
AUTOREV. Implies nobranch.
|
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
#Copyright (C) 2005 Richard Purdie
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
2015-09-18 16:35:22 +00:00
|
|
|
import errno
|
2011-01-10 14:23:36 +00:00
|
|
|
import os
|
2014-11-05 18:10:28 +00:00
|
|
|
import re
|
2011-01-10 14:23:36 +00:00
|
|
|
import bb
|
2016-01-11 09:32:28 +00:00
|
|
|
import errno
|
2016-07-06 04:26:10 +00:00
|
|
|
import bb.progress
|
2011-02-04 10:49:27 +00:00
|
|
|
from bb.fetch2 import FetchMethod
|
2011-01-10 18:05:07 +00:00
|
|
|
from bb.fetch2 import runfetchcmd
|
|
|
|
from bb.fetch2 import logger
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2016-07-06 04:26:10 +00:00
|
|
|
|
|
|
|
class GitProgressHandler(bb.progress.LineFilterProgressHandler):
|
|
|
|
"""Extract progress information from git output"""
|
|
|
|
def __init__(self, d):
|
|
|
|
self._buffer = ''
|
|
|
|
self._count = 0
|
|
|
|
super(GitProgressHandler, self).__init__(d)
|
|
|
|
# Send an initial progress event so the bar gets shown
|
|
|
|
self._fire_progress(-1)
|
|
|
|
|
|
|
|
def write(self, string):
|
|
|
|
self._buffer += string
|
|
|
|
stages = ['Counting objects', 'Compressing objects', 'Receiving objects', 'Resolving deltas']
|
|
|
|
stage_weights = [0.2, 0.05, 0.5, 0.25]
|
|
|
|
stagenum = 0
|
|
|
|
for i, stage in reversed(list(enumerate(stages))):
|
|
|
|
if stage in self._buffer:
|
|
|
|
stagenum = i
|
|
|
|
self._buffer = ''
|
|
|
|
break
|
|
|
|
self._status = stages[stagenum]
|
|
|
|
percs = re.findall(r'(\d+)%', string)
|
|
|
|
if percs:
|
|
|
|
progress = int(round((int(percs[-1]) * stage_weights[stagenum]) + (sum(stage_weights[:stagenum]) * 100)))
|
|
|
|
rates = re.findall(r'([\d.]+ [a-zA-Z]*/s+)', string)
|
|
|
|
if rates:
|
|
|
|
rate = rates[-1]
|
|
|
|
else:
|
|
|
|
rate = None
|
|
|
|
self.update(progress, rate)
|
|
|
|
else:
|
|
|
|
if stagenum == 0:
|
|
|
|
percs = re.findall(r': (\d+)', string)
|
|
|
|
if percs:
|
|
|
|
count = int(percs[-1])
|
|
|
|
if count > self._count:
|
|
|
|
self._count = count
|
|
|
|
self._fire_progress(-count)
|
|
|
|
super(GitProgressHandler, self).write(string)
|
|
|
|
|
|
|
|
|
2011-02-04 10:49:27 +00:00
|
|
|
class Git(FetchMethod):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""Class to fetch a module or modules from git repositories"""
|
|
|
|
def init(self, d):
|
2012-12-05 08:58:26 +00:00
|
|
|
pass
|
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def supports(self, ud, d):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
|
|
|
Check to see if a given url can be fetched with git.
|
|
|
|
"""
|
|
|
|
return ud.type in ['git']
|
|
|
|
|
2012-05-15 19:49:36 +00:00
|
|
|
def supports_checksum(self, urldata):
|
|
|
|
return False
|
|
|
|
|
2010-12-27 01:50:25 +00:00
|
|
|
def urldata_init(self, ud, d):
|
|
|
|
"""
|
|
|
|
init git specific variable within url data
|
|
|
|
so that the git method like latest_revision() can work
|
|
|
|
"""
|
2011-01-10 14:23:36 +00:00
|
|
|
if 'protocol' in ud.parm:
|
|
|
|
ud.proto = ud.parm['protocol']
|
|
|
|
elif not ud.host:
|
|
|
|
ud.proto = 'file'
|
|
|
|
else:
|
2011-05-24 07:41:14 +00:00
|
|
|
ud.proto = "git"
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2011-08-21 17:38:59 +00:00
|
|
|
if not ud.proto in ('git', 'file', 'ssh', 'http', 'https', 'rsync'):
|
2011-06-19 23:15:25 +00:00
|
|
|
raise bb.fetch2.ParameterError("Invalid protocol type", ud.url)
|
|
|
|
|
2011-05-26 07:29:37 +00:00
|
|
|
ud.nocheckout = ud.parm.get("nocheckout","0") == "1"
|
2011-02-02 12:48:32 +00:00
|
|
|
|
git fetcher: add support for rebaseable git repo
Some upstream git repo may rebase in the future, which means current
revision may disappear from the upstream repo after the rebase.
current git fetcher can not handle this case, because the git mirror
tar ball is per repo, and may also change in the rebase and lost the
current revision info.
To fix this issue, this patch
- add rebaseable tag in the SRC_URI
- for rebaseable repo, make git mirror tar ball per revision, in this
case, even upstream rebase, the git mirror still has the current
revision info.
- for rebaseable repo, generate mirror tar ball by default, since the
repo may change in the future.
(Bitbake rev: 92701d4c5372db48847c70da4ebd0736d79fd54b)
Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-15 14:33:30 +00:00
|
|
|
ud.rebaseable = ud.parm.get("rebaseable","0") == "1"
|
|
|
|
|
2014-01-07 10:45:34 +00:00
|
|
|
ud.nobranch = ud.parm.get("nobranch","0") == "1"
|
|
|
|
|
2016-08-18 16:12:01 +00:00
|
|
|
# usehead implies nobranch
|
|
|
|
ud.usehead = ud.parm.get("usehead","0") == "1"
|
|
|
|
if ud.usehead:
|
|
|
|
if ud.proto != "file":
|
|
|
|
raise bb.fetch2.ParameterError("The usehead option is only for use with local ('protocol=file') git repositories", ud.url)
|
|
|
|
ud.nobranch = 1
|
|
|
|
|
2012-02-23 21:08:42 +00:00
|
|
|
# bareclone implies nocheckout
|
|
|
|
ud.bareclone = ud.parm.get("bareclone","0") == "1"
|
|
|
|
if ud.bareclone:
|
|
|
|
ud.nocheckout = 1
|
|
|
|
|
2013-12-12 16:48:54 +00:00
|
|
|
ud.unresolvedrev = {}
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
branches = ud.parm.get("branch", "master").split(',')
|
|
|
|
if len(branches) != len(ud.names):
|
2011-02-04 10:26:21 +00:00
|
|
|
raise bb.fetch2.ParameterError("The number of name and branch parameters is not balanced", ud.url)
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
ud.branches = {}
|
2017-03-21 18:41:01 +00:00
|
|
|
for pos, name in enumerate(ud.names):
|
|
|
|
branch = branches[pos]
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
ud.branches[name] = branch
|
2013-12-12 16:48:54 +00:00
|
|
|
ud.unresolvedrev[name] = branch
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2016-08-18 16:12:01 +00:00
|
|
|
if ud.usehead:
|
|
|
|
ud.unresolvedrev['default'] = 'HEAD'
|
|
|
|
|
2016-11-25 15:28:08 +00:00
|
|
|
ud.basecmd = d.getVar("FETCHCMD_git") or "git -c core.fsyncobjectfiles=0"
|
2010-12-27 01:50:25 +00:00
|
|
|
|
2016-11-25 15:28:08 +00:00
|
|
|
ud.write_tarballs = ((d.getVar("BB_GENERATE_MIRROR_TARBALLS") or "0") != "0") or ud.rebaseable
|
2011-04-19 22:31:09 +00:00
|
|
|
|
2017-02-13 11:50:29 +00:00
|
|
|
ud.setup_revisions(d)
|
2011-04-20 01:13:23 +00:00
|
|
|
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
for name in ud.names:
|
2011-02-08 09:27:59 +00:00
|
|
|
# Ensure anything that doesn't look like a sha256 checksum/revision is translated into one
|
|
|
|
if not ud.revisions[name] or len(ud.revisions[name]) != 40 or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]):
|
2012-05-11 17:14:40 +00:00
|
|
|
if ud.revisions[name]:
|
2013-12-12 16:48:54 +00:00
|
|
|
ud.unresolvedrev[name] = ud.revisions[name]
|
2013-11-25 10:33:50 +00:00
|
|
|
ud.revisions[name] = self.latest_revision(ud, d, name)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2015-08-26 16:37:45 +00:00
|
|
|
gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.'))
|
|
|
|
if gitsrcname.startswith('.'):
|
|
|
|
gitsrcname = gitsrcname[1:]
|
|
|
|
|
git fetcher: add support for rebaseable git repo
Some upstream git repo may rebase in the future, which means current
revision may disappear from the upstream repo after the rebase.
current git fetcher can not handle this case, because the git mirror
tar ball is per repo, and may also change in the rebase and lost the
current revision info.
To fix this issue, this patch
- add rebaseable tag in the SRC_URI
- for rebaseable repo, make git mirror tar ball per revision, in this
case, even upstream rebase, the git mirror still has the current
revision info.
- for rebaseable repo, generate mirror tar ball by default, since the
repo may change in the future.
(Bitbake rev: 92701d4c5372db48847c70da4ebd0736d79fd54b)
Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-15 14:33:30 +00:00
|
|
|
# for rebaseable git repo, it is necessary to keep mirror tar ball
|
|
|
|
# per revision, so that even the revision disappears from the
|
|
|
|
# upstream repo in the future, the mirror will remain intact and still
|
|
|
|
# contains the revision
|
|
|
|
if ud.rebaseable:
|
|
|
|
for name in ud.names:
|
|
|
|
gitsrcname = gitsrcname + '_' + ud.revisions[name]
|
2017-03-21 18:41:02 +00:00
|
|
|
ud.mirrortarball = 'git2_%s.tar.gz' % gitsrcname
|
2016-11-25 15:28:08 +00:00
|
|
|
ud.fullmirror = os.path.join(d.getVar("DL_DIR"), ud.mirrortarball)
|
|
|
|
gitdir = d.getVar("GITDIR") or (d.getVar("DL_DIR") + "/git2/")
|
2012-05-11 17:15:16 +00:00
|
|
|
ud.clonedir = os.path.join(gitdir, gitsrcname)
|
git fetcher: add support for rebaseable git repo
Some upstream git repo may rebase in the future, which means current
revision may disappear from the upstream repo after the rebase.
current git fetcher can not handle this case, because the git mirror
tar ball is per repo, and may also change in the rebase and lost the
current revision info.
To fix this issue, this patch
- add rebaseable tag in the SRC_URI
- for rebaseable repo, make git mirror tar ball per revision, in this
case, even upstream rebase, the git mirror still has the current
revision info.
- for rebaseable repo, generate mirror tar ball by default, since the
repo may change in the future.
(Bitbake rev: 92701d4c5372db48847c70da4ebd0736d79fd54b)
Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-05-15 14:33:30 +00:00
|
|
|
|
|
|
|
ud.localfile = ud.clonedir
|
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def localpath(self, ud, d):
|
2011-02-07 09:13:44 +00:00
|
|
|
return ud.clonedir
|
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def need_update(self, ud, d):
|
2011-02-07 09:34:24 +00:00
|
|
|
if not os.path.exists(ud.clonedir):
|
|
|
|
return True
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
for name in ud.names:
|
2016-08-10 17:08:16 +00:00
|
|
|
if not self._contains_ref(ud, d, name, ud.clonedir):
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
return True
|
2011-02-10 15:14:49 +00:00
|
|
|
if ud.write_tarballs and not os.path.exists(ud.fullmirror):
|
|
|
|
return True
|
2011-01-10 14:23:36 +00:00
|
|
|
return False
|
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def try_premirror(self, ud, d):
|
2011-02-07 12:08:32 +00:00
|
|
|
# If we don't do this, updating an existing checkout with only premirrors
|
|
|
|
# is not possible
|
2016-11-25 15:28:08 +00:00
|
|
|
if d.getVar("BB_FETCH_PREMIRRORONLY") is not None:
|
2011-02-07 12:08:32 +00:00
|
|
|
return True
|
2011-01-10 14:23:36 +00:00
|
|
|
if os.path.exists(ud.clonedir):
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def download(self, ud, d):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""Fetch url"""
|
|
|
|
|
|
|
|
# If the checkout doesn't exist and the mirror tarball does, extract it
|
2011-02-10 15:14:49 +00:00
|
|
|
if not os.path.exists(ud.clonedir) and os.path.exists(ud.fullmirror):
|
2011-03-02 08:33:49 +00:00
|
|
|
bb.utils.mkdirhier(ud.clonedir)
|
2017-03-21 18:41:02 +00:00
|
|
|
runfetchcmd("tar -xzf %s" % ud.fullmirror, d, workdir=ud.clonedir)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2015-05-14 13:33:49 +00:00
|
|
|
repourl = self._get_repo_url(ud)
|
2011-08-30 20:39:58 +00:00
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
# If the repo still doesn't exist, fallback to cloning it
|
|
|
|
if not os.path.exists(ud.clonedir):
|
2012-06-22 11:52:30 +00:00
|
|
|
# We do this since git will use a "-l" option automatically for local urls where possible
|
2012-06-14 21:44:02 +00:00
|
|
|
if repourl.startswith("file://"):
|
|
|
|
repourl = repourl[7:]
|
2016-07-06 04:26:10 +00:00
|
|
|
clone_cmd = "LANG=C %s clone --bare --mirror %s %s --progress" % (ud.basecmd, repourl, ud.clonedir)
|
2012-05-04 14:05:14 +00:00
|
|
|
if ud.proto.lower() != 'file':
|
2016-11-21 12:31:43 +00:00
|
|
|
bb.fetch2.check_network_access(d, clone_cmd, ud.url)
|
2016-07-06 04:26:10 +00:00
|
|
|
progresshandler = GitProgressHandler(d)
|
|
|
|
runfetchcmd(clone_cmd, d, log=progresshandler)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
|
|
|
# Update the checkout if needed
|
2011-02-03 20:16:05 +00:00
|
|
|
needupdate = False
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
for name in ud.names:
|
2016-08-10 17:08:16 +00:00
|
|
|
if not self._contains_ref(ud, d, name, ud.clonedir):
|
2011-02-03 20:16:05 +00:00
|
|
|
needupdate = True
|
|
|
|
if needupdate:
|
2011-02-05 22:11:25 +00:00
|
|
|
try:
|
2016-08-10 17:08:16 +00:00
|
|
|
runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
|
2011-02-05 22:11:25 +00:00
|
|
|
except bb.fetch2.FetchError:
|
|
|
|
logger.debug(1, "No Origin")
|
2011-08-30 20:39:58 +00:00
|
|
|
|
2016-08-10 17:08:16 +00:00
|
|
|
runfetchcmd("%s remote add --mirror=fetch origin %s" % (ud.basecmd, repourl), d, workdir=ud.clonedir)
|
2016-07-06 04:26:10 +00:00
|
|
|
fetch_cmd = "LANG=C %s fetch -f --prune --progress %s refs/*:refs/*" % (ud.basecmd, repourl)
|
2012-05-04 14:05:14 +00:00
|
|
|
if ud.proto.lower() != 'file':
|
|
|
|
bb.fetch2.check_network_access(d, fetch_cmd, ud.url)
|
2016-07-06 04:26:10 +00:00
|
|
|
progresshandler = GitProgressHandler(d)
|
2016-08-10 17:08:16 +00:00
|
|
|
runfetchcmd(fetch_cmd, d, log=progresshandler, workdir=ud.clonedir)
|
|
|
|
runfetchcmd("%s prune-packed" % ud.basecmd, d, workdir=ud.clonedir)
|
|
|
|
runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d, workdir=ud.clonedir)
|
2015-09-15 20:56:06 +00:00
|
|
|
try:
|
|
|
|
os.unlink(ud.fullmirror)
|
|
|
|
except OSError as exc:
|
|
|
|
if exc.errno != errno.ENOENT:
|
|
|
|
raise
|
2013-12-05 15:21:38 +00:00
|
|
|
for name in ud.names:
|
2016-08-10 17:08:16 +00:00
|
|
|
if not self._contains_ref(ud, d, name, ud.clonedir):
|
2013-12-05 15:21:38 +00:00
|
|
|
raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def build_mirror_data(self, ud, d):
|
2011-01-10 14:23:36 +00:00
|
|
|
# Generate a mirror tarball if needed
|
2015-09-15 20:56:06 +00:00
|
|
|
if ud.write_tarballs and not os.path.exists(ud.fullmirror):
|
2013-05-07 16:39:20 +00:00
|
|
|
# it's possible that this symlink points to read-only filesystem with PREMIRROR
|
|
|
|
if os.path.islink(ud.fullmirror):
|
|
|
|
os.unlink(ud.fullmirror)
|
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
logger.info("Creating tarball of git repository")
|
2017-03-21 18:41:03 +00:00
|
|
|
runfetchcmd("tar -czf %s ." % ud.fullmirror, d, workdir=ud.clonedir)
|
|
|
|
runfetchcmd("touch %s.done" % ud.fullmirror, d)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2011-01-18 16:22:13 +00:00
|
|
|
def unpack(self, ud, destdir, d):
|
|
|
|
""" unpack the downloaded src to destdir"""
|
|
|
|
|
|
|
|
subdir = ud.parm.get("subpath", "")
|
|
|
|
if subdir != "":
|
2017-03-21 18:41:02 +00:00
|
|
|
readpathspec = ":%s" % subdir
|
2015-04-17 05:49:42 +00:00
|
|
|
def_destsuffix = "%s/" % os.path.basename(subdir.rstrip('/'))
|
2011-01-18 16:22:13 +00:00
|
|
|
else:
|
|
|
|
readpathspec = ""
|
2011-09-17 11:03:47 +00:00
|
|
|
def_destsuffix = "git/"
|
2011-01-18 16:22:13 +00:00
|
|
|
|
2011-09-17 11:03:47 +00:00
|
|
|
destsuffix = ud.parm.get("destsuffix", def_destsuffix)
|
2013-03-22 14:18:18 +00:00
|
|
|
destdir = ud.destdir = os.path.join(destdir, destsuffix)
|
2011-01-18 16:22:13 +00:00
|
|
|
if os.path.exists(destdir):
|
|
|
|
bb.utils.prunedir(destdir)
|
|
|
|
|
2012-02-23 21:08:42 +00:00
|
|
|
cloneflags = "-s -n"
|
|
|
|
if ud.bareclone:
|
|
|
|
cloneflags += " --mirror"
|
|
|
|
|
2016-04-05 10:35:51 +00:00
|
|
|
runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, cloneflags, ud.clonedir, destdir), d)
|
2015-05-14 13:33:49 +00:00
|
|
|
repourl = self._get_repo_url(ud)
|
2016-08-10 17:08:16 +00:00
|
|
|
runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d, workdir=destdir)
|
2011-02-02 12:48:32 +00:00
|
|
|
if not ud.nocheckout:
|
2011-05-26 07:37:56 +00:00
|
|
|
if subdir != "":
|
2016-08-10 17:08:16 +00:00
|
|
|
runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d,
|
|
|
|
workdir=destdir)
|
|
|
|
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d, workdir=destdir)
|
2015-07-09 07:18:01 +00:00
|
|
|
elif not ud.nobranch:
|
|
|
|
branchname = ud.branches[ud.names[0]]
|
|
|
|
runfetchcmd("%s checkout -B %s %s" % (ud.basecmd, branchname, \
|
2016-08-10 17:08:16 +00:00
|
|
|
ud.revisions[ud.names[0]]), d, workdir=destdir)
|
2017-09-07 09:15:55 +00:00
|
|
|
runfetchcmd("%s branch %s --set-upstream-to origin/%s" % (ud.basecmd, branchname, \
|
2016-08-10 17:08:16 +00:00
|
|
|
branchname), d, workdir=destdir)
|
2011-05-26 07:37:56 +00:00
|
|
|
else:
|
2016-08-10 17:08:16 +00:00
|
|
|
runfetchcmd("%s checkout %s" % (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=destdir)
|
2015-07-09 07:18:01 +00:00
|
|
|
|
2011-01-18 16:22:13 +00:00
|
|
|
return True
|
|
|
|
|
2011-02-09 22:30:29 +00:00
|
|
|
def clean(self, ud, d):
|
|
|
|
""" clean the git directory """
|
|
|
|
|
|
|
|
bb.utils.remove(ud.localpath, True)
|
|
|
|
bb.utils.remove(ud.fullmirror)
|
2013-12-27 06:51:52 +00:00
|
|
|
bb.utils.remove(ud.fullmirror + ".done")
|
2011-02-09 22:30:29 +00:00
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
def supports_srcrev(self):
|
|
|
|
return True
|
|
|
|
|
2016-08-10 17:08:16 +00:00
|
|
|
def _contains_ref(self, ud, d, name, wd):
|
2014-01-07 10:45:34 +00:00
|
|
|
cmd = ""
|
|
|
|
if ud.nobranch:
|
|
|
|
cmd = "%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (
|
|
|
|
ud.basecmd, ud.revisions[name])
|
|
|
|
else:
|
|
|
|
cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % (
|
|
|
|
ud.basecmd, ud.revisions[name], ud.branches[name])
|
2013-11-18 17:17:16 +00:00
|
|
|
try:
|
2016-08-10 17:08:16 +00:00
|
|
|
output = runfetchcmd(cmd, d, quiet=True, workdir=wd)
|
2013-11-18 17:17:16 +00:00
|
|
|
except bb.fetch2.FetchError:
|
|
|
|
return False
|
2013-11-19 13:08:59 +00:00
|
|
|
if len(output.split()) > 1:
|
|
|
|
raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
|
|
|
|
return output.split()[0] != "0"
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2015-05-14 13:33:49 +00:00
|
|
|
def _get_repo_url(self, ud):
|
|
|
|
"""
|
|
|
|
Return the repository URL
|
|
|
|
"""
|
|
|
|
if ud.user:
|
|
|
|
username = ud.user + '@'
|
|
|
|
else:
|
|
|
|
username = ""
|
|
|
|
return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
|
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def _revision_key(self, ud, d, name):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
|
|
|
Return a unique key for the url
|
|
|
|
"""
|
2013-12-12 16:48:54 +00:00
|
|
|
return "git:" + ud.host + ud.path.replace('/', '.') + ud.unresolvedrev[name]
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2014-02-28 17:22:54 +00:00
|
|
|
def _lsremote(self, ud, d, search):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
2014-02-28 17:22:54 +00:00
|
|
|
Run git ls-remote with the specified search string
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
2017-03-27 00:17:26 +00:00
|
|
|
# Prevent recursion e.g. in OE if SRCPV is in PV, PV is in WORKDIR,
|
|
|
|
# and WORKDIR is in PATH (as a result of RSS), our call to
|
|
|
|
# runfetchcmd() exports PATH so this function will get called again (!)
|
|
|
|
# In this scenario the return call of the function isn't actually
|
|
|
|
# important - WORKDIR isn't needed in PATH to call git ls-remote
|
|
|
|
# anyway.
|
|
|
|
if d.getVar('_BB_GIT_IN_LSREMOTE', False):
|
|
|
|
return ''
|
|
|
|
d.setVar('_BB_GIT_IN_LSREMOTE', '1')
|
|
|
|
try:
|
|
|
|
repourl = self._get_repo_url(ud)
|
|
|
|
cmd = "%s ls-remote %s %s" % \
|
|
|
|
(ud.basecmd, repourl, search)
|
|
|
|
if ud.proto.lower() != 'file':
|
|
|
|
bb.fetch2.check_network_access(d, cmd, repourl)
|
|
|
|
output = runfetchcmd(cmd, d, True)
|
|
|
|
if not output:
|
|
|
|
raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
|
|
|
|
finally:
|
|
|
|
d.delVar('_BB_GIT_IN_LSREMOTE')
|
2014-02-28 17:22:54 +00:00
|
|
|
return output
|
|
|
|
|
|
|
|
def _latest_revision(self, ud, d, name):
|
|
|
|
"""
|
|
|
|
Compute the HEAD revision for the url
|
|
|
|
"""
|
2015-01-08 20:57:45 +00:00
|
|
|
output = self._lsremote(ud, d, "")
|
|
|
|
# Tags of the form ^{} may not work, need to fallback to other form
|
2016-08-18 16:12:01 +00:00
|
|
|
if ud.unresolvedrev[name][:5] == "refs/" or ud.usehead:
|
2015-01-08 20:57:45 +00:00
|
|
|
head = ud.unresolvedrev[name]
|
|
|
|
tag = ud.unresolvedrev[name]
|
2014-11-04 11:29:32 +00:00
|
|
|
else:
|
2015-01-08 20:57:45 +00:00
|
|
|
head = "refs/heads/%s" % ud.unresolvedrev[name]
|
|
|
|
tag = "refs/tags/%s" % ud.unresolvedrev[name]
|
|
|
|
for s in [head, tag + "^{}", tag]:
|
2016-05-23 11:35:49 +00:00
|
|
|
for l in output.strip().split('\n'):
|
|
|
|
sha1, ref = l.split()
|
|
|
|
if s == ref:
|
|
|
|
return sha1
|
2015-05-13 11:24:57 +00:00
|
|
|
raise bb.fetch2.FetchError("Unable to resolve '%s' in upstream git repository in git ls-remote output for %s" % \
|
|
|
|
(ud.unresolvedrev[name], ud.host+ud.path))
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2014-11-05 18:10:28 +00:00
|
|
|
def latest_versionstring(self, ud, d):
|
|
|
|
"""
|
|
|
|
Compute the latest release name like "x.y.x" in "x.y.x+gitHASH"
|
|
|
|
by searching through the tags output of ls-remote, comparing
|
|
|
|
versions and returning the highest match.
|
|
|
|
"""
|
2015-07-15 00:30:57 +00:00
|
|
|
pupver = ('', '')
|
|
|
|
|
2016-11-25 15:28:08 +00:00
|
|
|
tagregex = re.compile(d.getVar('UPSTREAM_CHECK_GITTAGREGEX') or "(?P<pver>([0-9][\.|_]?)+)")
|
2014-11-05 18:10:28 +00:00
|
|
|
try:
|
2015-07-15 00:30:56 +00:00
|
|
|
output = self._lsremote(ud, d, "refs/tags/*")
|
2014-11-05 18:10:28 +00:00
|
|
|
except bb.fetch2.FetchError or bb.fetch2.NetworkAccess:
|
2015-07-15 00:30:57 +00:00
|
|
|
return pupver
|
2014-11-05 18:10:28 +00:00
|
|
|
|
2015-07-15 00:30:57 +00:00
|
|
|
verstring = ""
|
|
|
|
revision = ""
|
2014-11-05 18:10:28 +00:00
|
|
|
for line in output.split("\n"):
|
|
|
|
if not line:
|
|
|
|
break
|
|
|
|
|
2015-07-15 00:30:57 +00:00
|
|
|
tag_head = line.split("/")[-1]
|
2014-11-05 18:10:28 +00:00
|
|
|
# Ignore non-released branches
|
2015-07-15 00:30:57 +00:00
|
|
|
m = re.search("(alpha|beta|rc|final)+", tag_head)
|
2014-11-05 18:10:28 +00:00
|
|
|
if m:
|
|
|
|
continue
|
|
|
|
|
|
|
|
# search for version in the line
|
2015-07-15 00:30:57 +00:00
|
|
|
tag = tagregex.search(tag_head)
|
2014-11-05 18:10:28 +00:00
|
|
|
if tag == None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
tag = tag.group('pver')
|
|
|
|
tag = tag.replace("_", ".")
|
|
|
|
|
|
|
|
if verstring and bb.utils.vercmp(("0", tag, ""), ("0", verstring, "")) < 0:
|
|
|
|
continue
|
2015-07-15 00:30:57 +00:00
|
|
|
|
2014-11-05 18:10:28 +00:00
|
|
|
verstring = tag
|
2015-07-15 00:30:57 +00:00
|
|
|
revision = line.split()[0]
|
|
|
|
pupver = (verstring, revision)
|
2014-11-05 18:10:28 +00:00
|
|
|
|
2015-07-15 00:30:57 +00:00
|
|
|
return pupver
|
2014-11-05 18:10:28 +00:00
|
|
|
|
2013-11-19 14:32:08 +00:00
|
|
|
def _build_revision(self, ud, d, name):
|
fetch2: Allow multiple src rev to be used in one src_uri
* SRC_URI format:
the SRC_URI are extended to allow multiple src rev:
name=<name1>,<name2>,...<name-n>
branch=<branch1>,<branch2>,...,<branch-n>
also SRCREV can be defined with
SRCREV_<name1> = xxxxx
SRCREV_<name2> = xxxxx
* FetchData extention
to support multiple src rev, several FetchData data are added:
- FetchData.names: list of name in SRC_URI, one name per srcrev. name is the index of revision and branch
- FetchData.revisions: dictionary of name->revision.
- FetchData.branches: dictionary of name->branch.
For example, linux-yocto recipes becomes:
SRC_URI = "git://git.pokylinux.org/linux-yocto-2.6.37;protocol=git;branch=${KBRANCH},meta;name=machine,meta"
FetchData.names = ['machine', 'meta']
FetchData.revisions = { 'machine':xxxxx, 'meta':xxxxxx }
FetchData.branches = { 'machine':${KBRANCH}, 'meta':'meta'}
* generic revision handling extension
the related revision handling code in fetch2.__init__.py are changed accordingly. the major change is add name parameter to indicate which src rev to handling. originally there is one src rev per FetchData, so FetchData parameter is enough. now since one FetchData has multiple src rev, it is necessary to use FetchData + name to specifiy src rev.
* git extension
git fetcher are also revised to take advantage of the multiple src rev in FetchData. especially the download() method are enhanced to fetch multiple src rev.
* other fetcher (svn, hg, ...) does not support multiple src rev. they just sync the API to add name, and then simply ignore the name. no actually functional change
Signed-off-by: Yu Ke <ke.yu@intel.com>
2011-01-26 12:14:06 +00:00
|
|
|
return ud.revisions[name]
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2015-05-22 06:29:04 +00:00
|
|
|
def gitpkgv_revision(self, ud, d, name):
|
|
|
|
"""
|
|
|
|
Return a sortable revision number by counting commits in the history
|
|
|
|
Based on gitpkgv.bblass in meta-openembedded
|
|
|
|
"""
|
|
|
|
rev = self._build_revision(ud, d, name)
|
|
|
|
localpath = ud.localpath
|
|
|
|
rev_file = os.path.join(localpath, "oe-gitpkgv_" + rev)
|
|
|
|
if not os.path.exists(localpath):
|
|
|
|
commits = None
|
|
|
|
else:
|
|
|
|
if not os.path.exists(rev_file) or not os.path.getsize(rev_file):
|
|
|
|
from pipes import quote
|
|
|
|
commits = bb.fetch2.runfetchcmd(
|
2017-03-21 18:41:02 +00:00
|
|
|
"git rev-list %s -- | wc -l" % quote(rev),
|
2015-05-22 06:29:04 +00:00
|
|
|
d, quiet=True).strip().lstrip('0')
|
|
|
|
if commits:
|
|
|
|
open(rev_file, "w").write("%d\n" % int(commits))
|
|
|
|
else:
|
|
|
|
commits = open(rev_file, "r").readline(128).strip()
|
|
|
|
if commits:
|
|
|
|
return False, "%s+%s" % (commits, rev[:7])
|
|
|
|
else:
|
|
|
|
return True, str(rev)
|
|
|
|
|
2015-06-30 14:39:11 +00:00
|
|
|
def checkstatus(self, fetch, ud, d):
|
2011-08-24 20:04:23 +00:00
|
|
|
try:
|
2015-04-02 12:24:51 +00:00
|
|
|
self._lsremote(ud, d, "")
|
2011-08-24 20:04:23 +00:00
|
|
|
return True
|
2017-03-21 18:41:04 +00:00
|
|
|
except bb.fetch2.FetchError:
|
2011-08-24 20:04:23 +00:00
|
|
|
return False
|