File: makeTarball.sh

package info (click to toggle)
3depict 0.0.23-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 18,628 kB
  • sloc: cpp: 75,669; sh: 6,436; xml: 1,608; python: 350; ansic: 190; makefile: 177
file content (331 lines) | stat: -rwxr-xr-x 8,834 bytes parent folder | download | duplicates (2)
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#!/bin/bash
MSG_FILE=tmp-messages

if [ x`uname | grep Linux` != x"" ] ; then
	NUM_PROCS=`cat /proc/cpuinfo | grep cores | uniq | sed 's/.*:\s*//'`
else
	#For other platforms, guess!
	NUM_PROCS=4
fi




if [ ! -f configure ] ; then
	echo "Configure not found -- are you running this script from the top dir? " 
	exit 1
fi

#Don't overwrite message file
while [ -f $MSG_FILE ] ; 
do
	MSG_FILE=tmp-$MSG_FILE
done
	
#Check build for combinations of 
#	- enable/disable parallel 
#	- debug checking
#	- C++11
#	- ubsan
#-------
#CONF_ARGS=("--enable-openmp-parallel" "--disable-debug-checks " " --enable-debug-checks " " --enable-openmp-parallel --disable-debug-checks " " --enable-ubsan --enable-openmp-parallel " " --enable-ubsan "  )
#
#for i in ${CONF_ARGS[*]}
#do
#	if [ -f Makefile ] ; then
#		make distclean
#	fi
#
#	./configure "$i"
#
#	if [ $? -ne 0 ] ; then
#		echo "test-configuration failed to configure: arguments are $i"
#		exit 1
#	fi
#
#	if [ ! -f Makefile ] ; then
#		echo "Configure claimed everything was OK, but did not create a Makefile"
#		exit 1
#	fi
#
#	make -j $NUM_PROCS
#	if [ $? -ne 0 ] ; then
#		echo "failed to build: arguments are $i"
#		exit 1
#	fi
#
#	#Check for unit test availability, and run them
#	# where possible
#	pushd src
#	TEST_FLAG=`./3Depict --help  2>&1 | grep "\-\-test"`
#	if [ x"$TEST_FLAG" != x"" ] ; then
#		./3Depict -t
##		if [ $? -ne 0 ] ; then
##			echo "Unit tests failed for configure flag : $i" 
###			exit 1
##		fi
#	fi
#	popd	
#      
#	make distclean
#done
#-------

./configure
if [ $? -ne 0 ] ; then
	echo "Something went wrong with configure. Cannot continue"
	exit 1
fi
rm -rf autom4te.cache

#Build tarball
make dist -j $NUM_PROCS

if [ $? -ne 0 ] ; then
	echo "make dist failed";
	exit 1;
fi

#Various release-time checks
#----

echo "--------- RUNNING SANITY CHECKS -------"

#Check version
VER=`ls 3depict-*gz | sed 's/^3depict-\([0-9\.]*\).tar.gz$/\1/' `
echo "Version is apparently :" $VER

if [ x"`grep $VER .hgtags`" == x""  ] ; then
	echo " NOTICE: version number not seen in HG file..." >> $MSG_FILE
else
	echo " NOTICE: Version number exists in HG (OK)" >> $MSG_FILE
fi

#Check version number in various files is set concomitantly.
if [ x"`grep $VER ChangeLog.txt`" == x"" ] ; then
	echo " WARNING: Program version not set to match between configure.ac. and ChangeLog">> $MSG_FILE
fi

if [ x"`grep PROGRAM_VERSION src/common/constants.cpp | grep $VER`" == x"" ] ; then
	echo " WARNING: Program version not set to match between configure.ac. and constants.cpp">> $MSG_FILE
fi

#Check version number in deb & rpm
if [ x"`head -n 1 packaging/debian/changelog |grep 3depict | grep $VER`"  = x"" ] ; then
	echo " WARNING: Program version does not match between configure.ac and packaging/debian/changelog" >> $MSG_FILE
fi

if [ x"` grep '^Version:' packaging/RPM/3Depict.spec  | grep $VER`"  = x"" ] ; then
	echo " WARNING: Program version does not match between configure.ac and packaging/RPM/3Depict.spec" >> $MSG_FILE
fi

if [ x"` grep 'PRODUCT_VERSION'  packaging/mingw-debian-cross/windows-installer.nsi | grep $VER`"  = x"" ] ; then
	echo " WARNING: Program version does not match between configure.ac and packaging/mingw-debian-cross/windows-installer.nsi" >> $MSG_FILE
fi

#Check latex manual
if [ x"`grep --after-context=2 'Version:' docs/manual-latex/manual.tex | grep $VER`" == x"" ] ; then
	echo " WARNING: Program version does not match between configure.ac and docs/manual-latex/manual.tex" >> $MSG_FILE
fi

#Check that the fp exceptions are disabled.
if [ x"`grep feenableexcept src/3Depict.cpp | egrep -v '^\s*//'`" != x"" ] ; then
	echo " WARNING: Floating point exceptions still appear to be enabled..." >> $MSG_FILE
fi

#check that we are not using preprocessor macros incorrectly
#Apple preprocessor is exactly __APPLE__
RES=`find src/ -name *.cpp -exec grep APPLE {} \; | egrep '^\s*#' | grep -v EFFECTS_WORKAROUND | grep -v __APPLE__`
if [ x"$RES" != x"" ] ; then
	echo " WARNING: possible incorrect APPLE preprocessor token..." >> $MSG_FILE
	echo "$RES" >> $MSG_FILE
fi

RES=`find src/ -name *.h -exec grep APPLE {} \; | egrep '^\s*#' | grep -v EFFECTS_WORKAROUND | grep -v __APPLE__`
if [ x"$RES" != x"" ] ;  then
	echo " WARNING: possible incorrect APPLE preprocessor token..." >> $MSG_FILE
	echo "$RES" >> $MSG_FILE
fi

#Check for editor ~ files and orig files
SOMEFILES=`find ./ -name \*~`
if [ x"$SOMEFILES" != x"" ] ; then
	echo " WARNING : Found some maybe-backup files (~ extension)" >> $MSG_FILE
	echo "$FILES" >> $MSG_FILE
fi

SOMEFILES=`find ./ -name \*.orig`
if [ x"$SOMEFILES" != x"" ] ; then
	echo " WARNING : Found some maybe-backup files (\"orig\" extension)" >> $MSG_FILE
	echo "$FILES" >> $MSG_FILE
fi

SOMEFILES=`find ./ -name \*.rej`
if [ x"$SOMEFILES" != x"" ] ; then
	echo " WARNING : Found some maybe-backup files (\"rej\" extension)" >> $MSG_FILE
	echo "$FILES" >> $MSG_FILE
fi

#Check that PDF manual is built
PDF_FILE=docs/manual-latex/manual.pdf
if [ ! -f  $PDF_FILE ] ; then
	echo " WARNING : PDF manual was not found -- has it been compiled?" >> $MSG_FILE
	echo "$FILES" >> $MSG_FILE
else 
	#Check PDF is actually a pdf
	if [ x"`file $PDF_FILE | grep "PDF document" `" == x""  ] ; then
		echo " WARNING : PDF manual found, but does not appear to be a valid PDF?" >> $MSG_FILE
		echo "$FILES" >> $MSG_FILE
	
	fi
fi

#Check for outstanding mercurial changes
SOME_LINES=`hg diff | wc -l`
if [ x"$SOME_LINES" != x"0" ] ; then
	echo " WARNING : Oustanding mercurial changes! Normally should commit fixes!" >> $MSG_FILE
fi

#Check translation files for "span" element - transifex has a bad habit of encoding whitspace
SPAN_ELEMENT=`cat translations/3Depict_*po | grep "<span"`
if [ x"$SPAN_ELEMENT" != x"" ] ; then
	echo "WARNING : Found \"span\" element in translation file - normally this is due to transifex incorrectly parsing translation files" >> $MSG_FILE
fi

#Run licensecheck over files, if available
if [ x`which licensecheck` != x"" ] ; then
	LIC_CHECK_OUT=`licensecheck -r  --ignore=".*\.(sh|sci|py|tex|js|Po|am|xml|rng|rrng)$" src/ | grep -v "GPL (v[23] or later)" | grep -v "GENERATED FILE" | grep -v "MPL"  | grep -v "tarball/"`

	if [ x"$LIC_CHECK_OUT" != x"" ] ; then
		echo "WARNING:" $LIC_CHECK_OUT >> $MSG_FILE
	fi
else
	echo "Did not run licensecheck"
fi

if [ x`grep $VER ChangeLog.txt` == x"" ] ; then
	echo "Version missing from changelog"
else
	if [ x`grep $VER ChangeLog.txt |  grep  '?' ` != x"" ] ; then
		echo "Unexpected symbols on version line - Is the date set for the release?"
	fi
fi


#----


rm -rf tarball
mkdir tarball

#Take the autoconf-generated tarball, and perform some fixups, to
# generate the release version
pushd tarball
	tar -zxf ../3depict-$VER.tar.gz
	rm ../3depict-$VER.tar.gz
	#Autoconf buggers up the name case
	mv 3depict-$VER 3Depict-$VER

	#--- Translation stuff--

	#Build the translation files
	pushd ../translations
		./makeTranslations 
		mkdir -p ../tarball/3Depict-$VER/translations
		cp 3Depict*.mo ../tarball/3Depict-$VER/translations/
	popd

	#copy the manual
	cp ../docs/manual-latex/manual.pdf ./tarball/3Depict-$VER/docs/manual-latex/

	#Copy changelog
	cp ChangeLog.txt ./tarball/3Depict-$VER/


	pushd 3Depict-$VER/translations/

	#Move the .mo file to the correct subdir
		for i in `ls *.mo`
		do
			LOCALEVAL=`basename $i | sed 's/\.mo//' | sed 's/3Depict_//'`

			mkdir -p locales/$LOCALEVAL/LC_MESSAGES
			mv $i locales/$LOCALEVAL/LC_MESSAGES/3Depict.mo
		done

		if [ -d locales ] ; then
			mv locales ../
		else
			echo "ERROR: No Locales built.. Aborting"
			exit 1
		fi

	popd

	#--------------


	# Configure stuffs up the directories marked as extra-dist
	# if you don't use a trailing slash, some versions of configure die
	# if you do, other versions of configure add it as a subdir of itself
	# so lets just "fix it"
	#--------
	pushd 3Depict-$VER/
		for i in textures tex-source glade-skeleton 
		do
			if [ -d src/$i/$i ] ; then
				mv src/$i/$i/* src/$i/
				rmdir src/$i/$i/
			fi
		done



		for i in packaging docs m4 translations deps test data
		do
			if [ -d $i/$i ] ; then
				mv $i/$i/* $i/
				rmdir $i/$i/
			fi
		done
	popd

	#make the final source tarball
	tar -cz 3Depict-$VER > 3Depict-$VER.tar.gz
popd
#------

#OK, now try unpacking the thing, then building it.
mkdir tarball/extract/
if [ $? -ne 0 ] ; then
	echo "failed to make tarball extract dir"
fi
pushd tarball/extract

	tar -zxf ../3Depict-$VER.tar.gz

	pushd 3Depict-$VER;
		./configure
		if [ $? -ne 0 ] ; then
			echo "didn't configure after tarball extract"
		fi


		make  -j$NUM_PROCS 
		if [ $? -ne 0 ] ; then
			echo "rebuilding tarball failed."
		else
			echo "tarball rebuild OK!"
		fi

	popd
popd
#--------

if [ -f $MSG_FILE ] ; then
	echo "------------- SUMMARY ----------"
	cat $MSG_FILE
	echo "--------------------------------"

	rm $MSG_FILE
fi