summaryrefslogtreecommitdiffstats
path: root/Utilities/Scripts/update-third-party.bash
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-09-29 19:08:24 (GMT)
committerBrad King <brad.king@kitware.com>2021-09-29 19:08:24 (GMT)
commitae53a3071bfa9919b54a7a4e41a4b26f0b3c9d9f (patch)
treedd90dc775235cb63c18fe1332f6c9c7b68987f73 /Utilities/Scripts/update-third-party.bash
parent5bd94332c760a6f861b411273921b204076ab9a6 (diff)
downloadCMake-ae53a3071bfa9919b54a7a4e41a4b26f0b3c9d9f.zip
CMake-ae53a3071bfa9919b54a7a4e41a4b26f0b3c9d9f.tar.gz
CMake-ae53a3071bfa9919b54a7a4e41a4b26f0b3c9d9f.tar.bz2
update-third-party: update from upstream
Update to `update-common.sh` from commit `7134d5ebef` in https://gitlab.kitware.com/utils/git-import-third-party
Diffstat (limited to 'Utilities/Scripts/update-third-party.bash')
-rw-r--r--Utilities/Scripts/update-third-party.bash42
1 files changed, 38 insertions, 4 deletions
diff --git a/Utilities/Scripts/update-third-party.bash b/Utilities/Scripts/update-third-party.bash
index 0d0a667..bfe6828 100644
--- a/Utilities/Scripts/update-third-party.bash
+++ b/Utilities/Scripts/update-third-party.bash
@@ -42,6 +42,22 @@
# For convenience, the function may use the "git_archive" function which
# does a standard "git archive" extraction using the (optional) "paths"
# variable to only extract a subset of the source tree.
+#
+# Dependencies
+#
+# To update third party packages from git repositories with submodule,
+# you will need to install the "git-archive-all" Python package with
+#
+# pip install git-archive-all
+#
+# or install it from https://github.com/Kentzo/git-archive-all.
+#
+# This package installs a script named "git-archive-all" where pip
+# installs executables. If you run pip under your user privileges (i.e.,
+# not using "sudo"), this location may be $HOME/.local/bin. Make sure
+# that directory is in your path so that git can find the
+# "git-archive-all" script.
+#
########################################################################
########################################################################
@@ -52,11 +68,24 @@ git_archive () {
tar -C "$extractdir" -x
}
+confirm_archive_all_exists () {
+ which git-archive-all || die "git requires an archive-all command. Please run 'pip install git-archive-all'"
+}
+
+git_archive_all () {
+ confirm_archive_all_exists
+ local tmptarball="temp.tar"
+ git archive-all --prefix="" "$tmptarball"
+ mkdir -p "$extractdir/$name-reduced"
+ tar -C "$extractdir/$name-reduced" -xf "$tmptarball" $paths
+ rm -f "$tmptarball"
+}
+
disable_custom_gitattributes() {
pushd "${extractdir}/${name}-reduced"
# Git does not allow custom attributes in a subdirectory where we
# are about to merge the `.gitattributes` file, so disable them.
- sed -i '/^\[attr\]/ {s/^/#/}' .gitattributes
+ sed -i '/^\[attr\]/ {s/^/#/;}' .gitattributes
popd
}
@@ -71,6 +100,9 @@ warn () {
readonly regex_date='20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
readonly basehash_regex="$name $regex_date ([0-9a-f]*)"
+readonly toplevel_dir="$( git rev-parse --show-toplevel )"
+
+cd "$toplevel_dir"
########################################################################
# Sanity checking
@@ -95,7 +127,7 @@ if [ ! -d "$(git rev-parse --show-toplevel)/$subtree" ]; then
else
readonly basehash="$( git rev-list --author="$ownership" --grep="$basehash_regex" -n 1 HEAD )"
fi
-readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p}' | egrep '^[0-9a-f]+$' )"
+readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p;}' | egrep '^[0-9a-f]+$' )"
[ -n "$basehash" ] || \
warn "'basehash' is empty; performing initial import"
@@ -111,7 +143,7 @@ readonly extractdir="$workdir/extract"
trap "rm -rf '$workdir'" EXIT
# Get upstream
-git clone "$repo" "$upstreamdir"
+git clone --recursive "$repo" "$upstreamdir"
if [ -n "$basehash" ]; then
# Remove old worktrees
@@ -120,7 +152,7 @@ if [ -n "$basehash" ]; then
git worktree add "$extractdir" "$basehash"
# Clear out the working tree
pushd "$extractdir"
- git ls-files | xargs rm -v
+ git ls-files -z --recurse-submodules | xargs -0 rm -v
find . -type d -empty -delete
popd
else
@@ -132,6 +164,8 @@ fi
# Extract the subset of upstream we care about
pushd "$upstreamdir"
git checkout "$tag"
+git submodule sync --recursive
+git submodule update --recursive --init
readonly upstream_hash="$( git rev-parse HEAD )"
readonly upstream_hash_short="$( git rev-parse --short=8 "$upstream_hash" )"
readonly upstream_datetime="$( git rev-list "$upstream_hash" --format='%ci' -n 1 | grep -e "^$regex_date" )"