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.
9 #############################
11 #############################
13 ##Select the build target
14 BUILD_TARGET=${1:-none}
17 #BUILD_TARGET=debian_i386
18 #BUILD_TARGET=debian_amd64
19 #BUILD_TARGET=debian_armhf
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
26 export BUILD_NAME=15.02.1
27 TARGET_DIR=Cura-${BUILD_NAME}-${BUILD_TARGET}
33 GIT_HASH=$(git rev-parse --short=4 HEAD)
35 export FULL_VERSION=${BUILD_NAME}-${REVISION}-${GIT_HASH}
37 ##Which versions of external programs to use
38 WIN_PORTABLE_PY_VERSION=2.7.2.1
40 ##Which CuraEngine to use
41 if [ -z ${CURA_ENGINE_REPO:-} ] ; then
42 CURA_ENGINE_REPO="git@github.com:alephobjects/CuraEngine.git"
45 #############################
47 #############################
50 if [ -z "`which $1`" ]; then
51 echo "The $1 command must be somewhere in your \$PATH."
52 echo "Fix your \$PATH or install $2"
59 filename=`basename "$1"`
60 echo "Checking for $filename"
61 if [ ! -f "$filename" ]; then
65 echo "Failed to download $1"
74 echo "7z x -y $*" >> log.txt
77 echo "Failed to extract $*"
84 echo "Cloning $1 into $2"
96 #############################
98 #############################
99 if [ "$BUILD_TARGET" = "none" ]; then
100 echo "You need to specify a build target with:"
102 echo "$0 debian_i386"
103 echo "$0 debian_amd64"
104 echo "$0 debian_armhf"
107 echo "$0 fedora # current system"
108 echo "$0 fedora \"mock_config_file\" ... # different system(s)"
112 if [ -z `which make` ]; then
118 # Change working directory to the directory the script is in
119 # http://stackoverflow.com/a/246128
120 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
123 checkTool git "git: http://git-scm.com/"
124 checkTool curl "curl: http://curl.haxx.se/"
125 if [ $BUILD_TARGET = "win32" ]; then
126 checkTool avr-gcc "avr-gcc: http://winavr.sourceforge.net/ "
127 #Check if we have 7zip, needed to extract and packup a bunch of packages for windows.
128 checkTool 7z "7zip: http://www.7-zip.org/"
129 checkTool $MAKE "mingw: http://www.mingw.org/"
131 #For building under MacOS we need gnutar instead of tar
132 if [ -z `which gnutar` ]; then
138 #############################
139 # Build the required firmwares
140 #############################
142 if [ -d "C:/arduino-1.0.3" ]; then
143 ARDUINO_PATH=C:/arduino-1.0.3
145 elif [ -d "/Applications/Arduino.app/Contents/Resources/Java" ]; then
146 ARDUINO_PATH=/Applications/Arduino.app/Contents/Resources/Java
149 ARDUINO_PATH=/usr/share/arduino
153 if [ ! -d "$ARDUINO_PATH" ]; then
154 echo "Arduino path '$ARDUINO_PATH' doesn't exist"
159 #Build the Ultimaker Original firmwares.
160 gitClone https://github.com/Ultimaker/Marlin.git _UltimakerMarlin
161 cd _UltimakerMarlin/Marlin
162 git checkout Marlin_v1
164 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_250000 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"250000_single\"' BAUDRATE=250000 TEMP_SENSOR_1=0 EXTRUDERS=1"
165 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_115200 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"115200_single\"' BAUDRATE=115200 TEMP_SENSOR_1=0 EXTRUDERS=1"
166 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_Dual_250000 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"250000_dual\"' BAUDRATE=250000 TEMP_SENSOR_1=-1 EXTRUDERS=2"
167 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_Dual_115200 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"115200_dual\"' BAUDRATE=115200 TEMP_SENSOR_1=-1 EXTRUDERS=2"
168 git checkout Marlin_UM_HeatedBedUpgrade
170 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_HBK_250000 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"250000_single_HB\"' BAUDRATE=250000 TEMP_SENSOR_1=0 EXTRUDERS=1"
171 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_HBK_115200 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"115200_single_HB\"' BAUDRATE=115200 TEMP_SENSOR_1=0 EXTRUDERS=1"
172 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_HBK_Dual_250000 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"250000_dual_HB\"' BAUDRATE=250000 TEMP_SENSOR_1=-1 EXTRUDERS=2"
173 $MAKE -j 3 HARDWARE_MOTHERBOARD=7 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_HBK_Dual_115200 DEFINES="'VERSION_BASE=\"Ultimaker:_${BUILD_NAME}\"' 'VERSION_PROFILE=\"115200_dual_HB\"' BAUDRATE=115200 TEMP_SENSOR_1=-1 EXTRUDERS=2"
174 git checkout Marlin_UM_Original_Plus
176 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_Plus_250000 DEFINES="'VERSION_BASE=\"Ultimaker+:${BUILD_NAME}\"' 'VERSION_PROFILE=\"250000_single\"' BAUDRATE=250000 TEMP_SENSOR_1=0 EXTRUDERS=1"
177 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_Plus_115200 DEFINES="'VERSION_BASE=\"Ultimaker+:${BUILD_NAME}\"' 'VERSION_PROFILE=\"115200_single\"' BAUDRATE=115200 TEMP_SENSOR_1=0 EXTRUDERS=1"
178 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_Plus_Dual_250000 DEFINES="'VERSION_BASE=\"Ultimaker+:${BUILD_NAME}\"' 'VERSION_PROFILE=\"250000_dual\"' BAUDRATE=250000 TEMP_SENSOR_1=20 EXTRUDERS=2"
179 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_UltimakerMarlin_Plus_Dual_115200 DEFINES="'VERSION_BASE=\"Ultimaker+:${BUILD_NAME}\"' 'VERSION_PROFILE=\"115200_dual\"' BAUDRATE=115200 TEMP_SENSOR_1=20 EXTRUDERS=2"
182 gitClone https://github.com/Ultimaker/Ultimaker2Marlin.git _Ultimaker2Marlin
183 cd _Ultimaker2Marlin/Marlin
186 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2 DEFINES="'STRING_CONFIG_H_AUTHOR=\"Version:_${BUILD_NAME}\"' TEMP_SENSOR_1=0 EXTRUDERS=1"
187 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2Dual DEFINES="'STRING_CONFIG_H_AUTHOR=\"Version:_${BUILD_NAME}\"' TEMP_SENSOR_1=20 EXTRUDERS=2"
190 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2go DEFINES="'STRING_CONFIG_H_AUTHOR=\"Version:_${BUILD_NAME}go\"' TEMP_SENSOR_1=0 EXTRUDERS=1"
191 git checkout UM2extended
193 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2extended DEFINES="'STRING_CONFIG_H_AUTHOR=\"Version:_${BUILD_NAME}ex\"' TEMP_SENSOR_1=0 EXTRUDERS=1"
194 $MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2extendedDual DEFINES="'STRING_CONFIG_H_AUTHOR=\"Version:_${BUILD_NAME}ex\"' TEMP_SENSOR_1=20 EXTRUDERS=2"
197 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_250000/Marlin.hex resources/firmware/MarlinUltimaker-250000.hex
198 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_115200/Marlin.hex resources/firmware/MarlinUltimaker-115200.hex
199 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_Dual_250000/Marlin.hex resources/firmware/MarlinUltimaker-250000-dual.hex
200 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_Dual_115200/Marlin.hex resources/firmware/MarlinUltimaker-115200-dual.hex
201 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_HBK_250000/Marlin.hex resources/firmware/MarlinUltimaker-HBK-250000.hex
202 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_HBK_115200/Marlin.hex resources/firmware/MarlinUltimaker-HBK-115200.hex
203 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_HBK_Dual_250000/Marlin.hex resources/firmware/MarlinUltimaker-HBK-250000-dual.hex
204 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_HBK_Dual_115200/Marlin.hex resources/firmware/MarlinUltimaker-HBK-115200-dual.hex
205 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_Plus_250000/Marlin.hex resources/firmware/MarlinUltimaker-UMOP-250000.hex
206 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_Plus_115200/Marlin.hex resources/firmware/MarlinUltimaker-UMOP-115200.hex
207 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_Plus_Dual_250000/Marlin.hex resources/firmware/MarlinUltimaker-UMOP-250000-dual.hex
208 cp _UltimakerMarlin/Marlin/_UltimakerMarlin_Plus_Dual_115200/Marlin.hex resources/firmware/MarlinUltimaker-UMOP-115200-dual.hex
209 cp _Ultimaker2Marlin/Marlin/_Ultimaker2/Marlin.hex resources/firmware/MarlinUltimaker2.hex
210 cp _Ultimaker2Marlin/Marlin/_Ultimaker2Dual/Marlin.hex resources/firmware/MarlinUltimaker2-dual.hex
211 cp _Ultimaker2Marlin/Marlin/_Ultimaker2go/Marlin.hex resources/firmware/MarlinUltimaker2go.hex
212 cp _Ultimaker2Marlin/Marlin/_Ultimaker2extended/Marlin.hex resources/firmware/MarlinUltimaker2extended.hex
213 cp _Ultimaker2Marlin/Marlin/_Ultimaker2extendedDual/Marlin.hex resources/firmware/MarlinUltimaker2extended-dual.hex
215 #############################
217 #############################
219 if [ "$BUILD_TARGET" = "darwin" ]; then
220 TARGET_DIR=Cura-${BUILD_NAME}-MacOS
222 rm -rf scripts/darwin/build
223 rm -rf scripts/darwin/dist
225 python build_app.py py2app
227 if [[ $rc != 0 ]]; then
228 echo "Cannot build app."
232 #Add cura version file (should read the version from the bundle with pyobjc, but will figure that out later)
233 echo $BUILD_NAME > scripts/darwin/dist/Cura.app/Contents/Resources/version
235 gitClone ${CURA_ENGINE_REPO} CuraEngine
236 if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
237 $MAKE -C CuraEngine VERSION=${BUILD_NAME}
238 if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
239 cp CuraEngine/build/CuraEngine scripts/darwin/dist/Cura.app/Contents/Resources/CuraEngine
243 # Install QuickLook plugin
244 mkdir -p dist/Cura.app/Contents/Library/QuickLook
245 cp -a STLQuickLook.qlgenerator dist/Cura.app/Contents/Library/QuickLook/
249 $TAR cfp - Cura.app | gzip --best -c > ../../../${TARGET_DIR}.tar.gz
252 # Create sparse image for distribution
253 hdiutil detach /Volumes/Cura\ -\ Lulzbot/ || true
254 rm -rf Cura.dmg.sparseimage
255 hdiutil convert DmgTemplateCompressed.dmg -format UDSP -o Cura.dmg
256 hdiutil resize -size 500m Cura.dmg.sparseimage
257 hdiutil attach Cura.dmg.sparseimage
258 cp -a dist/Cura.app /Volumes/Cura\ -\ Lulzbot/Cura/
259 hdiutil detach /Volumes/Cura\ -\ Lulzbot
260 hdiutil convert Cura.dmg.sparseimage -format UDZO -imagekey zlib-level=9 -ov -o ../../${TARGET_DIR}.dmg
264 #############################
265 # FreeBSD part by CeDeROM
266 #############################
268 if [ "$BUILD_TARGET" = "freebsd" ]; then
270 gitClone https://github.com/GreatFruitOmsk/Power Power
271 gitClone ${CURA_ENGINE_REPO} CuraEngine
272 if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
273 gmake -j4 -C CuraEngine VERSION=${BUILD_NAME}
274 if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
275 rm -rf scripts/freebsd/dist
276 mkdir -p scripts/freebsd/dist/share/cura
277 mkdir -p scripts/freebsd/dist/share/applications
278 mkdir -p scripts/freebsd/dist/bin
279 cp -a Cura scripts/freebsd/dist/share/cura/
280 cp -a resources scripts/freebsd/dist/share/cura/
281 cp -a plugins scripts/freebsd/dist/share/cura/
282 cp -a CuraEngine/build/CuraEngine scripts/freebsd/dist/share/cura/
283 cp scripts/freebsd/cura.py scripts/freebsd/dist/share/cura/
284 cp scripts/freebsd/cura.desktop scripts/freebsd/dist/share/applications/
285 cp scripts/freebsd/cura scripts/freebsd/dist/bin/
286 cp -a Power/power scripts/freebsd/dist/share/cura/
287 echo $BUILD_NAME > scripts/freebsd/dist/share/cura/Cura/version
288 #Create file list (pkg-plist)
289 cd scripts/freebsd/dist
290 find * -type f > ../pkg-plist
291 DIRLVL=20; while [ $DIRLVL -ge 0 ]; do
292 DIRS=`find share/cura -type d -depth $DIRLVL`
294 echo "@dirrm $DIR" >> ../pkg-plist
296 DIRLVL=`expr $DIRLVL - 1`
299 # Create archive or package if root
300 if [ `whoami` == "root" ]; then
301 echo "Are you root? Use the Port Luke! :-)"
303 echo "You are not root, building simple package archive..."
305 $TAR czf ../../${TARGET_DIR}.tar.gz dist/**
310 #############################
312 #############################
314 if [ "$BUILD_TARGET" = "debian_i386" ]; then
315 export CXX="g++ -m32"
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_NAME}
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_NAME > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
330 cat scripts/linux/debian_control | sed "s/\[BUILD_NAME\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/i386/' > 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
335 dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_i386.deb
336 sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
340 #############################
342 #############################
344 if [ "$BUILD_TARGET" = "debian_amd64" ]; then
345 export CXX="g++ -m64"
346 gitClone https://github.com/GreatFruitOmsk/Power Power
347 gitClone ${CURA_ENGINE_REPO} CuraEngine
348 if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
349 $MAKE -C CuraEngine VERSION=${BUILD_NAME}
350 if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
351 rm -rf scripts/linux/${BUILD_TARGET}/usr/share/cura
352 mkdir -p scripts/linux/${BUILD_TARGET}/usr/share/cura
353 cp -a Cura scripts/linux/${BUILD_TARGET}/usr/share/cura/
354 cp -a resources scripts/linux/${BUILD_TARGET}/usr/share/cura/
355 cp -a plugins scripts/linux/${BUILD_TARGET}/usr/share/cura/
356 cp -a CuraEngine/build/CuraEngine scripts/linux/${BUILD_TARGET}/usr/share/cura/
357 cp scripts/linux/cura.py scripts/linux/${BUILD_TARGET}/usr/share/cura/
358 cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
359 echo $BUILD_NAME > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
360 cat scripts/linux/debian_control | sed "s/\[BUILD_NAME\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/amd64/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
361 sudo chown root:root scripts/linux/${BUILD_TARGET} -R
362 sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
363 sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
365 dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_amd64.deb
366 sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
370 #############################
372 #############################
374 if [ "$BUILD_TARGET" = "debian_armhf" ]; then
376 gitClone https://github.com/GreatFruitOmsk/Power Power
377 gitClone ${CURA_ENGINE_REPO} CuraEngine
378 if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
379 $MAKE -C CuraEngine VERSION=${BUILD_NAME}
380 if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
381 rm -rf scripts/linux/${BUILD_TARGET}/usr/share/cura
382 mkdir -p scripts/linux/${BUILD_TARGET}/usr/share/cura
383 cp -a Cura scripts/linux/${BUILD_TARGET}/usr/share/cura/
384 cp -a resources scripts/linux/${BUILD_TARGET}/usr/share/cura/
385 cp -a plugins scripts/linux/${BUILD_TARGET}/usr/share/cura/
386 cp -a CuraEngine/build/CuraEngine scripts/linux/${BUILD_TARGET}/usr/share/cura/
387 cp scripts/linux/cura.py scripts/linux/${BUILD_TARGET}/usr/share/cura/
388 cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
389 echo $BUILD_NAME > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
390 cat scripts/linux/debian_control | sed "s/\[BUILD_NAME\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/armhf/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
391 sudo chown root:root scripts/linux/${BUILD_TARGET} -R
392 sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
393 sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
395 dpkg-deb --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${BUILD_NAME}-${BUILD_TARGET}.deb
396 sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
400 #############################
402 #############################
404 function sanitiseVersion() {
406 echo "${_version//-/.}"
409 function fedoraCreateSRPM() {
411 local _version="$(sanitiseVersion "$2")"
412 local _srcSpecFile="$3"
413 local _srcSpecFileRelease="$4"
414 local _dstSrpmDir="$5"
416 local _dstTarSources="$HOME/rpmbuild/SOURCES/$_curaName-$_version.tar.gz"
417 local _dstSpec="$HOME/rpmbuild/SPECS/$_curaName-$_version.spec"
419 local _namePower="Power"
420 local _nameCuraEngine="CuraEngine"
422 gitClone "https://github.com/GreatFruitOmsk/Power" "$_namePower"
423 gitClone "$CURA_ENGINE_REPO" "$_nameCuraEngine"
426 local _gitPower="$(git rev-list -1 HEAD)"
429 cd "$_nameCuraEngine"
430 local _gitCuraEngine="$(git rev-list -1 HEAD)"
433 local _gitCura="$(git rev-list -1 HEAD)"
437 rm -fv "$_dstTarSources"
440 --transform "s#^#$_curaName-$_version/#" \
441 -zcvf "$_dstTarSources" \
447 scripts/linux/cura.py \
448 scripts/linux/fedora/usr
451 -e "s#__curaName__#$_curaName#" \
452 -e "s#__version__#$_version#" \
453 -e "s#__gitCura__#$_gitCura#" \
454 -e "s#__gitCuraEngine__#$_gitCuraEngine#" \
455 -e "s#__gitPower__#$_gitPower#" \
456 -e "s#__basedir__#scripts/linux/fedora#" \
460 rpmbuild -bs "$_dstSpec"
462 mkdir -pv "$_dstSrpmDir"
464 "$HOME/rpmbuild/SRPMS/$_curaName-$_version-$_srcSpecFileRelease.src.rpm" \
468 function buildFedora() {
469 local _nameForRpm="Cura"
470 local _versionForRpm="$(sanitiseVersion "$BUILD_NAME")"
476 local _srcSpecFile="scripts/linux/fedora/rpm.spec"
477 local _srcSpecFileRelease="$(rpmspec -P "$_srcSpecFile" | grep -E '^Release:'|awk '{print $NF}')"
478 local _dstSrpmDir="scripts/linux/fedora/SRPMS"
484 "$_srcSpecFileRelease" \
491 local _srpmFile="$_dstSrpmDir/$_nameForRpm-$_versionForRpm-$_srcSpecFileRelease.src.rpm"
492 local _dstRpmDir="scripts/linux/fedora/RPMS"
494 while [ $# -ne 0 ]; do
495 local _mockRelease="$(basename "${1%\.cfg}")"
496 local _mockReleaseArg=""
497 if [ -n "$_mockRelease" ]; then
498 _mockReleaseArg="-r $_mockRelease"
501 mkdir -pv "$_dstRpmDir/$_mockRelease"
504 --resultdir="$_dstRpmDir/$_mockRelease" \
511 #############################
513 #############################
515 if [ "$BUILD_TARGET" = "fedora" ]; then
516 shift 1 # skip "fedora" arg
518 if [ $# -eq 0 ]; then
519 "$0" "$BUILD_TARGET" ""
527 #############################
529 #############################
531 #############################
532 # Download all needed files.
533 #############################
535 if [ $BUILD_TARGET = "win32" ]; then
536 #Get portable python for windows and extract it. (Linux and Mac need to install python themselfs)
537 downloadURL http://ftp.nluug.nl/languages/python/portablepython/v2.7/PortablePython_${WIN_PORTABLE_PY_VERSION}.exe
538 downloadURL http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.win32.exe
539 downloadURL http://sourceforge.net/projects/pyopengl/files/PyOpenGL/3.0.1/PyOpenGL-3.0.1.win32.exe
540 downloadURL http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2-win32-superpack-python2.7.exe
541 downloadURL http://videocapture.sourceforge.net/VideoCapture-0.9-5.zip
542 #downloadURL http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20120927-git-13f0cd6-win32-static.7z
543 downloadURL http://sourceforge.net/projects/comtypes/files/comtypes/0.6.2/comtypes-0.6.2.win32.exe
544 downloadURL http://www.uwe-sieber.de/files/ejectmedia.zip
545 #Get the power module for python
546 gitClone https://github.com/GreatFruitOmsk/Power Power
547 if [ $? != 0 ]; then echo "Failed to clone Power"; exit 1; fi
548 gitClone ${CURA_ENGINE_REPO} CuraEngine
549 if [ $? != 0 ]; then echo "Failed to clone CuraEngine"; exit 1; fi
552 #############################
554 #############################
556 mkdir -p ${TARGET_DIR}
559 if [ $BUILD_TARGET = "win32" ]; then
560 if [ -z `which i686-w64-mingw32-g++` ]; then
563 CXX=i686-w64-mingw32-g++
566 #For windows extract portable python to include it.
567 extract PortablePython_${WIN_PORTABLE_PY_VERSION}.exe \$_OUTDIR/App
568 extract PortablePython_${WIN_PORTABLE_PY_VERSION}.exe \$_OUTDIR/Lib/site-packages
569 extract pyserial-2.5.win32.exe PURELIB
570 extract PyOpenGL-3.0.1.win32.exe PURELIB
571 extract numpy-1.6.2-win32-superpack-python2.7.exe numpy-1.6.2-sse2.exe
572 extract numpy-1.6.2-sse2.exe PLATLIB
573 extract VideoCapture-0.9-5.zip VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd
574 #extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe
575 #extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/licenses
576 extract comtypes-0.6.2.win32.exe
577 extract ejectmedia.zip Win32
579 mkdir -p ${TARGET_DIR}/python
580 mkdir -p ${TARGET_DIR}/Cura/
581 mv \$_OUTDIR/App/* ${TARGET_DIR}/python
582 mv \$_OUTDIR/Lib/site-packages/wx* ${TARGET_DIR}/python/Lib/site-packages/
583 mv PURELIB/serial ${TARGET_DIR}/python/Lib
584 mv PURELIB/OpenGL ${TARGET_DIR}/python/Lib
585 mv PURELIB/comtypes ${TARGET_DIR}/python/Lib
586 mv PLATLIB/numpy ${TARGET_DIR}/python/Lib
587 mv Power/power ${TARGET_DIR}/python/Lib
588 mv VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd ${TARGET_DIR}/python/DLLs
589 #mv ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe ${TARGET_DIR}/Cura/
590 #mv ffmpeg-20120927-git-13f0cd6-win32-static/licenses ${TARGET_DIR}/Cura/ffmpeg-licenses/
591 mv Win32/EjectMedia.exe ${TARGET_DIR}/Cura/
592 cp -a scripts/win32/nsisPlugins/libgcc_s_dw2-1.dll ${TARGET_DIR}
593 cp -a scripts/win32/nsisPlugins/libstdc++-6.dll ${TARGET_DIR}
599 rm -rf VideoCapture-0.9-5
600 rm -rf numpy-1.6.2-sse2.exe
601 #rm -rf ffmpeg-20120927-git-13f0cd6-win32-static
603 #Clean up portable python a bit, to keep the package size down.
604 rm -rf ${TARGET_DIR}/python/PyScripter.*
605 rm -rf ${TARGET_DIR}/python/Doc
606 rm -rf ${TARGET_DIR}/python/locale
607 rm -rf ${TARGET_DIR}/python/tcl
608 rm -rf ${TARGET_DIR}/python/Lib/test
609 rm -rf ${TARGET_DIR}/python/Lib/distutils
610 rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-2.8-msw-unicode/wx/tools
611 rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-2.8-msw-unicode/wx/locale
612 #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.
613 rm -rf ${TARGET_DIR}/python/Lib/OpenGL/DLLS/gle*
615 #Build the C++ engine
616 $MAKE -C CuraEngine VERSION=${BUILD_NAME} OS=Windows_NT CXX=${CXX}
617 if [ $? != 0 ]; then echo "Failed to build CuraEngine"; exit 1; fi
621 mkdir -p ${TARGET_DIR}/Cura ${TARGET_DIR}/resources ${TARGET_DIR}/plugins
622 cp -a Cura/* ${TARGET_DIR}/Cura
623 cp -a resources/* ${TARGET_DIR}/resources
624 cp -a plugins/* ${TARGET_DIR}/plugins
625 #Add cura version file
626 echo $BUILD_NAME > ${TARGET_DIR}/Cura/version
629 if [ $BUILD_TARGET = "win32" ]; then
630 cp -a scripts/${BUILD_TARGET}/*.bat $TARGET_DIR/
631 cp CuraEngine/build/CuraEngine.exe $TARGET_DIR
632 cp /usr/lib/gcc/i686-w64-mingw32/4.8/libgcc_s_sjlj-1.dll $TARGET_DIR
633 cp /usr/i686-w64-mingw32/lib/libwinpthread-1.dll $TARGET_DIR
634 cp /usr/lib/gcc/i686-w64-mingw32/4.8/libstdc++-6.dll $TARGET_DIR
638 if (( ${ARCHIVE_FOR_DISTRIBUTION} )); then
639 if [ $BUILD_TARGET = "win32" ]; then
640 #rm ${TARGET_DIR}.zip
642 #7z a ../${TARGET_DIR}.zip *
645 if [ ! -z `which wine` ]; then
646 #if we have wine, try to run our nsis script.
647 rm -rf scripts/win32/dist
648 ln -sf `pwd`/${TARGET_DIR} scripts/win32/dist
649 wine ~/.wine/drive_c/Program\ Files\ \(x86\)/NSIS/makensis.exe /DVERSION=${BUILD_NAME} scripts/win32/installer.nsi
650 if [ $? != 0 ]; then echo "Failed to package NSIS installer"; exit 1; fi
651 mv scripts/win32/Cura_${FULL_VERSION}.exe ./
653 if [ -f '/c/Program Files (x86)/NSIS/makensis.exe' ]; then
654 rm -rf scripts/win32/dist
655 mv "`pwd`/${TARGET_DIR}" scripts/win32/dist
656 '/c/Program Files (x86)/NSIS/makensis.exe' -DVERSION=${BUILD_NAME} 'scripts/win32/installer.nsi' >> log.txt
657 if [ $? != 0 ]; then echo "Failed to package NSIS installer"; exit 1; fi
658 mv scripts/win32/Cura_${BUILD_NAME}.exe ./
661 echo "Archiving to ${TARGET_DIR}.tar.gz"
662 $TAR cfp - ${TARGET_DIR} | gzip --best -c > ${TARGET_DIR}.tar.gz
665 echo "Installed into ${TARGET_DIR}"