makeDataTar.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # make a distribution tarball for larsoft_data, uboone_data, etc.
4 
5 usage()
6 {
7  cat 1>&2 <<EOF
8 Usage: $(basename ${0}) [-h]
9  $(basename ${0}) <options> <product_topdir> <product_name> <product_version>
10 
11 Options:
12 
13  -h This help.
14 
15 Arguments:
16 
17  product_topdir Top directory for relocatable-UPS products area.
18  product_name Product name, e.g., larsoft_data
19  product_version Product version, e.g., v0_03_01
20 
21 Notes:
22  The tarball will be made in the directory you are in when the script is called.
23  $(basename ${0}) is suitable for use with larsoft_data, not other products.
24 
25 EOF
26 }
27 
28 ########################################################################
29 # Main body.
30 
31 while getopts :fh OPT; do
32  case ${OPT} in
33  h)
34  usage
35  exit 1
36  ;;
37  *)
38  usage
39  exit 1
40  esac
41 done
42 shift `expr $OPTIND - 1`
43 OPTIND=1
44 
45 product_topdir=${1}
46 product_name=${2}
47 product_version=${3}
48 
49 working_dir=$(/bin/pwd)
50 dotver=`echo ${product_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
51 
52 if [ -z ${product_topdir} ]
53 then
54  usage
55  exit 1
56 fi
57 
58 if [ -z ${product_name} ]
59 then
60  usage
61  exit 1
62 fi
63 if [ -z ${product_version} ]
64 then
65  usage
66  exit 1
67 fi
68 
69 [[ -n "$working_dir" ]] && \
70  [[ -d "${working_dir}" ]] && \
71  [[ -w "${working_dir}" ]] || \
72  { echo "ERROR: Could not write to specified working directory \"${working_dir}\"." 1>&2; exit 1; }
73 
74 [[ -d ${product_topdir}/${product_name}/${product_version} ]] || \
75  { echo "ERROR: ${product_topdir}/${product_name}/${product_version} is not a directory." 1>&2; exit 1; }
76 [[ -d ${product_topdir}/${product_name}/${product_version}.version ]] || \
77  { echo "ERROR: ${product_topdir}/${product_name}/${product_version}.version is not a directory." 1>&2; exit 1; }
78 
79 set -x
80 cd ${product_topdir}
81 tar cjf ${working_dir}/${product_name}-${dotver}-noarch.tar.bz2 \
82  ${product_name}/${product_version}.version \
83  ${product_name}/${product_version}
84 cd ${working_dir}
85 ls -l ${product_name}-${dotver}-noarch.tar.bz2 || exit 1
86 set +x
87 
88 exit 0