Fix recent (ex PDF) assigment/archive/*.shtml typos.
[parallel_computing.git] / _script / make_tar.sh
1 #!/bin/bash
2 #
3 # (re)generate source tarballs for any directory containing a
4 # .make_tar file.  Will *not* include any dot files (e.g. .make_tar)
5 # .make_tar should contain a relative path to the directory that
6 # provides the tarball's base name.  For example
7 #   $ echo some_dir/src/.make_tar
8 #   ../
9 # calls for an output
10 #   some_dir/src/some_dir.tar.gz
11
12 CLEAN=0
13 if [ "$1" == '--clean' ]; then
14     CLEAN=1
15 fi
16
17 TAR_OPTS='--create --gzip --verbose --show-transformed-names --no-wildcards-match-slash --dereference'
18
19 find . -name '.make_tar' | while read MAKE_TAR_FILE
20 do
21     DIR=$(dirname "$MAKE_TAR_FILE")
22     REL_DIR=$(cat "$MAKE_TAR_FILE")
23     TAR_NAME=$(basename $(readlink --canonicalize "$DIR/$REL_DIR"))
24     OUTPUT="$DIR/$TAR_NAME.tar.gz"
25     if [ "$CLEAN" == "1" ]; then
26         rm -vf "$OUTPUT"
27     else
28         echo "$OUTPUT"
29         tar $TAR_OPTS --file "$OUTPUT" --exclude '.[^A--0-^?]*' --exclude "$TAR_NAME.tar.gz" --directory "$DIR" --transform "s,^./,./$TAR_NAME/," .
30         echo
31         # See
32         #   Jerry Peek et al.'s  "Uniz Power Tools"
33         #   15.5 Matching All "Dot Files" with Wildcards
34         #   http://docstore.mik.ua/orelly/unix/upt/ch15_05.htm
35         # for a description of the '.[^A--0-^?]*' expression.
36     fi
37 done