-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpack
executable file
·181 lines (151 loc) · 4.66 KB
/
pack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
#
#******************************************************************************
# pack (Sequencer64-doc)
#------------------------------------------------------------------------------
##
# \file pack
# \library Sequencer64-doc
# \author Chris Ahlstrom
# \date 2014-08-31
# \update 2018-09-25
# \version $Revision$
# \license $XPC_SUITE_GPL_LICENSE$
#
# Packs up the current project directory, ignoring some of the derived
# junk and the version-control infrastructure. Also does a "make clean" on
# the LaTeX source.
#
# Run "./pack --help" for more information.
#
#-----------------------------------------------------------------------------
CURRENTDATE=`date +%Y-%m-%d`
CURRENTDIR=`pwd`
WORKINGDIR=${CURRENTDIR##/*/} # strip all but last part of path
PACKAGENAME="bogus"
TAGSTRING="pack"
DODRYRUN="no"
DOCLEAN="no"
BRANCH=`git symbolic-ref -q HEAD 2> /dev/null`
if [ $? == 0 ] ; then
ISGITBRANCH="yes"
GITBRANCH=${BRANCH##*/}
else
ISGITBRANCH="no"
GITBRANCH=""
fi
if [ "$1" == "--help" ] || [ "$1" == "help" ] ; then
echo
echo "Sequencer64-doc pack 0.2 (2018-09-25)"
echo
echo "Usage: ./pack [--dry-run] [--clean] [tag]"
echo
echo "where tag is alternate information you want to include in the"
echo "name of the tarball; it replaces the current date."
echo
echo "This script packs the contents of the current directory into a"
echo "tarball that has the name of the directory and other information"
echo "as part of the filename."
echo
echo "This script packs the entire current directory ('$WORKINGDIR') into"
echo "a file named like the following (using no tag as an example):"
echo
echo " $WORKINGDIR-master-$TAGSTRING-my-code.tar.xz"
echo " $WORKINGDIR-$TAGSTRING-my-code.tar.xz"
echo
echo "Excluded from the tarball are derived products."
echo
echo "This script also detects the presence of a git branch, and incorporates"
echo "the branch name into the name of the tarball."
echo
else
while [ "$1" != "" ] ; do
case "$1" in
# Although this option is no longer needed, keep it around as an
# undocumented feature just in case the user wants to override the
# git discovery.
--branch | --git)
ISGITBRANCH="yes"
shift
GITBRANCH="$1"
;;
--dry-run)
DODRYRUN="yes"
;;
--clean)
DOCLEAN="yes"
;;
--no-clean)
DOCLEAN="no"
;;
*)
TAGSTRING="$1"
;;
esac
shift
done
if [ "$ISGITBRANCH" == "yes" ] ; then
TARBALLNAME="$WORKINGDIR-$GITBRANCH-$CURRENTDATE-$TAGSTRING.tar.xz"
else
TARBALLNAME="$WORKINGDIR-$CURRENTDATE-$TAGSTRING.tar.xz"
fi
echo "The tar-ball to be generated is '../$TARBALLNAME'..."
if [ "$DODRYRUN" == "yes" ] ; then
if [ "$DOCLEAN" == "yes" ] ; then
echo "Sequencer64-doc will be cleaned by 'make clean'."
fi
exit 1
fi
if [ "$DOCLEAN" == "yes" ] ; then
pushd tex
echo "Cleaning the project's derived files..."
make clean
popd
fi
# Here, we exclude the LaTeX derived files, including the PDFs.
# The PDFs are large and are derived from the real soure code files,
# the *.tex files. And they're already compressed, and so take forever
# to tar up.
pushd ..
if [ -d $WORKINGDIR ] ; then
tar cJf $TARBALLNAME \
--exclude-vcs \
--exclude="tex-stamp" \
--exclude="out.*" \
--exclude="*.aux" \
--exclude="*.BAK" \
--exclude="*.bak" \
--exclude="*.bz2" \
--exclude="*.fdb_latexmk" \
--exclude="*.fls" \
--exclude="*.gz" \
--exclude="*.idx" \
--exclude="*.ilg" \
--exclude="*.ind" \
--exclude="*.lof" \
--exclude="*.log" \
--exclude="*.lot" \
--exclude="*.out" \
--exclude="*.pdf" \
--exclude="*.toc" \
--exclude=".*.swp" \
--exclude="*.t" \
--exclude="*.tmp" \
--exclude="*.xz" \
$WORKINGDIR/
echo
else
echo "? Working directory $WORKINGDIR does not exist above this directory."
echo " Are you running pack.sh from the proper directory?"
echo " That is what you must do. See './pack --help'."
fi
popd
fi
#******************************************************************************
# pack (Sequencer64-doc)
#------------------------------------------------------------------------------
# Local Variables:
# End:
#------------------------------------------------------------------------------
# vim: ts=3 sw=3 et ft=sh
#------------------------------------------------------------------------------