<commit_before>#!/bin/bash
PUNGIBASE="/var/lib/pungi"
CREATEBASE=0
PUNGI="$(which --skip-alias --skip-functions pungi 2>/dev/null)"
MYNAME=$(basename ${0})

function usage {
  echo "Usage: ${MYNAME} -k <kickstartfile> [-c] [-d <destdir>] [-b basedir]"
  exit 1
}

if [ $# -eq 0 ]; then
  usage
fi


while getopts ":hck:d:b:" opt; do
  case ${opt} in
    k)
      KSFILE=${OPTARG}
      ;;
    d)
      DESTDIR=${OPTARG}
      ;;
    b)
      PUNGIBASE=${OPTARG}
      ;;
    c)
      CREATEBASE=1
      ;;
    h)
      usage
      ;;
    \?)
      echo "Invalid option: -${OPTARG}" >&2
      usage
      ;;
    :)
      echo "Option -${OPTARG} requires an argument." >&2
      usage
      ;;
  esac
done
shift $((OPTIND-1))

if [ -z "${KSFILE}" ]; then
  echo "No kickstartfile provided" >&2
  usage
fi

if ! [ -f "${KSFILE}" ]; then
  echo "Can not find ${KSFILE}" >&2
  exit 1
fi

if [ -n "${DESTDIR}" ]; then
  if ! [ -d "${DESTDIR}" ]; then
    echo "Can not find ${DESTDIR}"
    exit 1
  fi
else
  DESTDIR="."
fi

if [ -z "${PUNGI}" ]; then
  echo "Can not find pungi executable"
  exit 1
fi

if [ ${CREATEBASE} -eq 1 ]; then
  mkdir -p "${PUNGIBASE}/cache"
  mkdir "${PUNGIBASE}/root"
fi

# call pungi with the kickstart file<commit_msg>Add -p parameter to the pungibase mkdir<commit_after>#!/bin/bash
PUNGIBASE="/var/lib/pungi"
CREATEBASE=0
PUNGI="$(which --skip-alias --skip-functions pungi 2>/dev/null)"
MYNAME=$(basename ${0})

function usage {
  echo "Usage: ${MYNAME} -k <kickstartfile> [-c] [-d <destdir>] [-b basedir]"
  exit 1
}

if [ $# -eq 0 ]; then
  usage
fi


while getopts ":hck:d:b:" opt; do
  case ${opt} in
    k)
      KSFILE=${OPTARG}
      ;;
    d)
      DESTDIR=${OPTARG}
      ;;
    b)
      PUNGIBASE=${OPTARG}
      ;;
    c)
      CREATEBASE=1
      ;;
    h)
      usage
      ;;
    \?)
      echo "Invalid option: -${OPTARG}" >&2
      usage
      ;;
    :)
      echo "Option -${OPTARG} requires an argument." >&2
      usage
      ;;
  esac
done
shift $((OPTIND-1))

if [ -z "${KSFILE}" ]; then
  echo "No kickstartfile provided" >&2
  usage
fi

if ! [ -f "${KSFILE}" ]; then
  echo "Can not find ${KSFILE}" >&2
  exit 1
fi

if [ -n "${DESTDIR}" ]; then
  if ! [ -d "${DESTDIR}" ]; then
    echo "Can not find ${DESTDIR}"
    exit 1
  fi
else
  DESTDIR="."
fi

if [ -z "${PUNGI}" ]; then
  echo "Can not find pungi executable"
  exit 1
fi

if [ ${CREATEBASE} -eq 1 ]; then
  mkdir -p "${PUNGIBASE}/cache"
  mkdir -p "${PUNGIBASE}/root"
fi

# call pungi with the kickstart file
{'fraction_non_alphanumeric': 0.1797216699801193, 'fraction_numerical': 0.011928429423459244, 'mean_word_length': 2.3192612137203166, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 17, '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': '5477939', 'n_tokens_mistral': 1036, 'n_tokens_neox': 988, 'n_words': 284}