<commit_before>#!/bin/bash
CHEF_VERSION="provisionerless"
TEMPLATE=

run_help() {
  echo " Usage: $0 [-c] [-v CHEF_VERSION] -t path/to/template.json"
  echo
  echo " Build packer build and compress the qcow2 file"
  echo
  echo "  -c          Build with Chef"
  echo "  -v VERSION  Build with specific version of Chef"
  echo "  -t FILE     Packer template to use"
  exit 0
}

while getopts "hcv:t:" opt ; do
  case $opt in
    c)
      CHEF_VERSION="latest"
      ;;
    v)
      CHEF_VERSION="$OPTARG"
      ;;
    t)
      TEMPLATE="$OPTARG"
      ;;
    h)
      run_help
      ;;
    *)
      ;;
  esac
done

[ -z "$TEMPLATE" ] && echo "Error: Template file not set" && exit 1

DIR_NAME="packer-$(basename -s .json $TEMPLATE)"
IMAGE_NAME=$(grep vm_name $TEMPLATE | awk '{print $2}' | sed -e 's/\"//g' | sed -e 's/,//g')
set -xe
cd packer
packer build -var "chef_version=$CHEF_VERSION" $(basename $TEMPLATE)

if [ $(packer -v) == "0.7.5" ] ; then
  qemu-img convert -o compat=0.10 -O qcow2 -c ${DIR_NAME}/${IMAGE_NAME}.qcow2 \
    ${DIR_NAME}/${IMAGE_NAME}-compressed.qcow2
else
  qemu-img convert -o compat=0.10 -O qcow2 -c ${DIR_NAME}/${IMAGE_NAME} \
    ${DIR_NAME}/${IMAGE_NAME}-compressed.qcow2
fi<commit_msg>update packer version check for accuracy<commit_after>#!/bin/bash
CHEF_VERSION="provisionerless"
TEMPLATE=

run_help() {
  echo " Usage: $0 [-c] [-v CHEF_VERSION] -t path/to/template.json"
  echo
  echo " Build packer build and compress the qcow2 file"
  echo
  echo "  -c          Build with Chef"
  echo "  -v VERSION  Build with specific version of Chef"
  echo "  -t FILE     Packer template to use"
  exit 0
}

while getopts "hcv:t:" opt ; do
  case $opt in
    c)
      CHEF_VERSION="latest"
      ;;
    v)
      CHEF_VERSION="$OPTARG"
      ;;
    t)
      TEMPLATE="$OPTARG"
      ;;
    h)
      run_help
      ;;
    *)
      ;;
  esac
done

[ -z "$TEMPLATE" ] && echo "Error: Template file not set" && exit 1

DIR_NAME="packer-$(basename -s .json $TEMPLATE)"
IMAGE_NAME=$(grep vm_name $TEMPLATE | awk '{print $2}' | sed -e 's/\"//g' | sed -e 's/,//g')
set -xe
cd packer
packer build -var "chef_version=$CHEF_VERSION" $(basename $TEMPLATE)

if [ "$(packer version | grep ^Packer)" == "Packer v0.7.5" ] ; then
  qemu-img convert -o compat=0.10 -O qcow2 -c ${DIR_NAME}/${IMAGE_NAME}.qcow2 \
    ${DIR_NAME}/${IMAGE_NAME}-compressed.qcow2
else
  qemu-img convert -o compat=0.10 -O qcow2 -c ${DIR_NAME}/${IMAGE_NAME} \
    ${DIR_NAME}/${IMAGE_NAME}-compressed.qcow2
fi
{'fraction_non_alphanumeric': 0.156839149618933, 'fraction_numerical': 0.0152426795026073, 'mean_word_length': 2.739130434782609, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1643463', 'n_tokens_mistral': 1010, 'n_tokens_neox': 975, 'n_words': 257}