@@ -53,6 +53,7 @@ export PROJECT="${PROJECT:-hbase}"
5353SELF=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
5454# shellcheck source=SCRIPTDIR/release-util.sh
5555. " $SELF /release-util.sh"
56+ ORIG_PWD=" $( pwd) "
5657
5758function usage {
5859 local NAME
@@ -71,6 +72,7 @@ Options:
7172 -j [path] path to local JDK installation to use building. By default the script will
7273 use openjdk8 installed in the docker image.
7374 -p [project] project to build, such as 'hbase' or 'hbase-thirdparty'; defaults to $PROJECT env var
75+ -r [repo] git repo to use for remote git operations. defaults to ASF gitbox for project.
7476 -s [step] runs a single step of the process; valid steps are: tag|publish-dist|publish-release.
7577 If none specified, runs tag, then publish-dist, and then publish-release.
7678 'publish-snapshot' is also an allowed, less used, option.
@@ -82,13 +84,15 @@ WORKDIR=
8284IMGTAG=latest
8385JAVA=
8486RELEASE_STEP=
85- while getopts " d:fhj:p:s:t:" opt; do
87+ GIT_REPO=
88+ while getopts " d:fhj:p:r:s:t:" opt; do
8689 case $opt in
8790 d) WORKDIR=" $OPTARG " ;;
8891 f) DRY_RUN=0 ;;
8992 t) IMGTAG=" $OPTARG " ;;
9093 j) JAVA=" $OPTARG " ;;
9194 p) PROJECT=" $OPTARG " ;;
95+ r) GIT_REPO=" $OPTARG " ;;
9296 s) RELEASE_STEP=" $OPTARG " ;;
9397 h) usage ;;
9498 ? ) error " Invalid option. Run with -h for help." ;;
@@ -169,11 +173,65 @@ if [ -n "$JAVA" ]; then
169173 JAVA_VOL=(--volume " $JAVA :/opt/hbase-java" )
170174fi
171175
176+ # TODO some debug output would be good here
177+ GIT_REPO_MOUNT=()
178+ if [ -n " ${GIT_REPO} " ]; then
179+ case " ${GIT_REPO} " in
180+ # skip the easy to identify remote protocols
181+ ssh://* |git://* |http://* |https://* |ftp://* |ftps://* ) ;;
182+ # for sure local
183+ /* )
184+ GIT_REPO_MOUNT=(--mount " type=bind,src=${GIT_REPO} ,dst=/opt/hbase-repo" )
185+ echo " HOST_GIT_REPO=${GIT_REPO} " >> " ${ENVFILE} "
186+ GIT_REPO=" /opt/hbase-repo"
187+ ;;
188+ # on the host but normally git wouldn't use the local optimization
189+ file://* )
190+ echo " [INFO] converted file:// git repo to a local path, which changes git to assume --local."
191+ GIT_REPO_MOUNT=(--mount " type=bind,src=${GIT_REPO# file:// } ,dst=/opt/hbase-repo" )
192+ echo " HOST_GIT_REPO=${GIT_REPO} " >> " ${ENVFILE} "
193+ GIT_REPO=" /opt/hbase-repo"
194+ ;;
195+ # have to decide if it's a local path or the "scp-ish" remote
196+ * )
197+ declare colon_remove_prefix;
198+ declare slash_remove_prefix;
199+ declare local_path;
200+ colon_remove_prefix=" ${GIT_REPO#*: } "
201+ slash_remove_prefix=" ${GIT_REPO#*/ } "
202+ if [ " ${GIT_REPO} " = " ${colon_remove_prefix} " ]; then
203+ # if there was no colon at all, we assume this must be a local path
204+ local_path=" no colon at all"
205+ elif [ " ${GIT_REPO} " != " ${slash_remove_prefix} " ]; then
206+ # if there was a colon and there is no slash, then we assume it must be scp-style host
207+ # and a relative path
208+
209+ if [ " ${# colon_remove_prefix} " -lt " ${# slash_remove_prefix} " ]; then
210+ # Given the substrings made by removing everything up to the first colon and slash
211+ # we can determine which comes first based on the longer substring length.
212+ # if the slash is first, then we assume the colon is part of a path name and if the colon
213+ # is first then it is the seperator between a scp-style host name and the path.
214+ local_path=" slash happened before a colon"
215+ fi
216+ fi
217+ if [ -n " ${local_path} " ]; then
218+ # convert to an absolute path
219+ GIT_REPO=" $( cd " $( dirname " ${ORIG_PWD} /${GIT_REPO} " ) " ; pwd) /$( basename " ${ORIG_PWD} /${GIT_REPO} " ) "
220+ GIT_REPO_MOUNT=(--mount " type=bind,src=${GIT_REPO} ,dst=/opt/hbase-repo" )
221+ echo " HOST_GIT_REPO=${GIT_REPO} " >> " ${ENVFILE} "
222+ GIT_REPO=" /opt/hbase-repo"
223+ fi
224+ ;;
225+ esac
226+ echo " GIT_REPO=${GIT_REPO} " >> " ${ENVFILE} "
227+ fi
228+
172229echo " Building $RELEASE_TAG ; output will be at $WORKDIR /output"
173230cmd=(docker run -ti \
174231 --env-file " $ENVFILE " \
175232 --volume " $WORKDIR :/opt/hbase-rm" \
176233 " ${JAVA_VOL[@]} " \
234+ " ${GIT_REPO_MOUNT[@]} " \
177235 " hbase-rm:$IMGTAG " )
178236echo " ${cmd[*]} "
179237" ${cmd[@]} "
0 commit comments