download/git: support Git LFS
Git Large File Storage replaces large files with text pointers in the Git repository while storing the contents on a remote server. If a repository is using this extension, then git-lfs must be used to checkout the large files before the source archive is generated.
---
Currently this relies on git-lfs being installed on the host system and I'm not sure if that's considered acceptable or not.
Unfortunately, building it as a host package opens a can of worms because it is written in Go and pkg-golang only supports target packages at the moment.
docs/manual/adding-packages-generic.txt | 4 ++++ package/pkg-download.mk | 1 + support/download/dl-wrapper | 9 +++++---- support/download/git | 9 +++++++++ 4 files changed, 19 insertions(+), 4 deletions(-)
docs/manual/adding-packages-generic.txt +4 -0
@@ -327,6 +327,10 @@ information is (assuming the package name is +libfoo+) : submodules when they contain bundled libraries, in which case we prefer to use those libraries from their own package. +* +LIBFOO_GIT_LFS+ should be set to +YES+ if the Git repository uses + Git LFS to store large files out of band. This is only available for + packages downloaded with git (i.e. when +LIBFOO_SITE_METHOD=git+). + * +LIBFOO_STRIP_COMPONENTS+ is the number of leading components (directories) that tar must strip from file names on extraction. The tarball for most packages has one leading component named
package/pkg-download.mk +1 -0
@@ -104,6 +104,7 @@ define DOWNLOAD -N '$($(PKG)_RAWNAME)' \ -o '$($(PKG)_DL_DIR)/$(notdir $(1))' \ $(if $($(PKG)_GIT_SUBMODULES),-r) \ + $(if $($(PKG)_GIT_LFS),-l) \ $(DOWNLOAD_URIS) \ $(QUIET) \ -- \
support/download/dl-wrapper +5 -4
@@ -19,15 +19,15 @@ # We want to catch any unexpected failure, and exit immediately. set -e -export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:ru:qf:e" +export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:lru:qf:e" main() { local OPT OPTARG - local backend output hfile recurse quiet rc + local backend output hfile large_file recurse quiet rc local -a uris # Parse our options; anything after '--' is for the backend - while getopts ":hc:d:D:o:n:N:H:rf:u:q" OPT; do + while getopts ":hc:d:D:o:n:N:H:lrf:u:q" OPT; do case "${OPT}" in h) help; exit 0;; c) cset="${OPTARG}";;
@@ -37,6 +37,7 @@ main() { n) raw_base_name="${OPTARG}";; N) base_name="${OPTARG}";; H) hfile="${OPTARG}";; + l) large_file="-l";; r) recurse="-r";; f) filename="${OPTARG}";; u) uris+=( "${OPTARG}" );;
@@ -129,7 +130,7 @@ main() { -f "${filename}" \ -u "${uri}" \ -o "${tmpf}" \ - ${quiet} ${recurse} -- "${@}" + ${quiet} ${large_file} ${recurse} -- "${@}" then # cd back to keep path coherence cd "${OLDPWD}"
support/download/git +9 -0
@@ -17,10 +17,12 @@ set -e # GIT : the git command to call verbose= +large_file=0 recurse=0 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do case "${OPT}" in q) verbose=-q; exec >/dev/null;; + l) large_file=1;; r) recurse=1;; o) output="${OPTARG}";; u) uri="${OPTARG}";;
@@ -109,6 +111,13 @@ if [ ${recurse} -eq 1 ]; then _git submodule update --init --recursive fi +# If there are large files then fetch them. +if [ ${large_file} -eq 1 ]; then + _git lfs install + _git lfs fetch + _git lfs checkout +fi + # Generate the archive, sort with the C locale so that it is reproducible. # We do not want the .git dir; we keep other .git files, in case they are the # only files in their directory.
Signature · 1 line
2.17.0
John, All,
On 2018-04-26 18:36 +0100, John Keeping spake thusly:
Quoted 9 lines
Git Large File Storage replaces large files with text pointers in the Git repository while storing the contents on a remote server. If a repository is using this extension, then git-lfs must be used to checkout the large files before the source archive is generated.
Signed-off-by John Keeping <[email protected]>---
Currently this relies on git-lfs being installed on the host system and I'm not sure if that's considered acceptable or not.
I think that would be acceptable, but would require a dependency check, basically, something like
- support/depenencies/check-host-git.mk :
ifeq (,$(call suitable-host-package,git,$(GIT) $(if $(BR2_GIT_NEEDS_LFS).lfs)))
$(error You need a git that supports git-lfs)
endif - support/depenencies/check-host-git.sh
#!/bin/sh
GIT="${1}"
LFS="${2}"
# If LFS not required, any git is OK
if [ -z "${LFS}" ]; then
echo "${GIT}"
exit 0
fi
# Test LFS
if ${GIT} help lfs >/dev/null 2>&1; then
# Works!
echo "${GIT}"
exit 0
fi
exit 1Now, all you have, is to find a way to synthetise BR2_GIT_NEEDS_LFS. ;-)
Quoted 3 lines
Unfortunately, building it as a host package opens a can of worms because it is written in Go and pkg-golang only supports target packages at the moment.
Yup, but with the check above, that would be fine for me.
Quoted 11 lines
docs/manual/adding-packages-generic.txt | 4 ++++ package/pkg-download.mk | 1 + support/download/dl-wrapper | 9 +++++---- support/download/git | 9 +++++++++ 4 files changed, 19 insertions(+), 4 deletions(-)docs/manual/adding-packages-generic.txt +0
-0
docs/manual/adding-packages-generic.txt information is (assuming the package name is +libfoo+) : · line 332
Quoted 6 lines
docs/manual/adding-packages-generic.txt +3
-0@@ -327,6 +327,10 @@ information is (assuming the package name is +libfoo+) : submodules when they contain bundled libraries, in which case we prefer to use those libraries from their own package. +* +LIBFOO_GIT_LFS+ should be set to +YES+ if the Git repository uses + Git LFS to store large files out of band. This is only available for + packages downloaded with git (i.e. when +LIBFOO_SITE_METHOD=git+).
I'm a bit reluctant at adding yet another download-related option that applies to a single site method...
Can't we consider that LFS is some kind of recusrion, like submodules are?
And then, if FOO_GIT_SUBMODULES is YES, we do both: submodule and lfs.
package/pkg-download.mk define DOWNLOAD · line 107
Quoted 12 lines
docs/manual/adding-packages-generic.txt +0
-0* +LIBFOO_STRIP_COMPONENTS+ is the number of leading components (directories) that tar must strip from file names on extraction. The tarball for most packages has one leading component namedpackage/pkg-download.mk +1
-0@@ -104,6 +104,7 @@ define DOWNLOAD -N '$($(PKG)_RAWNAME)' \ -o '$($(PKG)_DL_DIR)/$(notdir $(1))' \ $(if $($(PKG)_GIT_SUBMODULES),-r) \ + $(if $($(PKG)_GIT_LFS),-l) \
So we would not need that new option.
support/download/dl-wrapper line 22
Quoted 13 lines
package/pkg-download.mk +0
-0$(DOWNLOAD_URIS) \ $(QUIET) \ -- \support/download/dl-wrapper +1
-1@@ -19,15 +19,15 @@ # We want to catch any unexpected failure, and exit immediately. set -e -export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:ru:qf:e" +export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:lru:qf:e"
And here neither...
support/download/dl-wrapper line 26
Quoted 4 lines
support/download/dl-wrapper +1
-1main() { local OPT OPTARG - local backend output hfile recurse quiet rc + local backend output hfile large_file recurse quiet rc
And no change here either...
support/download/dl-wrapper line 30
Quoted 5 lines
support/download/dl-wrapper +1
-1local -a uris # Parse our options; anything after '--' is for the backend - while getopts ":hc:d:D:o:n:N:H:rf:u:q" OPT; do + while getopts ":hc:d:D:o:n:N:H:lrf:u:q" OPT; do
Ditto...
support/download/dl-wrapper main() { · line 40
Quoted 8 lines
support/download/dl-wrapper +1
-0case "${OPT}" in h) help; exit 0;; c) cset="${OPTARG}";;@@ -37,6 +37,7 @@ main() { n) raw_base_name="${OPTARG}";; N) base_name="${OPTARG}";; H) hfile="${OPTARG}";; + l) large_file="-l";;
Ditto...
support/download/dl-wrapper main() { · line 133
Quoted 9 lines
support/download/dl-wrapper +1
-1r) recurse="-r";; f) filename="${OPTARG}";; u) uris+=( "${OPTARG}" );;@@ -129,7 +130,7 @@ main() { -f "${filename}" \ -u "${uri}" \ -o "${tmpf}" \ - ${quiet} ${recurse} -- "${@}" + ${quiet} ${large_file} ${recurse} -- "${@}"
Ditto...
support/download/git set -e · line 20
Quoted 12 lines
support/download/dl-wrapper +0
-0then # cd back to keep path coherence cd "${OLDPWD}"support/download/git +1
-0@@ -17,10 +17,12 @@ set -e # GIT : the git command to call verbose= +large_file=0
Ditto...
support/download/git set -e · line 25
Quoted 5 lines
support/download/git +1
-0recurse=0 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do case "${OPT}" in q) verbose=-q; exec >/dev/null;; + l) large_file=1;;
Ditto...
support/download/git if [ ${recurse} -eq 1 ]; then · line 119
Quoted 13 lines
support/download/git +6
-0r) recurse=1;; o) output="${OPTARG}";; u) uri="${OPTARG}";;@@ -109,6 +111,13 @@ if [ ${recurse} -eq 1 ]; then _git submodule update --init --recursive fi +# If there are large files then fetch them. +if [ ${large_file} -eq 1 ]; then + _git lfs install + _git lfs fetch + _git lfs checkout +fi
And this one would be swallowed into the recurse condition, above.
TBH, I would be very much happier if we would go that way... :-)
Otherwise, you may have seen that we have had quite some grief with the download rework lately, and there are still a lot of patches pending to fix various issues:
https://patchwork.ozlabs.org/project/buildroot/list/?series=40204
https://patchwork.ozlabs.org/project/buildroot/list/?series=40301
https://patchwork.ozlabs.org/project/buildroot/list/?series=40975
So, I'm a bit reluctant at applying this support for git-lfs so close to rc1 (due next week) when we still have serious download-related issues to fix...
Regards,
Yann E. MORIN.
Quoted 6 lines
support/download/git +0
-0# Generate the archive, sort with the C locale so that it is reproducible. # We do not want the .git dir; we keep other .git files, in case they are the # only files in their directory.Signature · 1 line
2.17.0
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
Quoted 42 lines · On Thu, 26 Apr 2018 22:24:40 +0200 "Yann E. MORIN" <[email protected]>…
On 2018-04-26 18:36 +0100, John Keeping spake thusly:
Quoted 9 lines
Git Large File Storage replaces large files with text pointers in the Git repository while storing the contents on a remote server. If a repository is using this extension, then git-lfs must be used to checkout the large files before the source archive is generated.
Signed-off-by John Keeping <[email protected]>---
Currently this relies on git-lfs being installed on the host system and I'm not sure if that's considered acceptable or not.I think that would be acceptable, but would require a dependency check, basically, something like
-
support/depenencies/check-host-git.mk:ifeq (,$(call suitable-host-package,git,$(GIT) $(if$(BR2_GIT_NEEDS_LFS).lfs))) $(error You need a git that supports git-lfs) endif
-
support/depenencies/check-host-git.sh#!/bin/sh GIT="${1}" LFS="${2}" # If LFS not required, any git is OK if [ -z "${LFS}" ]; then echo "${GIT}" exit 0 fi # Test LFS if ${GIT} help lfs >/dev/null 2>&1; then # Works! echo "${GIT}" exit 0 fi exit 1
Quoted 2 lines
Now, all you have, is to find a way to synthetise
BR2_GIT_NEEDS_LFS. ;-)
This makes sense, I'll add this check for v2.
Quoted 34 lines
Quoted 3 lines
Unfortunately, building it as a host package opens a can of worms because it is written in Go and pkg-golang only supports target packages at the moment.
Yup, but with the check above, that would be fine for me.
Quoted 18 lines
docs/manual/adding-packages-generic.txt | 4 ++++ package/pkg-download.mk | 1 + support/download/dl-wrapper | 9 +++++---- support/download/git | 9 +++++++++ 4 files changed, 19 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/docs/manual/adding-packages-generic.txtindex62906d92bb..63b5bf70c9100644 ---a/docs/manual/adding-packages-generic.txt+++b/docs/manual/adding-packages-generic.txt@@ -327,6 +327,10 @@ information is (assuming the package name is +libfoo+) : submodules when they contain bundled libraries, in which case we prefer to use those libraries from their own package.
+* +LIBFOO_GIT_LFS+ should be set to +YES+ if the Git repository uses
+ Git LFS to store large files out of band. This is only available forReview
Quoted 2 lines
(quoted diff) +2
-0+ packages downloaded with git (i.e. when +LIBFOO_SITE_METHOD=git+).I'm a bit reluctant at adding yet another download-related option that applies to a single site method...
Can't we consider that LFS is some kind of recusrion, like submodules are?
And then, if
FOO_GIT_SUBMODULESis YES, we do both: submodule and lfs.
[snip]
Quoted 1 line
TBH, I would be very much happier if we would go that way... :-)
I'm not so happy with that idea though... At the moment, I think submodules are a lot more common than repositories using LFS and for repositories that are primarily source code that's going to remain true.
Since git-submodule ships with Git, there is no additional dependency on the host system for using submodules, but with LFS we are imposing an additional requirement on the host system and if we combine both requirements behind a single flag we risk annoying people who use submodules but not LFS.
If the annoyance is threading method-specific flags through dl-wrapper, I wonder if we should consider something analagous to the compiler's -Wl,... option which passes an argument through to the download helper.
We could consider changing the SUBMODULE and LFS options so it looks more like:
LIBFOO_SITE_FEATURES = git-submodule git-lfs
and it is up to the download helper to reject features which are not supported by that backend.
Quoted 11 lines
Otherwise, you may have seen that we have had quite some grief with the download rework lately, and there are still a lot of patches pending to fix various issues:
https://patchwork.ozlabs.org/project/buildroot/list/?series=40204
https://patchwork.ozlabs.org/project/buildroot/list/?series=40301
https://patchwork.ozlabs.org/project/buildroot/list/?series=40975So, I'm a bit reluctant at applying this support for git-lfs so close to rc1 (due next week) when we still have serious download-related issues to fix...
I don't think Git LFS support is urgent, so there's no need to rush it into this release.
Regards,
John
Quoted 45 lines · On Fri, 27 Apr 2018 11:17:34 +0100 John Keeping <[email protected]> wrote:
Quoted 42 lines · On Thu, 26 Apr 2018 22:24:40 +0200 "Yann E. MORIN" <[email protected]>…
On 2018-04-26 18:36 +0100, John Keeping spake thusly:
Quoted 11 lines
Git Large File Storage replaces large files with text pointers in the Git repository while storing the contents on a remote server. If a repository is using this extension, then git-lfs must be used to checkout the large files before the source archive is generated.
Signed-off-by John Keeping <[email protected]>---
Currently this relies on git-lfs being installed on the host system and I'm not sure if that's considered acceptable or not.I think that would be acceptable, but would require a dependency check, basically, something like
-
support/depenencies/check-host-git.mk:ifeq (,$(call suitable-host-package,git,$(GIT) $(if$(BR2_GIT_NEEDS_LFS).lfs))) $(error You need a git that supports git-lfs) endif
-
support/depenencies/check-host-git.sh#!/bin/sh GIT="${1}" LFS="${2}" # If LFS not required, any git is OK if [ -z "${LFS}" ]; then echo "${GIT}" exit 0 fi # Test LFS if ${GIT} help lfs >/dev/null 2>&1; then # Works! echo "${GIT}" exit 0 fi
Quoted 6 lines
Quoted 4 lines
exit 1
Now, all you have, is to find a way to synthetise
BR2_GIT_NEEDS_LFS. ;-)This makes sense, I'll add this check for v2.
Actually, it looks like adding "git-lfs" to DL_TOOLS_DEPENDENCIES works and it's a lot simpler. What do you think about handling it that way?
Regards,
John
Quoted 53 lines
Quoted 50 lines · On Fri, 27 Apr 2018 11:17:34 +0100 John Keeping <[email protected]> wrote:
Quoted 46 lines · On Thu, 26 Apr 2018 22:24:40 +0200 "Yann E. MORIN" <[email protected]>…
On 2018-04-26 18:36 +0100, John Keeping spake thusly:
Quoted 11 lines
Git Large File Storage replaces large files with text pointers in the Git repository while storing the contents on a remote server. If a repository is using this extension, then git-lfs must be used to checkout the large files before the source archive is generated.
Signed-off-by John Keeping <[email protected]>---
Currently this relies on git-lfs being installed on the host system and I'm not sure if that's considered acceptable or not.I think that would be acceptable, but would require a dependency check, basically, something like
-
support/depenencies/check-host-git.mk:ifeq (,$(call suitable-host-package,git,$(GIT) $(if$(BR2_GIT_NEEDS_LFS).lfs))) $(error You need a git that supports git-lfs) endif
-
support/depenencies/check-host-git.sh#!/bin/sh GIT="${1}" LFS="${2}" # If LFS not required, any git is OK if [ -z "${LFS}" ]; then echo "${GIT}" exit 0 fi # Test LFS if ${GIT} help lfs >/dev/null 2>&1; then # Works! echo "${GIT}" exit 0 fi exit 1Now, all you have, is to find a way to synthetise
BR2_GIT_NEEDS_LFS. ;-)
Quoted 8 lines
Quoted 1 line
This makes sense, I'll add this check for v2.
Actually, it looks like adding "git-lfs" to
DL_TOOLS_DEPENDENCIESworks and it's a lot simpler. What do you think about handling it that way?Regards,
John
Can we revive this discussion? I don't see this implemented yet and I know our organization could really use this functionality.
- Vincent