-
Notifications
You must be signed in to change notification settings - Fork 14
/
pack
executable file
·268 lines (224 loc) · 7.18 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/bin/bash
#
#******************************************************************************
# pack (Seq66)
#------------------------------------------------------------------------------
##
# \file pack
# \library Seq66
# \author Chris Ahlstrom
# \date 2015-09-10
# \update 2020-11-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.
#
# Run "./pack --help" for more information.
#
# Allows some artifacts generated by bootstrap to be included, so that a
# conventional "GNU configure" tarfile can be generated. If you do
# not want that, do a "./bootstrap --full-clean" first.
#
# Please note that making a build from the resulting tarball will not include
# git version information, which is a good thing for release tarballs, which
# just need the date and version number.
#
#-----------------------------------------------------------------------------
CURRENTDATE=$(date +%Y-%m-%d)
CURRENTDIR=$(pwd)
WORKINGDIR=${CURRENTDIR##/*/} # strip all but last part of path
PACKAGENAME="bogus"
TAGSTRING="pack"
DODRYRUN="no"
DOCLEAN="no"
DORELEASE="no"
DODIFFS="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
cat << E_O_F
pack 0.9 2020-11-25
Usage: ./pack [--dry-run] [--clean] [--release package] [--diffs] [tag]
'tag' is information to include in the name of the tarball; it replaces the
current date.
This script packs the contents of the project directory into a tarball with the
name of the directory and other information as part of the filename. This
tarball can be suitable for unpacking, then running ./configure, and building
the default (currently rtmidi) build of Seq66 (currently the seq66
executable). To create such a tarball, see the instructions below.
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
If the --diffs option is specified, "seqpack" is used in lieu of the
current working directory. Obviously, this option will work only in a
git repository. It's a convenience for the developers.
For source-code releases, one first checks out the desired git branch,
then bootstraps the desired package (e.g. 'rtmidi'), then builds the code
(optional, but recommended), and then runs a command like the following:
./pack --release rtmidi 0.94.6
The resulting tarball can be distributed to users who just want to do
the beautiful "./configure ; make ; make install" mantra.
Excluded from the tarball are derived products. Version-control-system
directories are ignored. This script detects the presence of a git branch, and
incorporates the branch name into the name of the tarball.
Finally, it packs up 'configure', Makefile.in files, and other necessary files.
Do './bootstrap --full-clean' first, or './pack --clean', if you don't want
these files and want to start from scratch and build something difference from
the default build.
E_O_F
else
while [ "$1" != "" ] ; do
case "$1" in
--dry-run)
DODRYRUN="yes"
;;
--clean)
DOCLEAN="yes"
;;
--no-clean)
DOCLEAN="no"
;;
--release)
shift
DORELEASE="yes"
PACKAGENAME="$1"
;;
--diffs)
DODIFFS="yes"
;;
*)
TAGSTRING="$1"
;;
esac
shift
done
if [ "$ISGITBRANCH" == "yes" ] ; then
if [ "$DORELEASE" == "yes" ] ; then
TARBALLNAME="$WORKINGDIR-$GITBRANCH-$PACKAGENAME-$TAGSTRING.tar.xz"
make clean
elif [ "$DODIFFS" == "yes" ] ; then
TARBALLNAME="seqpack-$GITBRANCH-$CURRENTDATE-$TAGSTRING.tar.xz"
else
TARBALLNAME="$WORKINGDIR-$GITBRANCH-$CURRENTDATE-$TAGSTRING.tar.xz"
fi
else
if [ "$DODIFFS" == "yes" ] ; then
echo "The --diffs option requires a git repository, aborting!"
exit 1
fi
if [ "$DORELEASE" == "yes" ] ; then
TARBALLNAME="$WORKINGDIR-$PACKAGENAME-$TAGSTRING.tar.xz"
else
TARBALLNAME="$WORKINGDIR-$CURRENTDATE-$TAGSTRING.tar.xz"
fi
fi
echo "The tar-ball to be generated is '../$TARBALLNAME'"
if [ "$DODRYRUN" == "yes" ] ; then
if [ "$DOCLEAN" == "yes" ] ; then
echo "Seq66 will be cleaned by 'bootstrap --full-clean'."
fi
if [ "$DODIFFS" == "yes" ] ; then
echo "Will do 'tar cJf $TARBALLNAME \$(git diff --name-only)'"
else
echo "Will do 'tar cJf $TARBALLNAME $WORKINGDIR'"
fi
exit 1
fi
if [ "$DOCLEAN" == "yes" ] ; then
echo "Cleaning the project..."
./bootstrap --full-clean
fi
if [ "$DODIFFS" == "yes" ] ; then
tar cJf $TARBALLNAME $(git diff --name-only)
else
# Others that mostly, but not always, are not needed, and so aren't excluded
# at this time:
#
# Makefile.in
# Linux executable files
# --exclude="aux-files"
# --exclude="Makefile" (currently the ones in the "doc" directory
# --exclude="latex"
#
# Removed the slash after WORKINGDIR, and moved it to the end, which
# now allows tar to not include .git in the archive, saving a lot of time
# and space.
pushd ..
if [ -d $WORKINGDIR ] ; then
tar cJf $TARBALLNAME \
--exclude-vcs \
--exclude=".git" \
--exclude="Seq66/seq66" \
--exclude="Seq66qt5/qseq66" \
--exclude="Seq66cli/seq66cli" \
--exclude="config.h" \
--exclude="config.status" \
--exclude="libtool" \
--exclude="Debug" \
--exclude="Release" \
--exclude="debug" \
--exclude="release" \
--exclude="autom4te.cache" \
--exclude="core" \
--exclude="moc" \
--exclude="obj" \
--exclude="html" \
--exclude="ipch" \
--exclude="*stamp*" \
--exclude="tests" \
--exclude="out.*" \
--exclude=".deps" \
--exclude=".exes" \
--exclude=".libs" \
--exclude="*.a" \
--exclude="*.BAK" \
--exclude="*.bak" \
--exclude="*.bpi" \
--exclude="*.bz" \
--exclude="*.bz2" \
--exclude="*.deps" \
--exclude="*.gz" \
--exclude="*.o" \
--exclude="*.lo" \
--exclude="*.la" \
--exclude="*.lib" \
--exclude="*.log" \
--exclude="*.obj" \
--exclude="*.pch" \
--exclude="*.pdb" \
--exclude="*.Po" \
--exclude="*.sdf" \
--exclude="*.so" \
--exclude="*.stash" \
--exclude="*.swp" \
--exclude=".*.swp" \
--exclude="*.t" \
--exclude="*.tds" \
--exclude="*.tmp" \
--exclude="*.user" \
--exclude="*.xz" \
--exclude="*.testsettings" \
$WORKINGDIR
echo
else
echo "? Working directory $WORKINGDIR does not exist."
echo " Are you running pack from the proper directory?"
echo " That is what you must do. See './pack --help'."
fi
popd
fi
fi
#******************************************************************************
# pack (Seq66)
#------------------------------------------------------------------------------
# vim: ts=3 sw=3 et ft=sh
#------------------------------------------------------------------------------