Skip to content

Commit

Permalink
[yugabyte#8173] Remove the third-party submodule and add a text file …
Browse files Browse the repository at this point in the history
…with thirdparty SHA1

Summary:
We have a thirdparty submodule.  When switching branches, the thirdparty SHA1 is frequently left
pointing to its old target commit, leading to spurious check-ins changing or reverting the
thirdparty submodule. In this diff we are switching from using a submodule to just tracking the
thirdparty SHA1 hash in a file. When we actually need to build third-party dependencies, we just
clone the repository and check out the correct SHA1. If we are using a prebuilt third-party
archive, we don't even need to create the thirdparty subdirectory of YugabyteDB source root.

Test Plan:
./yb_build.sh locally
Jenkins: compile only

Reviewers: jason, rtsisyk, steve.varnau

Reviewed By: rtsisyk, steve.varnau

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D11384
  • Loading branch information
mbautin committed Apr 28, 2021
1 parent 300a1eb commit 3a9b061
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ rrdiagram*.jar*
.cache

target/

thirdparty/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "submodules/yugabyte-bash-common"]
path = submodules/yugabyte-bash-common
url = https://github.com/yugabyte/yugabyte-bash-common.git
[submodule "thirdparty"]
path = thirdparty
url = https://github.com/yugabyte/yugabyte-db-thirdparty.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ if (REBUILD_THIRDPARTY)
set(BUILD_THIRDPARTY_ARGS --build-type ${THIRDPARTY_INSTRUMENTATION_TYPE})
message("Invoking build_thirdparty.sh with these arguments: ${BUILD_THIRDPARTY_ARGS}")
execute_process(
COMMAND ${YB_THIRDPARTY_DIR}/build_thirdparty.sh ${BUILD_THIRDPARTY_ARGS}
COMMAND ${YB_SRC_ROOT}/build-support/invoke_thirdparty_build.sh ${BUILD_THIRDPARTY_ARGS}
RESULT_VARIABLE THIRDPARTY_SCRIPT_RESULT)
if (NOT (${THIRDPARTY_SCRIPT_RESULT} EQUAL 0))
message(FATAL_ERROR "Thirdparty was built unsuccessfully, terminating.")
Expand Down
6 changes: 1 addition & 5 deletions build-support/common-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ fi
YB_BASH_COMMON_DIR=$YB_SRC_ROOT/submodules/yugabyte-bash-common

# Initialize submodules. Only do this when the source directory is a git directory.
#
# The "thirdparty" subdirectory of the source directory is a submodule with a special location
# (outside of the "submodules" subdirectory).
if [[ ! -d $YB_BASH_COMMON_DIR || -z "$( ls -A "$YB_BASH_COMMON_DIR" )" ||
! -d $YB_SRC_ROOT/thirdparty || -z "$( ls -A "$YB_SRC_ROOT/thirdparty" )" ]] &&
if [[ ! -d $YB_BASH_COMMON_DIR || -z "$( ls -A "$YB_BASH_COMMON_DIR" )" ]] &&
[[ -d $YB_SRC_ROOT/.git ]]; then
( cd "$YB_SRC_ROOT"; git submodule update --init --recursive )
fi
Expand Down
34 changes: 34 additions & 0 deletions build-support/invoke_thirdparty_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -euo pipefail

# shellcheck source=build-support/common-build-env.sh
. "${BASH_SOURCE[0]%/*}/common-build-env.sh"

if [[ -n ${YB_THIRDPARTY_DIR:-} &&
$YB_THIRDPARTY_DIR != "$YB_SRC_ROOT/thirdparty" ]]; then
fatal "YB_THIRDPARTY_ROOT is set and is not the 'thirdparty' subdirectory of the source root" \
"($YB_SRC_ROOT)."
fi

thirdparty_sha1=$(<"$YB_BUILD_SUPPORT_DIR/thirdparty_sha1.txt")
if [[ ! $thirdparty_sha1 =~ ^[0-9a-f]{40}$ ]]; then
fatal "Invalid thirdparty SHA1: $thirdparty_sha1"
fi
YB_THIRDPARTY_DIR=$YB_SRC_ROOT/thirdparty
if [[ ! -d "$YB_THIRDPARTY_DIR" ]]; then
git clone https://github.com/yugabyte/yugabyte-db-thirdparty.git "$YB_THIRDPARTY_DIR"
fi
cd "$YB_THIRDPARTY_DIR"
current_sha1=$( git rev-parse HEAD )
if [[ ! $current_sha1 =~ ^[0-9a-f]{40}$ ]]; then
fatal "Could not get current git SHA1 in $PWD"
fi
if [[ $current_sha1 != $thirdparty_sha1 ]]; then
if ! git checkout "$thirdparty_sha1"; then
git fetch
git checkout "$thirdparty_sha1"
fi
fi

./build_thirdparty.sh "$@"
2 changes: 2 additions & 0 deletions build-support/thirdparty_sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ee4e2e453b5b83fb045b7a755f25305206a4e806

1 change: 0 additions & 1 deletion thirdparty
Submodule thirdparty deleted from ee4e2e

0 comments on commit 3a9b061

Please sign in to comment.