@@ -62,52 +62,121 @@ function usage {
6262Usage: $NAME [OPTIONS]
6363Runs release scripts inside a docker image.
6464Options:
65- -d [path] Required. Working directory. Output will be written to "output" in here.
66- -f "force" -- actually publish this release. Unless you specify '-f', it will
67- default to dry run mode, which checks and does local builds, but does not
68- upload anything.
69- -t [tag] Tag for the hbase-rm docker image to use for building (default: "latest").
70- -j [path] Path to local JDK installation to use building. By default the script will
71- use openjdk8 installed in the docker image.
72- -p [project] Project to build: e.g. 'hbase' or 'hbase-thirdparty'; defaults to PROJECT env var
73- -r [repo] Git repo to use for remote git operations. defaults to ASF gitbox for project.
74- -s [step] Runs a single step of the process; valid steps: tag|publish-dist|publish-release.
75- If none specified, runs tag, then publish-dist, and then publish-release.
76- 'publish-snapshot' is also an allowed, less used, option.
77- -x Debug. Does less clean up (env file, gpg forwarding on mac)
65+ -d [path], --directory=[path]
66+ Required. Working directory. Output will be written to "output" in here.
67+ -f, --force
68+ Optional. Perform any associated permanent action. Without this flag, the
69+ release defaults to 'dry run' mode, which checks and does local builds, but
70+ does not upload anything.
71+ -j [path], --java=[path]
72+ Optional. Path to JDK installation on the host OS, which is mounted into
73+ the container runtime. Mutually exclusive with the --jdk8 and --jdk11
74+ options.
75+ --jdk8
76+ Optional. Override the default JDK selection and use the OpenJDK 8
77+ installation provided by the container runtime. Mutually exclusive with the
78+ -j and --jdk11 options.
79+ --jdk11
80+ Optional. Override the default JDK selection and use the OpenJDK 11
81+ installation provided by the container runtime. Mutually exclusive with the
82+ -j and --jdk8 options. When none of -j, --jdk8, --jdk11 are specified, the
83+ default behavior is to behave as if this flag had been specified.
84+ -p [project], --project=[project]
85+ Optional. The name of the project to build: e.g. 'hbase' or
86+ 'hbase-thirdparty'; defaults to \` PROJECT\` environment variable.
87+ -r [repo], --repo=[repo]
88+ Optional. Git repo to use for remote git operations. defaults to ASF gitbox
89+ for project.
90+ -s [step], --step=[step]
91+ Optional. Runs a single step of the process; valid steps: \` tag\` ,
92+ \` publish-dist\` , \` publish-snapshot\` , \` publish-release\` . If not
93+ specified, runs \` tag\` , then \` publish-dist\` , and then \` publish-release\` .
94+ -t [tag], --tag=[tag]
95+ Optional. Tag for the hbase-rm docker image to use for building (default:
96+ "latest").
97+ -x, --debug
98+ Optional. Enable debug mode, which produces more verbose output and
99+ performs less clean up (env file, gpg forwarding on mac).
78100EOF
79101 exit 1
80102}
81103
104+ # For long option names, use GNU getopt. This script assumes the presence of docker anyway, so use
105+ # the getopt provided out-of-the-box by the linux distro. Use the same base image as is used by
106+ # hbase-rm/Dockerfile.
107+ GETOPT_OPTS=" $( docker container run \
108+ ubuntu:18.04 \
109+ /usr/bin/getopt \
110+ -o ' d:fhj:p:r:s:t:x' \
111+ --long ' directory:,force,help,java:,jdk8,jdk11,project:,repo:,step:,tag:,debug' \
112+ -n ' do-release-docker.sh' \
113+ -- \
114+ " $@ " ) "
115+ eval set -- " $GETOPT_OPTS "
116+
117+ if [[ " $1 " == " --" ]] ; then
118+ usage
119+ fi
120+
82121WORKDIR=
83- IMGTAG=latest
84- JAVA=
122+ IMGTAG=' latest'
85123RELEASE_STEP=
86124GIT_REPO=
87- while getopts " d:fhj:p:r:s:t:x" opt; do
88- case $opt in
89- d) WORKDIR=" $OPTARG " ;;
90- f) DRY_RUN=0 ;;
91- t) IMGTAG=" $OPTARG " ;;
92- j) JAVA=" $OPTARG " ;;
93- p) PROJECT=" $OPTARG " ;;
94- r) GIT_REPO=" $OPTARG " ;;
95- s) RELEASE_STEP=" $OPTARG " ;;
96- x) DEBUG=1 ;;
97- h) usage ;;
98- ? ) error " Invalid option. Run with -h for help." ;;
125+ while true ; do
126+ case " $1 " in
127+ -d | --directory )
128+ case " $2 " in
129+ " " ) shift 2 ;;
130+ * ) WORKDIR=" $2 " ; shift 2 ;;
131+ esac ;;
132+ -f | --force ) DRY_RUN=0 ; shift ;;
133+ -h | --help ) usage ;;
134+ -j | --java )
135+ case " $2 " in
136+ " " ) shift 2 ;;
137+ * ) JAVA=" $2 " ; shift 2 ;;
138+ esac ;;
139+ --jdk8 ) JDK8=1 ; shift ;;
140+ --jdk11 ) JDK11=1 ; shift ;;
141+ -p | --project )
142+ case " $2 " in
143+ " " ) shift 2 ;;
144+ * ) PROJECT=" $2 " ; shift 2 ;;
145+ esac ;;
146+ -r | --repo )
147+ case " $2 " in
148+ " " ) shift 2 ;;
149+ * ) GIT_REPO=" $2 " ; shift 2 ;;
150+ esac ;;
151+ -s | --step )
152+ case " $2 " in
153+ " " ) shift 2 ;;
154+ * ) RELEASE_STEP=" $2 " ; shift 2 ;;
155+ esac ;;
156+ -t | --tag )
157+ case " $2 " in
158+ " " ) shift 2 ;;
159+ * ) IMGTAG=" $2 " ; shift 2 ;;
160+ esac ;;
161+ -x | --debug ) DEBUG=1 ; shift ;;
162+ -- ) shift ; break ;;
163+ * ) error " Invalid option '$1 '. Run with -h for help." ;;
99164 esac
100165done
101- shift $(( OPTIND- 1 ))
102- if (( $# > 0 )) ; then
103- error " Arguments can only be provided with option flags, invalid args: $* "
104- fi
166+
105167export DEBUG
106168
107169if [ -z " $WORKDIR " ] || [ ! -d " $WORKDIR " ]; then
108170 error " Work directory (-d) must be defined and exist. Run with -h for help."
109171fi
110172
173+ JDK_ONE_OR_NONE=" ${JAVA: +x}${JDK8: +x}${JDK11: +x} "
174+ case " $JDK_ONE_OR_NONE " in
175+ xx | xxx )
176+ error " Options --java, --jdk8, --jdk11 are mutually exclusive. Run with -h for help."
177+ ;;
178+ esac
179+
111180if [ -d " $WORKDIR /output" ]; then
112181 read -r -p " Output directory already exists. Overwrite and continue? [y/n] " ANSWER
113182 if [ " $ANSWER " != " y" ]; then
@@ -229,6 +298,14 @@ if [ -n "$JAVA" ]; then
229298 JAVA_MOUNT=(--mount " type=bind,src=${JAVA} ,dst=/opt/hbase-java,readonly" )
230299fi
231300
301+ if [ -n " $JDK8 " ] ; then
302+ echo " JDK8=${JDK8} " >> " $ENVFILE "
303+ fi
304+
305+ if [ -n " $JDK11 " ] ; then
306+ echo " JDK11=${JDK11} " >> " $ENVFILE "
307+ fi
308+
232309# TODO some debug output would be good here
233310GIT_REPO_MOUNT=()
234311if [ -n " ${GIT_REPO} " ]; then
0 commit comments