diff --git a/CHANGELOG.md b/CHANGELOG.md
index 052de9f..ccb9853 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
## Version 6.2
+### Version 6.2.4.0 - 2019-09-05
+
+#### Added
+- An option to GPUdb.Options for bypassing SSL certificate verification
+ for HTTPS connections. Obtained by and set by Options.getBypassSslCertCheck()
+ and Options.setBypassSslCertCheck(boolean) methods.
+
### Version 6.2.3.0 - 2019-08-01
#### Added
diff --git a/VERSION b/VERSION
index dec4cf8..d39793e 100644
--- a/VERSION
+++ b/VERSION
@@ -1,4 +1,4 @@
MAJOR = 6
MINOR = 2
-REVISION = 3
+REVISION = 4
ABI_VERSION = 0
diff --git a/api/pom.xml b/api/pom.xml
index 66b2db8..668f842 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.gpudb
gpudb-api
- 6.2.3.0
+ 6.2.4.0
jar
Kinetica Java API
diff --git a/api/src/main/java/com/gpudb/GPUdbBase.java b/api/src/main/java/com/gpudb/GPUdbBase.java
index e5368a5..d1b8f20 100644
--- a/api/src/main/java/com/gpudb/GPUdbBase.java
+++ b/api/src/main/java/com/gpudb/GPUdbBase.java
@@ -6,6 +6,7 @@
import com.gpudb.protocol.ShowTableResponse;
import com.gpudb.protocol.ShowTypesRequest;
import com.gpudb.protocol.ShowTypesResponse;
+import com.gpudb.util.ssl.X509TrustManagerBypass;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -14,6 +15,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
+import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -31,6 +33,8 @@
import org.apache.commons.codec.binary.Base64;
import org.xerial.snappy.Snappy;
+
+
/**
* Base class for the GPUdb API that provides general functionality not specific
* to any particular GPUdb request. This class is never instantiated directly;
@@ -47,6 +51,7 @@ public static final class Options {
private String username;
private String password;
private boolean useSnappy = true;
+ private boolean bypassSslCertCheck = false;
private int threadCount = 1;
private ExecutorService executor;
private Map httpHeaders = new HashMap<>();
@@ -88,6 +93,18 @@ public boolean getUseSnappy() {
return useSnappy;
}
+ /**
+ * Gets the value of the flag indicating whether to verify the SSL
+ * certificate for HTTPS connections.
+ *
+ * @return the value of the SSL certificate verification bypass flag
+ *
+ * @see #setBypassSslCertCheck(boolean)
+ */
+ public boolean getBypassSslCertCheck() {
+ return this.bypassSslCertCheck;
+ }
+
/**
* Gets the number of threads that will be used during data encoding and
* decoding operations.
@@ -210,6 +227,24 @@ public Options setUseSnappy(boolean value) {
return this;
}
+ /**
+ * Sets the flag indicating whether to verify the SSL certificate for
+ * HTTPS connections. If {@code true}, then the SSL certificate sent
+ * by the server during HTTPS connection handshake will not be verified;
+ * the public key sent by the server will be blindly trusted and used
+ * to encrypt the packets. The default is {@code false}.
+ *
+ * @param value the value of the SSL certificate verification bypass
+ * flag
+ * @return the current {@link Options} instance
+ *
+ * @see #getBypassSslCertCheck()
+ */
+ public Options setBypassSslCertCheck(boolean value) {
+ this.bypassSslCertCheck = value;
+ return this;
+ }
+
/**
* Sets the number of threads that will be used during data encoding and
* decoding operations. If set to one (the default), all encoding and
@@ -562,6 +597,7 @@ public static Map options(String... values) {
private String password;
private String authorization;
private boolean useSnappy;
+ private boolean bypassSslCertCheck;
private int threadCount;
private ExecutorService executor;
private Map httpHeaders;
@@ -614,6 +650,19 @@ private void init(Options options) throws GPUdbException {
threadCount = options.getThreadCount();
executor = options.getExecutor();
+ // Handle SSL certificate verification bypass for HTTPS connections
+ this.bypassSslCertCheck = options.getBypassSslCertCheck();
+ if ( this.bypassSslCertCheck ) {
+ // This bypass works only for HTTPS connections
+ try {
+ X509TrustManagerBypass.install();
+ } catch (GeneralSecurityException ex) {
+ // Not doing anything about it since we're trying to bypass
+ // to reduce distractions anyway
+ }
+ }
+
+
// Create URLs for the host manager
this.hmUrls = new ArrayList();
for ( URL url : this.urls ) {
@@ -1456,38 +1505,68 @@ public T submitRequest(URL url, IndexedRecord request,
*/
}
- try (InputStream inputStream = connection.getResponseCode() < 400 ? connection.getInputStream() : connection.getErrorStream()) {
- if (inputStream == null) {
- throw new IOException("Server returned HTTP " + connection.getResponseCode() + " (" + connection.getResponseMessage() + ").");
+ // try (InputStream inputStream = connection.getResponseCode() < 400 ? connection.getInputStream() : connection.getErrorStream()) {
+
+ int response_code = connection.getResponseCode();
+
+ // Ensure that we're not getting any html snippet (may be
+ // returned by the HTTPD server)
+ if ( connection.getContentType().startsWith( "text" ) ) {
+ String responseMsg = connection.getResponseMessage();
+
+ String errorMsg;
+ if (response_code == 401) {
+ errorMsg = ("Unauthorized access: '"
+ + responseMsg + "'");
+ } else {
+ errorMsg = ("Cannot parse response from server: '"
+ + responseMsg + "'");
}
+ throw new SubmitException( url, request, requestSize, errorMsg );
+ }
- try {
- // Manually decode the RawGpudbResponse wrapper directly from
- // the stream to avoid allocation of intermediate buffers
+ // Parse response based on error code
+ InputStream inputStream;
+ if (response_code == 401) {
+ throw new SubmitException( url, request, requestSize,
+ connection.getResponseMessage());
+ }
+ else if (response_code < 400) {
+ inputStream = connection.getInputStream();
+ } else {
+ inputStream = connection.getErrorStream();
+ }
- BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(inputStream, null);
- String status = decoder.readString();
- String message = decoder.readString();
+ if (inputStream == null) {
+ throw new IOException("Server returned HTTP " + connection.getResponseCode() + " (" + connection.getResponseMessage() + ").");
+ }
- if (status.equals("ERROR")) {
- throw new SubmitException(url, request, requestSize, message);
- }
+ try {
+ // Manually decode the RawGpudbResponse wrapper directly from
+ // the stream to avoid allocation of intermediate buffers
- // Skip over data_type field
+ BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(inputStream, null);
+ String status = decoder.readString();
+ String message = decoder.readString();
- decoder.skipString();
+ if (status.equals("ERROR")) {
+ throw new SubmitException(url, request, requestSize, message);
+ }
- // Decode data field
+ // Skip over data_type field
- decoder.readInt();
- return new Avro.DatumReader(response.getSchema()).read(response, decoder);
- } finally {
- // Attempt to read any remaining data in the stream
+ decoder.skipString();
- try {
- inputStream.skip(Long.MAX_VALUE);
- } catch (Exception ex) {
- }
+ // Decode data field
+
+ decoder.readInt();
+ return new Avro.DatumReader(response.getSchema()).read(response, decoder);
+ } finally {
+ // Attempt to read any remaining data in the stream
+
+ try {
+ inputStream.skip(Long.MAX_VALUE);
+ } catch (Exception ex) {
}
}
} catch (SubmitException ex) {
diff --git a/api/src/main/java/com/gpudb/util/ssl/X509TrustManagerBypass.java b/api/src/main/java/com/gpudb/util/ssl/X509TrustManagerBypass.java
new file mode 100644
index 0000000..ec93608
--- /dev/null
+++ b/api/src/main/java/com/gpudb/util/ssl/X509TrustManagerBypass.java
@@ -0,0 +1,55 @@
+package com.gpudb.util.ssl;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509ExtendedTrustManager;
+import java.net.Socket;
+import java.security.GeneralSecurityException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+public class X509TrustManagerBypass extends X509ExtendedTrustManager {
+
+ public static void install() throws GeneralSecurityException {
+
+ TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManagerBypass() };
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
+ HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException {
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String authType, Socket socket)
+ throws CertificateException {
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String authType, SSLEngine sslEngine)
+ throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String authType, Socket socket)
+ throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String authType, SSLEngine sslEngine)
+ throws CertificateException {
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+}
diff --git a/rpmbuild/gpudb-api-java.spec b/rpmbuild/gpudb-api-java.spec
deleted file mode 100644
index 957a10c..0000000
--- a/rpmbuild/gpudb-api-java.spec
+++ /dev/null
@@ -1,38 +0,0 @@
-# Variables
-%define user gpudb
-%define owner gpudb
-%define prefix /opt/gpudb/api/java
-
-# Directives
-#%define __os_install_post %{nil}
-%define __jar_repack %{nil}
-
-# RPM Information
-Summary: Java client libraries for GPUdb.
-Name: gpudb-api-java
-Version: TEMPLATE_RPM_VERSION
-Release: TEMPLATE_RPM_RELEASE
-License: This product is licensed to use alongside GPUdb.
-Group: Applications/Databases
-Prefix: %{prefix}
-BuildArch: noarch
-Packager: GPUdb
-AutoReqProv: no
-URL: http://www.gpudb.com
-
-Source0: %{_sourcedir}/files.tgz
-
-%description
-Java client libraries for GPUdb.
-
-# ---------------------------------------------------------------------------
-%install
-mkdir -p $RPM_BUILD_ROOT%{prefix}
-pushd $RPM_BUILD_ROOT%{prefix}
-tar xzvf %{SOURCE0}
-popd
-
-# ---------------------------------------------------------------------------
-%files
-%defattr(0644,%{owner},%{user},0755)
-TEMPLATE_RPM_FILES
diff --git a/rpmbuild/make-dist-common.sh b/rpmbuild/make-dist-common.sh
deleted file mode 100644
index 24744db..0000000
--- a/rpmbuild/make-dist-common.sh
+++ /dev/null
@@ -1,456 +0,0 @@
-#!/usr/bin/env bash
-
-# This script only defines common functions used in all the make-xxx-dist scripts.
-# You must set the environment variable LOG=logfile.txt to capture the output.
-
-# The directory of this script.
-MAKE_DIST_COMMON_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-MAKE_DIST_COMMON_FILE="$SCRIPT_DIR/$(basename ${BASH_SOURCE[0]})"
-
-
-# ---------------------------------------------------------------------------
-# Echo to the $LOG file
-
-function log
-{
- echo "$1" | tee -a $LOG
-}
-
-# ---------------------------------------------------------------------------
-# Run a command and append output to $LOG file which should have already been set.
-
-function run_cmd
-{
- local CMD=$1
- #LOG=$2 easier to just use the global $LOG env var set in functions below
-
- echo " " >> $LOG
- echo "$CMD" 2>&1 | tee -a $LOG
- eval "$CMD" 2>&1 | tee -a $LOG
-
- #ret_code=$? this is return code of tee
- local ret_code=${PIPESTATUS[0]}
- if [ $ret_code != 0 ]; then
- printf "Error : [%d] when executing command: '$CMD'\n" $ret_code
- echo "Please see log file: $LOG"
- exit 1
- fi
-}
-
-# Change to a directory and exit if it failed
-function pushd_cmd
-{
- local DIR=$1
- pushd $DIR
-
- if [ $? -ne 0 ] ; then
- echo "ERROR pushd dir '$DIR'" | tee -a $LOG
- fi
-}
-
-# Pop from a directory and exit if the pushd stack was empty
-function popd_cmd
-{
- popd
-
- if [ $? -ne 0 ] ; then
- echo "ERROR popd from dir '$PWD'" | tee -a $LOG
- fi
-}
-
-# ---------------------------------------------------------------------------
-# Read a conf.ini parameter in the form "KEY SEPARATOR VALUE"
-# Usage: get_conf_file_property VARIABLE_NAME "KEY_NAME" "=" conf.ini
-
-function get_conf_file_property
-{
- local OUTPUT_VAR_NAME=$1
- local KEY=$2
- local SEPARATOR=$3
- local FILENAME=$4
-
- # NOTE: grep -E does not support \t directly, but it does support the tab
- # character, so we spit it out using echo.
- if ! grep -E "^[ $(echo -e '\t')]*$KEY[ $(echo -e '\t')]*$SEPARATOR" "$FILENAME" ; then
- echo "ERROR finding conf param '$KEY' in file '$FILENAME', exiting."
- exit 1
- fi
-
- local VALUE=$(grep -E "^[ $(echo -e '\t')]*$KEY[ $(echo -e '\t')]*$SEPARATOR" "$FILENAME" | cut -d "$SEPARATOR" -f2 | sed -e 's/^ *//' -e 's/ *$//')
- #echo $VALUE
-
- eval $OUTPUT_VAR_NAME="'$VALUE'"
-}
-
-# ---------------------------------------------------------------------------
-# Change a conf.ini parameter in the form "KEY = *" to "KEY = VAL" in FILENAME.
-# Usage: change_conf_file_property "KEY_NAME" "=" "NEW_VALUE" conf.ini
-
-function change_conf_file_property
-{
- local KEY=$1
- local SEPARATOR=$2
- local NEW_VALUE=$3
- local FILENAME=$4
-
- # NOTE: grep -E does not support \t directly, but it does support the tab
- # character, so we spit it out using echo. Also, -P does support it
- # but -Pz is currently an unsupported combination.
- # see... http://savannah.gnu.org/forum/forum.php?forum_id=8477
- # Also verify that it was written since sed always returns 0.
- if [[ $KEY == *"\n"* ]]; then
- run_cmd "sed -i \"N;s@\(^[ \t]*${KEY}[ \t]*${SEPARATOR}\).*@\1${NEW_VALUE}@\" $FILENAME"
- local UPDATED_SETTING=$(sed "$!N;/^[ \t]*${KEY}[ \t]*${SEPARATOR}${NEW_VALUE}/p;D" $FILENAME)
- echo "UPDATED_SETTING=$UPDATED_SETTING"
- if [ -z "$UPDATED_SETTING" ]; then
- echo "ERROR: Unable to update configuration setting $KEY to $NEW_VALUE in $FILENAME."
- exit 1
- fi
- # Cannot use the following as currently grep does not support the combination of
- # -P and -z when searching for beginning or end of line (^ or $).
- #run_cmd "grep -Pzo \"^[ $(echo -e '\t')]*${KEY}[ $(echo -e '\t')]*${SEPARATOR}${NEW_VALUE}\" $FILENAME"
- else
- run_cmd "sed -i \"s@\(^[ \t]*${KEY}[ \t]*${SEPARATOR}\).*@\1${NEW_VALUE}@\" $FILENAME"
- run_cmd "grep -E \"^[ $(echo -e '\t')]*${KEY}[ $(echo -e '\t')]*${SEPARATOR}${NEW_VALUE}\" $FILENAME"
- fi
-}
-
-function get_file_attrs
-{
- local SEARCH_PATH=$1
- local RESULT_FILE=$2
- local IGNORE_FILES="$(echo ${!3})"
- local CONFIG_FILES="$(echo ${!4})"
- local GHOST_FILES="$(echo ${!5})"
-
- echo > $RESULT_FILE
-
- pushd_cmd $SEARCH_PATH
- find . -print0 | while read -d '' -r file; do
- local f=$(echo $file | sed 's@^\./@@g')
- #echo "File attrs: $f"
- if [ -L "$file" ]; then
- # symlinks cannot have attr or dir
- echo "%{prefix}/$f" >> $RESULT_FILE
- elif [ -d "$file" ]; then
- # Is directory
- echo "%dir %attr(0755, %{owner}, %{user}) \"%{prefix}/$f\"" >> $RESULT_FILE
- elif ! echo "$IGNORE_FILES" | grep "$f" > /dev/null ; then
- local FILE_ATTR_PREFIX=""
- if echo "$CONFIG_FILES" | grep "$f" > /dev/null ; then
- FILE_ATTR_PREFIX='%config(noreplace) '
- elif echo "$GHOST_FILES" | grep "$f" > /dev/null ; then
- FILE_ATTR_PREFIX='%ghost '
- fi
-
- # These might be (re)compiled when used, don't let rpm -qV say that they're different, nobody cares.
- if [[ ("$f" == *".pyc") || ("$f" == *".pyo") ]]; then
- FILE_ATTR_PREFIX='%ghost '
- fi
-
- if [ -h "$file" ]; then
- # Symbolic link: warning: Explicit %attr() mode not applicaple to symlink: /opt/gpudb/lib/libjzmq.so.0
- echo "\"%{prefix}/$f\"" >> $RESULT_FILE
- elif [ -x "$file" ]; then
- # Is executable
- echo "$FILE_ATTR_PREFIX %attr(0755, %{owner}, %{user}) \"%{prefix}/$f\"" >> $RESULT_FILE
- else
- # Is normal file
- echo "$FILE_ATTR_PREFIX %attr(0644, %{owner}, %{user}) \"%{prefix}/$f\"" >> $RESULT_FILE
- fi
- fi
- done
-
- popd_cmd
-
-}
-
-# ---------------------------------------------------------------------------
-# Get the depenent libs for a specified exe or so.
-
-function get_dependent_libs
-{
- local OUTPUT_VAR_NAME=$1
- local EXE_NAME=$2
-
- local EXE_LIBS=$(ldd $EXE_NAME)
- local EXE_LIBS=$(echo "$EXE_LIBS" | awk '($2 == "=>") && ($3 != "not") && (substr($3,1,3) != "(0x") && (substr($0,length,1) != ":") && ($1" "$2" "$3" "$4 != "not a dynamic executable") {print $3}')
- local EXE_LIBS=$(echo "$EXE_LIBS" | sort | uniq)
-
- #echo "$EXE_LIBS"
-
- # Trim out the system libs in /usr/lib* and /lib*, easier to do a positive search.
- local EXE_LIBS=$(echo "$EXE_LIBS" | grep -e "gpudb-core-libs" -e "/home/" -e "/opt/" -e "/usr/local/" | grep -v "opt/sgi")
-
- eval $OUTPUT_VAR_NAME="'$EXE_LIBS'"
-}
-
-# ---------------------------------------------------------------------------
-# Turns hardcoded "#!/blah/blah/bin/python" to "#!/usr/bin/env python2.7"
-# Leaves "#!/usr/bin/env python" as is.
-# Fixes all the shebangs python setup.py hardcoded to the abs path to the python exe used for the install.
-# http://stackoverflow.com/questions/1530702/dont-touch-my-shebang
-function fix_python_shebang
-{
- local PYTHON_FILE="$1"
-
- local PY_SHEBANG="$(head -n 1 $PYTHON_FILE | grep -e '^#\!' | grep 'bin/python')"
-
- if [[ "a$PY_SHEBANG" != "a" ]]; then
- echo "Fixing shebang for '$PYTHON_FILE' - was '$PY_SHEBANG'"
- sed -i '1s@.*@#\!/usr/bin/env python2.7@' "$PYTHON_FILE"
- fi
-}
-
-# ---------------------------------------------------------------------------
-# Fix all the shebangs that python setup.py hardcoded to the python exe used for
-# the install. See above.
-
-
-function fix_python_shebangs
-{
- local DIR="$1"
- pushd_cmd $DIR
-
- for f in `find . -name '*.py'`; do
- fix_python_shebang "$f"
- done
-
- popd_cmd
-}
-
-# ---------------------------------------------------------------------------
-# Get OS and distribution info, e.g. .fc20, .el6, etc
-
-function get_os_dist
-{
- local OS=""
-
- if [ $(which rpmbuild) ]; then
- # returns ".fc20" for example
- OS=$(rpmbuild -E "%{dist}" | sed 's/.centos//g' 2> /dev/null)
-
- # SLES 11.3 has an older rpmbuild that doesn't have %{dist}, dig out the version number
- if [[ "a$OS" == "a%{dist}" ]]; then
- if [ -f /etc/SuSE-brand ]; then
- OS=".sles$(cat /etc/SuSE-release | grep VERSION | grep -oP "[0-9]+")sp$(cat /etc/SuSE-release | grep PATCHLEVEL | grep -oP "[0-9]*")"
- fi
- fi
- elif [ -f /etc/os-release ]; then
- # Ubuntu for example
- OS=".$(grep -E "^ID=" /etc/os-release | cut -d '=' -f 2)$(grep -E "^VERSION_ID=" /etc/os-release | cut -d '=' -f 2 | sed 's/"//g')"
- fi
-
- if [[ "a$OS" == "a" ]]; then
- # Print error to everywhere, we need to know when this fails.
- echo "Error - unknown OS! Please install 'rpmbuild' or add appropriate code to $MAKE_DIST_COMMON_FILE get_os_dist()"
- >&2 echo "Error - unknown OS! Please install 'rpmbuild' or add appropriate code to $MAKE_DIST_COMMON_FILE get_os_dist()"
- exit 1
- fi
-
- echo $OS
-}
-
-# ---------------------------------------------------------------------------
-# Get GIT repo info
-
-# Echos the git "Build Number" the YYYYMMDDHHMMSS of the last check-in.
-# Run this function in the git dir.
-function get_git_build_number
-{
- # Turn '2016-03-17 22:34:47 -0400' into '20160317223447'
- local GIT_BUILD_DATE="$(git --no-pager log -1 --pretty=format:'%ci')"
- echo $GIT_BUILD_DATE | sed 's/-//g;s/://g' | cut -d' ' -f1,2 | sed 's/ //g'
-}
-
-# Check if the git repo has modifications, return code 0 means no modifications
-# Run this function in the git dir.
-function git_repo_is_not_modified
-{
- # This line supposedly confirms that all files are actually unchanged
- # vs someone trying to manually force the git index to believe that a
- # file is unchanged (assume-unchanged). Not sure if it is necessary in our case, but we
- # are leaving it in for now.
- # See:
- # https://github.com/git/git/commit/b13d44093bac2eb75f37be01f0e369290211472c
- # and
- # http://stackoverflow.com/questions/5143795/how-can-i-check-in-a-bash-script-if-my-local-git-repo-has-changes
- # and
- # https://git-scm.com/docs/git-update-index
- git update-index -q --refresh
- # No local changes && no committed changes that have not yet been pushed (diff upsteam vs HEAD returns no results)
- if git diff-index --quiet HEAD -- && [ -z "$(git log @{u}..)" ] ; then
- return 0
- fi
-
- return 1
-}
-
-function git_repo_is_modified
-{
- if git_repo_is_not_modified ; then
- return 1
- fi
-
- return 0
-}
-
-# Echos the get_git_build_number with a trailing 'M' if there are local modifications.
-# Run this function in the git dir.
-function get_git_build_number_with_modifications
-{
- local RESULT=$(get_git_build_number)
- if git_repo_is_modified ; then
- RESULT="${RESULT}M"
- fi
- echo $RESULT
-}
-
-# Used to compare build numbers. Build numbers which have a modified flag
-# have a higher precedence than build numbers without, but if both build
-# numbers are modified are or not, then the numeric portion of the numbers
-# are used.
-#
-function get_maximum_build_number
-{
- local A=$1
- local B=$2
- echo "$A" | grep "M" > /dev/null
- local A_HAS_MODS=$?
- echo "$B" | grep "M" > /dev/null
- local B_HAS_MODS=$?
- local A_NUMBER=$(echo "$A" | sed s/M//g)
- local B_NUMBER=$(echo "$B" | sed s/M//g)
-
- if [ "$A_HAS_MODS" -ne "$B_HAS_MODS" ]; then
- if [ "$A_HAS_MODS" = 0 ]; then
- echo "$A"
- else
- echo "$B"
- fi
- else
- if [ "$A_NUMBER" -ge "$B_NUMBER" ]; then
- echo "$A"
- else
- echo "$B"
- fi
- fi
-}
-
-function get_build_number_has_modifications
-{
- local BUILD_NUMBER=$1
- return echo "$BUILD_NUMBER" | grep "M"
-}
-
-# Echos the current git branch we are on.
-function get_git_branch_name
-{
- git rev-parse --abbrev-ref HEAD
-}
-
-# Gets the "name" of the git repository - the bitbucket.org/gisfederal/NAME.git
-function get_git_repo_name
-{
- local OUTPUT_VAR_NAME="$1"
- local GIT_REPO_NAME_RESULT=$(git remote show origin -n | grep "Fetch URL:" | sed -r 's#^.*/(.*)$#\1#' | sed 's#.git$##')
- if [ "$?" -ne 0 ]; then
- >&2 echo "ERROR: Unable to retrieve git repo name of $(pwd)"
- exit 1
- fi
- eval "$OUTPUT_VAR_NAME='$GIT_REPO_NAME_RESULT'"
-}
-
-# Gets the hash of the latest commit
-function get_git_hash
-{
- local OUTPUT_VAR_NAME="$1"
- local GIT_HASH_RESULT=$(git --no-pager log --format=%H -1)
- if [ "$?" -ne 0 ]; then
- >&2 echo "ERROR: Unable to retrieve git hash in $(pwd)"
- exit 1
- fi
- eval $OUTPUT_VAR_NAME="$GIT_HASH_RESULT"
-}
-
-# Gets the root folder of the git repository.
-function get_git_root_dir
-{
- local OUTPUT_VAR_NAME="$1"
- local GIT_ROOT_DIR_RESULT=$(git rev-parse --show-toplevel)
- if [ "$?" -ne 0 ]; then
- >&2 echo "ERROR: Unable to get git root directory of $(pwd)"
- exit 1
- fi
- eval $OUTPUT_VAR_NAME="$GIT_ROOT_DIR_RESULT"
-}
-
-# Gets the version stored in the VERSION file of the repository
-function get_version
-{
- local OUTPUT_VAR_NAME="$1"
-
- # check local dir first, in case we are in a project where there are
- # multiple VERSION files and/or a non-standard location.
- local VERSION_FILE="$(pwd)/VERSION"
- # If that cannot be found, then look in the root dir for this repo.
- if [ ! -f $VERSION_FILE ]; then
- local GIT_ROOT_DIR=""
- get_git_root_dir "GIT_ROOT_DIR"
- local VERSION_FILE="$GIT_ROOT_DIR/VERSION"
- if [ ! -f $VERSION_FILE ]; then
- >&2 echo "ERROR: Unable to locate version file in $(pwd)"
- exit 1
- fi
- fi
- get_conf_file_property VERSION_INFO_MAJOR_VERSION "MAJOR" "=" $VERSION_FILE > /dev/null
- get_conf_file_property VERSION_INFO_MINOR_VERSION "MINOR" "=" $VERSION_FILE > /dev/null
- get_conf_file_property VERSION_INFO_REVISION "REVISION" "=" $VERSION_FILE > /dev/null
-
- eval $OUTPUT_VAR_NAME="$VERSION_INFO_MAJOR_VERSION.$VERSION_INFO_MINOR_VERSION.$VERSION_INFO_REVISION"
-}
-
-# Appends the version, latest git hash and branch name to the specified file.
-function get_version_info
-{
- local OUTPUT_VAR_NAME="$1"
-
- local GET_VERSION_INFO_REPO_NAME=""
- get_git_repo_name "GET_VERSION_INFO_REPO_NAME"
-
- local GET_VERSION_INFO_VERSION=""
- get_version "GET_VERSION_INFO_VERSION"
-
- local GET_VERSION_INFO_HASH=""
- get_git_hash "GET_VERSION_INFO_HASH"
-
- local GET_VERSION_INFO_BRANCH="$(get_git_branch_name)"
-
- local RESULT="${GET_VERSION_INFO_REPO_NAME}_VERSION=$GET_VERSION_INFO_VERSION-$(get_git_build_number_with_modifications)"
- local RESULT=$(printf "$RESULT\n${GET_VERSION_INFO_REPO_NAME}_HASH=$GET_VERSION_INFO_HASH")
- local RESULT=$(printf "$RESULT\n${GET_VERSION_INFO_REPO_NAME}_BRANCH=$GET_VERSION_INFO_BRANCH\n")
-
- #>&2 echo "VERSION INFO = $RESULT"
- #>&2 echo "OUTPUT_VAR_NAME=$OUTPUT_VAR_NAME"
- eval "$OUTPUT_VAR_NAME=\"$RESULT\""
-}
-
-# Returns 0 (success) if the provided version info contains a line
-# that matches *_VERSION=*M
-function version_info_contains_modification
-{
- if echo "$1" | grep "_VERSION" | grep "M$" > /dev/null; then
- return 0
- fi
- return 1
-}
-
-# Returns 0 (success) if the provided version info does not contain a line
-# that matches *_VERSION=*M
-function version_info_does_not_contain_modification
-{
- if version_info_contains_modification "$1"; then
- return 1
- fi
- return 0
-}
diff --git a/rpmbuild/makerpm.sh b/rpmbuild/makerpm.sh
deleted file mode 100755
index 668dcba..0000000
--- a/rpmbuild/makerpm.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env bash
-# The directory of this script
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-#import common functions
-source $SCRIPT_DIR/make-dist-common.sh
-
-LOG="$SCRIPT_DIR/makerpm.log"
-
-DIST_DIR="$SCRIPT_DIR/dist"
-SKIP_BUILD=0
-SOURCE_DIR="$SCRIPT_DIR/.."
-JAVA_API_DIR="$SCRIPT_DIR/../../gpudb-api-java"
-
-while [[ $# > 0 ]]; do
- key="$1"
- shift
-
- case $key in
- -d|--dist-dir)
- DIST_DIR="$1"
- shift
- ;;
- -s|--skip-build)
- SKIP_BUILD=1
- ;;
- *)
- echo "Unknown option: '$key', exiting."
- echo "$USAGE_STR"
- exit 1
- ;;
-esac
-done
-
-# ---------------------------------------------------------------------------
-# make sure we have a clean build
-if [ $SKIP_BUILD -eq 0 ]; then
-mkdir -p $DIST_DIR
- rm -rf $DIST_DIR/*
-
- run_cmd "cp -p $SCRIPT_DIR/../api/target/*.jar $DIST_DIR"
- run_cmd "mkdir $DIST_DIR/example"
- run_cmd "cp -rp $SCRIPT_DIR/../example/* $DIST_DIR/example"
-fi
-
-# ---------------------------------------------------------------------------
-# Ensure that the install directory exists
-DIST_DIR=$(readlink -m $DIST_DIR)
-if [ ! -d $DIST_DIR ]; then
- echo "ERROR: Install directory $DIST_DIR does not exist!"
- echo $USAGE_STR
- exit 1
-fi
-
-# ---------------------------------------------------------------------------
-# Clean up and create RPM directories
-RPM_BUILD_DIR=$SCRIPT_DIR
-for dir in SPECS SOURCES RPMS BUILDROOT
-do
- [[ -d $RPM_BUILD_DIR/$dir ]] && rm -Rf $RPM_BUILD_DIR/$dir
- mkdir -p $RPM_BUILD_DIR/$dir
-done
-
-# ---------------------------------------------------------------------------
-# Grab version
-pushd $DIST_DIR
-VERSION=$(find *.jar | grep -v -e javadoc | awk -F'-' '{print $3}' )
-popd
-log "Detected version: $VERSION"
-
-# ---------------------------------------------------------------------------
-# Archive files
-TARBALL=$RPM_BUILD_DIR/SOURCES/files.tgz
-pushd_cmd $DIST_DIR
-run_cmd "tar -cvzf $TARBALL *"
-popd_cmd
-
-# ---------------------------------------------------------------------------
-# Copy and fill in the SPEC file.
-SPEC_FILE=$RPM_BUILD_DIR/SPECS/gpudb-api-java.spec
-run_cmd "cp $SCRIPT_DIR/gpudb-api-java.spec $SPEC_FILE"
-
-# Add the list of files to the .spec file automatically, so we don't have to write them all out.
-INSTALL_FILES="$SCRIPT_DIR/install-files.txt"
-get_file_attrs $DIST_DIR $INSTALL_FILES '' '' ''
-echo
-echo INSTALL_FILES=
-cat $INSTALL_FILES
-echo
-
-run_cmd "sed -i -e \"/TEMPLATE_RPM_FILES/{r \"$INSTALL_FILES\"\" -e 'd}' $SPEC_FILE"
-run_cmd "sed -i s/TEMPLATE_RPM_VERSION/\"$VERSION\"/g $SPEC_FILE"
-run_cmd "sed -i s/TEMPLATE_RPM_RELEASE/\"$(get_git_build_number)\"/g $SPEC_FILE"
-
-if grep TEMPLATE_RPM_ $SPEC_FILE ; then
- echo "ERROR: There's some unconfigured TEMPLATE_RPM_* variables in $SPEC_FILE"
- exit 1
-fi
-
-# ---------------------------------------------------------------------------
-# Run RPMBuild
-pushd_cmd $RPM_BUILD_DIR
-run_cmd "rpmbuild -vv --define \"_topdir $(pwd)\" -bb $SPEC_FILE"
-#run_cmd "find RPMS/ -type f -name \"*.rpm\" -exec sh -c 'RPM={}; cd ${RPM%/*}; FILE=${RPM##*/}; md5sum ${FILE} > ${FILE%.*}.md5; rpm -qlp ${FILE} > ${FILE%.*}.mf; cd -' \;"
-popd_cmd
-
-echo "SUCCESS!"