<commit_before>
find_program (SNAP_EXE snapcraft)
if(EXISTS ${SNAP_EXE})
  set(SNAPCRAFT_FOUND ON)
endif()

if(SNAPCRAFT_FOUND)
  set(SNAPCRAFT_TEMPLATE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Installation/Ubuntu")
  set(SNAPCRAFT_SOURCE_DIR "${CMAKE_BINARY_DIR}/_CPack_Packages/SNAP")

  message(STATUS "Creating snap package")

  if (VERBOSE)
    message(STATUS "CPACK_PACKAGE_FILE_NAME :" ${CPACK_PACKAGE_FILE_NAME})
    message(STATUS "SNAPCRAFT_TEMPLATE_DIR: " ${SNAPCRAFT_TEMPLATE_DIR})
    message(STATUS "SNAPCRAFT_SOURCE_DIR: " ${SNAPCRAFT_SOURCE_DIR})
  endif ()

#  set(SNAP_PORT 8529)
  set(CPACK_STRIP_FILES ON)
  set(CMAKE_INSTALL_PREFIX "/")

  configure_file(
    "${SNAPCRAFT_TEMPLATE_DIR}/snapcraft.yaml.in"
    "${SNAPCRAFT_SOURCE_DIR}/snapcraft.yaml"
    NEWLINE_STYLE UNIX
    @ONLY
  )

  file(
    COPY        "${SNAPCRAFT_TEMPLATE_DIR}/arangodb.png"
    DESTINATION "${SNAPCRAFT_SOURCE_DIR}/"
    )

  add_custom_target(snap
    COMMENT "create snap-package"
    COMMAND ${SNAP_EXE} snap
    COMMAND ${CMAKE_COMMAND} -E copy ${SNAPCRAFT_SOURCE_DIR}/${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}*_${ARANGODB_PACKAGE_ARCHITECTURE}.snap ${PROJECT_BINARY_DIR}
    DEPENDS TGZ_package
    WORKING_DIRECTORY ${SNAPCRAFT_SOURCE_DIR}
  )

  add_custom_target(copy_snap_packages
    COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}*_${ARANGODB_PACKAGE_ARCHITECTURE}.snap ${PACKAGE_TARGET_DIR})

  list(APPEND COPY_PACKAGES_LIST copy_snap_packages)
<commit_msg>clean out the working directory for snap - just in case.<commit_after>
find_program (SNAP_EXE snapcraft)
if(EXISTS ${SNAP_EXE})
  set(SNAPCRAFT_FOUND ON)
endif()

if(SNAPCRAFT_FOUND)
  set(SNAPCRAFT_TEMPLATE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Installation/Ubuntu")
  set(SNAPCRAFT_SOURCE_DIR "${CMAKE_BINARY_DIR}/_CPack_Packages/SNAP")

  message(STATUS "Creating snap package")

  if (VERBOSE)
    message(STATUS "CPACK_PACKAGE_FILE_NAME :" ${CPACK_PACKAGE_FILE_NAME})
    message(STATUS "SNAPCRAFT_TEMPLATE_DIR: " ${SNAPCRAFT_TEMPLATE_DIR})
    message(STATUS "SNAPCRAFT_SOURCE_DIR: " ${SNAPCRAFT_SOURCE_DIR})
  endif ()

#  set(SNAP_PORT 8529)
  set(CPACK_STRIP_FILES ON)
  set(CMAKE_INSTALL_PREFIX "/")

  configure_file(
    "${SNAPCRAFT_TEMPLATE_DIR}/snapcraft.yaml.in"
    "${SNAPCRAFT_SOURCE_DIR}/snapcraft.yaml"
    NEWLINE_STYLE UNIX
    @ONLY
  )

  file(
    COPY        "${SNAPCRAFT_TEMPLATE_DIR}/arangodb.png"
    DESTINATION "${SNAPCRAFT_SOURCE_DIR}/"
    )

snapcraft clean arangodb3 -s pull

arangodb3
  
  add_custom_target(snap
    COMMENT "create snap-package"
    COMMAND ${SNAP_EXE} clean ${CPACK_PACKAGE_NAME}
    COMMAND ${SNAP_EXE} snap
    COMMAND ${CMAKE_COMMAND} -E copy ${SNAPCRAFT_SOURCE_DIR}/${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}*_${ARANGODB_PACKAGE_ARCHITECTURE}.snap ${PROJECT_BINARY_DIR}
    DEPENDS TGZ_package
    WORKING_DIRECTORY ${SNAPCRAFT_SOURCE_DIR}
  )

  add_custom_target(copy_snap_packages
    COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}*_${ARANGODB_PACKAGE_ARCHITECTURE}.snap ${PACKAGE_TARGET_DIR})

  list(APPEND COPY_PACKAGES_LIST copy_snap_packages)

{'fraction_non_alphanumeric': 0.10722239898186446, 'fraction_numerical': 0.003181673560292714, 'mean_word_length': 5.894736842105263, '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': '4194644', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1263, 'n_words': 165}