default_pre_build &&

if [[ $CACTI_PA == y ]]; then
  mk_source_dir "$SOURCE_DIRECTORY2"
  cd "$SOURCE_DIRECTORY2" &&
  unpack_file 2
fi &&

cd "$SOURCE_DIRECTORY" &&

if [[ -d "$SPELL_DIRECTORY/patches" ]]; then
  for patch in "$SPELL_DIRECTORY/patches"/*.patch; do
    patch -p1 < $patch
  done
fi &&

if [[ $CACTI_PA == y ]]; then
  cat "$SOURCE_DIRECTORY2/cacti-plugin-arch/pa.sql" >> cacti.sql &&
  patch -p1 < "$SOURCE_DIRECTORY2/cacti-plugin-arch/$SPELL-plugin-$VERSION-PA-v${VERSION_PA}.diff"
fi
