forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
external: fix submodule handling for parallel builds, submodule URL c…
…hanges. If we change an upstream URL, all submodules break. Users would need to run 'git submodule sync'. Note that the libbacktrace fix was merged upstream so this is no longer necessary, but it's good for future changes. Also, stress-testing reveals that git submodule fails locking '.git/config' when run in paralell. It also segfaults and other problems. This is my final attempt to fix submodules; I've wasted far too many days on obscure problems it creates: I've already lost one copy of my repo to apparently unfixable submodule preoblems. The next "fix" will be to simply import the source code so it works properly. Reported-by: @jsarenik Fixes: ElementsProject#1543 Signed-off-by: Rusty Russell <[email protected]>
- Loading branch information
1 parent
05ec4b7
commit 5d77c6a
Showing
2 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#! /bin/sh | ||
|
||
if [ $# = 0 ]; then | ||
echo "Usage: $0 <submoduledir1>..." >&2 | ||
exit 1 | ||
fi | ||
|
||
# git submodule can't run in parallel. Really. | ||
echo $$ > .refresh-submodules.$$ | ||
if ! mv -n .refresh-submodules.$$ .refresh-submodules; then | ||
rm -f .refresh-submodules.$$ | ||
exit 0 | ||
fi | ||
trap "rm -f .refresh-submodules" EXIT | ||
|
||
# Be a little careful here, since we do rm -rf! | ||
for m in "$@"; do | ||
if ! grep -q "path = $m\$" .gitmodules; then | ||
echo "$m is not a submodule!" >&2 | ||
exit 1 | ||
fi | ||
done | ||
|
||
# git submodule can segfault. Really. | ||
if [ $(git submodule status "$@" | grep -c '^ ') != $# ]; then | ||
echo Reinitializing submodules "$@"... | ||
git submodule sync "$@" | ||
rm -rf "$@" | ||
git submodule update --init "$@" | ||
fi |
5d77c6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful solution. Thank you Rusty!
EDIT: Just needs to correct the libbacktrace commit checksum and rebase to current master.