<commit_before>#!/bin/bash
#=====================================================================
#
# File:      post_process_build.sh
#
#(c) Copyright 2013 by Mentor Graphics Corp. All rights reserved.
#
#=====================================================================
# This document contains information proprietary and confidential to
# Mentor Graphics Corp. and is not for external distribution.
#=====================================================================
#
#
# Variables

product_version="$1"
release_type="$2"

if [ $# -lt 1 ]; then
  echo "Usage: $0 branch"
  exit 1
fi

BUILD_ADMIN="<EMAIL>"
MAIL_CMD="/usr/sbin/ssmtp"
MAIL_TEMP="mailtemp"
base_dir=`pwd`
# TODO - remove - build_base="${base_dir}/releases"
build_dir="${base_dir}/${branch}"
ROOTDIR=`cygpath -m ${build_dir}`
timestamp=`date +%Y%m%d`
build_tgt="${product_version}-${timestamp}"
release_base="/arch1/products/tiger/releases"
release_drop="${release_base}/${product_version}"
release_drop_dt="${release_base}/${build_tgt}"
download_url="http://tucson.wv.mentorg.com/tiger_releases/${product_version}"
log_dir="${build_dir}/log"
error_file="${log_dir}/.errors"
diff_file="${log_dir}/.diff_log"
server="tucson.wv.mentorg.com"
rsh="ssh"
nb_tag=""

version_length=${#product_version}

if [ ${version_length} -lt 21 ]; then
  ./create_tiger_release.sh ${product_version} ${release_type}

  if [ "$?" = "0" ]; then
    ${rsh} ${server} "(cd '${release_base}'; if [ ! -x '${release_drop_dt}' ]; then mkdir '${release_drop_dt}'; fi; cp -f '${release_drop}'/BridgePoint_extension_'${product_version}'.zip '${release_drop_dt}'/BridgePoint_extension_'${product_version}'.zip ; chown -R build:staff '${release_drop_dt}')"
	echo -e "Creating dated backup of the build"
  else
    echo -e "create_tiger_release.sh returned with a non-zero value ($?)"
  fi
  
  # Prune similar releases that are five days old.
  ${rsh} ${server} "(cd '${release_base}'; find -name '${product_version}-*' -mtime 5 -exec rm -rf {} \; ;)"
else
  echo -e "The version name ${product_version} is too long for the build server to handle." > ${error_file}
fi

# Build email report

echo -e "From: Nightly Build System <<EMAIL>>" > ${MAIL_TEMP}
if [ -s ${error_file} ]; then
  echo -e "Subject: ERROR - Nightly build report for ${build_tgt}"  >> ${MAIL_TEMP}
else
  echo -e "Subject: Nightly build report for ${build_tgt}"  >> ${MAIL_TEMP}
fi
echo -e "To: ${BUILD_ADMIN}" >> ${MAIL_TEMP}
echo -e "Nightly build report for: ${build_tgt}" >> ${MAIL_TEMP}
echo -e "The files that were used for the nightly build, and the logs of each build are located at: ${ROOTDIR} on `hostname`" >> ${MAIL_TEMP}

# Search for errors in the logs
if [ -s ${error_file} ]; then
  echo -e "The following was written to the error log:" >> ${MAIL_TEMP}
  echo -e "---------------" >> ${MAIL_TEMP}
  cat ${error_file} >> ${MAIL_TEMP}
  echo -e "---------------\n" >> ${MAIL_TEMP}
else
  echo -e "The release can be downloaded at: ${download_url}" >> ${MAIL_TEMP}
  
  if [ -s ${diff_file} ] && [ "${product_version}" = "HEAD" ]; then
    nb_tag="`date +N%F`"
    echo -e "The code base is tagged with ${nb_tag}" >> ${MAIL_TEMP}
  fi

  echo -e "\nCHANGELOG:" >> ${MAIL_TEMP}
  echo -e "---------------" >> ${MAIL_TEMP}
  cat ${diff_file} >> ${MAIL_TEMP}
  
  ./build_installer_bp.sh ${product_version}
  ./build_installer_bp_linux.sh ${product_version}
fi
cat ${MAIL_TEMP} | ${MAIL_CMD} ${BUILD_ADMIN}

rm -rf ${MAIL_TEMP}

if [ "${nb_tag}" != "" ]; then
  ./tag_bp_nb.sh ${nb_tag}
fi

exit 0
<commit_msg>Update post_process_build.sh<commit_after>#!/bin/bash
#=====================================================================
#
# File:      post_process_build.sh
#
#(c) Copyright 2013 by Mentor Graphics Corp. All rights reserved.
#
#=====================================================================
# This document contains information proprietary and confidential to
# Mentor Graphics Corp. and is not for external distribution.
#=====================================================================
#
#
# Variables

product_version="$1"
release_type="$2"

if [ $# -lt 1 ]; then
  echo "Usage: $0 branch"
  exit 1
fi

BUILD_ADMIN="<EMAIL>"
MAIL_CMD="/usr/sbin/ssmtp"
MAIL_TEMP="mailtemp"
base_dir=`pwd`
# TODO - remove - build_base="${base_dir}/releases"
build_dir="${base_dir}/${branch}"
ROOTDIR=`cygpath -m ${build_dir}`
timestamp=`date +%Y%m%d`
build_tgt="${product_version}-${timestamp}"
release_base="/arch1/products/tiger/releases"
release_drop="${release_base}/${product_version}"
release_drop_dt="${release_base}/${build_tgt}"
download_url="http://tucson.wv.mentorg.com/tiger_releases/${product_version}"
log_dir="${build_dir}/log"
error_file="${log_dir}/.errors"
diff_file="${log_dir}/diff.log"
server="tucson.wv.mentorg.com"
rsh="ssh"
nb_tag=""

version_length=${#product_version}

if [ ${version_length} -lt 21 ]; then
  ./create_tiger_release.sh ${product_version} ${release_type}

  if [ "$?" = "0" ]; then
    ${rsh} ${server} "(cd '${release_base}'; if [ ! -x '${release_drop_dt}' ]; then mkdir '${release_drop_dt}'; fi; cp -f '${release_drop}'/BridgePoint_extension_'${product_version}'.zip '${release_drop_dt}'/BridgePoint_extension_'${product_version}'.zip ; chown -R build:staff '${release_drop_dt}')"
	echo -e "Creating dated backup of the build"
  else
    echo -e "create_tiger_release.sh returned with a non-zero value ($?)"
  fi
  
  # Prune similar releases that are five days old.
  ${rsh} ${server} "(cd '${release_base}'; find -name '${product_version}-*' -mtime 5 -exec rm -rf {} \; ;)"
else
  echo -e "The version name ${product_version} is too long for the build server to handle." > ${error_file}
fi

# Build email report

echo -e "From: Nightly Build System <<EMAIL>>" > ${MAIL_TEMP}
if [ -s ${error_file} ]; then
  echo -e "Subject: ERROR - Nightly build report for ${build_tgt}"  >> ${MAIL_TEMP}
else
  echo -e "Subject: Nightly build report for ${build_tgt}"  >> ${MAIL_TEMP}
fi
echo -e "To: ${BUILD_ADMIN}" >> ${MAIL_TEMP}
echo -e "Nightly build report for: ${build_tgt}" >> ${MAIL_TEMP}
echo -e "The files that were used for the nightly build, and the logs of each build are located at: ${ROOTDIR} on `hostname`" >> ${MAIL_TEMP}

# Search for errors in the logs
if [ -s ${error_file} ]; then
  echo -e "The following was written to the error log:" >> ${MAIL_TEMP}
  echo -e "---------------" >> ${MAIL_TEMP}
  cat ${error_file} >> ${MAIL_TEMP}
  echo -e "---------------\n" >> ${MAIL_TEMP}
else
  echo -e "The release can be downloaded at: ${download_url}" >> ${MAIL_TEMP}
  
  if [ -s ${diff_file} ] && [ "${product_version}" = "HEAD" ]; then
    nb_tag="`date +N%F`"
    echo -e "The code base is tagged with ${nb_tag}" >> ${MAIL_TEMP}
  fi

  echo -e "\nCHANGELOG:" >> ${MAIL_TEMP}
  echo -e "---------------" >> ${MAIL_TEMP}
  cat ${diff_file} >> ${MAIL_TEMP}
  
  ./build_installer_bp.sh ${product_version}
  ./build_installer_bp_linux.sh ${product_version}
fi
cat ${MAIL_TEMP} | ${MAIL_CMD} ${BUILD_ADMIN}

rm -rf ${MAIL_TEMP}

if [ "${nb_tag}" != "" ]; then
  ./tag_bp_nb.sh ${nb_tag}
fi

exit 0

{'fraction_non_alphanumeric': 0.22913234486545853, 'fraction_numerical': 0.004118616144975288, 'mean_word_length': 4.041522491349481, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6597752', 'n_tokens_mistral': 2597, 'n_tokens_neox': 2551, 'n_words': 639}