With previous versions of bitbake, the git repo in the workdir would
point its remote/origin to the local clone in the DL_DIR. The
sourceipk class would thus need to go to the local clone to get the
true upstream remote.

With bitbake commit 80ecd1c54d4c748cee3a7ce0d64013a346e7671e
(branch: 1.30), the workdir repo now points to the true upstream repo

This fixes the sourceipk git preservation that was broken due to this
change in bitbake. Additional changes were required in the limit git
history feature to ensure that the preserved git points to the commit
used within the build.

Signed-off-by: Jacob Stiffler <j-stiff...@ti.com>
---
 meta-arago-distro/classes/sourceipk.bbclass | 32 +++++++++++++----------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/meta-arago-distro/classes/sourceipk.bbclass 
b/meta-arago-distro/classes/sourceipk.bbclass
index 2d19a18..6e71196 100644
--- a/meta-arago-distro/classes/sourceipk.bbclass
+++ b/meta-arago-distro/classes/sourceipk.bbclass
@@ -128,7 +128,9 @@ limit_git_history() {
 
     remote=`get_remote $PWD`
 
-    git clone --depth ${SRCIPK_SHALLOW_DEPTH} --branch ${BRANCH} 
file://$remote $gitshallowclone
+    # Clone a shallow version of the workdir repo so that the preserved git
+    # points to the commit used in the build.
+    git clone --depth ${SRCIPK_SHALLOW_DEPTH} --branch ${BRANCH} 
file://$PWD/.git $gitshallowclone
 
     # remove original kernel clone since we will replace it with the shallow
     # clone
@@ -138,6 +140,16 @@ limit_git_history() {
     mv $gitshallowclone/.git $tmp_dir/${SRCIPK_INSTALL_DIR}/
     rm -rf $gitshallowclone
 
+    # Remove the local remote
+    git remote rm origin
+
+    # This is forceful, but unfortuantely, removing the origin remote does not
+    # remove all origin refs, and that causes problems.
+    rm -rf ./.git/refs/remotes/origin
+
+    # Point remote back to upstream
+    git remote add origin $remote
+
     cd -
 }
 
@@ -148,13 +160,8 @@ adjust_git() {
 
     if [ -d ".git" ]
     then
-        # Get the location of the local repository
-        local_repo=`get_remote $PWD`
-
-        if [ -d $local_repo -a "${SRCIPK_PRESERVE_GIT}" = "true" ]
+        if [ "${SRCIPK_PRESERVE_GIT}" = "true" ]
         then
-            cd $local_repo
-
             # If SRCIPK_SHALLOW_CLONE is true then make a shallow copy of the
             # git repository and then fix up the git URLs
             if [ "${SRCIPK_SHALLOW_CLONE}" == "true" ]
@@ -162,17 +169,6 @@ adjust_git() {
                 limit_git_history
             fi
 
-            # Grab actual url used to create the repository
-            remote_repo=`get_remote $PWD`
-
-            cd -
-
-            # Some crazy reason I need to add these two lines when doing a
-            # shallow copy. Otherwise, I had problems where git fetch wasn't
-            # properly fetching all the commits and extra remotes.
-            git remote rm origin
-            git remote add origin $remote_repo
-
             # Repackage the repository so its a proper clone of the original
             # (remote) git repository
             git repack -a -d
-- 
2.7.4

_______________________________________________
meta-arago mailing list
meta-arago@arago-project.org
http://arago-project.org/cgi-bin/mailman/listinfo/meta-arago

Reply via email to