diff options
author | soloturn <soloturn@gmail.com> | 2022-03-20 10:35:09 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2022-07-29 11:00:01 +1000 |
commit | e017a5975cfe3e53670848bd45c982524d6745af (patch) | |
tree | 8dedafb7b7c41381d521c090010e45775a2bc86c | |
parent | 79bd512181af12ec80fd8f79486fc9508fa4a1b3 (diff) |
makepkg: Add GITFLAGS environmental variable to customise checkout
The default flag used to clone a git repository when using makepkg
is "--mirror". However, when working with huge repositories, the use
of different flags during cloning can allow an faster checkout. For
example, using "--filter=blob:none" allows for small checkouts, at
the expense of requiring downloads during the build stage if anything
but the HEAD commit is used for the build. In addition, this example
would serve as a replacement for the often requested (but broken)
addition of --depth=1.
Add support for the environment variable GITFLAG to pass flags for
the git clone command. Note that this overrides the default rather
than adding to it in order to prevent incompatibilities.
-rw-r--r-- | doc/makepkg.8.asciidoc | 4 | ||||
-rw-r--r-- | scripts/libmakepkg/source/git.sh.in | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/doc/makepkg.8.asciidoc b/doc/makepkg.8.asciidoc index 38032e7b..d023b038 100644 --- a/doc/makepkg.8.asciidoc +++ b/doc/makepkg.8.asciidoc @@ -287,6 +287,10 @@ Environment Variables **BUILDTOOLVER=**"<version>":: The version of the '$BUILDTOOL' used. +**GITFLAGS**:: + The options to pass when checking out git sources, replacing the default + "--mirror". + Configuration ------------- See linkman:makepkg.conf[5] for more details on configuring makepkg using the diff --git a/scripts/libmakepkg/source/git.sh.in b/scripts/libmakepkg/source/git.sh.in index bcff958d..f809cc9e 100644 --- a/scripts/libmakepkg/source/git.sh.in +++ b/scripts/libmakepkg/source/git.sh.in @@ -46,9 +46,12 @@ download_git() { url=${url%%#*} url=${url%%\?*} + # Allow overriding of options passed to git clone command, e.g. --filter=blob:none for partial cloning of big repos + local gitflags=${GITFLAGS:---mirror} + if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git" - if ! git clone --mirror "$url" "$dir"; then + if ! git clone $GITFLAGS "$url" "$dir"; then error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git" plainerr "$(gettext "Aborting...")" exit 1 |