forked from fltk/fltk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makesrcdist
executable file
·301 lines (244 loc) · 9.24 KB
/
makesrcdist
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/sh
#
# makesrcdist - make a distribution of FLTK.
#
# There are 3 different modes of operation, dependent on commandline arguments:
#
# (1) Create snapshot:
#
# ./makesrcdist [snapshot]
#
# Use no arguments or "snapshot" (verbatim).
#
# (2) Create distribution tarballs for test and verification:
#
# ./makesrcdist <version> <doc-dir>
#
# <version> : Use a version number as argument, e.g. "1.3.3" or "1.3.4rc2".
# This can be used for local testing.
#
# <doc-dir> : This *MUST* be a CMake build folder where all the
# documentation (HTML, PDF, Fluid-HTML, and Fluid-PDF) were built.
# The directory name can be relative to the FLTK root or absolute.
#
# Note: the release tarballs will be created from the current
# 'HEAD' revision of your local Git repository. Make sure that
# you committed all changes.
#
# (3) Create distribution tarballs (final):
#
# ./makesrcdist <version> <doc-dir> tag
#
# Same as (2), but create Git tag with version number.
# Enter "tag" (verbatim) as 3rd argument.
# This will create the Git tag "release-<version>" for the
# current revision in the (local) FLTK Git repository and export the
# FLTK sources from this tag for creation of distribution files.
#
# Note: You need to 'git push' the Git tag manually when you
# are satisfied with the result. You may use:
# $ git push <origin> release-<version>
# where <origin> is your remote repository, e.g. "origin" or "upstream"
# and <version> is the version number (argument #1)
#
# Note: define FLTK_TAR if you want to use a different compatible tar
# command than "tar", e.g. to use "gtar" (bash syntax):
# $ export FLTK_TAR="gtar"
#
TAR="tar"
if test "x$FLTK_TAR" != "x"; then
TAR="$FLTK_TAR"
fi
# Default version numbers from commandline, overwritten later for snapshots
version="$1"
fileversion="$1"
# Set DOC_DIR for full source distribution with documentation.
# This is not used for snapshots, see comments above.
DOC_DIR="$2"
# These are the release and snapshot download URL's currently in use.
# The 'DOWNLOAD' URL is on GitHub since FLTK 1.4.1,
# the 'SNAPSHOT' URL is on fltk.org.
DOWNLOAD="https://github.com/fltk/fltk/releases/download" # /release-$1/fltk-$1-source.tar.gz
SNAPSHOT='https://www.fltk.org/pub/fltk/snapshots'
DATE="`date +'%Y%m%d'`"
GIT_REVISION=$(git rev-parse HEAD)
git_rev=$(git rev-parse --short=12 HEAD)
# VS = short version number ('major.minor'), for instance '1.4'.
# Note: VS is used only for snapshot generation
# fltk_version = full version number w/o 'rcN' (from file fltk_version.dat)
# git_rev = short Git revision (12 chars)
fltk_version="`cat fltk_version.dat`"
VS="`echo $fltk_version | cut -f 1-2 -d '.'`"
echo "Getting distribution..."
if test $# = 0 -o "x$1" = "xsnapshot"; then
echo Getting snapshot revision...
version="${VS}-${git_rev}"
fileversion="${VS}.x-${DATE}-$git_rev"
fileurl="$SNAPSHOT/fltk-$fileversion.tar.gz"
else
# DOC_DIR must be specified
if test $# = 1 ; then
echo "ERROR: doc-dir (2nd argument) must be specified"
exit
fi
# DOC_DIR must be a CMake build folder
if test ! -f $DOC_DIR/CMakeCache.txt ; then
echo "ERROR: doc-dir (2nd argument) must be a CMake build folder."
echo "Please generate all docs in this CMake build before distributing:"
echo " cd $DOC_DIR"
echo " make|ninja html pdf fluid_docs fluid_pdf"
exit
fi
if test ! -e "$DOC_DIR/documentation/html/"; then
echo "ERROR: Please generate the HTML documentation before distributing:"
echo " cd $DOC_DIR"
echo " make|ninja html pdf fluid_docs fluid_pdf"
exit
fi
if test ! -e "$DOC_DIR/documentation/fltk.pdf"; then
echo "ERROR: Please generate the PDF documentation before distributing:"
echo " cd $DOC_DIR"
echo " make|ninja pdf fluid_docs fluid_pdf"
exit
fi
if test ! -e "$DOC_DIR/fluid/documentation/fluid.pdf"; then
echo "ERROR: Please generate the fluid documentation before distributing:"
echo " cd $DOC_DIR"
echo " ninja fluid_docs fluid_pdf"
exit
fi
fileurl="$DOWNLOAD/release-$version/fltk-$fileversion-source.tar.gz"
if test "x$3" = "xtag"; then
echo "Creating Git tag 'release-$version' ..."
git tag -a -m "Release $version" release-$version || exit 1
fi
fi
# where to build the distribution tarballs and other files:
TEMP_DIR="/tmp/fltk-$version"
# subdirectory of $TEMP_DIR for documentation in their tarballs
#
# This resembles the directory structure of releases where documentation
# would likely be installed in "/usr/share/doc/fltk".
DOC_TEMPDIR="share/doc/fltk"
# Debug:
### echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
### echo "fltk_version = $fltk_version"
### echo "version = $version"
### echo "fileversion = $fileversion"
### echo "fileurl = $fileurl"
### echo "GIT_REVISION = $GIT_REVISION"
### echo "git_rev = $git_rev"
### echo "TEMP_DIR = $TEMP_DIR"
### echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
echo Exporting $fltk_version to $TEMP_DIR/...
rm -rf /tmp/fltk-$version
mkdir /tmp/fltk-$version
git archive --format=tar HEAD | $TAR -C /tmp/fltk-$version -x --
if test $# != 0 -a "x$1" != "xsnapshot"; then
mkdir -p $TEMP_DIR/$DOC_TEMPDIR/fluid
echo "Copying HTML and PDF documentation..."
cp -r $DOC_DIR/documentation/html $TEMP_DIR/$DOC_TEMPDIR/
cp $DOC_DIR/documentation/fltk.pdf $TEMP_DIR/$DOC_TEMPDIR/
echo "Copying FLUID HTML and PDF documentation..."
cp -r $DOC_DIR/fluid/documentation/html $TEMP_DIR/$DOC_TEMPDIR/fluid/
cp $DOC_DIR/fluid/documentation/fluid.pdf $TEMP_DIR/$DOC_TEMPDIR/
fi
echo Applying version number...
cd /tmp/fltk-$version
sed -e '1,$s/@FLTK_VERSION@/'$version'/' \
-e '1,$s#^Source:.*#Source: '$fileurl'#' \
<fltk.spec.in >fltk.spec
# Debug:
### echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
### echo "$ egrep --color -1 'Source:|$version|$git_rev' fltk.spec"
### echo "··································································"
### egrep --color -1 "Source:|$version|$git_rev" fltk.spec
### echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
# Write git revision file with full git revision
# which will be stored in the distribution tarball
echo Writing git revision file...
echo "$GIT_REVISION" > fltk_git_rev.dat
echo Creating configure script...
autoconf -f
echo Cleaning developer files...
rm -rf OpenGL autom4te* bc5 config forms glut images packages themes
cd ..
if test $# != 0 -a "x$1" != "xsnapshot"; then
echo "Making HTML docs distribution..."
$TAR czf fltk-$fileversion-docs-html.tar.gz fltk-$version/$DOC_TEMPDIR/html/
echo "Making PDF docs distribution..."
$TAR czf fltk-$fileversion-docs-pdf.tar.gz fltk-$version/$DOC_TEMPDIR/fltk.pdf
echo "Making Fluid HTML docs distribution..."
$TAR czf fltk-$fileversion-fluid-docs-html.tar.gz fltk-$version/$DOC_TEMPDIR/fluid/html/
echo "Making Fluid PDF docs distribution..."
$TAR czf fltk-$fileversion-fluid-docs-pdf.tar.gz fltk-$version/$DOC_TEMPDIR/fluid.pdf
fi
echo "Removing documentation..."
rm -rf fltk-$version/$DOC_TEMPDIR
echo "Making UNIX (.tar.gz) distribution..."
$TAR czf fltk-$fileversion-source.tar.gz fltk-$version
echo "Making UNIX (.tar.bz2) distribution..."
$TAR cjf fltk-$fileversion-source.tar.bz2 fltk-$version
# echo "Making Windows (.zip) distribution..."
# rm -f fltk-$fileversion-source.zip
# zip -r9 fltk-$fileversion-source.zip fltk-$version
echo "Removing distribution directory..."
rm -rf fltk-$version
# Create releases.txt and sha256sums.txt
OUT="`pwd`/fltk-$fileversion-releases.txt"
SHA="`pwd`/fltk-$fileversion-sha256sums.txt"
echo
echo "Creating Release Info in $OUT and $SHA"
echo "" > $OUT
echo "github $fltk_version $fileversion" >> $OUT
echo "" >> $OUT
rm -f $SHA
touch $SHA
# make sure the order is source, html, pdf, fluid-html, fluid-pdf and gz, bz2
for f in source docs-html docs-pdf fluid-docs-html fluid-docs-pdf; do
for t in gz bz2; do
FILE="fltk-$fileversion-$f.tar.$t"
if [ -f $FILE ] ; then
# (a) releases file:
MD5=`md5sum $FILE | cut -f1 -d' '`
SIZ=`wc -c $FILE | cut -f1 -d' '`
echo "$MD5 $FILE $SIZ" >> $OUT
# (b) sha256sum file
sha256sum $FILE >> $SHA
fi
done
done
# finally add the sha256sum file (after it is complete) to the releases file
FILE="fltk-$fileversion-sha256sums.txt"
MD5=`md5sum $FILE | cut -f1 -d' '`
SIZ=`wc -c $FILE | cut -f1 -d' '`
echo "$MD5 $FILE $SIZ" >> $OUT
echo
echo "Done!"
echo
echo "================================================================================"
echo
echo "$OUT:"
echo
echo "--- copy the contents of this file to the top of data/releases.dat:"
cat $OUT
echo "--- end of file ---"
echo
echo "$SHA:"
echo
cat $SHA
if test "x$3" = "xtag"; then
echo
echo "================================================================================"
echo "Don't forget to push the Git tag if the result is OK"
echo "(assuming your remote Git repository is 'origin'):"
echo
echo "Use: \$ git push origin release-$version"
echo
echo "If test results are not OK you can delete the tag before pushing:"
echo
echo "$ git tag -d release-$version"
fi
echo
echo "================================================================================"
echo