fetch overhaul - API reorg and git optimization
cover fetch overhaul - API reorg and git optimization
Hi Richard,
This patch series is for the fetcher overhaul phase 2 - new API reorg, and part of phase 3 - git optimization. the details are:
- Split go() methods into the following steps:
i) download() - do whatever transfer is necessary to get the sources locally
ii) build_mirror_data() - generate any data that would be needed to construct a source mirror
iii) unpack() - takes a directory as an argument of where to place extracted sources
- Change Poky's fetch task to call a "download" method in the fetcher instead of go().
- Change Poky's unpack to call an unpack method in the fetchers.
- Optimise git fetcher for the new layout so for a git checkout, we clone the repository in download(), then unpack just does a clone with references to the original repo.
The remaining item for phase 3 are:
- Add a new "BB_NO_NETWORK" option to only perform local fetch
- Add multiple branch/srcrev support for git fetcher
Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: kyu3/fetcher-api
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kyu3/fetcher-api
Thanks,
Yu Ke <[email protected]>
---
Yu Ke (11):
bitbake/fetch2/git: Add backwards compatibility code for branch name
handling
bb.fetch2: add unpack method in fetcher
bb.fetch2: revise the Fetch.unpack API
bb.fetch: add fetch version to distinguish bb.fetch and bb.fetch2 base.bbclass: use bb.fetch2 unpack API
bb.fetch2: rename "go" with "download" to better reflect its
functionality
bbclasee: rename "go" with "download"
bb.fetch2.git: split download to download() + build_mirror_data() bb.fetch2: remove the obsolate Fetch.try_mirrors referrence bb.fetch2: add git unpack
git.py: remove the source tree tar ball
bitbake/lib/bb/fetch/__init__.py | 2 + bitbake/lib/bb/fetch2/__init__.py | 95 +++++++++++++++++++++- bitbake/lib/bb/fetch2/bzr.py | 2 +- bitbake/lib/bb/fetch2/cvs.py | 2 +- bitbake/lib/bb/fetch2/git.py | 158 ++++++++++++++++++++++-------------- bitbake/lib/bb/fetch2/hg.py | 2 +- bitbake/lib/bb/fetch2/local.py | 2 +- bitbake/lib/bb/fetch2/osc.py | 2 +- bitbake/lib/bb/fetch2/perforce.py | 2 +- bitbake/lib/bb/fetch2/repo.py | 2 +- bitbake/lib/bb/fetch2/ssh.py | 2 +- bitbake/lib/bb/fetch2/svk.py | 2 +- bitbake/lib/bb/fetch2/svn.py | 2 +- bitbake/lib/bb/fetch2/wget.py | 4 +- meta/classes/base.bbclass | 13 +++- meta/classes/sstate.bbclass | 5 +- 16 files changed, 216 insertions(+), 81 deletions(-)
PATCH 1/11 bitbake/fetch2/git: Add backwards compatibility code for branch name handling
this patch has been applied for bitbake/fetch/git, so also apply it for bitbake/fetch/git
--- bitbake/lib/bb/fetch2/git.py | 82 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 80 insertions(+), 2 deletions(-)
bitbake/lib/bb/fetch2/git.py +80 -2
@@ -22,6 +22,7 @@ BitBake 'Fetch' git implementation import os import bb +import bb.persist_data from bb import data from bb.fetch2 import Fetch from bb.fetch2 import runfetchcmd
@@ -116,6 +117,7 @@ class Git(Fetch): repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) + coname = '%s' % (ud.tag) codir = os.path.join(ud.clonedir, coname)
@@ -205,11 +207,19 @@ class Git(Fetch): output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True) return output.split()[0] != "0" - def _revision_key(self, url, ud, d): + def _revision_key(self, url, ud, d, branch=False): """ Return a unique key for the url """ - return "git:" + ud.host + ud.path.replace('/', '.') + ud.branch + key = 'git:' + ud.host + ud.path.replace('/', '.') + if branch: + return key + ud.branch + else: + return key + + def generate_revision_key(self, url, ud, d, branch=False): + key = self._revision_key(url, ud, d, branch) + return "%s-%s" % (key, bb.data.getVar("PN", d, True) or "") def _latest_revision(self, url, ud, d): """
@@ -227,6 +237,74 @@ class Git(Fetch): raise bb.fetch2.FetchError("Fetch command %s gave empty output\n" % (cmd)) return output.split()[0] + def latest_revision(self, url, ud, d): + """ + Look in the cache for the latest revision, if not present ask the SCM. + """ + persisted = bb.persist_data.persist(d) + revs = persisted['BB_URI_HEADREVS'] + + key = self.generate_revision_key(url, ud, d, branch=True) + rev = revs[key] + if rev is None: + # Compatibility with old key format, no branch included + oldkey = self.generate_revision_key(url, ud, d, branch=False) + rev = revs[oldkey] + if rev is not None: + del revs[oldkey] + else: + rev = self._latest_revision(url, ud, d) + revs[key] = rev + + return str(rev) + + def sortable_revision(self, url, ud, d): + """ + + """ + pd = bb.persist_data.persist(d) + localcounts = pd['BB_URI_LOCALCOUNT'] + key = self.generate_revision_key(url, ud, d, branch=True) + oldkey = self.generate_revision_key(url, ud, d, branch=False) + + latest_rev = self._build_revision(url, ud, d) + last_rev = localcounts[key + '_rev'] + if last_rev is None: + last_rev = localcounts[oldkey + '_rev'] + if last_rev is not None: + del localcounts[oldkey + '_rev'] + localcounts[key + '_rev'] = last_rev + + uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False + count = None + if uselocalcount: + count = Fetch.localcount_internal_helper(ud, d) + if count is None: + count = localcounts[key + '_count'] + if count is None: + count = localcounts[oldkey + '_count'] + if count is not None: + del localcounts[oldkey + '_count'] + localcounts[key + '_count'] = count + + if last_rev == latest_rev: + return str(count + "+" + latest_rev) + + buildindex_provided = hasattr(self, "_sortable_buildindex") + if buildindex_provided: + count = self._sortable_buildindex(url, ud, d, latest_rev) + if count is None: + count = "0" + elif uselocalcount or buildindex_provided: + count = str(count) + else: + count = str(int(count) + 1) + + localcounts[key + '_rev'] = latest_rev + localcounts[key + '_count'] = count + + return str(count + "+" + latest_rev) + def _build_revision(self, url, ud, d): return ud.tag
Signature · 1 line
1.7.0.4
PATCH 2/11 bb.fetch2: add unpack method in fetcher
In reply to Yu Kecopy exactly the base.bbclass:oe_unpack_file() to bb.fetch2 as the code base
--- bitbake/lib/bb/fetch2/__init__.py | 84 +++++++++++++++++++++++++++++++++++++ 1 files changed, 84 insertions(+), 0 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +84 -0
@@ -259,6 +259,13 @@ def verify_checksum(u, ud, d): ud.sha256_expected, sha256data) raise FetchError("%s checksum mismatch." % u) +def subprocess_setup(): + import signal + # Python installs a SIGPIPE handler by default. This is usually not what + # non-Python subprocesses expect. + # SIGPIPE errors are known issues with gzip/bash + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + def go(d, urls = None): """ Fetch all urls
@@ -629,6 +636,83 @@ class Fetch(object): """ raise NoMethodError("Missing implementation for url") + def unpack(file, data, url = None): + import subprocess + if not url: + url = "file://%s" % file + dots = file.split(".") + if dots[-1] in ['gz', 'bz2', 'Z']: + efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1]))) + else: + efile = file + cmd = None + if file.endswith('.tar'): + cmd = 'tar x --no-same-owner -f %s' % file + elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): + cmd = 'tar xz --no-same-owner -f %s' % file + elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'): + cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file + elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'): + cmd = 'gzip -dc %s > %s' % (file, efile) + elif file.endswith('.bz2'): + cmd = 'bzip2 -dc %s > %s' % (file, efile) + elif file.endswith('.tar.xz'): + cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file + elif file.endswith('.xz'): + cmd = 'xz -dc %s > %s' % (file, efile) + elif file.endswith('.zip') or file.endswith('.jar'): + cmd = 'unzip -q -o' + (type, host, path, user, pswd, parm) = bb.decodeurl(url) + if 'dos' in parm: + cmd = '%s -a' % cmd + cmd = "%s '%s'" % (cmd, file) + elif os.path.isdir(file): + filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, 1)) + destdir = "." + if file[0:len(filesdir)] == filesdir: + destdir = file[len(filesdir):file.rfind('/')] + destdir = destdir.strip('/') + if len(destdir) < 1: + destdir = "." + elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK): + os.makedirs("%s/%s" % (os.getcwd(), destdir)) + cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir) + else: + (type, host, path, user, pswd, parm) = bb.decodeurl(url) + if not 'patch' in parm: + # The "destdir" handling was specifically done for FILESPATH + # items. So, only do so for file:// entries. + if type == "file" and path.find("/") != -1: + destdir = path.rsplit("/", 1)[0] + else: + destdir = "." + bb.mkdirhier("%s/%s" % (os.getcwd(), destdir)) + cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir) + + if not cmd: + return True + + dest = os.path.join(os.getcwd(), os.path.basename(file)) + if os.path.exists(dest): + if os.path.samefile(file, dest): + return True + + # Change to subdir before executing command + save_cwd = os.getcwd(); + parm = bb.decodeurl(url)[5] + if 'subdir' in parm: + newdir = ("%s/%s" % (os.getcwd(), parm['subdir'])) + bb.mkdirhier(newdir) + os.chdir(newdir) + + cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd) + bb.note("Unpacking %s to %s/" % (file, os.getcwd())) + ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True) + + os.chdir(save_cwd) + + return ret == 0 + def try_premirror(self, url, urldata, d): """ Should premirrors be used?
Signature · 1 line
1.7.0.4
PATCH 3/11 bb.fetch2: revise the Fetch.unpack API
In reply to Yu Keuse the urldata and rootdir parameter for more natural info passing:
- urldata is the FetchData instance
- rootdir is the dir to put the extracted source. the original unpack use current dir (os.getcwd) as destination dir, which is not flexible and error-prone
--- bitbake/lib/bb/fetch2/__init__.py | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +13 -16
@@ -636,10 +636,9 @@ class Fetch(object): """ raise NoMethodError("Missing implementation for url") - def unpack(file, data, url = None): + def unpack(self, urldata, rootdir, data): import subprocess - if not url: - url = "file://%s" % file + file = urldata.localpath dots = file.split(".") if dots[-1] in ['gz', 'bz2', 'Z']: efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
@@ -662,8 +661,7 @@ class Fetch(object): cmd = 'xz -dc %s > %s' % (file, efile) elif file.endswith('.zip') or file.endswith('.jar'): cmd = 'unzip -q -o' - (type, host, path, user, pswd, parm) = bb.decodeurl(url) - if 'dos' in parm: + if 'dos' in urldata.parm: cmd = '%s -a' % cmd cmd = "%s '%s'" % (cmd, file) elif os.path.isdir(file):
@@ -674,34 +672,33 @@ class Fetch(object): destdir = destdir.strip('/') if len(destdir) < 1: destdir = "." - elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK): - os.makedirs("%s/%s" % (os.getcwd(), destdir)) - cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir) + elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK): + os.makedirs("%s/%s" % (rootdir, destdir)) + cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir) else: - (type, host, path, user, pswd, parm) = bb.decodeurl(url) - if not 'patch' in parm: + if not 'patch' in urldata.parm: # The "destdir" handling was specifically done for FILESPATH # items. So, only do so for file:// entries. if type == "file" and path.find("/") != -1: destdir = path.rsplit("/", 1)[0] else: destdir = "." - bb.mkdirhier("%s/%s" % (os.getcwd(), destdir)) - cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir) + bb.mkdirhier("%s/%s" % (rootdir, destdir)) + cmd = 'cp %s %s/%s/' % (file, rootdir, destdir) if not cmd: return True - dest = os.path.join(os.getcwd(), os.path.basename(file)) + dest = os.path.join(rootdir, os.path.basename(file)) if os.path.exists(dest): if os.path.samefile(file, dest): return True # Change to subdir before executing command save_cwd = os.getcwd(); - parm = bb.decodeurl(url)[5] - if 'subdir' in parm: - newdir = ("%s/%s" % (os.getcwd(), parm['subdir'])) + os.chdir(rootdir) + if 'subdir' in urldata.parm: + newdir = ("%s/%s" % (rootdir, urldata.parm['subdir'])) bb.mkdirhier(newdir) os.chdir(newdir)
Signature · 1 line
1.7.0.4
PATCH 4/11 bb.fetch: add fetch version to distinguish bb.fetch and bb.fetch2
In reply to Yu Ke--- bitbake/lib/bb/fetch/__init__.py | 2 ++ bitbake/lib/bb/fetch2/__init__.py | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
bitbake/lib/bb/fetch/__init__.py +2 -0
@@ -32,6 +32,8 @@ import bb from bb import data from bb import persist_data +__version__ = "1" + logger = logging.getLogger("BitBake.Fetch") class MalformedUrl(Exception):
bitbake/lib/bb/fetch2/__init__.py +2 -0
@@ -32,6 +32,8 @@ import bb from bb import data from bb import persist_data +__version__ = "2" + logger = logging.getLogger("BitBake.Fetch") class MalformedUrl(Exception):
Signature · 1 line
1.7.0.4
PATCH 5/11 base.bbclass: use bb.fetch2 unpack API
In reply to Yu Ke--- meta/classes/base.bbclass | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
meta/classes/base.bbclass +7 -1
@@ -256,7 +256,13 @@ python base_do_unpack() { continue local = os.path.realpath(local) lf = bb.utils.lockfile(urldata[url].lockfile) - ret = oe_unpack_file(local, localdata, url) + if bb.fetch.__version__ == "1": + ret = oe_unpack_file(local, localdata, url) + else: + # use bb.fetch2 unpack API + ud = urldata[url] + rootdir = bb.data.getVar('WORKDIR', localdata, True) + ret = ud.method.unpack(ud, rootdir, localdata) bb.utils.unlockfile(lf) if not ret: raise bb.build.FuncFailed("oe_unpack_file failed with return value %s" % ret)
Signature · 1 line
1.7.0.4
PATCH 6/11 bb.fetch2: rename "go" with "download" to better reflect its functionality
In reply to Yu Keno functional change
--- bitbake/lib/bb/fetch2/__init__.py | 8 ++++---- bitbake/lib/bb/fetch2/bzr.py | 2 +- bitbake/lib/bb/fetch2/cvs.py | 2 +- bitbake/lib/bb/fetch2/git.py | 6 +++--- bitbake/lib/bb/fetch2/hg.py | 2 +- bitbake/lib/bb/fetch2/local.py | 2 +- bitbake/lib/bb/fetch2/osc.py | 2 +- bitbake/lib/bb/fetch2/perforce.py | 2 +- bitbake/lib/bb/fetch2/repo.py | 2 +- bitbake/lib/bb/fetch2/ssh.py | 2 +- bitbake/lib/bb/fetch2/svk.py | 2 +- bitbake/lib/bb/fetch2/svn.py | 2 +- bitbake/lib/bb/fetch2/wget.py | 4 ++-- 13 files changed, 19 insertions(+), 19 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +4 -4
@@ -268,7 +268,7 @@ def subprocess_setup(): # SIGPIPE errors are known issues with gzip/bash signal.signal(signal.SIGPIPE, signal.SIG_DFL) -def go(d, urls = None): +def download(d, urls = None): """ Fetch all urls init must have previously been called
@@ -298,7 +298,7 @@ def go(d, urls = None): if m.forcefetch(u, ud, d) or not localpath: # Next try fetching from the original uri, u try: - m.go(u, ud, d) + m.download(u, ud, d) localpath = ud.localpath except FetchError: # Remove any incomplete file
@@ -504,7 +504,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False): if found: return found else: - ud.method.go(newuri, ud, ld) + ud.method.download(newuri, ud, ld) return ud.localpath except (bb.fetch2.MissingParameterError, bb.fetch2.FetchError,
@@ -631,7 +631,7 @@ class Fetch(object): """ return False - def go(self, url, urldata, d): + def download(self, url, urldata, d): """ Fetch urls Assumes localpath was called first
bitbake/lib/bb/fetch2/bzr.py +1 -1
@@ -79,7 +79,7 @@ class Bzr(Fetch): return bzrcmd - def go(self, loc, ud, d): + def download(self, loc, ud, d): """Fetch url""" if os.access(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir), '.bzr'), os.R_OK):
bitbake/lib/bb/fetch2/cvs.py +1 -1
@@ -72,7 +72,7 @@ class Cvs(Fetch): return True return False - def go(self, loc, ud, d): + def download(self, loc, ud, d): method = ud.parm.get('method', 'pserver') localdir = ud.parm.get('localdir', ud.module)
bitbake/lib/bb/fetch2/git.py +3 -3
@@ -107,7 +107,7 @@ class Git(Fetch): return True - def go(self, loc, ud, d): + def download(self, loc, ud, d): """Fetch url""" if ud.user:
@@ -320,7 +320,7 @@ class Git(Fetch): if not os.path.exists(ud.clonedir): print("no repo") - self.go(None, ud, d) + self.download(None, ud, d) 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
@@ -328,7 +328,7 @@ class Git(Fetch): os.chdir(ud.clonedir) if not self._contains_ref(rev, d): - self.go(None, ud, d) + self.download(None, ud, d) output = runfetchcmd("%s rev-list %s -- 2> /dev/null | wc -l" % (ud.basecmd, rev), d, quiet=True) os.chdir(cwd)
bitbake/lib/bb/fetch2/hg.py +1 -1
@@ -112,7 +112,7 @@ class Hg(Fetch): return cmd - def go(self, loc, ud, d): + def download(self, loc, ud, d): """Fetch url""" logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'")
bitbake/lib/bb/fetch2/local.py +1 -1
@@ -56,7 +56,7 @@ class Local(Fetch): # We don't set localfile as for this fetcher the file is already local! return newpath - def go(self, url, urldata, d): + def download(self, url, urldata, d): """Fetch urls (no-op for Local method)""" # no need to fetch local files, we'll deal with them in place. return 1
bitbake/lib/bb/fetch2/osc.py +1 -1
@@ -79,7 +79,7 @@ class Osc(Fetch): return osccmd - def go(self, loc, ud, d): + def download(self, loc, ud, d): """ Fetch url """
bitbake/lib/bb/fetch2/perforce.py +1 -1
@@ -121,7 +121,7 @@ class Perforce(Fetch): return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile) - def go(self, loc, ud, d): + def download(self, loc, ud, d): """ Fetch urls """
bitbake/lib/bb/fetch2/repo.py +1 -1
@@ -55,7 +55,7 @@ class Repo(Fetch): return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - def go(self, loc, ud, d): + def download(self, loc, ud, d): """Fetch url""" if os.access(os.path.join(data.getVar("DL_DIR", d, True), ud.localfile), os.R_OK):
bitbake/lib/bb/fetch2/ssh.py +1 -1
@@ -74,7 +74,7 @@ class SSH(Fetch): lpath = os.path.join(data.getVar('DL_DIR', d, True), host, os.path.basename(path)) return lpath - def go(self, url, urldata, d): + def download(self, url, urldata, d): dldir = data.getVar('DL_DIR', d, 1) m = __pattern__.match(url)
bitbake/lib/bb/fetch2/svk.py +1 -1
@@ -57,7 +57,7 @@ class Svk(Fetch): def forcefetch(self, url, ud, d): return ud.date == "now" - def go(self, loc, ud, d): + def download(self, loc, ud, d): """Fetch urls""" svkroot = ud.host + ud.path
bitbake/lib/bb/fetch2/svn.py +1 -1
@@ -128,7 +128,7 @@ class Svn(Fetch): return svncmd - def go(self, loc, ud, d): + def download(self, loc, ud, d): """Fetch url""" logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'")
bitbake/lib/bb/fetch2/wget.py +2 -2
@@ -48,7 +48,7 @@ class Wget(Fetch): return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - def go(self, uri, ud, d, checkonly = False): + def download(self, uri, ud, d, checkonly = False): """Fetch urls""" def fetch_uri(uri, ud, d):
@@ -90,4 +90,4 @@ class Wget(Fetch): def checkstatus(self, uri, ud, d): - return self.go(uri, ud, d, True) + return self.download(uri, ud, d, True)
Signature · 1 line
1.7.0.4
PATCH 7/11 bbclasee: rename "go" with "download"
In reply to Yu Keno functional change
--- meta/classes/base.bbclass | 5 ++++- meta/classes/sstate.bbclass | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
meta/classes/base.bbclass +4 -1
@@ -135,7 +135,10 @@ python base_do_fetch() { raise bb.build.FuncFailed("Malformed URL: %s" % value) try: - bb.fetch.go(localdata) + if bb.fetch.__version__ == "1": + bb.fetch.go(localdata) + else: + bb.fetch.download(localdata) except bb.fetch.MissingParameterError: (type, value, traceback) = sys.exc_info() raise bb.build.FuncFailed("Missing parameters: %s" % value)
meta/classes/sstate.bbclass +4 -1
@@ -319,7 +319,10 @@ def pstaging_fetch(sstatepkg, d): # we will build the package try: bb.fetch.init([srcuri], localdata) - bb.fetch.go(localdata, [srcuri]) + if bb.fetch.__version__ == "1": + bb.fetch.go(localdata, [srcuri]) + else: + bb.fetch.download(localdata, [srcuri]) # Need to optimise this, if using file:// urls, the fetcher just changes the local path # For now work around by symlinking localpath = bb.data.expand(bb.fetch.localpath(srcuri, localdata), localdata)
Signature · 1 line
1.7.0.4
PATCH 8/11 bb.fetch2.git: split download to download() + build_mirror_data()
In reply to Yu KeAs the name implies, the download is to fetch the source from URL, build_mirror_data is to create the mirror tar ball. the original go() method mix them together, it is more clean to split them.
--- bitbake/lib/bb/fetch2/__init__.py | 4 ++++ bitbake/lib/bb/fetch2/git.py | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +4 -0
@@ -299,6 +299,8 @@ def download(d, urls = None): # Next try fetching from the original uri, u try: m.download(u, ud, d) + if hasattr(m, "build_mirror_data"): + m.build_mirror_data(u, ud, d) localpath = ud.localpath except FetchError: # Remove any incomplete file
@@ -505,6 +507,8 @@ def try_mirrors(d, uri, mirrors, check = False, force = False): return found else: ud.method.download(newuri, ud, ld) + if hasattr(ud.method,"build_mirror_data"): + ud.method.build_mirror_data(newuri, ud, ld) return ud.localpath except (bb.fetch2.MissingParameterError, bb.fetch2.FetchError,
bitbake/lib/bb/fetch2/git.py +5 -3
@@ -118,9 +118,6 @@ class Git(Fetch): repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) - coname = '%s' % (ud.tag) - codir = os.path.join(ud.clonedir, coname) - # If we have no existing clone and no mirror tarball, try and obtain one if not os.path.exists(ud.clonedir) and not os.path.exists(repofile): try:
@@ -151,7 +148,12 @@ class Git(Fetch): runfetchcmd("%s prune-packed" % ud.basecmd, d) runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d) + def build_mirror_data(self, url, ud, d): # Generate a mirror tarball if needed + coname = '%s' % (ud.tag) + codir = os.path.join(ud.clonedir, coname) + repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) + os.chdir(ud.clonedir) mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) if mirror_tarballs != "0" or 'fullclone' in ud.parm:
Signature · 1 line
1.7.0.4
PATCH 9/11 bb.fetch2: remove the obsolate Fetch.try_mirrors referrence
In reply to Yu KeFetch.try_mirrors is no longer exists, so the code is obsolate
--- bitbake/lib/bb/fetch2/git.py | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-)
bitbake/lib/bb/fetch2/git.py +0 -8
@@ -117,14 +117,6 @@ class Git(Fetch): repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) - - # If we have no existing clone and no mirror tarball, try and obtain one - if not os.path.exists(ud.clonedir) and not os.path.exists(repofile): - try: - Fetch.try_mirrors(ud.mirrortarball) - except: - pass - # 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)
Signature · 1 line
1.7.0.4
PATCH 10/11 bb.fetch2: add git unpack
In reply to Yu Kegit download will clone git repo to local, and git unpack just do a clone with referrence to the original repo
--- bitbake/lib/bb/fetch2/git.py | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
bitbake/lib/bb/fetch2/git.py +16 -0
@@ -193,6 +193,22 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + def unpack(self, ud, destdir, d): + """ unpack the downloaded src to destdir""" + subdir = ud.parm.get("subpath", "") + if subdir != "": + readpathspec = ":%s" % (subdir) + else: + readpathspec = "" + + # extract to ${WORKDIR}/git + destdir = destdir + "/git/" + + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return 1 + def supports_srcrev(self): return True
Signature · 1 line
1.7.0.4
Re: [PATCH 10/11] bb.fetch2: add git unpack
Hi Ke,
Quoted 23 lines · Yu Ke
git download will clone git repo to local, and git unpack just do a clone with referrence to the original repo
Signed-off-by Yu Ke <[email protected]>--- bitbake/lib/bb/fetch2/git.py | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)bitbake/lib/bb/fetch2/git.py +8
-0@@ -193,6 +193,22 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + def unpack(self, ud, destdir, d): + """ unpack the downloaded src to destdir""" + subdir = ud.parm.get("subpath", "") + if subdir != "": + readpathspec = ":%s" % (subdir) + else: + readpathspec = "" +
bitbake/lib/bb/fetch2/git.py class Git(Fetch): · line 213
Quoted 10 lines
bitbake/lib/bb/fetch2/git.py +8
-0+ # extract to ${WORKDIR}/git + destdir = destdir + "/git/" + + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return 1 + def supports_srcrev(self): return True
I know we talked about this via email and you revised the description to:
I'm wondering if we could optimise this cp command to be a "git clone -l" or a "git clone -s" (see man git-clone). I'm cc'ing Bruce for his thoughts on this and whether the linux-yocto tools would have a problem with either of these.
The idea would be one central checkout with the references in and then the subcomponents would all just reference the one local clone saving diskspace and time.
Cheers,
Richard
Re: [PATCH 10/11] bb.fetch2: add git unpack
Quoted 40 lines · Richard Purdie
Hi Ke,
Quoted 31 lines · Yu Ke
git download will clone git repo to local, and git unpack just do a clone with referrence to the original repo
Signed-off-by Yu Ke <[email protected]>---
bitbake/lib/bb/fetch2/git.py | 16 ++++++++++++++++1 files changed, 16 insertions(+), 0 deletions(-)bitbake/lib/bb/fetch2/git.py +16
-0@@ -193,6 +193,22 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + def unpack(self, ud, destdir, d): + """ unpack the downloaded src to destdir""" + subdir = ud.parm.get("subpath", "") + if subdir != "": + readpathspec = ":%s" % (subdir) + else: + readpathspec = "" + + # extract to ${WORKDIR}/git + destdir = destdir + "/git/" + + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return 1 +Quoted 2 lines
def
supports_srcrev(self):
return TrueI know we talked about this via email and you revised the description to:
Quoted 6 lines
I'm wondering if we could optimise this cp command to be a "git clone -l" or a "git clone -s" (see man git-clone). I'm cc'ing Bruce for his thoughts on this and whether the linux-yocto tools would have a problem with either of these.
Neither will pose a problem, and for what it is worth, I think using git for the copy from src/dest is a good idea. In other build systems, I'm doing the same thing with --shared (so I know for sure that works), and --local should also be fine.
Quoted 4 lines
The idea would be one central checkout with the references in and then the subcomponents would all just reference the one local clone saving diskspace and time.
Absolutely. And if someone does something to the central checkout, minor errors ensue, but that can be recovered as well.
Cheers,
Bruce
Quoted 12 lines
Cheers,
Richard
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Re: [PATCH 10/11] bb.fetch2: add git unpack
Quoted 49 lines · Bruce Ashfield
Quoted 40 lines · Richard Purdie
Hi Ke,
Quoted 31 lines · Yu Ke
git download will clone git repo to local, and git unpack just do a clone with referrence to the original repo
Signed-off-by Yu Ke <[email protected]>---
bitbake/lib/bb/fetch2/git.py | 16 ++++++++++++++++1 files changed, 16 insertions(+), 0 deletions(-)bitbake/lib/bb/fetch2/git.py +16
-0@@ -193,6 +193,22 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + def unpack(self, ud, destdir, d): + """ unpack the downloaded src to destdir""" + subdir = ud.parm.get("subpath", "") + if subdir != "": + readpathspec = ":%s" % (subdir) + else: + readpathspec = "" + + # extract to ${WORKDIR}/git + destdir = destdir + "/git/" + + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return 1 +Quoted 2 lines
def
supports_srcrev(self):
return TrueI know we talked about this via email and you revised the description to:
Quoted 6 lines
I'm wondering if we could optimise this cp command to be a "git clone -l" or a "git clone -s" (see man git-clone). I'm cc'ing Bruce for his thoughts on this and whether the linux-yocto tools would have a problem with either of these.
Quoted 4 lines
Neither will pose a problem, and for what it is worth, I think using git for the copy from src/dest is a good idea. In other build systems, I'm doing the same thing with --shared (so I know for sure that works), and --local should also be fine.
"git clone" is my first try when cooking the patch, unfortunately I meet one issue here. the git clone target dir is ${WORKDIR}, while git requires the target dir to be empty, which is not true for ${WORKDIR}, so git clone will fail. so I fall back to cp approach.
But I agree that git clone is better. So I'd like use this apprach: git clone to {WORKDIR}/git/, and modify the kernel-yocto.bbclass:do_kernel_checkout() to use the new layout.
I will revise the patch accordingly for review. Regards
Ke
Quoted 35 lines
Quoted 5 lines
The idea would be one central checkout with the references in and then the subcomponents would all just reference the one local clone saving diskspace and time.
Absolutely. And if someone does something to the central checkout, minor errors ensue, but that can be recovered as well.
Cheers,
Bruce
Quoted 12 lines
Cheers,
Richard
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/pokySignature · 6 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end" _______________________________________________ poky mailing list [email protected] https://lists.yoctoproject.org/listinfo/poky
Re: [PATCH 10/11] bb.fetch2: add git unpack
Quoted 55 lines · Yu Ke
Quoted 49 lines · Bruce Ashfield
Quoted 40 lines · Richard Purdie
Hi Ke,
Quoted 31 lines · Yu Ke
git download will clone git repo to local, and git unpack just do a clone with referrence to the original repo
Signed-off-by Yu Ke <[email protected]>---
bitbake/lib/bb/fetch2/git.py | 16 ++++++++++++++++1 files changed, 16 insertions(+), 0 deletions(-)bitbake/lib/bb/fetch2/git.py +16
-0@@ -193,6 +193,22 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + def unpack(self, ud, destdir, d): + """ unpack the downloaded src to destdir""" + subdir = ud.parm.get("subpath", "") + if subdir != "": + readpathspec = ":%s" % (subdir) + else: + readpathspec = "" + + # extract to ${WORKDIR}/git + destdir = destdir + "/git/" + + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return 1 +Quoted 2 lines
def
supports_srcrev(self):
return TrueI know we talked about this via email and you revised the description to:
Quoted 6 lines
I'm wondering if we could optimise this cp command to be a "git clone -l" or a "git clone -s" (see man git-clone). I'm cc'ing Bruce for his thoughts on this and whether the linux-yocto tools would have a problem with either of these.
Quoted 4 lines
Neither will pose a problem, and for what it is worth, I think using git for the copy from src/dest is a good idea. In other build systems, I'm doing the same thing with --shared (so I know for sure that works), and --local should also be fine.
Quoted 6 lines
"git clone" is my first try when cooking the patch, unfortunately I meet one issue here. the git clone target dir is ${WORKDIR}, while git requires the target dir to be empty, which is not true for ${WORKDIR}, so git clone will fail. so I fall back to cp approach.
But I agree that git clone is better. So I'd like use this apprach: git clone to {WORKDIR}/git/, and modify the kernel-yocto.bbclass:do_kernel_checkout() to use the new layout.
I will revise the patch accordingly for review. Regards Ke
This may be problematic. The kernel checkout needs to be done in a very specific way. After the clone, you must have all branches local (no origin/) and in the 'linux' directory. There are other tools that depend on this particular
layout.
The most efficient way to do this has proven to be to do a bare clone and then forcibly convert it to a non-bare clone. That gets you the instantiation
and local branches in a single clone + minor fix ups to the directory.
Just some things to consider, I'll wait to see the patches before commenting further.
Bruce
Quoted 37 lines
Quoted 36 lines
Quoted 6 lines
The idea would be one central checkout with the references in and then the subcomponents would all just reference the one local clone saving diskspace and time.
Absolutely. And if someone does something to the central checkout, minor errors ensue, but that can be recovered as well.
Cheers,
Bruce
Quoted 12 lines
Cheers,
Richard
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Re: [PATCH 10/11] bb.fetch2: add git unpack
Quoted 19 lines · Bruce Ashfield
Quoted 6 lines · Yu Ke
"git clone" is my first try when cooking the patch, unfortunately I meet one issue here. the git clone target dir is ${WORKDIR}, while git requires the target dir to be empty, which is not true for ${WORKDIR}, so git clone will fail. so I fall back to cp approach.
But I agree that git clone is better. So I'd like use this apprach: git clone to {WORKDIR}/git/, and modify the kernel-yocto.bbclass:do_kernel_checkout() to use the new layout. I will revise the patch accordingly for review.
Regards
KeThis may be problematic. The kernel checkout needs to be done in a very specific way. After the clone, you must have all branches local (no origin/) and in the 'linux' directory. There are other tools that depend on this particular
layout.The most efficient way to do this has proven to be to do a bare clone and then forcibly convert it to a non-bare clone. That gets you the instantiation
and local branches in a single clone + minor fix ups to the directory.
Quoted 4 lines
Just some things to consider, I'll wait to see the patches before commenting further.
Bruce
Bruce, thanks for the comments. You are right. I realize that kernel checkout need to output a specific layout, so I only change the input layout of kernel checkout. more specificly, change the input dir from ${WORKDIR}/.git to ${WORKDIR}/git/.git. and the output layout is unchanged.
please see if the revised patch works for you:
git unpack patch - http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/commit/?h=kyu3/git-unpack&id=e654e3d75550282c4d112f1050465cde850c93e9
bitbake/lib/bb/fetch2/git.py +25 -0
@@ -194,6 +194,31 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + 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) + + if 'fullclone' in ud.parm: + runfetchcmd("git clone -l -n %s %s" % (ud.clonedir, destdir), d) + if os.path.exists("%s/.git/refs/remotes/origin" % ud.clonedir): + 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) + else: + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return True + def supports_srcrev(self): return True
kernel checkout patch - http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/commit/?h=kyu3/git-unpack&id=b1916da1f1a8b7e3c4b50d540918aa72be704d9a
meta/classes/kernel-yocto.bbclass +2 -2
@@ -89,11 +89,11 @@ do_patch() { } do_kernel_checkout() { - if [ -d ${WORKDIR}/.git/refs/remotes/origin ]; then + if [ -d ${WORKDIR}/git/.git/refs/remotes/origin ]; then echo "Fixing up git directory for ${LINUX_KERNEL_TYPE}/${KMACHINE}" rm -rf ${S} mkdir ${S} - mv ${WORKDIR}/.git ${S} + mv ${WORKDIR}/git/.git ${S} if [ -e ${S}/.git/packed-refs ]; then cd ${S}
Quoted 48 lines
Quoted 38 lines
Quoted 37 lines
Quoted 7 lines
The idea would be one central checkout with the references in and then the subcomponents would all just reference the one local clone saving diskspace and time.
Absolutely. And if someone does something to the central checkout, minor errors ensue, but that can be recovered as well.
Cheers,
Bruce
Quoted 12 lines
Cheers,
Richard
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/pokySignature · 6 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end" _______________________________________________ poky mailing list [email protected] https://lists.yoctoproject.org/listinfo/poky
Re: [PATCH 10/11] bb.fetch2: add git unpack
Quoted 20 lines · Yu Ke
Quoted 19 lines · Bruce Ashfield
Quoted 6 lines · Yu Ke
"git clone" is my first try when cooking the patch, unfortunately I meet one issue here. the git clone target dir is ${WORKDIR}, while git requires the target dir to be empty, which is not true for ${WORKDIR}, so git clone will fail. so I fall back to cp approach.
But I agree that git clone is better. So I'd like use this apprach: git clone to {WORKDIR}/git/, and modify the kernel-yocto.bbclass:do_kernel_checkout() to use the new layout. I will revise the patch accordingly for review.
Regards
KeThis may be problematic. The kernel checkout needs to be done in a very specific way. After the clone, you must have all branches local (no origin/) and in the 'linux' directory. There are other tools that depend on this particular
layout.The most efficient way to do this has proven to be to do a bare clone and then forcibly convert it to a non-bare clone. That gets you the instantiation
and local branches in a single clone + minor fix ups to the directory.
Quoted 8 lines
Quoted 4 lines
Just some things to consider, I'll wait to see the patches before commenting further.
Bruce
Bruce, thanks for the comments. You are right. I realize that kernel checkout need to output a specific layout, so I only change the input layout of kernel checkout. more specificly, change the input dir from ${WORKDIR}/.git to ${WORKDIR}/git/.git. and the output layout is unchanged.
please see if the revised patch works for you:
I haven't actually tried the patch, but just by having a look at it, it looks fine. No harm in the directory shuffling at all, and it makes more sense this way.
Cheers,
Bruce
Quoted 110 lines
git unpack patch - http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/commit/?h=kyu3/git-unpack&id=e654e3d75550282c4d112f1050465cde850c93e9
bitbake/lib/bb/fetch2/git.py +25
-0@@ -194,6 +194,31 @@ class Git(Fetch): os.chdir(ud.clonedir) bb.utils.prunedir(codir) + 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) + + if 'fullclone' in ud.parm: + runfetchcmd("git clone -l -n %s %s" % (ud.clonedir, destdir), d) + if os.path.exists("%s/.git/refs/remotes/origin" % ud.clonedir): + 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) + else: + os.chdir(ud.clonedir) + runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) + runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, destdir), d) + return True +def
supports_srcrev(self):
return Truekernel checkout patch - http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/commit/?h=kyu3/git-unpack&id=b1916da1f1a8b7e3c4b50d540918aa72be704d9a
meta/classes/kernel-yocto.bbclass +1
-1@@ -89,11 +89,11 @@ do_patch() { } do_kernel_checkout() { - if [ -d ${WORKDIR}/.git/refs/remotes/origin ]; then + if [ -d ${WORKDIR}/git/.git/refs/remotes/origin ]; thenecho "Fixing up git directory for ${LINUX_KERNEL_TYPE}/${KMACHINE}" rm -rf ${S}
mkdir ${S}
- mv ${WORKDIR}/.git ${S}
+ mv ${WORKDIR}/git/.git ${S}if [ -e ${S}/.git/packed-refs ]; then cd ${S}
Quoted 48 lines
Quoted 30 lines
Quoted 30 lines
Quoted 7 lines
The idea would be one central checkout with the references in and then the subcomponents would all just reference the one local clone saving diskspace and time.
Absolutely. And if someone does something to the central checkout, minor errors ensue, but that can be recovered as well.
Cheers,
Bruce
Quoted 12 lines
Cheers,
Richard
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/pokyQuoted 8 lines
Quoted 7 lines
--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky--
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
PATCH 11/11 git.py: remove the source tree tar ball
In reply to Yu Kewe already create repo tar ball, so no need to create the source tree tar ball
--- bitbake/lib/bb/fetch2/git.py | 62 +++--------------------------------------- 1 files changed, 4 insertions(+), 58 deletions(-)
bitbake/lib/bb/fetch2/git.py +4 -58
@@ -61,24 +61,14 @@ class Git(Fetch): ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git" + ud.repochanged = False def localpath(self, url, ud, d): ud.tag = ud.revision if not ud.tag or ud.tag == "master": ud.tag = self.latest_revision(url, ud, d) - subdir = ud.parm.get("subpath", "") - if subdir != "": - if subdir.endswith("/"): - subdir = subdir[:-1] - subdirpath = os.path.join(ud.path, subdir); - else: - subdirpath = ud.path; - - if 'fullclone' in ud.parm: - ud.localfile = ud.mirrortarball - else: - ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d) + ud.localfile = ud.mirrortarball if 'noclone' in ud.parm: ud.localfile = None
@@ -91,8 +81,6 @@ class Git(Fetch): return True if 'noclone' in ud.parm: return False - if os.path.exists(ud.localpath): - return False if not self._contains_ref(ud.tag, d): return True return False
@@ -139,60 +127,18 @@ class Git(Fetch): 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 def build_mirror_data(self, url, ud, d): # Generate a mirror tarball if needed - coname = '%s' % (ud.tag) - codir = os.path.join(ud.clonedir, coname) repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) os.chdir(ud.clonedir) mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) - if mirror_tarballs != "0" or 'fullclone' in ud.parm: + if mirror_tarballs != "0" or 'fullclone' in ud.parm or ud.repochanged: logger.info("Creating tarball of git repository") runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) - if 'fullclone' in ud.parm: - return - - if os.path.exists(codir): - bb.utils.prunedir(codir) - - subdir = ud.parm.get("subpath", "") - if subdir != "": - if subdir.endswith("/"): - subdirbase = os.path.basename(subdir[:-1]) - else: - subdirbase = os.path.basename(subdir) - else: - subdirbase = "" - - if subdir != "": - readpathspec = ":%s" % (subdir) - codir = os.path.join(codir, "git") - coprefix = os.path.join(codir, subdirbase, "") - else: - readpathspec = "" - coprefix = os.path.join(codir, "git", "") - - scmdata = ud.parm.get("scmdata", "") - if scmdata == "keep": - runfetchcmd("%s clone -n %s %s" % (ud.basecmd, ud.clonedir, coprefix), d) - os.chdir(coprefix) - runfetchcmd("%s checkout -q -f %s%s" % (ud.basecmd, ud.tag, readpathspec), d) - else: - bb.mkdirhier(codir) - os.chdir(ud.clonedir) - runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) - runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, coprefix), d) - - os.chdir(codir) - logger.info("Creating tarball of git checkout") - runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) - - os.chdir(ud.clonedir) - bb.utils.prunedir(codir) - def unpack(self, ud, destdir, d): """ unpack the downloaded src to destdir""" subdir = ud.parm.get("subpath", "")
Signature · 1 line
1.7.0.4