diff options
-rwxr-xr-x | jwstdp/utils/archive_cal_code.sh | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/jwstdp/utils/archive_cal_code.sh b/jwstdp/utils/archive_cal_code.sh new file mode 100755 index 0000000..393b99a --- /dev/null +++ b/jwstdp/utils/archive_cal_code.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# A tool for generating a JWST CAL software tarball and the associated +# project code linecount summary and depositing it into the provided +# archival area. + +if [[ $# -eq 0 ]]; +then + printf "\nUsage:\n" + printf "$(basename $0) <jwst-tag> <destination-base-path>\n\n" + exit 0 +fi + +if [[ $1 == '' ]]; +then + echo "JWST repository tag is required" + exit 1 +fi +tag=$1 + +if [[ $2 == '' ]]; +then + echo "Destination root directory is required" + exit 1 +fi +dest_root=$2 # dms_x.y(.z) + +code_dest_path=${dest_root}/software_bundles +doc_dest_path=${dest_root}/code_counts +if [[ ! -d $code_dest_path ]]; +then + echo "${code_dest_path} does not exist!" + exit 1 +fi +if [[ ! -d $doc_dest_path ]]; +then + echo "${doc_dest_path} does not exist!" + exit 1 +fi + +which sloccount +if [[ $? -ne 0 ]]; +then + echo "'sloccount' not found. Install before attempting again." +fi +which csplit +if [[ $? -ne 0 ]]; +then + echo "'csplit' not found. Install before attempting again." +fi + +set -e + +local_checkout_dir=jwst-cal-archive +git clone https://github.com/stsci-jwst/jwst.git $local_checkout_dir +pushd $local_checkout_dir +git checkout $tag + +# Create the line count summary. Strip off any superfluous leading text to +# leave only the report data itself. +countname="jwst-${tag}-sloccount.txt" +sloccount . > temp.txt 2>&1 +csplit --digits=0 --prefix $countname temp.txt %SLOC% +mv ${countname}0 ${countname} + +python setup.py sdist + +cp -a dist/jwst-${tag}.tar.gz ${code_dest_path} +cp -a $countname ${doc_dest_path} |