Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-24297 release scripts should be able to use an existing project clone#1725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -53,6 +53,7 @@ export PROJECT="${PROJECT:-hbase}" | ||
| SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| # shellcheck source=SCRIPTDIR/release-util.sh | ||
| . "$SELF/release-util.sh" | ||
| ORIG_PWD="$(pwd)" | ||
| function usage { | ||
| local NAME | ||
| @@ -71,6 +72,7 @@ Options: | ||
| -j [path] path to local JDK installation to use building. By default the script will | ||
| use openjdk8 installed in the docker image. | ||
| -p [project] project to build, such as 'hbase' or 'hbase-thirdparty'; defaults to $PROJECT env var | ||
| -r [repo] git repo to use for remote git operations. defaults to ASF gitbox for project. | ||
| -s [step] runs a single step of the process; valid steps are: tag|publish-dist|publish-release. | ||
| If none specified, runs tag, then publish-dist, and then publish-release. | ||
| 'publish-snapshot' is also an allowed, less used, option. | ||
| @@ -81,13 +83,15 @@ WORKDIR= | ||
| IMGTAG=latest | ||
| JAVA= | ||
| RELEASE_STEP= | ||
| while getopts "d:fhj:p:s:t:" opt; do | ||
| GIT_REPO= | ||
| while getopts "d:fhj:p:r:s:t:" opt; do | ||
| case $opt in | ||
| d) WORKDIR="$OPTARG" ;; | ||
| f) DRY_RUN=0 ;; | ||
| t) IMGTAG="$OPTARG" ;; | ||
| j) JAVA="$OPTARG" ;; | ||
| p) PROJECT="$OPTARG" ;; | ||
| r) GIT_REPO="$OPTARG" ;; | ||
| s) RELEASE_STEP="$OPTARG" ;; | ||
| h) usage ;; | ||
| ?) error "Invalid option. Run with -h for help." ;; | ||
| @@ -168,11 +172,65 @@ if [ -n "$JAVA" ]; then | ||
| JAVA_VOL=(--volume "$JAVA:/opt/hbase-java") | ||
| fi | ||
| #TODO some debug output would be good here | ||
| GIT_REPO_MOUNT=() | ||
| if [ -n "${GIT_REPO}" ]; then | ||
| case "${GIT_REPO}" in | ||
| # skip the easy to identify remote protocols | ||
| ssh://*|git://*|http://*|https://*|ftp://*|ftps://*) ;; | ||
| # for sure local | ||
| /*) | ||
| GIT_REPO_MOUNT=(--mount "type=bind,src=${GIT_REPO},dst=/opt/hbase-repo") | ||
| echo "HOST_GIT_REPO=${GIT_REPO}" >> "${ENVFILE}" | ||
| GIT_REPO="/opt/hbase-repo" | ||
| ;; | ||
| # on the host but normally git wouldn't use the local optimization | ||
| file://*) | ||
| echo "[INFO] converted file:// git repo to a local path, which changes git to assume --local." | ||
| GIT_REPO_MOUNT=(--mount "type=bind,src=${GIT_REPO#file://},dst=/opt/hbase-repo") | ||
| echo "HOST_GIT_REPO=${GIT_REPO}" >> "${ENVFILE}" | ||
| GIT_REPO="/opt/hbase-repo" | ||
| ;; | ||
| # have to decide if it's a local path or the "scp-ish" remote | ||
| *) | ||
busbey marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| declare colon_remove_prefix; | ||
| declare slash_remove_prefix; | ||
| declare local_path; | ||
| colon_remove_prefix="${GIT_REPO#*:}" | ||
| slash_remove_prefix="${GIT_REPO#*/}" | ||
| if [ "${GIT_REPO}" = "${colon_remove_prefix}" ]; then | ||
| # if there was no colon at all, we assume this must be a local path | ||
| local_path="no colon at all" | ||
| elif [ "${GIT_REPO}" != "${slash_remove_prefix}" ]; then | ||
| # if there was a colon and there is no slash, then we assume it must be scp-style host | ||
| # and a relative path | ||
| if [ "${#colon_remove_prefix}" -lt "${#slash_remove_prefix}" ]; then | ||
| # Given the substrings made by removing everything up to the first colon and slash | ||
| # we can determine which comes first based on the longer substring length. | ||
| # if the slash is first, then we assume the colon is part of a path name and if the colon | ||
| # is first then it is the seperator between a scp-style host name and the path. | ||
| local_path="slash happened before a colon" | ||
| fi | ||
| fi | ||
| if [ -n "${local_path}" ]; then | ||
| # convert to an absolute path | ||
| GIT_REPO="$(cd "$(dirname "${ORIG_PWD}/${GIT_REPO}")"; pwd)/$(basename "${ORIG_PWD}/${GIT_REPO}")" | ||
| GIT_REPO_MOUNT=(--mount "type=bind,src=${GIT_REPO},dst=/opt/hbase-repo") | ||
| echo "HOST_GIT_REPO=${GIT_REPO}" >> "${ENVFILE}" | ||
| GIT_REPO="/opt/hbase-repo" | ||
| fi | ||
| ;; | ||
| esac | ||
| echo "GIT_REPO=${GIT_REPO}" >> "${ENVFILE}" | ||
| fi | ||
| echo "Building $RELEASE_TAG; output will be at $WORKDIR/output" | ||
| cmd=(docker run -ti \ | ||
| --env-file "$ENVFILE" \ | ||
| --volume "$WORKDIR:/opt/hbase-rm" \ | ||
| "${JAVA_VOL[@]}" \ | ||
| "${GIT_REPO_MOUNT[@]}" \ | ||
| "hbase-rm:$IMGTAG") | ||
| echo "${cmd[*]}" | ||
| "${cmd[@]}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -389,6 +389,43 @@ function configure_maven { | ||
| EOF | ||
| } | ||
| # clone of the repo, deleting anything that exists in the working directory named after the project. | ||
| # optionally with auth details for pushing. | ||
| function git_clone_overwrite { | ||
| local asf_repo | ||
| if [ -z "${PROJECT}" ] || [ "${PROJECT}" != "${PROJECT#/}" ]; then | ||
| error "Project name must be defined and not start with a '/'. PROJECT='${PROJECT}'" | ||
| fi | ||
| rm -rf "${PROJECT}" | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit nervous here about malformed project names like "../.." | ||
| if [[ -z "${GIT_REPO}" ]]; then | ||
| asf_repo="gitbox.apache.org/repos/asf/${PROJECT}.git" | ||
| echo "[INFO] clone will be of the gitbox repo for ${PROJECT}." | ||
| if [ -n "${ASF_USERNAME}" ] && [ -n "${ASF_PASSWORD}" ]; then | ||
| # Ugly! | ||
| encoded_username=$(python -c "import urllib; print urllib.quote('''$ASF_USERNAME''')") | ||
| encoded_password=$(python -c "import urllib; print urllib.quote('''$ASF_PASSWORD''')") | ||
| GIT_REPO="https://$encoded_username:$encoded_password@${asf_repo}" | ||
| else | ||
| GIT_REPO="https://${asf_repo}" | ||
| fi | ||
| else | ||
| echo "[INFO] clone will be of provided git repo." | ||
| fi | ||
| # N.B. we use the shared flag because the clone is short lived and if a local repo repo was | ||
busbey marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # given this will let us refer to objects there directly instead of hardlinks or copying. | ||
| # The option is silently ignored for non-local repositories. see the note on git help clone | ||
| # for the --shared option for details. | ||
busbey marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| git clone --shared -b "${GIT_BRANCH}" -- "${GIT_REPO}" "${PROJECT}" | ||
| # If this was a host local git repo then add in an alternates and remote that will | ||
| # work back on the host if the RM needs to do any post-processing steps, i.e. pushing the git tag | ||
busbey marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # for more info see 'git help remote' and 'git help repository-layout'. | ||
| if [ -n "$HOST_GIT_REPO" ]; then | ||
| echo "${HOST_GIT_REPO}/objects" >> "${PROJECT}/.git/objects/info/alternates" | ||
| (cd "${PROJECT}"; git remote add host "${HOST_GIT_REPO}") | ||
| fi | ||
| } | ||
| # Writes report into cwd! | ||
| function generate_api_report { | ||
| local project="$1" | ||
Uh oh!
There was an error while loading. Please reload this page.