All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] suport/download: fix git wrapper with submodules on older git versions
@ 2020-06-17 20:58 Yann E. MORIN
  2020-07-15 19:51 ` Peter Korsgaard
  0 siblings, 1 reply; 2+ messages in thread
From: Yann E. MORIN @ 2020-06-17 20:58 UTC (permalink / raw)
  To: buildroot

commit: https://git.buildroot.net/buildroot/commit/?id=8fe9894f655fd79207c41673e1966cc4d4d101d1
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Older versions of git store the absolute path of the submodules'
repository as stored in the super-project, e.g.:

    $ cat some-submodule/.git
    gitdir: /path/to/super-project/.git/modules/some-submodule

Obviously, this is not very reproducible.

More recent versions of git, however, store relative paths, which
de-facto makes it reproducible.

Fix older versions by replacing the absolute paths with relative ones.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 support/download/git | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/support/download/git b/support/download/git
index 075f665bbf..15d8c66e05 100755
--- a/support/download/git
+++ b/support/download/git
@@ -176,6 +176,19 @@ date="$( _git log -1 --pretty=format:%cD )"
 # There might be submodules, so fetch them.
 if [ ${recurse} -eq 1 ]; then
     _git submodule update --init --recursive
+
+    # Older versions of git will store the absolute path of the git tree
+    # in the .git of submodules, while newer versions just use relative
+    # paths. Detect and fix the older variants to use relative paths, so
+    # that the archives are reproducible across a wider range of git
+    # versions. However, we can't do that if git is too old and uses
+    # full repositories for submodules.
+    cmd='printf "%s\n" "${path}/"'
+    for module_dir in $( _git submodule --quiet foreach "'${cmd}'" ); do
+        [ -f "${module_dir}/.git" ] || continue
+        relative_dir="$( sed -r -e 's,/+,/,g; s,[^/]+/,../,g' <<<"${module_dir}" )"
+        sed -r -i -e "s:^gitdir\: $(pwd)/:gitdir\: "${relative_dir}":" "${module_dir}/.git"
+    done
 fi
 
 # Generate the archive, sort with the C locale so that it is reproducible.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Buildroot] [git commit] suport/download: fix git wrapper with submodules on older git versions
  2020-06-17 20:58 [Buildroot] [git commit] suport/download: fix git wrapper with submodules on older git versions Yann E. MORIN
@ 2020-07-15 19:51 ` Peter Korsgaard
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2020-07-15 19:51 UTC (permalink / raw)
  To: buildroot

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > commit: https://git.buildroot.net/buildroot/commit/?id=8fe9894f655fd79207c41673e1966cc4d4d101d1
 > branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

 > Older versions of git store the absolute path of the submodules'
 > repository as stored in the super-project, e.g.:

 >     $ cat some-submodule/.git
 >     gitdir: /path/to/super-project/.git/modules/some-submodule

 > Obviously, this is not very reproducible.

 > More recent versions of git, however, store relative paths, which
 > de-facto makes it reproducible.

 > Fix older versions by replacing the absolute paths with relative ones.

 > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>

Committed to 2020.02.x and 2020.05.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-15 19:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 20:58 [Buildroot] [git commit] suport/download: fix git wrapper with submodules on older git versions Yann E. MORIN
2020-07-15 19:51 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.