-
Notifications
You must be signed in to change notification settings - Fork 3
/
pack
executable file
·168 lines (132 loc) · 4.09 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
#!/bin/bash
#
#******************************************************************************
# pack (yoshimi-doc)
#------------------------------------------------------------------------------
##
# \file pack
# \library yoshimi-doc
# \author Chris Ahlstrom
# \date 2014-05-21
# \update 2019-04-07
# \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
TAGSTRING="pack"
DODRYRUN="no"
DOCLEAN="yes"
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
cat << E_O_F
yoshimi-doc pack 0.2 edited on 2019-04-07
Usage: ./pack [--dry-run] [--no-clean] [tag]
where tag is alternate information you want to include in the name of the
tarball; it replaces the current date.
This script packs the contents of the current directory into a tarball that has
the name of the directory and other information as part of the filename.
This script packs the entire current directory ('$WORKINGDIR') into a file named
like the following (using no tag as an example):
$WORKINGDIR-master-$TAGSTRING-my-code.tar.xz
$WORKINGDIR-$TAGSTRING-my-code.tar.xz
Excluded from the tarball are derived products. This script also detects the
presence of a git branch, and incorporates the branch name into the name of the
tarball.
E_O_F
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"
;;
--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 "yoshimi-doc will be cleaned by 'make clean'."
fi
exit 1
fi
if [ "$DOCLEAN" == "yes" ] ; then
pushd tex
make clean
popd
fi
pushd ..
if [ -d $WORKINGDIR ] ; then
# tar cJf $TARBALLNAME $WORKINGDIR/ \
tar cJf $TARBALLNAME \
--exclude-vcs \
--exclude=".git" \
--exclude="tex-stamp" \
--exclude="out.*" \
--exclude="*.aux" \
--exclude="*.bak" \
--exclude="*.fdb_latexmk" \
--exclude="*.fls" \
--exclude="*.idx" \
--exclude="*.ilg" \
--exclude="*.ind" \
--exclude="*.lof" \
--exclude="*.log" \
--exclude="*.lot" \
--exclude="*.out" \
--exclude="*.toc" \
--exclude="*.bak" \
--exclude=".*.swp" \
--exclude="*.t" \
--exclude="*.tmp" \
$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 (yoshimi-doc)
#------------------------------------------------------------------------------
# Local Variables:
# End:
#------------------------------------------------------------------------------
# vim: ts=3 sw=3 et ft=sh
#------------------------------------------------------------------------------