<commit_before>#!/bin/bash

set -xeo pipefail

if [ $# -lt 1 ]; then
  echo "Usage: $0 <package> [<destination>]"
  echo "packages: deb rpm"
  exit 1
fi

: "${PACKAGE_VERSION:?'Environment variable PACKAGE_VERSION must be set.'}"

PACKAGE_NAME="${PACKAGE_NAME-sota_client}"
PACKAGE_DIR="$(cd "$(dirname "$0")" && pwd)"
PREFIX=/opt/ats

export OTA_AUTH_URL="${OTA_AUTH_URL-http://localhost:9001}"
export OTA_CORE_URL="${OTA_CORE_URL-http://localhost:8080}"
export OTA_CREDENTIALS_FILE="${OTA_CREDENTIALS_FILE-${PREFIX}/credentials.toml}"
export OTA_CONSOLE="${OTA_CONSOLE-false}"
export OTA_HTTP="${OTA_HTTP-false}"
export OTA_WEBSOCKET="${OTA_WEBSOCKET-true}"

case $1 in
  "deb" )
    export PACKAGE_MANAGER="deb"
    PKG_BUILD_OPTS="--deb-systemd ${PACKAGE_DIR}/sota_client.service"
    ;;
  "rpm" )
    export PACKAGE_MANAGER="rpm"
    PKG_BUILD_OPTS="--rpm-service ${PACKAGE_DIR}/sota_client.service"
    ;;
  *)
    echo "unknown package format $1"
    exit 2
esac
shift

function make_pkg {
  destination=$1
  template=$(mktemp)

  envsubst < "${PACKAGE_DIR}/sota.toml.template" > "${template}"
  if [[ -n "${OTA_NO_AUTH}" ]]; then
    sed -i '1,/\[device\]/{/\[device\]/p;d}' "${template}"
  fi
  chmod 600 "$template"

  fpm \
    -s dir \
    -t "${PACKAGE_MANAGER}" \
    --architecture native \
    --name "${PACKAGE_NAME}" \
    --version "${PACKAGE_VERSION}" \
    --package NAME-VERSION.TYPE \
    --prefix "${PREFIX}" \
    ${PKG_BUILD_OPTS} \
    "${PACKAGE_DIR}/sota_client=sota_client" \
    "${template}=sota.toml"

  if [ -n "$destination" ]; then
    mv -f "sota_client*.${PACKAGE_MANAGER}" "${destination}"
  fi
  rm -f "${template}"
}<commit_msg>Set PACKAGE_NAME to sota-client in pkg.sh<commit_after>#!/bin/bash

set -xeo pipefail

if [ $# -lt 1 ]; then
  echo "Usage: $0 <package> [<destination>]"
  echo "packages: deb rpm"
  exit 1
fi

: "${PACKAGE_VERSION:?'Environment variable PACKAGE_VERSION must be set.'}"

PACKAGE_NAME="${PACKAGE_NAME-sota-client}"
PACKAGE_DIR="$(cd "$(dirname "$0")" && pwd)"
PREFIX=/opt/ats

export OTA_AUTH_URL="${OTA_AUTH_URL-http://localhost:9001}"
export OTA_CORE_URL="${OTA_CORE_URL-http://localhost:8080}"
export OTA_CREDENTIALS_FILE="${OTA_CREDENTIALS_FILE-${PREFIX}/credentials.toml}"
export OTA_CONSOLE="${OTA_CONSOLE-false}"
export OTA_HTTP="${OTA_HTTP-false}"
export OTA_WEBSOCKET="${OTA_WEBSOCKET-true}"

case $1 in
  "deb" )
    export PACKAGE_MANAGER="deb"
    PKG_BUILD_OPTS="--deb-systemd ${PACKAGE_DIR}/sota_client.service"
    ;;
  "rpm" )
    export PACKAGE_MANAGER="rpm"
    PKG_BUILD_OPTS="--rpm-service ${PACKAGE_DIR}/sota_client.service"
    ;;
  *)
    echo "unknown package format $1"
    exit 2
esac
shift

function make_pkg {
  destination=$1
  template=$(mktemp)

  envsubst < "${PACKAGE_DIR}/sota.toml.template" > "${template}"
  if [[ -n "${OTA_NO_AUTH}" ]]; then
    sed -i '1,/\[device\]/{/\[device\]/p;d}' "${template}"
  fi
  chmod 600 "$template"

  fpm \
    -s dir \
    -t "${PACKAGE_MANAGER}" \
    --architecture native \
    --name "${PACKAGE_NAME}" \
    --version "${PACKAGE_VERSION}" \
    --package NAME-VERSION.TYPE \
    --prefix "${PREFIX}" \
    ${PKG_BUILD_OPTS} \
    "${PACKAGE_DIR}/sota_client=sota_client" \
    "${template}=sota.toml"

  if [ -n "$destination" ]; then
    mv -f "sota-client*.${PACKAGE_MANAGER}" "${destination}"
  fi
  rm -f "${template}"
}
{'fraction_non_alphanumeric': 0.1859774212715389, 'fraction_numerical': 0.011883541295306001, 'mean_word_length': 3.922514619883041, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '163747', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1273, 'n_words': 235}