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
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
#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-01-10 18:05:07 +00:00
|
|
|
from bb.fetch2 import Fetch
|
|
|
|
from bb.fetch2 import runfetchcmd
|
|
|
|
from bb.fetch2 import logger
|
2011-01-10 14:23:36 +00:00
|
|
|
|
|
|
|
class Git(Fetch):
|
|
|
|
"""Class to fetch a module or modules from git repositories"""
|
|
|
|
def init(self, d):
|
|
|
|
#
|
|
|
|
# Only enable _sortable revision if the key is set
|
|
|
|
#
|
|
|
|
if bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True):
|
|
|
|
self._sortable_buildindex = self._sortable_buildindex_disabled
|
|
|
|
def supports(self, url, ud, d):
|
|
|
|
"""
|
|
|
|
Check to see if a given url can be fetched with git.
|
|
|
|
"""
|
|
|
|
return ud.type in ['git']
|
|
|
|
|
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:
|
|
|
|
ud.proto = "rsync"
|
|
|
|
|
2011-02-02 12:48:32 +00:00
|
|
|
ud.nocheckout = False
|
|
|
|
if 'nocheckout' in ud.parm:
|
|
|
|
ud.nocheckout = 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
|
|
|
branches = ud.parm.get("branch", "master").split(',')
|
|
|
|
if len(branches) != len(ud.names):
|
|
|
|
raise bb.fetch2.ParameterError("SRC_URI (%) name and branch number mismatch" % ud.url)
|
|
|
|
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
|
|
|
|
|
|
|
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
|
|
|
|
ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname)
|
|
|
|
ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
|
|
|
|
|
2010-12-27 01:50:25 +00:00
|
|
|
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
|
|
|
|
|
|
|
def localpath(self, url, ud, 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:
|
|
|
|
if not ud.revisions[name] or ud.revisions[name] == "master":
|
|
|
|
ud.revisions[name] = self.latest_revision(url, ud, d, name)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
2011-01-18 16:58:42 +00:00
|
|
|
ud.localfile = ud.mirrortarball
|
2011-01-10 14:23:36 +00:00
|
|
|
|
|
|
|
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
|
|
|
|
|
|
|
|
def forcefetch(self, url, ud, 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:
|
|
|
|
if not self._contains_ref(ud.revisions[name], d):
|
|
|
|
return True
|
2011-01-10 14:23:36 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
def try_premirror(self, u, ud, d):
|
|
|
|
if 'noclone' in ud.parm:
|
|
|
|
return False
|
|
|
|
if os.path.exists(ud.clonedir):
|
|
|
|
return False
|
|
|
|
if os.path.exists(ud.localpath):
|
|
|
|
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 = ""
|
|
|
|
|
|
|
|
repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball)
|
|
|
|
|
2011-01-18 16:58:42 +00:00
|
|
|
ud.repochanged = not os.path.exists(repofile)
|
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
# If the checkout doesn't exist and the mirror tarball does, extract it
|
|
|
|
if not os.path.exists(ud.clonedir) and os.path.exists(repofile):
|
|
|
|
bb.mkdirhier(ud.clonedir)
|
|
|
|
os.chdir(ud.clonedir)
|
|
|
|
runfetchcmd("tar -xzf %s" % (repofile), d)
|
|
|
|
|
|
|
|
# If the repo still doesn't exist, fallback to cloning it
|
|
|
|
if not os.path.exists(ud.clonedir):
|
2011-01-24 07:56:54 +00:00
|
|
|
bb.fetch2.check_network_access(d, "git clone %s%s" % (ud.host, ud.path))
|
2011-01-10 14:23:36 +00:00
|
|
|
runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.clonedir), d)
|
|
|
|
|
|
|
|
os.chdir(ud.clonedir)
|
|
|
|
# Update the checkout if needed
|
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):
|
|
|
|
# Remove all but the .git directory
|
|
|
|
bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path))
|
|
|
|
runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name]), d)
|
|
|
|
runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d)
|
|
|
|
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-01-18 15:35:30 +00:00
|
|
|
repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball)
|
|
|
|
|
2011-01-10 14:23:36 +00:00
|
|
|
os.chdir(ud.clonedir)
|
|
|
|
mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, 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
|
|
|
if mirror_tarballs != "0" and ud.repochanged:
|
2011-01-10 14:23:36 +00:00
|
|
|
logger.info("Creating tarball of git repository")
|
|
|
|
runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d)
|
|
|
|
|
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)
|
|
|
|
else:
|
|
|
|
readpathspec = ""
|
|
|
|
|
|
|
|
destdir = os.path.join(destdir, "git/")
|
|
|
|
if os.path.exists(destdir):
|
|
|
|
bb.utils.prunedir(destdir)
|
|
|
|
|
2011-02-02 12:48:32 +00:00
|
|
|
runfetchcmd("git clone -s -n %s %s" % (ud.clonedir, destdir), d)
|
|
|
|
if os.path.exists("%s/.git/refs/remotes/origin" % ud.clonedir):
|
2011-02-02 17:46:37 +00:00
|
|
|
bb.mkdirhier("%s/.git/refs/remotes/origin/" % destdir)
|
2011-02-02 12:48:32 +00:00
|
|
|
runfetchcmd("cp -af %s/.git/refs/remotes/origin/* %s/.git/refs/remotes/origin/" %(ud.clonedir, destdir), d)
|
|
|
|
if os.path.exists("%s/.git/packed-refs" % ud.clonedir):
|
|
|
|
runfetchcmd("cp -af %s/.git/packed-refs %s/.git/" %(ud.clonedir, destdir), d)
|
|
|
|
if not ud.nocheckout:
|
|
|
|
os.chdir(destdir)
|
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
|
|
|
runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
|
2011-02-02 12:48:32 +00:00
|
|
|
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
|
2011-01-18 16:22:13 +00:00
|
|
|
return True
|
|
|
|
|
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"
|
|
|
|
output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True)
|
|
|
|
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 = ""
|
|
|
|
|
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
|
|
|
bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branches[name]))
|
2011-01-10 14:23:36 +00:00
|
|
|
basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
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
|
|
|
cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name])
|
2011-01-10 14:23:36 +00:00
|
|
|
output = runfetchcmd(cmd, d, True)
|
|
|
|
if not output:
|
2011-01-10 18:05:07 +00:00
|
|
|
raise bb.fetch2.FetchError("Fetch command %s gave empty output\n" % (cmd))
|
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
|
|
|
|
|
|
|
def _sortable_buildindex_disabled(self, url, ud, d, rev):
|
|
|
|
"""
|
|
|
|
Return a suitable buildindex for the revision specified. This is done by counting revisions
|
|
|
|
using "git rev-list" which may or may not work in different circumstances.
|
|
|
|
"""
|
|
|
|
|
|
|
|
cwd = os.getcwd()
|
|
|
|
|
|
|
|
# Check if we have the rev already
|
|
|
|
|
|
|
|
if not os.path.exists(ud.clonedir):
|
|
|
|
print("no repo")
|
2011-01-18 15:03:53 +00:00
|
|
|
self.download(None, ud, d)
|
2011-01-10 14:23:36 +00:00
|
|
|
if not os.path.exists(ud.clonedir):
|
|
|
|
logger.error("GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value", url, ud.clonedir)
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
os.chdir(ud.clonedir)
|
|
|
|
if not self._contains_ref(rev, d):
|
2011-01-18 15:03:53 +00:00
|
|
|
self.download(None, ud, d)
|
2011-01-10 14:23:36 +00:00
|
|
|
|
|
|
|
output = runfetchcmd("%s rev-list %s -- 2> /dev/null | wc -l" % (ud.basecmd, rev), d, quiet=True)
|
|
|
|
os.chdir(cwd)
|
|
|
|
|
|
|
|
buildindex = "%s" % output.split()[0]
|
|
|
|
logger.debug(1, "GIT repository for %s in %s is returning %s revisions in rev-list before %s", url, ud.clonedir, buildindex, rev)
|
|
|
|
return buildindex
|