You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ms...@apache.org on 2019/03/07 03:18:41 UTC

[cassandra-builds] 01/01: WIP: dual-JDK tar artifact build scripts

This is an automated email from the ASF dual-hosted git repository.

mshuler pushed a commit to branch tar-artifact-build
in repository https://gitbox.apache.org/repos/asf/cassandra-builds.git

commit d7b102bcded9146e11744121b33d61dc3fa41d83
Author: Michael Shuler <mi...@pbandjelly.org>
AuthorDate: Wed Mar 6 21:17:27 2019 -0600

    WIP: dual-JDK tar artifact build scripts
---
 docker/build-tars.sh       | 75 ++++++++++++++++++++++++++++++++++++++++++++++
 docker/buster-image.docker | 43 ++++++++++++++++++++++++++
 2 files changed, 118 insertions(+)

diff --git a/docker/build-tars.sh b/docker/build-tars.sh
new file mode 100755
index 0000000..f0bd31e
--- /dev/null
+++ b/docker/build-tars.sh
@@ -0,0 +1,75 @@
+#!/bin/bash -x
+set -e
+
+if [ "$#" -ne 1 ]; then
+   echo "$0 <branch>"
+   exit 1
+fi
+
+CASSANDRA_BRANCH=$1
+
+cd $CASSANDRA_DIR
+git fetch
+git checkout $CASSANDRA_BRANCH || exit 1
+
+# Used version for build will always depend on the git referenced used for checkout above
+# Branches will always be created as snapshots, while tags are releases
+tag=`git describe --tags --exact-match` 2> /dev/null || true
+branch=`git symbolic-ref -q --short HEAD` 2> /dev/null || true
+
+is_tag=false
+is_branch=false
+git_version=''
+
+if [ "$tag" ]; then
+   is_tag=true
+   # Official release
+   regx_tag="cassandra-([0-9.]+)$"
+   # Tentative release
+   regx_tag_tentative="([0-9.]+)-tentative$"
+   if [[ $tag =~ $regx_tag ]] || [[ $tag =~ $regx_tag_tentative ]]; then
+      git_version=${BASH_REMATCH[1]}
+   else
+      echo "Error: could not recognize version from tag $tag">&2
+      exit 2
+   fi
+elif [ "$branch" ]; then
+   # Dev branch
+   is_branch=true
+   regx_branch="cassandra-([0-9.]+)$"
+   if [[ $branch =~ $regx_branch ]]; then
+      git_version=${BASH_REMATCH[1]}
+   else
+      # This could be either trunk or any dev branch, so we won't be able to get the version
+      # from the branch name. In this case, fall back to debian change log version.
+      git_version=$(dpkg-parsechangelog | sed -ne 's/^Version: \([^-|~|+]*\).*/\1/p')
+      if [ -z $git_version ]; then
+         echo "Error: could not recognize version from branch $branch">&2
+         exit 2
+      else
+         echo "Warning: could not recognize version from branch, using dpkg version: $git_version"
+      fi
+   fi
+else
+   echo "Error: invalid git reference; must either be branch or tag">&2
+   exit 1
+fi
+
+# Version (base.version) in build.xml must be set manually as well. Let's validate the set value.
+buildxml_version=`grep 'property\s*name="base.version"' build.xml |sed -ne 's/.*value="\([^"]*\)".*/\1/p'`
+if [ $buildxml_version != $git_version ]; then
+   echo "Error: build.xml version ($buildxml_version) not matching git tag derived version ($git_version)">&2
+   exit 4
+fi
+
+# Dual JDK build for version >= 4.*
+if dpkg --compare-versions $buildxml_version ge 4; then
+   export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
+   export JAVA8_HOME=/usr/lib/jvm/java-8-openjdk-amd64
+fi
+
+#TODO: dev build - check release/tentative and pass '-Drelease=true'
+ant artifacts
+
+# Copy created artifacts to dist dir mapped to docker host directory (must have proper permissions)
+cp build/apache-cassandra-*.tar.gz $DIST_DIR
diff --git a/docker/buster-image.docker b/docker/buster-image.docker
new file mode 100644
index 0000000..7eb120a
--- /dev/null
+++ b/docker/buster-image.docker
@@ -0,0 +1,43 @@
+FROM debian:buster
+
+ENV DIST_DIR=/dist
+ENV BUILD_HOME=/home/build
+ENV CASSANDRA_DIR=$BUILD_HOME/cassandra
+
+LABEL org.cassandra.buildenv=buster
+
+VOLUME ${DIST_DIR}
+
+# install deps
+RUN apt-get update && apt-get -y install \
+   ant \
+   build-essential \
+   curl \
+   devscripts \
+   git \
+   sudo
+
+RUN apt-get -y --no-install-recommends install \
+   openjdk-8-jdk-headless \
+   openjdk-11-jdk-headless
+
+RUN apt-get -y install \
+   python-sphinx \
+   python-sphinx-rtd-theme
+
+RUN update-java-alternatives --set java-1.8.0-openjdk-amd64
+
+# create and change to build user
+RUN adduser --disabled-login --gecos build build && gpasswd -a build sudo
+RUN echo "build ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/build && \
+   chmod 0440 /etc/sudoers.d/build
+
+USER build
+
+# clone Cassandra and cache maven artifacts
+ARG CASSANDRA_GIT_URL=https://gitbox.apache.org/repos/asf/cassandra.git
+RUN git clone ${CASSANDRA_GIT_URL} ${CASSANDRA_DIR}
+WORKDIR ${CASSANDRA_DIR}
+RUN ant maven-ant-tasks-retrieve-build
+
+COPY build-tars.sh $BUILD_HOME/


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org