<commit_before>#!/usr/bin/env bash

MACHINENAME=unknown
MACHINEDIR=`dirname ${0}`/machines
BUILDER=all

usage()
{
cat<<EOF
usage : $0 options

Build a machine with packer using default variable values

OPTIONS:
  -h      Show this message
  -m      The machine name
  -b      The builder (all builders is the default)

EOF
}

while getopts "b:m:h" OPTION
do
    case $OPTION in
        h)
            usage
            exit 0
            ;;
        m)
            MACHINENAME=${OPTARG}
            DESTDIR=${MACHINEDIR}/${MACHINENAME}
            ;;
        b)
            BUILDER=${OPTARG}
            ;;
        ?)
            usage
            exit 1
            ;;
    esac
done

if [[ ${MACHINENAME} == "unknown" ]]
then
    echo "A machine name is required"
    usage
    exit 2
fi

set -x
cmd="packer build"

for vf in common ubuntu ubuntu14.04;
do
    cmd="${cmd} -var-file=../../common/variables-${vf}.json"
done

if [[ ${BUILDER} != "all" ]]
then
    cmd="${cmd} -only ${BUILDER}"
fi
cmd="${cmd} machine.json"

cd ${DESTDIR}
if [ -e Puppetfile ]
then
    r10k -v DEBUG puppetfile install
fi
pwd
$cmd
<commit_msg>Remove previous output so build can proceed<commit_after>#!/usr/bin/env bash

MACHINENAME=unknown
MACHINEDIR=`dirname ${0}`/machines
BUILDER=all

usage()
{
cat<<EOF
usage : $0 options

Build a machine with packer using default variable values

OPTIONS:
  -h      Show this message
  -m      The machine name
  -b      The builder (all builders is the default)

EOF
}

while getopts "b:m:h" OPTION
do
    case $OPTION in
        h)
            usage
            exit 0
            ;;
        m)
            MACHINENAME=${OPTARG}
            DESTDIR=${MACHINEDIR}/${MACHINENAME}
            ;;
        b)
            BUILDER=${OPTARG}
            ;;
        ?)
            usage
            exit 1
            ;;
    esac
done

if [[ ${MACHINENAME} == "unknown" ]]
then
    echo "A machine name is required"
    usage
    exit 2
fi

set -x
cmd="packer build"

for vf in common ubuntu ubuntu14.04;
do
    cmd="${cmd} -var-file=../../common/variables-${vf}.json"
done

if [[ ${BUILDER} != "all" ]]
then
    cmd="${cmd} -only ${BUILDER}"
fi
cmd="${cmd} machine.json"

cd ${DESTDIR}
if [ -e output ]
then
    rm -rf output
fi

if [ -e Puppetfile ]
then
    r10k -v DEBUG puppetfile install
fi
pwd
$cmd

{'fraction_non_alphanumeric': 0.12338222605694564, 'fraction_numerical': 0.009490940465918895, 'mean_word_length': 1.950381679389313, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6766251', 'n_tokens_mistral': 841, 'n_tokens_neox': 800, 'n_words': 238}