Skip to content

Commit aada0c0

Browse files
committed
add support for multiple jdk versions
Include both jdk8 and jdk11 in our docker image. Extend `do-release-docker.sh` to support selecting a jdk version ; doing so required switching from the bash build-in `getopts` to the less featureful command `getopt`, which supports parsing long command options.
1 parent 2594508 commit aada0c0

File tree

3 files changed

+114
-33
lines changed

3 files changed

+114
-33
lines changed

dev-support/create-release/do-release-docker.sh

Lines changed: 108 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,52 +62,121 @@ function usage {
6262
Usage: $NAME [OPTIONS]
6363
Runs release scripts inside a docker image.
6464
Options:
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).
78100
EOF
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+
82121
WORKDIR=
83-
IMGTAG=latest
84-
JAVA=
122+
IMGTAG='latest'
85123
RELEASE_STEP=
86124
GIT_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
100165
done
101-
shift $((OPTIND-1))
102-
if (( $# > 0 )); then
103-
error "Arguments can only be provided with option flags, invalid args: $*"
104-
fi
166+
105167
export DEBUG
106168

107169
if [ -z "$WORKDIR" ] || [ ! -d "$WORKDIR" ]; then
108170
error "Work directory (-d) must be defined and exist. Run with -h for help."
109171
fi
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+
111180
if [ -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")
230299
fi
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
233310
GIT_REPO_MOUNT=()
234311
if [ -n "${GIT_REPO}" ]; then

dev-support/create-release/do-release.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ if [ "$RUNNING_IN_DOCKER" = "1" ]; then
8181
if [ -n "$JAVA_HOME" ]; then
8282
echo "Using JAVA_HOME from host."
8383
export PATH="$JAVA_HOME/bin:$PATH"
84-
else
85-
# JAVA_HOME for the openjdk package.
84+
elif [ -n "$JDK8" ] ; then
85+
# JAVA_HOME for the openjdk8 package.
8686
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
87+
else
88+
# default to JAVA_HOME for the openjdk11 package.
89+
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
8790
fi
8891
else
8992
# Outside docker, need to ask for information about the release.

dev-support/create-release/hbase-rm/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y update \
3333
libxml2-dev='2.9.13+dfsg-*' \
3434
libxml2-utils='2.9.13+dfsg-*' \
3535
lsof='4.93.2+dfsg-*' \
36+
openjdk-8-jdk-headless='8*' \
3637
openjdk-11-jdk-headless='11*' \
3738
python3-pip='22.0.2+dfsg-*' \
3839
subversion='1.14.1-*' \

0 commit comments

Comments
 (0)