Skip to contentSkip to conversation

support/download: fix git/svn corrupted cache

PATCH New Thomas De Schampheleire 2 participants 2 messages Mar 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/download: fix git/svn corrupted cache

From: Thomas De Schampheleire <[email protected]>

Commit 54d3d94b6e3846447b5796ef8587b08b537cd348 ("support/download: print command used for download") broke the git and svn download helpers, because these helpers have invocations of the _git/_svn commands where the exact output matters.

For example for git, this would result in:

date: invalid date ?GIT_DIR=.../dl/libyuv/git/.git git log -1 --pretty=format:%ci \n2019-04-12 17:48:45 +0000? Detected a corrupted git cache.
Removing it and starting afresh.

Fix by splitting the _git function in two: _git and _plain_git. The former echoes the command, and then calls the latter.
Most invocations use _git as before, but those cases where the output should not be disturbed, directly call _plain_git.

For symmetry, all download helpers are aligned, even though only the git and svn helpers were broken.

---

Note: the prefix _plain is open for discussion and could also be _bare, _pure, _quiet, or others. I avoided 'quiet' because the command may not be quiet at all, depending on the options passed. _bare could be confusing as it is also a git-specific term. But I have no strong opinion on any of the options.

 support/download/bzr  |  4 ++++
 support/download/cvs  |  4 ++++
 support/download/file |  4 ++++
 support/download/git  | 10 +++++++---
 support/download/hg   |  4 ++++
 support/download/scp  |  4 ++++
 support/download/svn  |  6 +++++-
 support/download/wget |  4 ++++
 8 files changed, 36 insertions(+), 4 deletions(-)
support/download/bzr +4 -0
index 835f6ef564..6f77bc286e 100755
@@ -37,6 +37,10 @@ _bzr() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${BZR} "${@}"; printf '\n'
     fi
+    _plain_bzr "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_bzr() {
     eval ${BZR} "${@}"
 }
 
support/download/cvs +4 -0
index ed034ade2d..0c079e2403 100755
@@ -42,6 +42,10 @@ _cvs() {
     if [ -z "${quiet}" ]; then
         printf '%s ' timeout 10m ${CVS} "${@}"; printf '\n'
     fi
+    _plain_cvs "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_cvs() {
     eval timeout 10m ${CVS} "${@}"
 }
 
support/download/file +4 -0
index f2a638b1a8..a893ca5cc3 100755
@@ -39,6 +39,10 @@ _localfiles() {
     if [ -n "${verbose}" ]; then
         printf '%s ' ${LOCALFILES} "${@}"; printf '\n'
     fi
+    _plain_localfiles "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
support/download/git +7 -3
index 336e170126..1e690d4444 100755
@@ -82,6 +82,10 @@ _git() {
     if [ -z "${quiet}" ]; then
         printf '%s ' GIT_DIR="${git_cache}/.git" ${GIT} "${@}"; printf '\n'
     fi
+    _plain_git "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_git() {
     eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
 }
 
@@ -115,7 +119,7 @@ _EOF_
 _git init .
 
 # Ensure the repo has an origin (in case a previous run was killed).
-if ! _git remote |grep -q -E '^origin$'; then
+if ! _plain_git remote |grep -q -E '^origin$'; then
     _git remote add origin "'${uri}'"
 fi
 
@@ -181,7 +185,7 @@ _git clean -ffdx
 
 # Get date of commit to generate a reproducible archive.
 # %ci is ISO 8601, so it's fully qualified, with TZ and all.
-date="$( _git log -1 --pretty=format:%ci )"
+date="$( _plain_git log -1 --pretty=format:%ci )"
 
 # There might be submodules, so fetch them.
 if [ ${recurse} -eq 1 ]; then
@@ -194,7 +198,7 @@ if [ ${recurse} -eq 1 ]; then
     # 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
+    for module_dir in $( _plain_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"
support/download/hg +4 -0
index add697d6ad..a7542e5c84 100755
@@ -36,6 +36,10 @@ _hg() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${HG} "${@}"; printf '\n'
     fi
+    _plain_hg "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_hg() {
     eval ${HG} "${@}"
 }
 
support/download/scp +4 -0
index 27dcb5550f..14e768b601 100755
@@ -34,6 +34,10 @@ _scp() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${SCP} "${@}"; printf '\n'
     fi
+    _plain_scp "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_scp() {
     eval ${SCP} "${@}"
 }
 
support/download/svn +5 -1
index e85ff6981f..b23b7773d3 100755
@@ -43,6 +43,10 @@ _svn() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${SVN} "${@}"; printf '\n'
     fi
+    _plain_svn "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_svn() {
     eval ${SVN} "${@}"
 }
 
@@ -53,7 +57,7 @@ _svn export --ignore-keywords ${quiet} "${@}" "'${uri}@${rev}'" "'${basename}'"
 # UTC timezone), which we can feed as-is to the --mtime option for tar.
 # In case there is a redirection (e.g. http -> https), just keep the
 # last line (svn outputs everything on stdout)
-date="$( _svn info "'${uri}@${rev}'" \
+date="$( _plain_svn info "'${uri}@${rev}'" \
         |sed -r -e '/^Last Changed Date: /!d; s///'
        )"
 
support/download/wget +4 -0
index 383b1edd26..68bd0b13c8 100755
@@ -36,6 +36,10 @@ _wget() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${WGET} "${@}"; printf '\n'
     fi
+    _plain_wget "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_wget() {
     eval ${WGET} "${@}"
 }
 
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 support/download: fix git/svn corrupted cache

Thomas, All,

On 2021-03-19 21:15 +0100, Thomas De Schampheleire spake thusly:

Quoted 18 lines

From: Thomas De Schampheleire <[email protected]>

Commit 54d3d94b6e3846447b5796ef8587b08b537cd348 ("support/download: print command used for download") broke the git and svn download helpers, because these helpers have invocations of the _git/_svn commands where the exact output matters.

For example for git, this would result in:

date: invalid date ?GIT_DIR=.../dl/libyuv/git/.git git log -1 --pretty=format:%ci \n2019-04-12 17:48:45 +0000? Detected a corrupted git cache.
Removing it and starting afresh.

Fix by splitting the _git function in two: _git and _plain_git. The former echoes the command, and then calls the latter.
Most invocations use _git as before, but those cases where the output should not be disturbed, directly call _plain_git.

Quoted 4 lines

For symmetry, all download helpers are aligned, even though only the git and svn helpers were broken.

Thanks for the quick patch.

I've just added the reference to the bug report, as well as a reference to an autobuilder failure, and applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 181 lines

---

Note: the prefix _plain is open for discussion and could also be _bare, _pure, _quiet, or others. I avoided 'quiet' because the command may not be quiet at all, depending on the options passed. _bare could be confusing as it is also a git-specific term. But I have no strong opinion on any of the options.

 support/download/bzr  |  4 ++++
 support/download/cvs  |  4 ++++
 support/download/file |  4 ++++
 support/download/git  | 10 +++++++---
 support/download/hg   |  4 ++++
 support/download/scp  |  4 ++++
 support/download/svn  |  6 +++++-
 support/download/wget |  4 ++++
 8 files changed, 36 insertions(+), 4 deletions(-)
support/download/bzr +4 -0
index 835f6ef564..6f77bc286e 100755
@@ -37,6 +37,10 @@ _bzr() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${BZR} "${@}"; printf '\n'
     fi
+    _plain_bzr "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_bzr() {
     eval ${BZR} "${@}"
 }
 
support/download/cvs +4 -0
index ed034ade2d..0c079e2403 100755
@@ -42,6 +42,10 @@ _cvs() {
     if [ -z "${quiet}" ]; then
         printf '%s ' timeout 10m ${CVS} "${@}"; printf '\n'
     fi
+    _plain_cvs "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_cvs() {
     eval timeout 10m ${CVS} "${@}"
 }
 
support/download/file +4 -0
index f2a638b1a8..a893ca5cc3 100755
@@ -39,6 +39,10 @@ _localfiles() {
     if [ -n "${verbose}" ]; then
         printf '%s ' ${LOCALFILES} "${@}"; printf '\n'
     fi
+    _plain_localfiles "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
support/download/git +7 -3
index 336e170126..1e690d4444 100755
@@ -82,6 +82,10 @@ _git() {
     if [ -z "${quiet}" ]; then
         printf '%s ' GIT_DIR="${git_cache}/.git" ${GIT} "${@}"; printf '\n'
     fi
+    _plain_git "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_git() {
     eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
 }
 
@@ -115,7 +119,7 @@ _EOF_
 _git init .
 
 # Ensure the repo has an origin (in case a previous run was killed).
-if ! _git remote |grep -q -E '^origin$'; then
+if ! _plain_git remote |grep -q -E '^origin$'; then
     _git remote add origin "'${uri}'"
 fi
 
@@ -181,7 +185,7 @@ _git clean -ffdx
 
 # Get date of commit to generate a reproducible archive.
 # %ci is ISO 8601, so it's fully qualified, with TZ and all.
-date="$( _git log -1 --pretty=format:%ci )"
+date="$( _plain_git log -1 --pretty=format:%ci )"
 
 # There might be submodules, so fetch them.
 if [ ${recurse} -eq 1 ]; then
@@ -194,7 +198,7 @@ if [ ${recurse} -eq 1 ]; then
     # 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
+    for module_dir in $( _plain_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"
support/download/hg +4 -0
index add697d6ad..a7542e5c84 100755
@@ -36,6 +36,10 @@ _hg() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${HG} "${@}"; printf '\n'
     fi
+    _plain_hg "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_hg() {
     eval ${HG} "${@}"
 }
 
support/download/scp +4 -0
index 27dcb5550f..14e768b601 100755
@@ -34,6 +34,10 @@ _scp() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${SCP} "${@}"; printf '\n'
     fi
+    _plain_scp "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_scp() {
     eval ${SCP} "${@}"
 }
 
support/download/svn +5 -1
index e85ff6981f..b23b7773d3 100755
@@ -43,6 +43,10 @@ _svn() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${SVN} "${@}"; printf '\n'
     fi
+    _plain_svn "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_svn() {
     eval ${SVN} "${@}"
 }
 
@@ -53,7 +57,7 @@ _svn export --ignore-keywords ${quiet} "${@}" "'${uri}@${rev}'" "'${basename}'"
 # UTC timezone), which we can feed as-is to the --mtime option for tar.
 # In case there is a redirection (e.g. http -> https), just keep the
 # last line (svn outputs everything on stdout)
-date="$( _svn info "'${uri}@${rev}'" \
+date="$( _plain_svn info "'${uri}@${rev}'" \
         |sed -r -e '/^Last Changed Date: /!d; s///'
        )"
 
support/download/wget +4 -0
index 383b1edd26..68bd0b13c8 100755
@@ -36,6 +36,10 @@ _wget() {
     if [ -z "${quiet}" ]; then
         printf '%s ' ${WGET} "${@}"; printf '\n'
     fi
+    _plain_wget "$@"
+}
+# Note: please keep command below aligned with what is printed above
+_plain_wget() {
     eval ${WGET} "${@}"
 }
 
Signature · 6 lines
2.26.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'