tar_em_up.sh 8.7 KB
Newer Older
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
1
2
3
4
5
6
7
8
9
10
#!/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

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
11
12
	echo "     -b    build a deb (incremental, all platforms)"
	echo "     -B    build a deb (complete recompile)"
13
	echo "     -c    core Pd source tarball"
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
14
15
16
	echo "     -e    everything"
	echo "     -f    full installer (incremental)"
	echo "     -F    full installer (complete recompile)"
17
	echo "     -n    skip package creation (-bB, -fF)"
Ivica Bukvic's avatar
Ivica Bukvic committed
18
19
20
	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"
21
22
	echo "     -z    build a Windows installer (incremental)"
	echo "     -Z    build a Windows installer (complete recompile)"
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
23
	echo
24
25
26
27
28
	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
29
30
31
32
33
34
35
	exit 1
fi

addon=0
deb=0
core=0
full=0
Ivica Bukvic's avatar
Ivica Bukvic committed
36
sys_cwiid=0
Ivica Bukvic's avatar
Ivica Bukvic committed
37
rpi=0
38
pkg=1
39
inno=0
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
40

41
inst_dir=${inst_dir:-/usr/local}
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
42

43
44
45
46
47
48
49
# 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
50
51
52
if [[ $os == "darwin" ]]; then
	os=osx
fi
53

54
55
56
57
58
59
60
61
62
# Fetch the nw.js binary if we haven't already. We want to fetch it even
# for building with no libs, so we do it before all options
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
63

64
	# for rpi
65
	if [ `uname -m` == "armv7l" ]; then
66
67
68
		arch="armv7l"
	fi

69
	if [[ $os == "win" || $os == "osx" ]]; then
70
		ext="zip"
71
72
73
74
75
	else
		ext="tar.gz"
	fi

	if [[ $os == "win" ]]; then
76
77
78
79
		# 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
80
		# temporary kluge for rpi-- only 0.15.1 is available atm
81
		if [ `uname -m` == "armv7l" ]; then
82
83
			nwjs_version="v0.15.1"
		else
84
			nwjs_version="v0.18.4"
85
		fi
86
87
	fi

88
89
90
	nwjs="nwjs-sdk"
	nwjs_dirname=${nwjs}-${nwjs_version}-${os}-${arch}
	nwjs_filename=${nwjs_dirname}.${ext}
91
92
	nwjs_url=https://git.purrdata.net/jwilkes/nwjs-binaries/raw/master
	nwjs_url=${nwjs_url}/$nwjs_filename
93
94
95
	echo "Fetching the nwjs binary from"
	echo "$nwjs_url"
	wget $nwjs_url
96
97
98
99
100
	if [[ $os == "win" ]]; then
		unzip $nwjs_filename
	else
		tar -xf $nwjs_filename
	fi
101
	mv $nwjs_dirname ../pd/nw/nw
102
103
104
105
106
	# make sure the nw binary is executable on GNU/Linux and OSX
	if [[ $os != "win" ]]; then
		chmod 755 ../pd/nw/nw/nw
	fi
	chmod 755 ../pd/nw/nw/nw
107
108
109
	rm $nwjs_filename
fi

110
111
112
113
114
115
116
117
118
119
120
121
# 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


while getopts ":abBcdefFnRruwzZ" Option
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
do case $Option in
		a)		addon=1;;

		b)		deb=1
				inst_dir=/usr;;

		B)		deb=2
				inst_dir=/usr;;

		c)		core=1;;

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

		f)		full=1;;

		F)		full=2;;

141
142
		n)		pkg=0;;

143
144
145
146
147
148
149
150
		R)		deb=2
				inst_dir=/usr
				rpi=1;;

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

Ivica Bukvic's avatar
Ivica Bukvic committed
151
		w)		sys_cwiid=1
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
152
153
				;;

154
155
156
157
158
159
		z)		inno=1
				inst_dir=/usr;;

		Z)		inno=2
				inst_dir=/usr;;

Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
160
161
162
163
		*)		echo "Error: unknown option";;
	esac
done

164
165
export TAR_EM_UP_PREFIX=$inst_dir

Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
166
167
168
169
170
171
172
173
174
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/
	make clean
	cd ../../
175
	tar -jcf ./Pd-l2ork-`date +%Y%m%d`.tar.bz2 pd
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
176
177
fi

178
if [ $full -gt 0 -o $deb -gt 0 -o $inno -gt 0 ]
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
179
then
180
181
	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..."

182
183
184
	if [ -d .git ]; then
		# check if Gem submodule is empty, and if so do first init
		if [ "$(ls -A Gem)" ]; then
185
186
			git submodule update
			#git submodule foreach git pull origin master
187
		else
188
			# init all submodules (only necessary the first time)
189
			git submodule init
190
191
			git submodule update
			#git submodule foreach git pull origin master
192
		fi
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
193
194
195
	fi


196
	if [ $full -eq 2 -o $deb -eq 2 -o $inno -eq 2 ]
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
197
198
199
200
201
202
	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
		make clean
203
204
205
		cd ../
		make gem_clean
		cd ../Gem/src/
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
206
207
208
209
210
211
212
213
214
		make distclean
		rm -rf ./.libs
		rm -rf ./*/.libs
		cd ../
		make distclean
		rm gemglutwindow.pd_linux
		rm Gem.pd_linux
		aclocal
		./autogen.sh
215
		export INCREMENTAL=""
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
216
217
	else
		cd Gem/
218
		export INCREMENTAL="yes"
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
219
	fi
220
	cd ../pd/src && aclocal && autoconf
221
222
223
224
225
226
	if [[ $os == "win" ]]; then
		cd ../../packages/win32_inno
	else
		cd ../../packages/linux_make
	fi
	if [ $full -gt 1 -o $deb -eq 2 -o $inno -eq 2 ]
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
227
228
	then
		make distclean
229
230
231
232
233
234
235
		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
		cp ../../pd/src/s_stuff.h ../../externals/build/include
		cp ../../pd/src/t_tk.h ../../externals/build/include
		cp ../../pd/src/g_all_guis.h ../../externals/build/include								
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
236
237
		rm -rf build/
	fi
Ivica Bukvic's avatar
Ivica Bukvic committed
238
239
240
241
	if [ $rpi -eq 0 ]
	then
		echo "installing desktop version..."
		cp -f debian/control.desktop debian/control
242
		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
243
244
245
	else
		echo "installing raspbian version..."
		cp -f debian/control.raspbian debian/control
246
		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
247
248
		cat ../../externals/OSCx/src/Makefile | sed -e s/-lpd//g > ../../externals/OSCx/src/Makefile
	fi
249
250
251
252
253
254
255
	if [[ $os == "win" ]]; then
		echo "Making Windows package..."
		echo `pwd`
		make install && make package
	else
		make install prefix=$inst_dir
	fi
256
	echo "copying pd-l2ork-specific externals..."
257
258
	# 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
259
260
	# patch_name
	# spectdelay
261
262
263
264
265
266
267
268
269
270
271
	if [[ $os == "win" ]]; then
		cd ../../l2ork_addons
	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
272
	# install raspberry pi externals (if applicable)
273
	if [ $inno -eq 0 ]; then
274
275
276
277
278
279
280
281
		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
282

283
	echo "done with l2ork addons."
284
	cd ../
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
	# finish install for deb
	if [ $inno -eq 0 ]; then
		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
303
			mv *.deb ../../
304
305
306
		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
307
			mv -f build/pd*bz2 ../..
308
309
310
311
312
		fi
		elif [ $deb -gt 0 ]; then
			make debstage prefix=$inst_dir
		fi
		cd ../../
313
	fi
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
314
315
316
317
318
fi

if [ $addon -eq 1 ]
then
	echo "l2ork addons..."
319
	rm -f ../l2ork_addons-`uname -m`-`date +%Y%m%d`.tar.bz2 2> /dev/null
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
320
	#cp -rf /usr/local/lib/pd/* l2ork_addons/externals/
321
	tar -jcf ../l2ork_addons-`uname -m`-`date +%Y%m%d`.tar.bz2 l2ork_addons
Ivica Ico Bukvic's avatar
Ivica Ico Bukvic committed
322
323
324
325
326
327
328
fi

cd l2ork_addons/

echo "done."

exit 0