A new repository that is cloned with "--reference" in turn creates an
objects/info/alternates file in the new repo containing the path back to
the reference repo objects.  This is normally a "one-and-done" type
operation and the reference never changes.

However we can envision where a package leaves behind a dead end
"stable" fork and re-aligns itself with the main branch, or a newer
stable fork.  In the case of kernel, a real world example would be
leaving behind v5.4.x in favour of v5.10.x for a baseline.

This commit is a consideration for those users - with an existing copy
in their downloads dir that is using a reference that has since been
updated in the SRC_URI of the package recipe.

If we removed the old reference and replaced it, we would break any old
build directories that had branches based on v5.4.x specific commits, so
that is clearly not an option.

If we simply did nothing, things would still work just fine for them;
any v5.10.x objects not found in the v5.4.x reference would be simply
obtained automatically from the server during a fetch update, and placed
in the endpoint repo that is using the older v5.4.x as a reference.

However, since alternates supports a multi-line format, we can simply
append the new reference.  This leaves any v5.4.x build "consumers"
functioning as-is, and also gives a path back to v5.10.x objects in the
new reference, so they need not be duplicated over into the endpoint repo.

Signed-off-by: Paul Gortmaker <paul.gortma...@windriver.com>
---
 bitbake/lib/bb/fetch2/git.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index e742010229c3..3b0c068bc020 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -421,6 +421,15 @@ class Git(FetchMethod):
 
         # Update the checkout if needed
         if self.clonedir_need_update(ud, d):
+            if ud.altref:
+                # if altref changed in SRC_URI then append new value.
+                alts = os.path.join(ud.clonedir, 'objects', 'info', 
'alternates')
+                try:
+                    runfetchcmd("grep -q %s %s" % (ud.altref, alts), d, 
quiet=True, workdir=ud.clonedir)
+                except (bb.fetch2.FetchError,ValueError):
+                    with open(alts, "a") as f:
+                        f.write("../../%s/objects\n" % ud.altref)
+
             output = runfetchcmd("%s remote" % ud.basecmd, d, quiet=True, 
workdir=ud.clonedir)
             if "origin" in output:
               runfetchcmd("%s remote rm origin" % ud.basecmd, d, 
workdir=ud.clonedir)
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9642): 
https://lists.yoctoproject.org/g/linux-yocto/message/9642
Mute This Topic: https://lists.yoctoproject.org/mt/81808163/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to