aboutsummaryrefslogtreecommitdiff
path: root/jwstdp/utils/archive_cal_code.sh
diff options
context:
space:
mode:
authorMatt Rendina <rendinam@users.noreply.github.com>2020-06-24 13:35:49 -0400
committerGitHub <noreply@github.com>2020-06-24 13:35:49 -0400
commitb8f13f6694afce69ae97d1631b93c483be3c67fb (patch)
tree76edb0b43516749f200575f52f16b738836a34bd /jwstdp/utils/archive_cal_code.sh
parentfc528bfa3db28075ac2f94aa67c145a631913a8f (diff)
downloadastroconda-releases-testing-b8f13f6694afce69ae97d1631b93c483be3c67fb.tar.gz
add archival tool (#127)
* Add CAL code linecount and package archival tool.
Diffstat (limited to 'jwstdp/utils/archive_cal_code.sh')
-rwxr-xr-xjwstdp/utils/archive_cal_code.sh69
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}