tar_em_up.sh 10 KB
Newer Older
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
1
2
3
4
#!/bin/bash
# super-simplistic installer for l2ork things by Ivica Ico Bukvic <ico@vt.edu>
# for info on L2Ork visit http://l2ork.music.vt.edu

5
6
7
8
9
10
11
12
cleanup() {
    # maybe we'd want to do some actual cleanup here
    test $2 -ne 0 && echo "$0: $1: command failed with exit code $2, exiting now." && echo "$0: $1: $BASH_COMMAND"
    exit $2
}

trap 'cleanup $LINENO $?' ERR

Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
13
14
15
16
17
18
if [ $# -eq 0 ] # should check for no arguments
then
	echo
	echo "   Usage: ./tar_em_up.sh -option1 -option2 ..."
	echo "   Options:"
	echo "     -a    l2ork addon to the dev package"
Ivica Bukvic's avatar
Ivica Bukvic committed
19
20
	echo "     -b    build a deb (incremental, all platforms)"
	echo "     -B    build a deb (complete recompile)"
21
	echo "     -c    core Pd source tarball"
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
22
23
24
	echo "     -e    everything"
	echo "     -f    full installer (incremental)"
	echo "     -F    full installer (complete recompile)"
25
	echo "     -n    skip package creation (-bB, -fF)"
Ivica Bukvic's avatar
Ivica Bukvic committed
26
27
28
	echo "     -R    build a Raspberry Pi deb (complete recompile)"
	echo "     -r    build a Raspberry Pi deb (incremental)"
	echo "     -w    install custom version of cwiid system-wide"
29
	echo "     -X    build an OSX installer (dmg)"
30
31
	echo "     -z    build a Windows installer (incremental)"
	echo "     -Z    build a Windows installer (complete recompile)"
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
32
	echo
33
34
35
36
37
	echo "   For custom install locations do the following before"
	echo "   running this script:"
	echo
	echo "           export inst_dir=/some/custom/location"
	echo
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
38
39
40
41
42
43
44
	exit 1
fi

addon=0
deb=0
core=0
full=0
Ivica Bukvic's avatar
Ivica Bukvic committed
45
sys_cwiid=0
Ivica Bukvic's avatar
Ivica Bukvic committed
46
rpi=0
47
pkg=1
48
inno=0
49
dmg=0
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
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
while getopts ":abBcdefFnRruwXzZ" Option
do case $Option in
		a)		addon=1;;

		b)		deb=1
				inst_dir=${inst_dir:-/usr};;

		B)		deb=2
				inst_dir=${inst_dir:-/usr};;

		c)		core=1;;

		e)		addon=1
				core=1
				full=1;;

		f)		full=1;;

		F)		full=2;;

		n)		pkg=0;;

		R)		deb=2
				inst_dir=/usr
				rpi=1;;

		r)		deb=1
				inst_dir=/usr
				rpi=1;;

		w)		sys_cwiid=1
				;;

		X)		dmg=1
				inst_dir=/usr;;

		z)		inno=1
				inst_dir=/usr;;

		Z)		inno=2
				inst_dir=/usr;;

		*)		echo "Error: unknown option";;
	esac
done

inst_dir=${inst_dir:-/usr/local}

export TAR_EM_UP_PREFIX=$inst_dir

101
102
103
104
105
106
107
# Get the OS we're running under, normalized to names that can be used
# to fetch the nwjs binaries below

os=`uname | tr '[:upper:]' '[:lower:]'`
if [[ $os == *"mingw32"* ]]; then
	os=win
fi
108
109
110
if [[ $os == "darwin" ]]; then
	os=osx
fi
111

112
# Fetch the nw.js binary if we haven't already. We want to fetch it even
Jonathan Wilkes's avatar
Jonathan Wilkes committed
113
# for building with no libs, so we do it regardless of the options
114
115
116
117
118
119
120
echo nwjs-sdk-v0.16.0-`uname | tr '[:upper:]' '[:lower:]'`
if [ ! -d "../pd/nw/nw" ]; then
	if [ `getconf LONG_BIT` -eq 32 ]; then
		arch="ia32"
	else
		arch="x64"
	fi
121

122
	# for rpi
123
	if [ `uname -m` == "armv7l" ]; then
124
125
126
		arch="armv7l"
	fi

127
	if [[ $os == "win" || $os == "osx" ]]; then
128
		ext="zip"
129
130
131
132
	else
		ext="tar.gz"
	fi

133
	if [[ $os == "win" || $osx_version == "10.8" ]]; then
134
135
136
137
		# We need the lts version to be able to run on XP. For
                # simplicity we use that same version for 64 bit Windows, too
		nwjs_version="v0.14.7"
	else
138
		# temporary kluge for rpi-- only 0.15.1 is available atm
139
		if [ `uname -m` == "armv7l" ]; then
Jonathan Wilkes's avatar
Jonathan Wilkes committed
140
			nwjs_version="v0.17.6"
141
		else
142
			nwjs_version="v0.22.1"
143
		fi
144
145
	fi

146
147
148
	nwjs="nwjs-sdk"
	nwjs_dirname=${nwjs}-${nwjs_version}-${os}-${arch}
	nwjs_filename=${nwjs_dirname}.${ext}
149
150
	nwjs_url=https://git.purrdata.net/jwilkes/nwjs-binaries/raw/master
	nwjs_url=${nwjs_url}/$nwjs_filename
151
152
	echo "Fetching the nwjs binary from"
	echo "$nwjs_url"
153
        wget -nv $nwjs_url
154
	if [[ $os == "win" || $os == "osx" ]]; then
155
156
157
158
		unzip $nwjs_filename
	else
		tar -xf $nwjs_filename
	fi
159
160
161
162
163
164
	# Special case for arm binary's inconsistent directory name
	# (It's not the same as the `uname -m` output)
	if [ `uname -m` == "armv7l" ]; then
		nwjs_dirname=`echo $nwjs_dirname | sed 's/armv7l/arm/'`
	fi
        mv $nwjs_dirname ../pd/nw/nw
165
166
	# make sure the nw binary is executable on GNU/Linux
	if [[ $os != "win" && $dmg == 0 ]]; then
167
168
		chmod 755 ../pd/nw/nw/nw
	fi
169
170
171
	rm $nwjs_filename
fi

172
173
174
175
176
177
178
179
180
181
# For Windows, fetch the ASIO SDK if we don't have it already
if [[ $os == "win" ]]; then
	if [ ! -d "../pd/lib" ]; then
		mkdir ../pd/lib
		wget http://www.steinberg.net/sdk_downloads/asiosdk2.3.zip
		unzip asiosdk2.3.zip
		mv ASIOSDK2.3 ../pd/lib
	fi
fi

Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
182
183
184
185
186
187
188
cd ../

if [ $core -eq 1 ]
then
	echo "core Pd..."
	rm -f ../Pd-l2ork-`date +%Y%m%d`.tar.bz2 2> /dev/null
	cd pd/src/
189
	make clean || true # this may fail on 1st attempt
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
190
	cd ../../
191
	tar -jcf ./Pd-l2ork-`date +%Y%m%d`.tar.bz2 pd
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
192
193
fi

194
if [ $full -gt 0 -o $deb -gt 0 -o $inno -gt 0 -o $dmg -gt 0 ]
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
195
then
196
197
	echo "Pd-L2Ork full installer... IMPORTANT! To ensure you have the most up-to-date submodules, this process requires internet connection to pull sources from various repositories..."

198
199
200
	if [ -d .git ]; then
		# check if Gem submodule is empty, and if so do first init
		if [ "$(ls -A Gem)" ]; then
201
202
			git submodule update
			#git submodule foreach git pull origin master
203
		else
204
			# init all submodules (only necessary the first time)
205
			git submodule init
206
207
			git submodule update
			#git submodule foreach git pull origin master
208
		fi
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
209
210
211
	fi


212
	if [ $full -eq 2 -o $deb -eq 2 -o $inno -eq 2 -o $dmg -eq 2 ]
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
213
214
215
216
217
	then
	#	echo "Since we are doing a complete recompile we are assuming we will need to install l2ork version of the cwiid library. You will need to remove any existing cwiid libraries manually as they will clash with this one. L2Ork version is fully backwards compatible while also offering unique features like full extension support including the passthrough mode. YOU SHOULD REMOVE EXISTING CWIID LIBRARIES PRIOR TO RUNNING THIS INSTALL... You will also have to enter sudo password to install these... Press any key to continue or CTRL+C to cancel install..."
	#	read dummy
		# clean files that may remain stuck even after doing global make clean (if any)
		cd externals/miXed
218
		make clean || true # this may fail on 1st attempt
219
		cd ../
220
		make gem_clean || true # this may fail on 1st attempt
221
		cd ../Gem/src/
222
		make distclean || true # this may fail on 1st attempt
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
223
224
225
		rm -rf ./.libs
		rm -rf ./*/.libs
		cd ../
226
227
228
		make distclean || true # this may fail on 1st attempt
		rm -f gemglutwindow.pd_linux
		rm -f Gem.pd_linux
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
229
230
		aclocal
		./autogen.sh
231
		export INCREMENTAL=""
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
232
233
	else
		cd Gem/
234
		export INCREMENTAL="yes"
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
235
	fi
236
	cd ../pd/src && aclocal && autoconf
237
238
	if [[ $os == "win" ]]; then
		cd ../../packages/win32_inno
Jonathan Wilkes's avatar
Jonathan Wilkes committed
239
	elif [[ $os == "osx" ]]; then
240
		cd ../../packages/darwin_app
241
242
243
	else
		cd ../../packages/linux_make
	fi
244
	if [ $full -gt 1 -o $deb -eq 2 -o $inno -eq 2 -o $dmg -eq 2 ]
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
245
	then
246
		make distclean || true # this may fail on 1st attempt
247
248
249
250
		cp ../../pd/src/g_all_guis.h ../../externals/build/include
		cp ../../pd/src/g_canvas.h ../../externals/build/include
		cp ../../pd/src/m_imp.h ../../externals/build/include
		cp ../../pd/src/m_pd.h ../../externals/build/include
251
252
253
		# ag: s_stuff.h may not exist at this point yet (will be
		# generated later), is this really needed here?
		test -f ../../pd/src/s_stuff.h && cp ../../pd/src/s_stuff.h ../../externals/build/include
254
		cp ../../pd/src/g_all_guis.h ../../externals/build/include								
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
255
256
		rm -rf build/
	fi
Ivica Bukvic's avatar
Ivica Bukvic committed
257
258
259
260
	if [ $rpi -eq 0 ]
	then
		echo "installing desktop version..."
		cp -f debian/control.desktop debian/control
261
		cp -f ../../l2ork_addons/flext/config-lnx-pd-gcc.txt.intel ../../externals/grill/trunk/flext/buildsys/config-lnx-pd-gcc.txt
Ivica Bukvic's avatar
Ivica Bukvic committed
262
263
264
	else
		echo "installing raspbian version..."
		cp -f debian/control.raspbian debian/control
265
		cp -f ../../l2ork_addons/flext/config-lnx-pd-gcc.txt.rpi ../../externals/grill/trunk/flext/buildsys/config-lnx-pd-gcc.txt
Ivica Bukvic's avatar
Ivica Bukvic committed
266
267
		cat ../../externals/OSCx/src/Makefile | sed -e s/-lpd//g > ../../externals/OSCx/src/Makefile
	fi
268
269
270
271
	if [[ $os == "win" ]]; then
		echo "Making Windows package..."
		echo `pwd`
		make install && make package
Jonathan Wilkes's avatar
Jonathan Wilkes committed
272
	elif [[ $os == "osx" ]]; then
273
274
275
		echo "Making OSX package (dmg)..."
		echo `pwd`
		make install && make package
276
277
278
	else
		make install prefix=$inst_dir
	fi
279
	echo "copying pd-l2ork-specific externals..."
280
281
	# create images folder
	mkdir -p ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra/images
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
282
283
	# patch_name
	# spectdelay
284
285
	if [[ $os == "win" ]]; then
		cd ../../l2ork_addons
Jonathan Wilkes's avatar
Jonathan Wilkes committed
286
	elif [[ $os == "osx" ]]; then
287
		cd ../../l2ork_addons
288
289
290
291
292
293
294
295
296
	else
		cd ../../l2ork_addons/spectdelay/spectdelay~
		./linux-install.sh
		cp -f spectdelay~.pd_linux ../../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		cp -f spectdelay~-help.pd ../../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		cp -f array* ../../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		# return to l2ork_addons folder
		cd ../../
	fi
Ivica Bukvic's avatar
Ivica Bukvic committed
297
	# install raspberry pi externals (if applicable)
298
	if [ $inno -eq 0 -a $dmg -eq 0 ]; then
299
300
301
302
303
304
305
306
		cd raspberry_pi
		./makeall.sh
		cp -f disis_gpio/disis_gpio.pd_linux ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		cp -f disis_gpio/disis_gpio-help.pd ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		cp -f disis_spi/disis_spi.pd_linux ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		cp -f disis_spi/disis_spi-help.pd ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra
		cd ../
	fi
307

308
	echo "done with l2ork addons."
309
	cd ../
310
	# finish install for deb
311
	if [ $inno -eq 0 -a $dmg -eq 0 ]; then
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
		cd packages/linux_make
		rm -f build/usr/local/lib/pd
		if [ $pkg -gt 0 ]; then
		echo "tar full installer..."
		if [ $deb -gt 0 ]
		then
			cd build/
			rm -rf DEBIAN/ etc/
			cd ../
			make deb prefix=$inst_dir
		else
			make tarbz2 prefix=$inst_dir
		fi
		echo "move full installer..."
		if [ $deb -gt 0 ]
		then
328
			mv *.deb ../../
329
330
331
		else
			#rm -f ../../../Pd-l2ork-full-`uname -m`-`date +%Y%m%d`.tar.bz2 2> /dev/null
			#mv build/Pd*bz2 ../../../Pd-l2ork-full-`uname -m`-`date +%Y%m%d`.tar.bz2
332
			mv -f build/pd*bz2 ../..
333
334
335
336
337
		fi
		elif [ $deb -gt 0 ]; then
			make debstage prefix=$inst_dir
		fi
		cd ../../
338
339
340
	# move OSX dmg installer
	elif [ $dmg -gt 0 ]; then
		mv packages/darwin_app/Pd*.dmg .
341
	elif [ $inno -gt 0 ]; then
Jonathan Wilkes's avatar
Jonathan Wilkes committed
342
		mv packages/win32_inno/Output/Purr*.exe .
343
	fi
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
344
345
346
347
348
fi

if [ $addon -eq 1 ]
then
	echo "l2ork addons..."
349
	rm -f ../l2ork_addons-`uname -m`-`date +%Y%m%d`.tar.bz2 2> /dev/null
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
350
	#cp -rf /usr/local/lib/pd/* l2ork_addons/externals/
351
	tar -jcf ../l2ork_addons-`uname -m`-`date +%Y%m%d`.tar.bz2 l2ork_addons
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
352
353
354
355
356
357
358
fi

cd l2ork_addons/

echo "done."

exit 0