Arduino.SlackBuild 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #!/bin/bash
  2. # Slackware build script for Arduino
  3. # Copyright 2015, 2022 Mario Preksavec, Zagreb, Croatia
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=Arduino
  24. VERSION=${VERSION:-1.8.19}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. # Examples
  29. EXAMPLES=${EXAMPLES:-1.9.1}
  30. # Libraries
  31. ETHERNET=${ETHERNET:-2.0.0}
  32. GSM=${GSM:-1.0.6}
  33. STEPPER=${STEPPER:-1.1.3}
  34. TFT=${TFT:-1.0.6}
  35. WIFI=${WIFI:-1.2.7}
  36. FIRMATA=${FIRMATA:-2.5.8}
  37. BRIDGE=${BRIDGE:-1.7.0}
  38. ROBOT_CONTROL=${ROBOT_CONTROL:-1.0.4}
  39. ROBOT_MOTOR=${ROBOT_MOTOR:-1.0.3}
  40. ROBOTIRREMOTE=${ROBOTIRREMOTE:-2.0.0}
  41. SPACEBREWYUN=${SPACEBREWYUN:-1.0.2}
  42. TEMBOO=${TEMBOO:-1.2.1}
  43. ESPLORA=${ESPLORA:-1.0.4}
  44. MOUSE=${MOUSE:-1.0.1}
  45. KEYBOARD=${KEYBOARD:-1.0.2}
  46. SD=${SD:-1.2.4}
  47. SERVO=${SERVO:-1.1.8}
  48. LIQUIDCRYSTAL=${LIQUIDCRYSTAL:-1.0.7}
  49. ADAFRUIT=${ADAFRUIT:-1.11.3}
  50. WIFI101UPDATER=${WIFI101UPDATER:-0.12.0}
  51. LIBASTYLEJ=${LIBASTYLEJ:-2.05.1-5}
  52. LIBLISTSERIALS=${LIBLISTSERIALS:-1.4.2-2}
  53. ARDUINOBUILDER=${ARDUINOBUILDER:-1.6.1}
  54. AVRDUDE=${AVRDUDE:-6.3.0-arduino17}
  55. AVRCORE=${AVRCORE:-1.8.3}
  56. ARDUINOOTA=${ARDUINOOTA:-1.3.0}
  57. # Toolchain
  58. GCC=${GCC:-7.3.0}
  59. AVR=${AVR:-3.6.1}
  60. AVR_BUILD=${AVR_BUILD:-arduino7}
  61. AUTOCONF=${AUTOCONF:-2.64}
  62. AUTOMAKE=${AUTOMAKE:-1.11.1}
  63. GMP=${GMP:-5.0.2}
  64. MPFR=${MPFR:-3.1.0}
  65. MPC=${MPC:-0.9}
  66. ATMEL_ATMEGA_PACK=${ATMEL_ATMEGA_PACK:-1.4.351}
  67. ATMEL_ATTINY_PACK=${ATMEL_ATTINY_PACK:-1.4.310}
  68. ATMEL_DX_PACK=${ATMEL_DX_PACK:-1.0.27}
  69. if [ -z "$ARCH" ]; then
  70. case "$( uname -m )" in
  71. i?86) ARCH=i586 ;;
  72. arm*) ARCH=arm ;;
  73. *) ARCH=$( uname -m ) ;;
  74. esac
  75. fi
  76. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  77. # the name of the created package would be, and then exit. This information
  78. # could be useful to other scripts.
  79. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  80. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  81. exit 0
  82. fi
  83. TMP=${TMP:-/tmp/SBo}
  84. PKG=$TMP/package-$PRGNAM
  85. OUTPUT=${OUTPUT:-/tmp}
  86. if [ "$ARCH" = "i586" ]; then
  87. LIB="32"
  88. AVRDUDEARCH="i686"
  89. ARDUINOOTAARCH="386"
  90. elif [ "$ARCH" = "x86_64" ]; then
  91. LIB="64"
  92. AVRDUDEARCH="$ARCH"
  93. ARDUINOOTAARCH="amd64"
  94. else
  95. echo "$ARCH is not supported."
  96. exit 1
  97. fi
  98. set -e
  99. rm -rf $PKG
  100. mkdir -p $TMP $PKG $OUTPUT
  101. cd $TMP
  102. rm -rf $PRGNAM-$VERSION
  103. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  104. cd $PRGNAM-$VERSION
  105. chown -R root:root .
  106. find -L . \
  107. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  108. -o -perm 511 \) -exec chmod 755 {} \; -o \
  109. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  110. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  111. # Prepare toolchain
  112. tar xvf $CWD/toolchain-avr-$GCC-atmel$AVR-$AVR_BUILD.tar.gz
  113. cp $CWD/autoconf-$AUTOCONF.tar.bz2 \
  114. $CWD/automake-$AUTOMAKE.tar.bz2 \
  115. $CWD/avr-binutils.tar.bz2 \
  116. $CWD/gmp-$GMP.tar.bz2 \
  117. $CWD/mpfr-$MPFR.tar.bz2 \
  118. $CWD/mpc-$MPC.tar.gz \
  119. $CWD/gcc-$GCC.tar.xz \
  120. $CWD/avr-libc.tar.bz2 \
  121. $CWD/avr8-headers.zip \
  122. $CWD/avr-gdb.tar.bz2 \
  123. $CWD/Atmel.ATmega_DFP.$ATMEL_ATMEGA_PACK.atpack \
  124. $CWD/Atmel.ATtiny_DFP.$ATMEL_ATTINY_PACK.atpack \
  125. $CWD/Atmel.AVR-Dx_DFP.$ATMEL_DX_PACK.atpack \
  126. toolchain-avr-$GCC-atmel$AVR-$AVR_BUILD/
  127. cp $CWD/patches/gcc-add-missing-isl-includes.patch \
  128. toolchain-avr-$GCC-atmel$AVR-$AVR_BUILD/avr-gcc-patches/
  129. # Build toolchain
  130. ( cd toolchain-avr-$GCC-atmel$AVR-$AVR_BUILD
  131. patch -p1 <$CWD/patches/toolchain-fixes.diff
  132. chmod +x ./atpack.Dx.build.bash
  133. ./tools.bash
  134. ./binutils.build.bash
  135. ./gcc.build.bash
  136. ./avr-libc.build.bash
  137. ./gdb.build.bash
  138. rm -rf objdir/{info,man,share}
  139. ./atpack.build.bash
  140. ./atpack.tiny.build.bash
  141. ./atpack.Dx.build.bash
  142. )
  143. # Copy toolchain to where it can be found (`mv` will preserve some space)
  144. mkdir -p build/linux/work/hardware/tools/avr/
  145. mv toolchain-avr-$GCC-atmel$AVR-$AVR_BUILD/objdir/* \
  146. build/linux/work/hardware/tools/avr/
  147. # AVRDUDE build script was removed :-/
  148. tar --strip 1 -C build/linux/work/hardware/tools/avr/ \
  149. -xvf $CWD/avrdude-$AVRDUDE-$AVRDUDEARCH-pc-linux-gnu.tar.bz2
  150. # ArduinoOTA ships binary as well
  151. tar --strip 1 -C build/linux/work/hardware/tools/avr/ \
  152. -xvf $CWD/arduinoOTA-$ARDUINOOTA-linux_amd64.tar.bz2
  153. # Builder needs to know about the stuff we put above
  154. cat > build/linux/work/hardware/tools/avr/builtin_tools_versions.txt <<EOF
  155. arduino.avrdude=$AVRDUDE
  156. arduino.arduinoOTA=$ARDUINOOTA
  157. arduino.avr-gcc=$GCC-atmel$AVR-$AVR_BUILD
  158. EOF
  159. # Use already present toolchain and library bundles
  160. sed -e '/<antcall target="avr-toolchain-bundle">/,/<\/antcall>/d' \
  161. -i build/build.xml
  162. # Copy shared packages
  163. cp $CWD/WiFi101-Updater-ArduinoIDE-Plugin-${WIFI101UPDATER}.zip build/shared/
  164. # Copy libraries - with new names
  165. cp $CWD/Adafruit_CircuitPlayground-$ADAFRUIT.zip build/Adafruit_Circuit_Playground-$ADAFRUIT.zip
  166. cp $CWD/arduino-$FIRMATA.zip build/Firmata-$FIRMATA.zip
  167. # Copy libraries
  168. cp $CWD/arduino-examples-$EXAMPLES.zip \
  169. $CWD/Ethernet-$ETHERNET.zip \
  170. $CWD/GSM-$GSM.zip \
  171. $CWD/Stepper-$STEPPER.zip \
  172. $CWD/TFT-$TFT.zip \
  173. $CWD/WiFi-$WIFI.zip \
  174. $CWD/Bridge-$BRIDGE.zip \
  175. $CWD/Robot_Control-$ROBOT_CONTROL.zip \
  176. $CWD/Robot_Motor-$ROBOT_MOTOR.zip \
  177. $CWD/RobotIRremote-$ROBOTIRREMOTE.zip \
  178. $CWD/SpacebrewYun-$SPACEBREWYUN.zip \
  179. $CWD/Temboo-$TEMBOO.zip \
  180. $CWD/Esplora-$ESPLORA.zip \
  181. $CWD/Mouse-$MOUSE.zip \
  182. $CWD/Keyboard-$KEYBOARD.zip \
  183. $CWD/SD-$SD.zip \
  184. $CWD/Servo-$SERVO.zip \
  185. $CWD/LiquidCrystal-$LIQUIDCRYSTAL.zip \
  186. $CWD/libastylej-$LIBASTYLEJ.zip \
  187. $CWD/liblistSerials-$LIBLISTSERIALS.zip \
  188. $CWD/arduino-builder-linux$LIB-$ARDUINOBUILDER.tar.bz2 \
  189. $CWD/avr-$AVRCORE.tar.bz2 build/
  190. # Finally, build Arduino
  191. ( cd build ; ant )
  192. # Our files are here
  193. cd build/linux/work/
  194. # Manual install ensues
  195. mkdir -p $PKG/opt/$PRGNAM
  196. mv arduino{,-builder} examples hardware lib libraries \
  197. tools{,-builder} $PKG/opt/$PRGNAM
  198. # Ownership fixup
  199. chown -R root:root $PKG/opt/$PRGNAM/tools-builder $PKG/opt/Arduino/hardware
  200. # Make it a bit more user friendly
  201. mkdir -p $PKG/usr/{bin,share/applications}
  202. sed "s/FULL_PATH/\/opt\/$PRGNAM/" $CWD/arduino.desktop \
  203. > $PKG/usr/share/applications/$PRGNAM.desktop
  204. ln -s /opt/$PRGNAM/arduino $PKG/usr/bin/$PRGNAM
  205. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  206. cp -a revisions.txt $TMP/$PRGNAM-$VERSION/{README.md,license.txt} \
  207. $PKG/usr/doc/$PRGNAM-$VERSION
  208. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  209. mkdir -p $PKG/install
  210. cat $CWD/slack-desc > $PKG/install/slack-desc
  211. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  212. cd $PKG
  213. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE