Repository: incubator-ratis Updated Branches: refs/heads/master 7edcd52b0 -> 630ad7f4d
RATIS-4. Setup jenkins. Contributed by Marton Elek. Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/630ad7f4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/630ad7f4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/630ad7f4 Branch: refs/heads/master Commit: 630ad7f4d0ca83e729c33d4a4c8f4a3682280a9b Parents: 7edcd52 Author: Jitendra Pandey <[email protected]> Authored: Thu Nov 2 14:42:41 2017 -0700 Committer: Jitendra Pandey <[email protected]> Committed: Thu Nov 2 14:42:41 2017 -0700 ---------------------------------------------------------------------- .gitignore | 1 + dev-support/ci/README.md | 40 ++++++++ dev-support/ci/common.sh | 37 +++++++ dev-support/ci/nightly-build.sh | 47 +++++++++ dev-support/ci/precommit-build.sh | 49 +++++++++ dev-support/docker/Dockerfile | 90 +++++++++++++++++ dev-support/test-patch | 18 ++++ dev-support/yetus-personality.sh | 32 ++++++ dev-support/yetus-wrapper | 177 +++++++++++++++++++++++++++++++++ start-build-env.sh | 55 ++++++++++ 10 files changed, 546 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index d208ca9..688c2ea 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ .settings target build +patchprocess http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/ci/README.md ---------------------------------------------------------------------- diff --git a/dev-support/ci/README.md b/dev-support/ci/README.md new file mode 100644 index 0000000..7d6bbef --- /dev/null +++ b/dev-support/ci/README.md @@ -0,0 +1,40 @@ +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. See accompanying LICENSE file. +--> + +RATIS CI scripts +---------------- + +These scripts are called from jenkins for ratis pre-commit and nightly build jobs. + +On jenkins, the repository is checked out to a subdirectory (sourcedir) and the script is called from the parent directory which is also used to store temporary files (yetus/out/...). + +IT'S NOT RECOMMENDED to run it locally unless you know what could be expected. The script runs in sentinel/robot mode, so: + + * Old docker images are removed by the script + * Local commits are removed by the script + + +## Running locally + +To test the jenkins build locally: + + 1. create a new directory + 2. Clone the ratis repository to a subdirectory: `git clone git://github.com/apache/incubator-ratis.git sourcedir` + 3. Run the script fro the parent directory ./sourcedir/dev-support/ci/nightly-build.sh + +For nightly-build.sh you can set the BRANCH environment variable to define which branch should be tested. + +For precommit-build.sh you should set ISSUE_NUM (eg. 122, RATIS prefix should not be added). + +The variables are set by the jenkins. http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/ci/common.sh ---------------------------------------------------------------------- diff --git a/dev-support/ci/common.sh b/dev-support/ci/common.sh new file mode 100644 index 0000000..a3129e6 --- /dev/null +++ b/dev-support/ci/common.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +#Workspace is set by the jenkins, by default (local run) is the parent directory of the checkout. +WORKSPACE=${WORKSPACE:-$DIR/../../..} +cd $WORKSPACE + +YETUSDIR=${WORKSPACE}/yetus +TESTPATCHBIN=${YETUSDIR}/bin/test-patch +ARTIFACTS=${WORKSPACE}/out +BASEDIR=${WORKSPACE}/sourcedir +TOOLS=${WORKSPACE}/tools +rm -rf "${ARTIFACTS}" "${YETUSDIR}" +mkdir -p "${ARTIFACTS}" "${YETUSDIR}" "${TOOLS}" + +#It's not on all the branches, so we need to copy it from the checkout out source +cp $BASEDIR/dev-support/yetus-personality.sh $WORKSPACE/ +cp $BASEDIR/dev-support/docker/Dockerfile $WORKSPACE/ + +echo "Downloading Yetus" +curl -L https://archive.apache.org/dist/yetus/0.5.0/yetus-0.5.0-bin.tar.gz -o yetus.tar.gz +gunzip -c yetus.tar.gz | tar xpf - -C "${YETUSDIR}" --strip-components 1 http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/ci/nightly-build.sh ---------------------------------------------------------------------- diff --git a/dev-support/ci/nightly-build.sh b/dev-support/ci/nightly-build.sh new file mode 100644 index 0000000..ff11058 --- /dev/null +++ b/dev-support/ci/nightly-build.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $DIR/common.sh + +YETUS_ARGS+=("--archive-list=checkstyle-errors.xml,findbugsXml.xml") +YETUS_ARGS+=("--basedir=${BASEDIR}") +YETUS_ARGS+=("--branch=${BRANCH:-master}") +YETUS_ARGS+=("--brief-report-file=${ARTIFACTS}/email-report.txt") +YETUS_ARGS+=("--build-url-artifacts=artifact/out") +YETUS_ARGS+=("--console-report-file=${ARTIFACTS}/console-report.txt") +YETUS_ARGS+=("--console-urls") +YETUS_ARGS+=("--docker") +YETUS_ARGS+=("--dockerfile=${WORKSPACE}/Dockerfile") +YETUS_ARGS+=("--dockermemlimit=20g") +YETUS_ARGS+=("--empty-patch") +YETUS_ARGS+=("--html-report-file=${ARTIFACTS}/console-report.html") +YETUS_ARGS+=("--java-home=/usr/lib/jvm/java-8-openjdk-amd64") +YETUS_ARGS+=("--jenkins") +YETUS_ARGS+=("--mvn-custom-repos") +YETUS_ARGS+=("--patch-dir=${ARTIFACTS}") +YETUS_ARGS+=("--plugins=all,-author") +YETUS_ARGS+=("--proclimit=5000") +YETUS_ARGS+=("--project=ratis") +YETUS_ARGS+=("--personality=${WORKSPACE}/yetus-personality.sh") +YETUS_ARGS+=("--resetrepo") +YETUS_ARGS+=("--sentinel") +YETUS_ARGS+=("--shelldocs=/testptch/hadoop/dev-support/bin/shelldocs") +YETUS_ARGS+=("--tests-filter=cc,checkstyle,javac,javadoc,pylint,shellcheck,shelldocs,whitespace") + +TESTPATCHBIN=${YETUSDIR}/bin/test-patch + +/bin/bash ${TESTPATCHBIN} "${YETUS_ARGS[@]}" http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/ci/precommit-build.sh ---------------------------------------------------------------------- diff --git a/dev-support/ci/precommit-build.sh b/dev-support/ci/precommit-build.sh new file mode 100644 index 0000000..7cae44f --- /dev/null +++ b/dev-support/ci/precommit-build.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $DIR/common.sh + +YETUS_ARGS+=("--archive-list=checkstyle-errors.xml,findbugsXml.xml") +YETUS_ARGS+=("--basedir=${BASEDIR}") +YETUS_ARGS+=("--brief-report-file=${ARTIFACTS}/email-report.txt") +YETUS_ARGS+=("--build-url-artifacts=artifact/out") +YETUS_ARGS+=("--console-report-file=${ARTIFACTS}/console-report.txt") +YETUS_ARGS+=("--console-urls") +YETUS_ARGS+=("--docker") +YETUS_ARGS+=("--dockerfile=${WORKSPACE}/Dockerfile") +YETUS_ARGS+=("--dockermemlimit=20g") +YETUS_ARGS+=("--findbugs-strict-precheck") +YETUS_ARGS+=("--html-report-file=${ARTIFACTS}/console-report.html") +YETUS_ARGS+=("--jenkins") +YETUS_ARGS+=("--jira-password=${JIRA_PASSWORD}") +YETUS_ARGS+=("--jira-user=hadoopqa") +YETUS_ARGS+=("--multijdkdirs=/usr/lib/jvm/java-8-oracle") +YETUS_ARGS+=("--mvn-custom-repos") +YETUS_ARGS+=("--patch-dir=${ARTIFACTS}") +YETUS_ARGS+=("--project=ratis") +YETUS_ARGS+=("--personality=${WORKSPACE}/yetus-personality.sh") +YETUS_ARGS+=("--proclimit=5000") +YETUS_ARGS+=("--resetrepo") +YETUS_ARGS+=("--sentinel") +YETUS_ARGS+=("--shelldocs=/testptch/hadoop/dev-support/bin/shelldocs") +YETUS_ARGS+=("--skip-dir=dev-support") +YETUS_ARGS+=("--tests-filter=checkstyle,pylint,shelldocs") + +YETUS_ARGS+=("RATIS-${ISSUE_NUM}") + + +/bin/bash ${TESTPATCHBIN} "${YETUS_ARGS[@]}" http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/docker/Dockerfile ---------------------------------------------------------------------- diff --git a/dev-support/docker/Dockerfile b/dev-support/docker/Dockerfile new file mode 100644 index 0000000..8381a21 --- /dev/null +++ b/dev-support/docker/Dockerfile @@ -0,0 +1,90 @@ + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Dockerfile for installing the necessary dependencies for building Hadoop. +# See BUILDING.txt. + + +FROM ubuntu:xenial + +WORKDIR /root + +ENV DEBIAN_FRONTEND noninteractive +ENV DEBCONF_TERSE true + +###### +# Install common dependencies from packages +# +# WARNING: DO NOT PUT JAVA APPS HERE! Otherwise they will install default +# Ubuntu Java. See Java section below! +###### +RUN apt-get -q update && apt-get -q install --no-install-recommends -y \ + curl \ + unzip \ + git \ + wget \ + rsync + +# wget configuration + +RUN echo "dot_style = mega" > "/root/.wgetrc" +RUN echo "quiet = on" >> "/root/.wgetrc" + + +####### +# OpenJDK Java +####### + +RUN apt-get -q install -y openjdk-8-jdk + +###### +# Install protobuf compiler 3.1 +###### + +RUN mkdir -p $HOME/protobuf && \ + cd $HOME/protobuf && wget https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip && \ + unzip protoc-3.1.0-linux-x86_64.zip && \ + mv $HOME/protobuf/bin/protoc /usr/local/bin && \ + chmod 755 /usr/local/bin/protoc + + +###### +# Install Apache Maven +###### +RUN mkdir -p /opt/maven && \ + curl -L -s -S \ + http://www-us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ + -o /opt/maven.tar.gz && \ + tar xzf /opt/maven.tar.gz --strip-components 1 -C /opt/maven +ENV MAVEN_HOME /opt/maven +ENV PATH "$PATH:/opt/maven/bin" + +###### +# Install findbugs +###### +#RUN mkdir -p /opt/findbugs && \ +# curl -L -s -S \ +# https://sourceforge.net/projects/findbugs/files/findbugs/3.0.1/findbugs-noUpdateChecks-3.0.1.tar.gz/download \ +# -o /opt/findbugs.tar.gz && \ +# tar xzf /opt/findbugs.tar.gz --strip-components 1 -C /opt/findbugs +#ENV FINDBUGS_HOME /opt/findbugs + +### +# Avoid out of memory errors in builds +### +ENV MAVEN_OPTS -Xms256m -Xmx512m + http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/test-patch ---------------------------------------------------------------------- diff --git a/dev-support/test-patch b/dev-support/test-patch new file mode 100644 index 0000000..25d9d81 --- /dev/null +++ b/dev-support/test-patch @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +BINDIR=$(cd -P -- "$(dirname -- "${BASH_SOURCE-0}")" >/dev/null && pwd -P) +exec "${BINDIR}/yetus-wrapper" test-patch --project=ratis --dockerfile="$BINDIR/docker/Dockerfile" --personality=$BINDIR/yetus-personality.sh --skip-dir=dev-support "$@" http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/yetus-personality.sh ---------------------------------------------------------------------- diff --git a/dev-support/yetus-personality.sh b/dev-support/yetus-personality.sh new file mode 100644 index 0000000..d700512 --- /dev/null +++ b/dev-support/yetus-personality.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +personality_plugins "all" + +## @description Globals specific to this personality +## @audience private +## @stability evolving +function personality_globals +{ + # shellcheck disable=SC2034 + BUILDTOOL=maven + #shellcheck disable=SC2034 + PATCH_BRANCH_DEFAULT=master + #shellcheck disable=SC2034 + JIRA_ISSUE_RE='^RATIS-[0-9]+$' + #shellcheck disable=SC2034 + GITHUB_REPO="apache/incubator-ratis" +} http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/dev-support/yetus-wrapper ---------------------------------------------------------------------- diff --git a/dev-support/yetus-wrapper b/dev-support/yetus-wrapper new file mode 100644 index 0000000..dc40a7e --- /dev/null +++ b/dev-support/yetus-wrapper @@ -0,0 +1,177 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# you must be this high to ride the ride +if [[ -z "${BASH_VERSINFO[0]}" ]] \ + || [[ "${BASH_VERSINFO[0]}" -lt 3 ]] \ + || [[ "${BASH_VERSINFO[0]}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then + echo "bash v3.2+ is required. Sorry." + exit 1 +fi + +set -o pipefail + +## @description Print a message to stderr +## @audience public +## @stability stable +## @replaceable no +## @param string +function yetus_error +{ + echo "$*" 1>&2 +} + +## @description Given a filename or dir, return the absolute version of it +## @audience public +## @stability stable +## @param directory +## @replaceable no +## @return 0 success +## @return 1 failure +## @return stdout abspath +function yetus_abs +{ + declare obj=$1 + declare dir + declare fn + declare dirret + + if [[ ! -e ${obj} ]]; then + return 1 + elif [[ -d ${obj} ]]; then + dir=${obj} + else + dir=$(dirname -- "${obj}") + fn=$(basename -- "${obj}") + fn="/${fn}" + fi + + dir=$(cd -P -- "${dir}" >/dev/null 2>/dev/null && pwd -P) + dirret=$? + if [[ ${dirret} = 0 ]]; then + echo "${dir}${fn}" + return 0 + fi + return 1 +} + + +WANTED="$1" +shift +ARGV=("$@") + +HADOOP_YETUS_VERSION=${HADOOP_YETUS_VERSION:-0.4.0} +BIN=$(yetus_abs "${BASH_SOURCE-$0}") +BINDIR=$(dirname "${BIN}") +echo "${WANTED}" +### +### if YETUS_HOME is set, then try to use it +### +if [[ -n "${YETUS_HOME}" + && -x "${YETUS_HOME}/bin/${WANTED}" ]]; then + exec "${YETUS_HOME}/bin/${WANTED}" "${ARGV[@]}" +fi + +# +# this directory is ignored by git and maven +# +HADOOP_PATCHPROCESS=${HADOOP_PATCHPROCESS:-"${BINDIR}/../../patchprocess"} + +if [[ ! -d "${HADOOP_PATCHPROCESS}" ]]; then + mkdir -p "${HADOOP_PATCHPROCESS}" +fi + +mytmpdir=$(yetus_abs "${HADOOP_PATCHPROCESS}") +ret=$? +if [[ ${ret} != 0 ]]; then + yetus_error "yetus-dl: Unable to cwd to ${HADOOP_PATCHPROCESS}" + exit 1 +fi +HADOOP_PATCHPROCESS=${mytmpdir} + +## +## if we've already DL'd it, then short cut +## +if [[ -x "${HADOOP_PATCHPROCESS}/yetus-${HADOOP_YETUS_VERSION}/bin/${WANTED}" ]]; then + exec "${HADOOP_PATCHPROCESS}/yetus-${HADOOP_YETUS_VERSION}/bin/${WANTED}" "${ARGV[@]}" +fi + +## +## need to DL, etc +## + +BASEURL="https://archive.apache.org/dist/yetus/${HADOOP_YETUS_VERSION}/" +TARBALL="yetus-${HADOOP_YETUS_VERSION}-bin.tar" + +GPGBIN=$(command -v gpg) +CURLBIN=$(command -v curl) + +if ! pushd "${HADOOP_PATCHPROCESS}" >/dev/null; then + yetus_error "ERROR: yetus-dl: Cannot pushd to ${HADOOP_PATCHPROCESS}" + exit 1 +fi + +if [[ -n "${CURLBIN}" ]]; then + if ! "${CURLBIN}" -f -s -L -O "${BASEURL}/${TARBALL}.gz"; then + yetus_error "ERROR: yetus-dl: unable to download ${BASEURL}/${TARBALL}.gz" + exit 1 + fi +else + yetus_error "ERROR: yetus-dl requires curl." + exit 1 +fi + +if [[ -n "${GPGBIN}" ]]; then + if ! mkdir -p .gpg; then + yetus_error "ERROR: yetus-dl: Unable to create ${HADOOP_PATCHPROCESS}/.gpg" + exit 1 + fi + if ! chmod -R 700 .gpg; then + yetus_error "ERROR: yetus-dl: Unable to chmod ${HADOOP_PATCHPROCESS}/.gpg" + exit 1 + fi + if ! "${CURLBIN}" -s -L -o KEYS_YETUS https://dist.apache.org/repos/dist/release/yetus/KEYS; then + yetus_error "ERROR: yetus-dl: unable to fetch https://dist.apache.org/repos/dist/release/yetus/KEYS" + exit 1 + fi + if ! "${CURLBIN}" -s -L -O "${BASEURL}/${TARBALL}.gz.asc"; then + yetus_error "ERROR: yetus-dl: unable to fetch ${BASEURL}/${TARBALL}.gz.asc" + exit 1 + fi + if ! "${GPGBIN}" --homedir "${HADOOP_PATCHPROCESS}/.gpg" --import "${HADOOP_PATCHPROCESS}/KEYS_YETUS" >/dev/null 2>&1; then + yetus_error "ERROR: yetus-dl: gpg unable to import ${HADOOP_PATCHPROCESS}/KEYS_YETUS" + exit 1 + fi + if ! "${GPGBIN}" --homedir "${HADOOP_PATCHPROCESS}/.gpg" --verify "${TARBALL}.gz.asc" >/dev/null 2>&1; then + yetus_error "ERROR: yetus-dl: gpg verify of tarball in ${HADOOP_PATCHPROCESS} failed" + exit 1 + fi +fi + +if ! (gunzip -c "${TARBALL}.gz" | tar xpf -); then + yetus_error "ERROR: ${TARBALL}.gz is corrupt. Investigate and then remove ${HADOOP_PATCHPROCESS} to try again." + exit 1 +fi + +if [[ -x "${HADOOP_PATCHPROCESS}/yetus-${HADOOP_YETUS_VERSION}/bin/${WANTED}" ]]; then + popd >/dev/null + exec "${HADOOP_PATCHPROCESS}/yetus-${HADOOP_YETUS_VERSION}/bin/${WANTED}" "${ARGV[@]}" +fi + +## +## give up +## +yetus_error "ERROR: ${WANTED} is not part of Apache Yetus ${HADOOP_YETUS_VERSION}" +exit 1 http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/630ad7f4/start-build-env.sh ---------------------------------------------------------------------- diff --git a/start-build-env.sh b/start-build-env.sh new file mode 100644 index 0000000..db182b3 --- /dev/null +++ b/start-build-env.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # exit on error + +cd "$(dirname "$0")" # connect to root + +docker build -t ratis-build dev-support/docker + +if [ "$(uname -s)" == "Linux" ]; then + USER_NAME=${SUDO_USER:=$USER} + USER_ID=$(id -u "${USER_NAME}") + GROUP_ID=$(id -g "${USER_NAME}") +else # boot2docker uid and gid + USER_NAME=$USER + USER_ID=1000 + GROUP_ID=50 +fi + +docker build -t "ratis-build-${USER_ID}" - <<UserSpecificDocker +FROM ratis-build +RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME} +RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} +ENV HOME /home/${USER_NAME} +UserSpecificDocker + +TTY_MODE="-t -i" +if [ "$#" -gt 0 ]; then + TTY_MODE="" +fi +# By mapping the .m2 directory you can do an mvn install from +# within the container and use the result on your normal +# system. And this also is a significant speedup in subsequent +# builds because the dependencies are downloaded only once. +docker run --rm=true $TTY_MODE \ + -v "${PWD}:/home/${USER_NAME}/ratis" \ + -w "/home/${USER_NAME}/ratis" \ + -v "${HOME}/.m2:/home/${USER_NAME}/.m2" \ + -u "${USER_NAME}" \ + "ratis-build-${USER_ID}" \ + "$@"
