<commit_before>#!/bin/bash
#
# Copyright (C) 2009-2013 FoundationDB, LLC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

usage() {
    echo "Usage: $0 [-e EPOCH] [-h] [-r] <deb|rpm|pkg|targz>" >&2
    echo "    -e  Epoch number (default is current timestamp, ignored for release)" >&2
    echo "    -h  Display this help message" >&2
    echo "    -r  Building a release" >&2
}

ARGS=$(getopt "e:hr" "${@}")
if [ "$?" != "0" ]; then
    usage
    exit 1
fi

RELEASE="0"
eval set -- "${ARGS}"
while true; do
    case "${1}" in
        -e)
            EPOCH="${2}"
            shift 2
        ;;
        -h)
            usage
            exit 0
        ;;
        -r)
            RELEASE="1"
            shift 1
        ;;
        --)
            shift
            break
        ;;
    esac
done

if [ "$2" != "" ]; then
    echo "Unexpected extra arguments" >&2
    usage
    exit 1
fi


set -e

PACKAGING_DIR=$(cd $(dirname "${0}") ; echo "${PWD}")
TOP_DIR=$(cd "${PACKAGING_DIR}/.." ; echo "${PWD}")
STAGE_DIR="${TOP_DIR}/target/packaging"


mvn_package() {
    mvn clean package -q -B -U -DskipTests=true -Dfdbsql.release=${RELEASE} >/dev/null
}

# $1 - output bin dir
# $2 - output jar dir
build_sql_layer() {
    if [ "$1" = "" -o "$2" = "" ]; then
        echo "Missing argument" >&2
        exit 1
    fi
    LAYER_MVN_VERSION=$(cd "${TOP_DIR}/fdb-sql-layer-core" ; mvn -B org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version |grep '^[0-9]')
    LAYER_VERSION=${LAYER_MVN_VERSION%-SNAPSHOT}
    LAYER_JAR_NAME="fdb-sql-layer-core-${LAYER_MVN_VERSION}.jar"
    RF_MVN_VERSION=$(cd "${TOP_DIR}/routine-firewall" ; mvn -B org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version |grep '^[0-9]')
    RF_VERSION=${RF_MVN_VERSION%-SNAPSHOT}
    RF_JAR_NAME="routine-firewall-${RF_MVN_VERSION}.jar"    


    echo "Building FoundationDB SQL Layer ${LAYER_VERSION} Release ${RELEASE}"
    pushd .
    cd "${TOP_DIR}"
    mvn_package
    mkdir -p "${1}" "${2}"/{server,plugins,routine-firewall}
    cp "${TOP_DIR}/bin/fdbsqllayer" "${1}/"
    cp "fdb-sql-layer-core/target/${LAYER_JAR_NAME}" "${2}/"
    cp fdb-sql-layer-core/target/dependency/* "${2}/server/"
    cp "routine-firewall/target/${RF_JAR_NAME}" "${2}/routine-firewall/"
    cp "sql-layer.policy" "${2}/"
    popd
}

# $1 - output bin dir
# $2 - output jar dir
build_client_tools() {
    : ${TOOLS_LOC:="<EMAIL>:FoundationDB/sql-layer-client-tools.git"}
    : ${TOOLS_REF:="master"}
    
    pushd .
    mkdir -p "${1}"
    mkdir -p "${2}"
    cd "${TOP_DIR}/target/packaging"
    rm -rf client-tools
    git clone -q "${TOOLS_LOC}" client-tools
    cd client-tools
    git checkout -b scratch "${TOOLS_REF}"
    if [ "${RELEASE}" = "1" ]; then
        CLIENT_RELEASE="-r"
    else
        CLIENT_RELEASE=""
    fi
    bash packaging/build_packages.sh "${CLIENT_RELEASE}" targz
    cd target/packaging/targz/
    DIR=$(ls)<commit_msg>update build for unix-like systems<commit_after>#!/bin/bash
#
# Copyright (C) 2009-2013 FoundationDB, LLC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

usage() {
    echo "Usage: $0 [-e EPOCH] [-h] [-r] <deb|rpm|pkg|targz>" >&2
    echo "    -e  Epoch number (default is current timestamp, ignored for release)" >&2
    echo "    -h  Display this help message" >&2
    echo "    -r  Building a release" >&2
}

ARGS=$(getopt "e:hr" "${@}")
if [ "$?" != "0" ]; then
    usage
    exit 1
fi

RELEASE="0"
eval set -- "${ARGS}"
while true; do
    case "${1}" in
        -e)
            EPOCH="${2}"
            shift 2
        ;;
        -h)
            usage
            exit 0
        ;;
        -r)
            RELEASE="1"
            shift 1
        ;;
        --)
            shift
            break
        ;;
    esac
done

if [ "$2" != "" ]; then
    echo "Unexpected extra arguments" >&2
    usage
    exit 1
fi


set -e

PACKAGING_DIR=$(cd $(dirname "${0}") ; echo "${PWD}")
TOP_DIR=$(cd "${PACKAGING_DIR}/.." ; echo "${PWD}")
STAGE_DIR="${TOP_DIR}/target/packaging"


mvn_package() {
    mvn clean package -q -B -U -DskipTests=true -Dfdbsql.release=${RELEASE} >/dev/null
}

# $1 - output bin dir
# $2 - output jar dir
build_sql_layer() {
    if [ "$1" = "" -o "$2" = "" ]; then
        echo "Missing argument" >&2
        exit 1
    fi
    LAYER_MVN_VERSION=$(cd "${TOP_DIR}/fdb-sql-layer-core" ; mvn -B org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version |grep '^[0-9]')
    LAYER_VERSION=${LAYER_MVN_VERSION%-SNAPSHOT}
    LAYER_JAR_NAME="fdb-sql-layer-core-${LAYER_MVN_VERSION}.jar"
    RF_MVN_VERSION=$(cd "${TOP_DIR}/routine-firewall" ; mvn -B org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version |grep '^[0-9]')
    RF_VERSION=${RF_MVN_VERSION%-SNAPSHOT}
    RF_JAR_NAME="routine-firewall-${RF_MVN_VERSION}.jar"    


    echo "Building FoundationDB SQL Layer ${LAYER_VERSION} Release ${RELEASE}"
    pushd .
    cd "${TOP_DIR}"
    mvn_package
    mkdir -p "${1}" "${2}"/{server,plugins,routine-firewall}
    cp "${TOP_DIR}/bin/fdbsqllayer" "${1}/"
    cp "fdb-sql-layer-core/target/${LAYER_JAR_NAME}" "${2}/"
    cp fdb-sql-layer-core/target/dependency/* "${2}/server/"
    cp "routine-firewall/target/${RF_JAR_NAME}" "${2}/routine-firewall/"
    popd
}

# $1 - output bin dir
# $2 - output jar dir
build_client_tools() {
    : ${TOOLS_LOC:="<EMAIL>:FoundationDB/sql-layer-client-tools.git"}
    : ${TOOLS_REF:="master"}
    
    pushd .
    mkdir -p "${1}"
    mkdir -p "${2}"
    cd "${TOP_DIR}/target/packaging"
    rm -rf client-tools
    git clone -q "${TOOLS_LOC}" client-tools
    cd client-tools
    git checkout -b scratch "${TOOLS_REF}"
    if [ "${RELEASE}" = "1" ]; then
        CLIENT_RELEASE="-r"
    else
        CLIENT_RELEASE=""
    fi
    bash packaging/build_packages.sh "${CLIENT_RELEASE}" targz
    cd target/packaging/targz/
    DIR=$(ls)
{'fraction_non_alphanumeric': 0.1575698049670268, 'fraction_numerical': 0.01529395257471587, 'mean_word_length': 2.7476340694006307, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5496122', 'n_tokens_mistral': 2588, 'n_tokens_neox': 2456, 'n_words': 670}