chiark / gitweb /
Update LulzBot Mini's maximum print height
[cura.git] / package.sh
1 #!/usr/bin/env bash
2
3 set -e
4 set -u
5
6 # This script is to package the Cura package for Windows/Linux and Mac OS X
7 # This script should run under Linux and Mac OS X, as well as Windows with Cygwin.
8
9 #############################
10 # CONFIGURATION
11 #############################
12
13 ##Select the build target
14 BUILD_TARGET=${1:-none}
15 #BUILD_TARGET=win32
16 #BUILD_TARGET=darwin
17 #BUILD_TARGET=debian_i386
18 #BUILD_TARGET=debian_amd64
19 #BUILD_TARGET=debian_armhf
20 #BUILD_TARGET=freebsd
21
22 ##Do we need to create the final archive
23 ARCHIVE_FOR_DISTRIBUTION=1
24 ##Which version name are we appending to the final archive
25
26
27 ##Version
28 version_file="./Cura/version"
29 while IFS= read -r line
30 do
31     export BUILD_VERSION="$line"
32 done <"$version_file"
33 TARGET_DIR=Cura-${BUILD_VERSION}-${BUILD_TARGET}
34
35 ##Git commit
36 GIT_HASH=$(git rev-parse --short=4 HEAD)
37
38 export FULL_VERSION=${BUILD_VERSION}-${GIT_HASH}
39
40 ##Which versions of external programs to use
41 WIN_PORTABLE_PY_VERSION=2.7.6.1
42
43 ##Which CuraEngine to use
44 if [ -z ${CURA_ENGINE_REPO:-} ] ; then
45         CURA_ENGINE_REPO="https://code.alephobjects.com/diffusion/CE/curaengine.git"
46 fi
47
48 #############################
49 # Support functions
50 #############################
51 function checkTool
52 {
53         if [ -z "`which $1`" ]; then
54                 echo "The $1 command must be somewhere in your \$PATH."
55                 echo "Fix your \$PATH or install $2"
56                 exit 1
57         fi
58 }
59
60 function downloadURL
61 {
62         filename=`basename "$1"`
63         echo "Checking for $filename"
64         if [ ! -f "$filename" ]; then
65                 echo "Downloading $1"
66                 curl -L -O "$1"
67                 if [ $? != 0 ]; then
68                         echo "Failed to download $1"
69                         exit 1
70                 fi
71         fi
72 }
73
74 function extract
75 {
76         echo "Extracting $*"
77         echo "7z x -y $*" >> log.txt
78         $EXTRACT x -y $* >> log.txt
79         if [ $? != 0 ]; then
80         echo "Failed to extract $*"
81         exit 1
82         fi
83 }
84
85 function gitClone
86 {
87         echo "Cloning $1 into $2"
88         if [ -d $2 ]; then
89                 cd $2
90                 git clean -dfx
91                 git reset --hard
92                 git pull
93                 cd -
94         else
95                 git clone $1 $2
96         fi
97 }
98
99 #############################
100 # Actual build script
101 #############################
102 if [ "$BUILD_TARGET" = "none" ]; then
103         echo "You need to specify a build target with:"
104         echo "$0 win32"
105         echo "$0 debian_i386"
106         echo "$0 debian_amd64"
107         echo "$0 debian_armhf"
108         echo "$0 darwin"
109         echo "$0 freebsd"
110         echo "$0 fedora                         # current   system"
111         echo "$0 fedora \"mock_config_file\" ...  # different system(s)"
112         exit 0
113 fi
114
115 if [ -z `which make` ]; then
116         MAKE=mingw32-make
117 else
118         MAKE=make
119 fi
120
121 if [ -z `which 7za` ]; then
122         EXTRACT=7z
123 else
124         EXTRACT=7za
125 fi
126
127 # Change working directory to the directory the script is in
128 # http://stackoverflow.com/a/246128
129 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
130 cd "$SCRIPT_DIR"
131
132 checkTool git "git: http://git-scm.com/"
133 checkTool curl "curl: http://curl.haxx.se/"
134 if [ $BUILD_TARGET = "win32" ]; then
135         checkTool avr-gcc "avr-gcc: http://winavr.sourceforge.net/ "
136         #Check if we have 7zip, needed to extract and packup a bunch of packages for windows.
137         checkTool $EXTRACT "7zip: http://www.7-zip.org/"
138         checkTool $MAKE "mingw: http://www.mingw.org/"
139 fi
140 #For building under MacOS we need gnutar instead of tar
141 if [ -z `which gnutar` ]; then
142         TAR=tar
143 else
144         TAR=gnutar
145 fi
146
147 #############################
148 # Build the required firmwares
149 #############################
150
151 gitClone "https://github.com/Ultimaker/cura-binary-data" _cura_binary_data
152
153 cp -v _cura_binary_data/cura/resources/firmware/* resources/firmware/
154
155 #############################
156 # Darwin
157 #############################
158
159 if [ "$BUILD_TARGET" = "darwin" ]; then
160     TARGET_DIR=Cura-${BUILD_VERSION}-MacOS
161
162         rm -rf scripts/darwin/build
163         rm -rf scripts/darwin/dist
164
165         python build_app.py py2app
166         rc=$?
167         if [[ $rc != 0 ]]; then
168                 echo "Cannot build app."
169                 exit 1
170         fi
171
172     #Add cura version file (should read the version from the bundle with pyobjc, but will figure that out later)
173     echo $BUILD_VERSION > scripts/darwin/dist/Cura.app/Contents/Resources/version
174         rm -rf CuraEngine
175         gitClone ${CURA_ENGINE_REPO} CuraEngine
176     if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
177         $MAKE -C CuraEngine VERSION=${BUILD_VERSION}
178     if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
179         cp CuraEngine/build/CuraEngine scripts/darwin/dist/Cura.app/Contents/Resources/CuraEngine
180
181         cd scripts/darwin
182
183         # Install QuickLook plugin
184         mkdir -p dist/Cura.app/Contents/Library/QuickLook
185         cp -a STLQuickLook.qlgenerator dist/Cura.app/Contents/Library/QuickLook/
186
187         # Archive app
188         cd dist
189         $TAR cfp - Cura.app | gzip --best -c > ../../../${TARGET_DIR}.tar.gz
190         cd ..
191
192         # Create sparse image for distribution
193         hdiutil detach /Volumes/Cura\ -\ Lulzbot/ || true
194         rm -rf Cura.dmg.sparseimage
195         hdiutil convert DmgTemplateCompressed.dmg -format UDSP -o Cura.dmg
196         hdiutil resize -size 500m Cura.dmg.sparseimage
197         hdiutil attach Cura.dmg.sparseimage
198         cp -a dist/Cura.app /Volumes/Cura\ -\ Lulzbot/Cura/
199         hdiutil detach /Volumes/Cura\ -\ Lulzbot
200         hdiutil convert Cura.dmg.sparseimage -format UDZO -imagekey zlib-level=9 -ov -o ../../${TARGET_DIR}.dmg
201         exit
202 fi
203
204 #############################
205 # FreeBSD part by CeDeROM
206 #############################
207
208 if [ "$BUILD_TARGET" = "freebsd" ]; then
209         export CXX="c++"
210         gitClone https://github.com/GreatFruitOmsk/Power Power
211         gitClone ${CURA_ENGINE_REPO} CuraEngine
212     if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
213         gmake -j4 -C CuraEngine VERSION=${BUILD_VERSION}
214     if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
215         rm -rf scripts/freebsd/dist
216         mkdir -p scripts/freebsd/dist/share/cura
217         mkdir -p scripts/freebsd/dist/share/applications
218         mkdir -p scripts/freebsd/dist/bin
219         cp -a Cura scripts/freebsd/dist/share/cura/
220         cp -a resources scripts/freebsd/dist/share/cura/
221         cp -a plugins scripts/freebsd/dist/share/cura/
222         cp -a CuraEngine/build/CuraEngine scripts/freebsd/dist/share/cura/
223         cp scripts/freebsd/cura.py scripts/freebsd/dist/share/cura/
224         cp scripts/freebsd/cura.desktop scripts/freebsd/dist/share/applications/
225         cp scripts/freebsd/cura scripts/freebsd/dist/bin/
226         cp -a Power/power scripts/freebsd/dist/share/cura/
227         echo $BUILD_VERSION > scripts/freebsd/dist/share/cura/Cura/version
228         #Create file list (pkg-plist)
229         cd scripts/freebsd/dist
230         find * -type f > ../pkg-plist
231         DIRLVL=20; while [ $DIRLVL -ge 0 ]; do
232                 DIRS=`find share/cura -type d -depth $DIRLVL`
233                 for DIR in $DIRS; do
234                         echo "@dirrm $DIR" >> ../pkg-plist
235                 done
236                 DIRLVL=`expr $DIRLVL - 1`
237         done
238         cd ..
239         # Create archive or package if root
240         if [ `whoami` == "root" ]; then
241             echo "Are you root? Use the Port Luke! :-)"
242         else
243             echo "You are not root, building simple package archive..."
244             pwd
245             $TAR czf ../../${TARGET_DIR}.tar.gz dist/**
246         fi
247         exit
248 fi
249
250 #############################
251 # Debian 32bit .deb
252 #############################
253
254 if [ "$BUILD_TARGET" = "debian_i386" ]; then
255     export CXX="g++ -m32"
256         gitClone https://github.com/GreatFruitOmsk/Power Power
257         gitClone ${CURA_ENGINE_REPO} CuraEngine
258     if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
259         $MAKE -C CuraEngine VERSION=${BUILD_VERSION}
260     if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
261         rm -rf scripts/linux/${BUILD_TARGET}/usr/share/cura
262         mkdir -p scripts/linux/${BUILD_TARGET}/usr/share/cura
263         cp -a Cura scripts/linux/${BUILD_TARGET}/usr/share/cura/
264         cp -a resources scripts/linux/${BUILD_TARGET}/usr/share/cura/
265         cp -a plugins scripts/linux/${BUILD_TARGET}/usr/share/cura/
266         cp -a CuraEngine/build/CuraEngine scripts/linux/${BUILD_TARGET}/usr/share/cura/
267         cp scripts/linux/cura.py scripts/linux/${BUILD_TARGET}/usr/share/cura/
268         cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
269         echo $BUILD_VERSION > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
270         cat scripts/linux/debian_control | sed "s/\[BUILD_VERSION\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/i386/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
271         sudo chown root:root scripts/linux/${BUILD_TARGET} -R
272         sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
273         sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
274         cd scripts/linux
275         dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_i386.deb
276         sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
277         exit
278 fi
279
280 #############################
281 # Debian 64bit .deb
282 #############################
283
284 if [ "$BUILD_TARGET" = "debian_amd64" ]; then
285     export CXX="g++ -m64"
286         gitClone https://github.com/GreatFruitOmsk/Power Power
287         gitClone ${CURA_ENGINE_REPO} CuraEngine
288     if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
289         $MAKE -C CuraEngine VERSION=${BUILD_VERSION}
290     if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
291         rm -rf scripts/linux/${BUILD_TARGET}/usr/share/cura
292         mkdir -p scripts/linux/${BUILD_TARGET}/usr/share/cura
293         cp -a Cura scripts/linux/${BUILD_TARGET}/usr/share/cura/
294         cp -a resources scripts/linux/${BUILD_TARGET}/usr/share/cura/
295         cp -a plugins scripts/linux/${BUILD_TARGET}/usr/share/cura/
296         cp -a CuraEngine/build/CuraEngine scripts/linux/${BUILD_TARGET}/usr/share/cura/
297         cp scripts/linux/cura.py scripts/linux/${BUILD_TARGET}/usr/share/cura/
298         cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
299         echo $BUILD_VERSION > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
300         cat scripts/linux/debian_control | sed "s/\[BUILD_VERSION\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/amd64/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
301         sudo chown root:root scripts/linux/${BUILD_TARGET} -R
302         sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
303         sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
304         cd scripts/linux
305         dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_amd64.deb
306         sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
307         exit
308 fi
309
310 #############################
311 # Debian armhf .deb
312 #############################
313
314 if [ "$BUILD_TARGET" = "debian_armhf" ]; then
315     export CXX="g++"
316         gitClone https://github.com/GreatFruitOmsk/Power Power
317         gitClone ${CURA_ENGINE_REPO} CuraEngine
318     if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
319         $MAKE -C CuraEngine VERSION=${BUILD_VERSION}
320     if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
321         rm -rf scripts/linux/${BUILD_TARGET}/usr/share/cura
322         mkdir -p scripts/linux/${BUILD_TARGET}/usr/share/cura
323         cp -a Cura scripts/linux/${BUILD_TARGET}/usr/share/cura/
324         cp -a resources scripts/linux/${BUILD_TARGET}/usr/share/cura/
325         cp -a plugins scripts/linux/${BUILD_TARGET}/usr/share/cura/
326         cp -a CuraEngine/build/CuraEngine scripts/linux/${BUILD_TARGET}/usr/share/cura/
327         cp scripts/linux/cura.py scripts/linux/${BUILD_TARGET}/usr/share/cura/
328         cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
329         echo $BUILD_VERSION > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
330         cat scripts/linux/debian_control | sed "s/\[BUILD_VERSION\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/armhf/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
331         sudo chown root:root scripts/linux/${BUILD_TARGET} -R
332         sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
333         sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
334         cd scripts/linux
335         dpkg-deb --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${BUILD_VERSION}-${BUILD_TARGET}.deb
336         sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
337         exit
338 fi
339
340 #############################
341 # Fedora Generic
342 #############################
343
344 function sanitiseVersion() {
345   local _version="$1"
346   echo "${_version//-/.}"
347 }
348
349 function fedoraCreateSRPM() {
350   local _curaName="$1"
351   local _version="$(sanitiseVersion "$2")"
352   local _srcSpecFile="$3"
353   local _srcSpecFileRelease="$4"
354   local _dstSrpmDir="$5"
355
356   local _dstTarSources="$HOME/rpmbuild/SOURCES/$_curaName-$_version.tar.gz"
357   local _dstSpec="$HOME/rpmbuild/SPECS/$_curaName-$_version.spec"
358
359   local _namePower="Power"
360   local _nameCuraEngine="CuraEngine"
361
362   gitClone "https://github.com/GreatFruitOmsk/Power" "$_namePower"
363   gitClone "$CURA_ENGINE_REPO" "$_nameCuraEngine"
364
365   cd "$_namePower"
366   local _gitPower="$(git rev-list -1 HEAD)"
367   cd -
368
369   cd "$_nameCuraEngine"
370   local _gitCuraEngine="$(git rev-list -1 HEAD)"
371   cd -
372
373   local _gitCura="$(git rev-list -1 HEAD)"
374
375   rpmdev-setuptree
376
377   rm -fv "$_dstTarSources"
378   tar \
379     --exclude-vcs \
380     --transform "s#^#$_curaName-$_version/#" \
381     -zcvf "$_dstTarSources" \
382       "$_nameCuraEngine" \
383       "$_namePower" \
384       Cura \
385       resources \
386       plugins \
387       scripts/linux/cura.py \
388       scripts/linux/fedora/usr
389
390   sed \
391     -e "s#__curaName__#$_curaName#" \
392     -e "s#__version__#$_version#" \
393     -e "s#__gitCura__#$_gitCura#" \
394     -e "s#__gitCuraEngine__#$_gitCuraEngine#" \
395     -e "s#__gitPower__#$_gitPower#" \
396     -e "s#__basedir__#scripts/linux/fedora#" \
397     "$_srcSpecFile" \
398     > "$_dstSpec"
399
400   rpmbuild -bs "$_dstSpec"
401
402   mkdir -pv "$_dstSrpmDir"
403   cp -v \
404     "$HOME/rpmbuild/SRPMS/$_curaName-$_version-$_srcSpecFileRelease.src.rpm" \
405     "$_dstSrpmDir"
406 }
407
408 function buildFedora() {
409   local _nameForRpm="Cura"
410   local _versionForRpm="$(sanitiseVersion "$BUILD_VERSION")"
411
412   #
413   # SRPM
414   #
415
416   local _srcSpecFile="scripts/linux/fedora/rpm.spec"
417   local _srcSpecFileRelease="$(rpmspec -P "$_srcSpecFile" | grep -E '^Release:'|awk '{print $NF}')"
418   local _dstSrpmDir="scripts/linux/fedora/SRPMS"
419
420   fedoraCreateSRPM \
421     "$_nameForRpm" \
422     "$_versionForRpm" \
423     "$_srcSpecFile" \
424     "$_srcSpecFileRelease" \
425     "$_dstSrpmDir"
426
427   #
428   # RPM
429   #
430
431   local _srpmFile="$_dstSrpmDir/$_nameForRpm-$_versionForRpm-$_srcSpecFileRelease.src.rpm"
432   local _dstRpmDir="scripts/linux/fedora/RPMS"
433
434   while [ $# -ne 0 ]; do
435     local _mockRelease="$(basename "${1%\.cfg}")"
436     local _mockReleaseArg=""
437     if [ -n "$_mockRelease" ]; then
438       _mockReleaseArg="-r $_mockRelease"
439     fi
440
441     mkdir -pv "$_dstRpmDir/$_mockRelease"
442     mock \
443       $_mockReleaseArg \
444       --resultdir="$_dstRpmDir/$_mockRelease" \
445       "$_srpmFile"
446
447     shift 1
448   done
449 }
450
451 #############################
452 # Fedora RPMs
453 #############################
454
455 if [ "$BUILD_TARGET" = "fedora" ]; then
456   shift 1 # skip "fedora" arg
457
458   if [ $# -eq 0 ]; then
459     "$0" "$BUILD_TARGET" ""
460   else
461     buildFedora "${@}"
462   fi
463
464   exit
465 fi
466
467 #############################
468 # Rest
469 #############################
470
471 #############################
472 # Download all needed files.
473 #############################
474
475 if [ $BUILD_TARGET = "win32" ]; then
476         #Get portable python for windows and extract it. (Linux and Mac need to install python themselfs)
477         downloadURL http://ftp.nluug.nl/languages/python/portablepython/v2.7/PortablePython_${WIN_PORTABLE_PY_VERSION}.exe
478         downloadURL http://sourceforge.net/projects/pyopengl/files/PyOpenGL/3.0.1/PyOpenGL-3.0.1.win32.exe
479         downloadURL http://videocapture.sourceforge.net/VideoCapture-0.9-5.zip
480         #downloadURL http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20120927-git-13f0cd6-win32-static.7z
481         downloadURL http://sourceforge.net/projects/comtypes/files/comtypes/0.6.2/comtypes-0.6.2.win32.exe
482         downloadURL http://www.uwe-sieber.de/files/ejectmedia.zip
483         #Get the power module for python
484         gitClone https://github.com/GreatFruitOmsk/Power Power
485     if [ $? != 0 ]; then echo "Failed to clone Power"; exit 1; fi
486         gitClone ${CURA_ENGINE_REPO} CuraEngine
487     if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
488 fi
489
490 #############################
491 # Build the packages
492 #############################
493 rm -rf ${TARGET_DIR}
494 mkdir -p ${TARGET_DIR}
495
496 rm -f log.txt
497 if [ $BUILD_TARGET = "win32" ]; then
498         if [ -z `which i686-w64-mingw32-g++` ]; then
499                 CXX=g++
500         else
501                 CXX=i686-w64-mingw32-g++
502         fi
503         
504         #For windows extract portable python to include it.
505         extract PortablePython_${WIN_PORTABLE_PY_VERSION}.exe App
506         extract PyOpenGL-3.0.1.win32.exe PURELIB
507         extract VideoCapture-0.9-5.zip VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd
508         #extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe
509         #extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/licenses
510         extract comtypes-0.6.2.win32.exe
511         extract ejectmedia.zip Win32
512
513         mkdir -p ${TARGET_DIR}/python
514         mkdir -p ${TARGET_DIR}/Cura/
515         mv App/Lib/site-packages/ PURELIB/
516         mv App/* ${TARGET_DIR}/python
517         mkdir -p ${TARGET_DIR}/python/Lib/site-packages/
518         mv PURELIB/site-packages/setuptools* PURELIB/site-packages/site.py PURELIB/site-packages/easy_install.py ${TARGET_DIR}/python/Lib/site-packages/
519         mv PURELIB/site-packages/numpy* ${TARGET_DIR}/python/Lib/site-packages/
520         mv PURELIB/site-packages/serial* ${TARGET_DIR}/python/Lib/site-packages/
521         mv PURELIB/site-packages/pyserial* ${TARGET_DIR}/python/Lib/site-packages/
522         mv PURELIB/site-packages/wx* ${TARGET_DIR}/python/Lib/site-packages/
523         mv PURELIB/OpenGL ${TARGET_DIR}/python/Lib
524         mv PURELIB/comtypes ${TARGET_DIR}/python/Lib
525         mv Power/power ${TARGET_DIR}/python/Lib
526         mv VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd ${TARGET_DIR}/python/DLLs
527         #mv ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe ${TARGET_DIR}/Cura/
528         #mv ffmpeg-20120927-git-13f0cd6-win32-static/licenses ${TARGET_DIR}/Cura/ffmpeg-licenses/
529         mv Win32/EjectMedia.exe ${TARGET_DIR}/Cura/
530         cp -a scripts/win32/nsisPlugins/libgcc_s_dw2-1.dll ${TARGET_DIR}
531         cp -a scripts/win32/nsisPlugins/libstdc++-6.dll ${TARGET_DIR}
532         
533         rm -rf Power/
534         rm -rf App
535         rm -rf PURELIB
536         rm -rf VideoCapture-0.9-5
537         #rm -rf ffmpeg-20120927-git-13f0cd6-win32-static
538
539         #Clean up portable python a bit, to keep the package size down.
540         rm -rf ${TARGET_DIR}/python/PyScripter.*
541         rm -rf ${TARGET_DIR}/python/Doc
542         rm -rf ${TARGET_DIR}/python/locale
543         rm -rf ${TARGET_DIR}/python/tcl
544         rm -rf ${TARGET_DIR}/python/Lib/test
545         rm -rf ${TARGET_DIR}/python/Lib/distutils
546         rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-3.0-msw/wx/tools
547         rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-3.0-msw/wx/locale
548         #Remove the gle files because they require MSVCR71.dll, which is not included. We also don't need gle, so it's safe to remove it.
549         rm -rf ${TARGET_DIR}/python/Lib/OpenGL/DLLS/gle*
550
551         # New in 2.7.6.1
552         rm -rf ${TARGET_DIR}/python/PyCharm/
553         rm -rf ${TARGET_DIR}/python/share/
554         rm -rf ${TARGET_DIR}/python/qt.conf
555
556         #Build the C++ engine
557         $MAKE -C CuraEngine VERSION=${BUILD_VERSION} OS=Windows_NT CXX=${CXX}
558     if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
559 fi
560
561 #add Cura
562 mkdir -p ${TARGET_DIR}/Cura ${TARGET_DIR}/resources ${TARGET_DIR}/plugins
563 cp -a Cura/* ${TARGET_DIR}/Cura
564 cp -a resources/* ${TARGET_DIR}/resources
565 cp -a plugins/* ${TARGET_DIR}/plugins
566 #Add cura version file
567 echo $BUILD_VERSION > ${TARGET_DIR}/Cura/version
568
569 #add script files
570 if [ $BUILD_TARGET = "win32" ]; then
571     cp -a scripts/win32/cura.bat $TARGET_DIR/
572     cp CuraEngine/build/CuraEngine.exe $TARGET_DIR
573     #cp /usr/lib/gcc/i686-w64-mingw32/4.8/libgcc_s_sjlj-1.dll $TARGET_DIR
574     #cp /usr/i686-w64-mingw32/lib/libwinpthread-1.dll $TARGET_DIR
575     #cp /usr/lib/gcc/i686-w64-mingw32/4.8/libstdc++-6.dll $TARGET_DIR
576 fi
577
578 #package the result
579 if (( ${ARCHIVE_FOR_DISTRIBUTION} )); then
580         if [ $BUILD_TARGET = "win32" ]; then
581                 #rm ${TARGET_DIR}.zip
582                 #cd ${TARGET_DIR}
583                 #7z a ../${TARGET_DIR}.zip *
584                 #cd ..
585
586                 if [ ! -z `which wine` ]; then
587                         #if we have wine, try to run our nsis script.
588                         rm -rf scripts/win32/dist
589                         ln -sf `pwd`/${TARGET_DIR} scripts/win32/dist
590                         wine ~/.wine/drive_c/Program\ Files\ \(x86\)/NSIS/makensis.exe /DVERSION=${BUILD_VERSION} scripts/win32/installer.nsi
591                         if [ $? != 0 ]; then echo "Failed to package NSIS installer"; exit 1; fi
592                         mv scripts/win32/Cura_${FULL_VERSION}.exe ./
593                 fi
594                 if [ -f '/c/Program Files (x86)/NSIS/makensis.exe' ]; then
595                         rm -rf scripts/win32/dist
596                         mv "`pwd`/${TARGET_DIR}" scripts/win32/dist
597                         '/c/Program Files (x86)/NSIS/makensis.exe' -DVERSION=${BUILD_VERSION} 'scripts/win32/installer.nsi' >> log.txt
598                         if [ $? != 0 ]; then echo "Failed to package NSIS installer"; exit 1; fi
599                         mv scripts/win32/Cura_${BUILD_VERSION}.exe ./
600                 fi
601         else
602                 echo "Archiving to ${TARGET_DIR}.tar.gz"
603                 $TAR cfp - ${TARGET_DIR} | gzip --best -c > ${TARGET_DIR}.tar.gz
604         fi
605 else
606         echo "Installed into ${TARGET_DIR}"
607 fi