fetch/git: Add an 'update' unpack mode to the fetchers (git only for now)
PATCH 1/1 fetch/git: Add an 'update' unpack mode to the fetchers (git only for now)
We need a way to allow the git fetcher to update data in place rather than remove and replace. This change adds an unpack_update() function which can be used in place of the usual unpack() call. This will attempt to rebase changes on top of the upstream changes. It will raise an error if any local uncommitted changes are present.
The implementation adds a "dldir" origin to the list of origins in the git repo which we can then fetch from and update against. This origin may be of use to users accessing the git repo outside the fetcher too.
unpack_update() should never delete existing data in the way unpack() does but can error out in many more different ways due to the number of possible input states.
Currently only git is supported.
The intention is for this to use used by bitbake-setup instead of unpack.
--- lib/bb/fetch2/__init__.py | 13 ++++++++-- lib/bb/fetch2/git.py | 51 +++++++++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 7 deletions(-)
lib/bb/fetch2/__init__.py +11 -2
@@ -1634,6 +1634,9 @@ class FetchMethod(object): return + def unpack_update(self, urldata, rootdir, data): + raise RuntimeError("No method available for this url type: %s" % urldata.type) + def clean(self, urldata, d): """ Clean any existing full or partial download
@@ -1990,7 +1993,7 @@ class Fetch(object): if not ret: raise FetchError("URL doesn't work", u) - def unpack(self, root, urls=None): + def unpack(self, root, urls=None, update=False): """ Unpack urls to root """
@@ -2009,7 +2012,10 @@ class Fetch(object): lf = bb.utils.lockfile(ud.lockfile) unpack_tracer.start_url(u) - ud.method.unpack(ud, root, self.d) + if update: + ud.method.unpack_update(ud, root, self.d) + else: + ud.method.unpack(ud, root, self.d) unpack_tracer.finish_url(u) finally:
@@ -2018,6 +2024,9 @@ class Fetch(object): unpack_tracer.complete() + def unpack_update(self, root, urls=None): + self.unpack(root, urls, update=True) + def clean(self, urls=None): """ Clean files that the fetcher gets or places
lib/bb/fetch2/git.py +46 -5
91 lines not on this page · raw message