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.
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import bb
|
|
|
|
from bb import data
|
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
|
|
|
|
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
|
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
def supports(self, url, ud, d):
|
|
|
|
"""
|
|
|
|
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"
|
|
|
|
|
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
|
|
|
|
|
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 = {}
|
|
|
|
for name in ud.names:
|
|
|
|
branch = branches[ud.names.index(name)]
|
|
|
|
ud.branches[name] = branch
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2010-12-27 01:50:25 +00:00
|
|
|
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
|
|
|
|
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.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0") or ud.rebaseable
|
2011-04-19 22:31:09 +00:00
|
|
|
|
2011-04-20 01:13:23 +00:00
|
|
|
ud.setup_revisons(d)
|
|
|
|
|
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]:
|
|
|
|
ud.branches[name] = ud.revisions[name]
|
2011-02-08 09:33:52 +00:00
|
|
|
ud.revisions[name] = self.latest_revision(ud.url, ud, d, name)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2012-06-22 11:53:56 +00:00
|
|
|
gitsrcname = '%s%s' % (ud.host.replace(':','.'), ud.path.replace('/', '.').replace('*', '.'))
|
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]
|
|
|
|
ud.mirrortarball = 'git2_%s.tar.gz' % (gitsrcname)
|
2012-05-11 17:15:16 +00:00
|
|
|
ud.fullmirror = os.path.join(d.getVar("DL_DIR", True), ud.mirrortarball)
|
|
|
|
gitdir = d.getVar("GITDIR", True) or (d.getVar("DL_DIR", True) + "/git2/")
|
|
|
|
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
|
|
|
|
|
2011-02-07 09:13:44 +00:00
|
|
|
def localpath(self, url, ud, d):
|
|
|
|
return ud.clonedir
|
|
|
|
|
2011-02-07 12:08:32 +00:00
|
|
|
def need_update(self, u, ud, d):
|
2011-02-07 09:34:24 +00:00
|
|
|
if not os.path.exists(ud.clonedir):
|
|
|
|
return True
|
|
|
|
os.chdir(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
|
|
|
for name in ud.names:
|
|
|
|
if not self._contains_ref(ud.revisions[name], d):
|
|
|
|
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
|
|
|
|
|
|
|
|
def try_premirror(self, u, 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
|
2011-11-25 14:57:53 +00:00
|
|
|
if d.getVar("BB_FETCH_PREMIRRORONLY", True) 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
|
|
|
|
|
2011-01-18 15:03:53 +00:00
|
|
|
def download(self, loc, ud, d):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""Fetch url"""
|
|
|
|
|
|
|
|
if ud.user:
|
|
|
|
username = ud.user + '@'
|
|
|
|
else:
|
|
|
|
username = ""
|
|
|
|
|
2011-02-10 15:14:49 +00:00
|
|
|
ud.repochanged = not os.path.exists(ud.fullmirror)
|
2011-01-18 16:58:42 +00:00
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
# 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)
|
2011-01-10 14:23:36 +00:00
|
|
|
os.chdir(ud.clonedir)
|
2011-02-10 15:14:49 +00:00
|
|
|
runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2011-08-30 20:39:58 +00:00
|
|
|
repourl = "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
|
|
|
|
|
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:]
|
2012-06-22 11:52:30 +00:00
|
|
|
clone_cmd = "%s clone --bare --mirror %s %s" % (ud.basecmd, repourl, ud.clonedir)
|
2012-05-04 14:05:14 +00:00
|
|
|
if ud.proto.lower() != 'file':
|
|
|
|
bb.fetch2.check_network_access(d, clone_cmd)
|
2011-05-20 23:06:12 +00:00
|
|
|
runfetchcmd(clone_cmd, d)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
|
|
|
os.chdir(ud.clonedir)
|
|
|
|
# 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:
|
|
|
|
if not self._contains_ref(ud.revisions[name], d):
|
2011-02-03 20:16:05 +00:00
|
|
|
needupdate = True
|
|
|
|
if needupdate:
|
2011-02-05 22:11:25 +00:00
|
|
|
try:
|
|
|
|
runfetchcmd("%s remote rm origin" % ud.basecmd, d)
|
|
|
|
except bb.fetch2.FetchError:
|
|
|
|
logger.debug(1, "No Origin")
|
2011-08-30 20:39:58 +00:00
|
|
|
|
|
|
|
runfetchcmd("%s remote add --mirror=fetch origin %s" % (ud.basecmd, repourl), d)
|
2011-09-27 21:41:39 +00:00
|
|
|
fetch_cmd = "%s fetch -f --prune %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)
|
2011-05-20 23:06:12 +00:00
|
|
|
runfetchcmd(fetch_cmd, d)
|
2011-02-03 20:16:05 +00:00
|
|
|
runfetchcmd("%s prune-packed" % ud.basecmd, d)
|
|
|
|
runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
|
|
|
|
ud.repochanged = True
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2011-01-18 15:35:30 +00:00
|
|
|
def build_mirror_data(self, url, ud, d):
|
2011-01-10 14:23:36 +00:00
|
|
|
# Generate a mirror tarball if needed
|
2011-02-10 15:14:49 +00:00
|
|
|
if ud.write_tarballs and (ud.repochanged or 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-02-10 15:14:49 +00:00
|
|
|
os.chdir(ud.clonedir)
|
2011-01-10 14:23:36 +00:00
|
|
|
logger.info("Creating tarball of git repository")
|
2011-02-10 15:14:49 +00:00
|
|
|
runfetchcmd("tar -czf %s %s" % (ud.fullmirror, os.path.join(".") ), d)
|
2012-03-23 14:52:23 +00:00
|
|
|
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 != "":
|
|
|
|
readpathspec = ":%s" % (subdir)
|
2011-09-17 11:03:47 +00:00
|
|
|
def_destsuffix = "%s/" % os.path.basename(subdir)
|
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"
|
|
|
|
|
2012-08-18 15:15:18 +00:00
|
|
|
# Versions of git prior to 1.7.9.2 have issues where foo.git and foo get confused
|
|
|
|
# and you end up with some horrible union of the two when you attempt to clone it
|
|
|
|
# The least invasive workaround seems to be a symlink to the real directory to
|
|
|
|
# fool git into ignoring any .git version that may also be present.
|
|
|
|
#
|
|
|
|
# The issue is fixed in more recent versions of git so we can drop this hack in future
|
|
|
|
# when that version becomes common enough.
|
|
|
|
clonedir = ud.clonedir
|
|
|
|
if not ud.path.endswith(".git"):
|
|
|
|
indirectiondir = destdir[:-1] + ".indirectionsymlink"
|
|
|
|
if os.path.exists(indirectiondir):
|
|
|
|
os.remove(indirectiondir)
|
2012-09-25 14:55:27 +00:00
|
|
|
bb.utils.mkdirhier(os.path.dirname(indirectiondir))
|
2012-08-18 15:15:18 +00:00
|
|
|
os.symlink(ud.clonedir, indirectiondir)
|
|
|
|
clonedir = indirectiondir
|
|
|
|
|
|
|
|
runfetchcmd("git clone %s %s/ %s" % (cloneflags, clonedir, destdir), d)
|
2011-02-02 12:48:32 +00:00
|
|
|
if not ud.nocheckout:
|
|
|
|
os.chdir(destdir)
|
2011-05-26 07:37:56 +00:00
|
|
|
if subdir != "":
|
|
|
|
runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
|
|
|
|
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
|
|
|
|
else:
|
|
|
|
runfetchcmd("%s checkout %s" % (ud.basecmd, ud.revisions[ud.names[0]]), d)
|
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)
|
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
def supports_srcrev(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def _contains_ref(self, tag, d):
|
|
|
|
basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
2011-09-16 07:38:22 +00:00
|
|
|
cmd = "%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag)
|
|
|
|
output = runfetchcmd(cmd, d, quiet=True)
|
|
|
|
if len(output.split()) > 1:
|
|
|
|
raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
|
2011-01-10 14:23:36 +00:00
|
|
|
return output.split()[0] != "0"
|
|
|
|
|
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
|
|
|
def _revision_key(self, url, ud, d, name):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
|
|
|
Return a unique key for the 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
|
|
|
return "git:" + ud.host + ud.path.replace('/', '.') + ud.branches[name]
|
2011-01-10 14:23:36 +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
|
|
|
def _latest_revision(self, url, ud, d, name):
|
2011-01-10 14:23:36 +00:00
|
|
|
"""
|
|
|
|
Compute the HEAD revision for the url
|
|
|
|
"""
|
|
|
|
if ud.user:
|
|
|
|
username = ud.user + '@'
|
|
|
|
else:
|
|
|
|
username = ""
|
|
|
|
|
|
|
|
basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
2014-01-20 14:30:11 +00:00
|
|
|
cmd = "%s ls-remote %s://%s%s%s refs/heads/%s refs/tags/%s" % \
|
|
|
|
(basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name], ud.branches[name])
|
2012-05-04 14:05:14 +00:00
|
|
|
if ud.proto.lower() != 'file':
|
|
|
|
bb.fetch2.check_network_access(d, cmd)
|
2011-01-10 14:23:36 +00:00
|
|
|
output = runfetchcmd(cmd, d, True)
|
|
|
|
if not output:
|
2011-02-04 10:26:21 +00:00
|
|
|
raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, url)
|
2011-01-10 14:23:36 +00:00
|
|
|
return output.split()[0]
|
|
|
|
|
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
|
|
|
def _build_revision(self, url, ud, d, name):
|
|
|
|
return ud.revisions[name]
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2011-08-24 20:04:23 +00:00
|
|
|
def checkstatus(self, uri, ud, d):
|
|
|
|
fetchcmd = "%s ls-remote %s" % (ud.basecmd, uri)
|
|
|
|
try:
|
|
|
|
runfetchcmd(fetchcmd, d, quiet=True)
|
|
|
|
return True
|
|
|
|
except FetchError:
|
|
|
|
return False
|