<commit_before>#!/bin/sh

set -e

BUILD_SCRIPT_LOCATION=$(cd "$(dirname "$0")"; pwd)
. ${BUILD_SCRIPT_LOCATION}/../jenkins/common.sh
. ${BUILD_SCRIPT_LOCATION}/common.sh

# sanity checks
[ ! -z $CVMFS_BUILD_LOCATION    ] || die "CVMFS_BUILD_LOCATION missing"
[ ! -z $CVMFS_SOURCE_LOCATION   ] || die "CVMFS_SOURCE_LOCATION missing"
[ ! -z $CVMFS_BUILD_SCRIPT ]      || die "CVMFS_BUILD_SCRIPT missing"
[ ! -z $CVMFS_CI_PLATFORM_LABEL ] || die "CVMFS_CI_PLATFORM_LABEL missing"

# setup a fresh build workspace
if [ -d $CVMFS_BUILD_LOCATION ]; then
  echo "removing previous build location..."
  rm -fR $CVMFS_BUILD_LOCATION
fi
echo "creating a fresh build location in ${CVMFS_BUILD_LOCATION}..."
mkdir -p "$CVMFS_BUILD_LOCATION"

# run the build
echo "looking for build script to invoke..."
build_script="${CVMFS_SOURCE_LOCATION}/ci/${CVMFS_BUILD_SCRIPT}"

# check if the script exists and is executable
[ -f $build_script ] || die "Build script '${build_script}' not found"
[ -x $build_script ] || die "Build script '${build_script}' not executable"

echo "switching to $CVMFS_BUILD_LOCATION and invoking build script..."
cd "$CVMFS_BUILD_LOCATION"

# parse the command line arguments (keep quotation marks)
args=""
while [ $# -gt 0 ]; do
  if echo "$1" | grep -q "[[:space:]]"; then
    args="$args \"$1\""
  else
    args="$args $1"
  fi
  shift 1
done

# build the invocation string and print it for debugging reasons
command_tmpl="$build_script ${CVMFS_SOURCE_LOCATION} ${CVMFS_BUILD_LOCATION} $args"
echo "++ $command_tmpl"

# run the build script
$command_tmpl<commit_msg>allow for dockerized build<commit_after>#!/bin/sh

set -e

BUILD_SCRIPT_LOCATION=$(cd "$(dirname "$0")"; pwd)
. ${BUILD_SCRIPT_LOCATION}/../jenkins/common.sh
. ${BUILD_SCRIPT_LOCATION}/common.sh

# sanity checks
[ ! -z $CVMFS_BUILD_LOCATION    ] || die "CVMFS_BUILD_LOCATION missing"
[ ! -z $CVMFS_SOURCE_LOCATION   ] || die "CVMFS_SOURCE_LOCATION missing"
[ ! -z $CVMFS_PACKAGE           ] || die "CVMFS_PACKAGE missing"
[ ! -z $CVMFS_CI_PLATFORM_LABEL ] || die "CVMFS_CI_PLATFORM_LABEL missing"
[ ! -z $CVMFS_BUILD_PLATFORM    ] || die "CVMFS_BUILD_PLATFORM missing"
[ ! -z $CVMFS_BUILD_ARCH        ] || die "CVMFS_BUILD_ARCH missing"

# setup a fresh build workspace
if [ -d $CVMFS_BUILD_LOCATION ]; then
  echo "removing previous build location..."
  rm -fR $CVMFS_BUILD_LOCATION
fi
echo "creating a fresh build location in ${CVMFS_BUILD_LOCATION}..."
mkdir -p "$CVMFS_BUILD_LOCATION"

# run the build
echo "looking for build script to invoke..."
build_script="${CVMFS_SOURCE_LOCATION}/ci/build_package.sh"

# check if the script exists and is executable
[ -f $build_script ] || die "Build script '${build_script}' not found"
[ -x $build_script ] || die "Build script '${build_script}' not executable"

echo "switching to $CVMFS_BUILD_LOCATION and invoking build script..."
cd "$CVMFS_BUILD_LOCATION"

# parse the command line arguments (keep quotation marks)
args="$CVMFS_PACKAGE"
while [ $# -gt 0 ]; do
  if echo "$1" | grep -q "[[:space:]]"; then
    args="$args \"$1\""
  else
    args="$args $1"
  fi
  shift 1
done

# check if we should run in a dockerized environment and set up the build script
# invocation accordingly
command_tmpl=""
if [ x"$CVMFS_CI_PLATFORM_LABEL" = x"docker" ]; then
  command_tmpl="${CVMFS_SOURCE_LOCATION}/ci/build_on_docker.sh \
                    ${CVMFS_SOURCE_LOCATION}                   \
                    ${CVMFS_BUILD_LOCATION}                    \
                    ${CVMFS_BUILD_PLATFORM}                    \
                    $build_script $args" # Note: build_on_docker.sh calls the
                                         #       build script with the right
                                         #       parameter by convention!
                                         #       (compare: else-branch)
else
  command_tmpl="$build_script ${CVMFS_SOURCE_LOCATION} ${CVMFS_BUILD_LOCATION} $args"
fi

# run the build script
echo "++ $command_tmpl"
$command_tmpl
{'fraction_non_alphanumeric': 0.12187187187187187, 'fraction_numerical': 0.003003003003003003, 'mean_word_length': 3.3445652173913043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2098099', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1337, 'n_words': 356}