arduino: 1.0.6 -> 1.6.9 (#17060)

Based on @brodul work at
https://github.com/brodul/nixpkgs/tree/arduino-update

Desktop file generation is from #13690

- Solved all download problems. Package/library lists are changing
daily, so I've created my own snapshot of them.
- Prepatch jssc .so inside jar - @brodul mentions that it can be copied
into $HOME while running program.
- Removed some unnecessary dependencies

Tested it by uploading simple sketch to Arduino Uno.

authored by Alexey Lebedeff and committed by Domen Kožar 8b1976c7 ddfc4ba9

+172 -27
+80 -26
pkgs/development/arduino/arduino-core/default.nix
··· 1 - { stdenv, fetchFromGitHub, jdk, jre, ant, coreutils, gnugrep, file, libusb 2 , withGui ? false, gtk2 ? null 3 }: 4 5 assert withGui -> gtk2 != null; 6 7 stdenv.mkDerivation rec { 8 - 9 - version = "1.0.6"; 10 name = "arduino${stdenv.lib.optionalString (withGui == false) "-core"}-${version}"; 11 12 src = fetchFromGitHub { 13 owner = "arduino"; 14 repo = "Arduino"; 15 rev = "${version}"; 16 - sha256 = "0nr5b719qi03rcmx6swbhccv6kihxz3b8b6y46bc2j348rja5332"; 17 }; 18 19 - buildInputs = [ jdk ant file ]; 20 21 buildPhase = '' 22 - cd ./core && ant 23 - cd ../build && ant 24 cd .. 25 ''; 26 27 installPhase = '' 28 mkdir -p $out/share/arduino 29 - cp -r ./build/linux/work/* "$out/share/arduino/" 30 echo ${version} > $out/share/arduino/lib/version.txt 31 32 ${stdenv.lib.optionalString withGui '' 33 - mkdir -p "$out/bin" 34 - sed -i -e "s|^java|${jdk}/bin/java|" "$out/share/arduino/arduino" 35 - sed -i -e "s|^LD_LIBRARY_PATH=|LD_LIBRARY_PATH=${gtk2}/lib:|" "$out/share/arduino/arduino" 36 ln -sr "$out/share/arduino/arduino" "$out/bin/arduino" 37 ''} 38 39 - # Fixup "/lib64/ld-linux-x86-64.so.2" like references in ELF executables. 40 - echo "running patchelf on prebuilt binaries:" 41 - find "$out" | while read filepath; do 42 - if file "$filepath" | grep -q "ELF.*executable"; then 43 - # skip target firmware files 44 - if echo "$filepath" | grep -q "\.elf$"; then 45 - continue 46 - fi 47 - echo "setting interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) in $filepath" 48 - patchelf --set-interpreter "$(cat "$NIX_CC"/nix-support/dynamic-linker)" "$filepath" 49 - test $? -eq 0 || { echo "patchelf failed to process $filepath"; exit 1; } 50 - fi 51 done 52 53 - patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ libusb ]} \ 54 - "$out/share/arduino/hardware/tools/avrdude" 55 ''; 56 57 meta = with stdenv.lib; { ··· 60 license = stdenv.lib.licenses.gpl2; 61 platforms = platforms.all; 62 maintainers = with maintainers; [ antono robberer bjornfor ]; 63 - }; 64 }
··· 1 + { stdenv, lib, fetchFromGitHub, fetchurl, jdk, ant 2 + , libusb, libusb1, unzip, zlib, ncurses, readline 3 , withGui ? false, gtk2 ? null 4 }: 5 6 assert withGui -> gtk2 != null; 7 8 + let 9 + externalDownloads = import ./downloads.nix {inherit fetchurl;}; 10 + # Some .so-files are later copied from .jar-s to $HOME, so patch them beforehand 11 + patchelfInJars = 12 + lib.optional (stdenv.system == "x86_64-linux") {jar = "share/arduino/lib/jssc-2.8.0.jar"; file = "libs/linux/libjSSC-2.8_x86_64.so";} 13 + ++ lib.optional (stdenv.system == "i686-linux") {jar = "share/arduino/lib/jssc-2.8.0.jar"; file = "libs/linux/libjSSC-2.8_x86.so";} 14 + ; 15 + # abiVersion 6 is default, but we need 5 for `avrdude_bin` executable 16 + ncurses5 = ncurses.override { abiVersion = "5"; }; 17 + in 18 stdenv.mkDerivation rec { 19 + version = "1.6.9"; 20 name = "arduino${stdenv.lib.optionalString (withGui == false) "-core"}-${version}"; 21 22 src = fetchFromGitHub { 23 owner = "arduino"; 24 repo = "Arduino"; 25 rev = "${version}"; 26 + sha256 = "0ksd6mkcf41114n0h37q80y1bz3a2q3z8kg6m9i11c3wrj8n80np"; 27 }; 28 29 + buildInputs = [ jdk ant libusb libusb1 unzip zlib ncurses5 readline ]; 30 + downloadSrcList = builtins.attrValues externalDownloads; 31 + downloadDstList = builtins.attrNames externalDownloads; 32 33 buildPhase = '' 34 + # Copy pre-downloaded files to proper locations 35 + download_src=($downloadSrcList) 36 + download_dst=($downloadDstList) 37 + while [[ "''${#download_src[@]}" -ne 0 ]]; do 38 + file_src=''${download_src[0]} 39 + file_dst=''${download_dst[0]} 40 + mkdir -p $(dirname $file_dst) 41 + download_src=(''${download_src[@]:1}) 42 + download_dst=(''${download_dst[@]:1}) 43 + cp -v $file_src $file_dst 44 + done 45 + 46 + # Loop above creates library_index.json.gz, package_index.json.gz and package_index.json.sig in 47 + # current directory. And now we can inject them into build process. 48 + library_index_url=file://$(pwd)/library_index.json 49 + package_index_url=file://$(pwd)/package_index.json 50 + 51 + cd ./arduino-core && ant 52 + cd ../build && ant -Dlibrary_index_url=$library_index_url -Dpackage_index_url=$package_index_url 53 cd .. 54 ''; 55 56 + # This will be patched into `arduino` wrapper script 57 + # Java loads gtk dynamically, so we need to provide it using LD_LIBRARY_PATH 58 + dynamicLibraryPath = lib.makeLibraryPath [gtk2]; 59 + javaPath = lib.makeBinPath [jdk]; 60 + 61 + # Everything else will be patched into rpath 62 + rpath = (lib.makeLibraryPath [zlib libusb libusb1 readline ncurses5 stdenv.cc.cc]); 63 + 64 installPhase = '' 65 mkdir -p $out/share/arduino 66 + cp -r ./build/linux/work/* "$out/share/arduino/" #*/ 67 echo ${version} > $out/share/arduino/lib/version.txt 68 69 ${stdenv.lib.optionalString withGui '' 70 + mkdir -p $out/bin 71 + substituteInPlace $out/share/arduino/arduino \ 72 + --replace "JAVA=java" "JAVA=$javaPath/java" \ 73 + --replace "LD_LIBRARY_PATH=" "LD_LIBRARY_PATH=$dynamicLibraryPath:" 74 ln -sr "$out/share/arduino/arduino" "$out/bin/arduino" 75 + 76 + cp -r build/shared/icons $out/share/arduino 77 + mkdir -p $out/share/applications 78 + cp build/linux/dist/desktop.template $out/share/applications/arduino.desktop 79 + substituteInPlace $out/share/applications/arduino.desktop \ 80 + --replace '<BINARY_LOCATION>' "$out/bin/arduino" \ 81 + --replace '<ICON_NAME>' "$out/share/arduino/icons/128x128/apps/arduino.png" 82 ''} 83 + ''; 84 85 + # So we don't accidentally mess with firmware files 86 + dontStrip = true; 87 + dontPatchELF = true; 88 + 89 + preFixup = '' 90 + for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do 91 + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true 92 + patchelf --set-rpath ${rpath}:$out/lib $file || true 93 done 94 95 + ${lib.concatMapStringsSep "\n" 96 + ({jar, file}: 97 + '' 98 + jar xvf $out/${jar} ${file} 99 + patchelf --set-rpath $rpath ${file} 100 + jar uvf $out/${jar} ${file} 101 + rm -f ${file} 102 + '' 103 + ) 104 + patchelfInJars} 105 + 106 + # avrdude_bin is linked against libtinfo.so.5 107 + mkdir $out/lib/ 108 + ln -s ${lib.makeLibraryPath [ncurses5]}/libncursesw.so.5 $out/lib/libtinfo.so.5 109 ''; 110 111 meta = with stdenv.lib; { ··· 114 license = stdenv.lib.licenses.gpl2; 115 platforms = platforms.all; 116 maintainers = with maintainers; [ antono robberer bjornfor ]; 117 + }; 118 }
+92
pkgs/development/arduino/arduino-core/downloads.nix
···
··· 1 + {fetchurl}: 2 + 3 + { 4 + # Following 3 files are snapshots of files that were downloaded from http://download.arduino.cc/ 5 + # Because original URLs update daily. https://github.com/binarin/arduino-indexes also contains script 6 + # for updating those snapshots. 7 + "package_index.json.gz" = fetchurl { 8 + url = "https://github.com/binarin/arduino-indexes/raw/snapshot-2016-07-18/package_index.json.gz"; 9 + sha256 = "11y16864bca6h5n03xbk8cw3v9b4xwvjz5mkirkcxslkkf7cx5yg"; 10 + }; 11 + "package_index.json.sig" = fetchurl { 12 + url = "https://github.com/binarin/arduino-indexes/raw/snapshot-2016-07-18/package_index.json.sig"; 13 + sha256 = "14ky3qb81mvqswaw9g5cpg5jcjqx6knfm75mzx1si7fbx576amls"; 14 + }; 15 + "library_index.json.gz" = fetchurl { 16 + url = "https://github.com/binarin/arduino-indexes/raw/snapshot-2016-07-18/library_index.json.gz"; 17 + sha256 = "19md4yf4m4wh9vnc3aj0gm3jak1qa591z5yhg0x8lsxx5hr2v85z"; 18 + }; 19 + 20 + "build/shared/reference-1.6.6-3.zip" = fetchurl { 21 + url = "http://downloads.arduino.cc/reference-1.6.6-3.zip"; 22 + sha256 = "119nj1idz85l71fy6a6wwsx0mcd8y0ib1wy0l6j9kz88nkwvggy3"; 23 + }; 24 + "build/shared/Galileo_help_files-1.6.2.zip" = fetchurl { 25 + url = "http://downloads.arduino.cc/Galileo_help_files-1.6.2.zip"; 26 + sha256 = "0qda0xml353sfhjmx9my4mlcyzbf531k40dcr1cnsa438xp2fw0w"; 27 + }; 28 + "build/shared/Edison_help_files-1.6.2.zip" = fetchurl { 29 + url = "http://downloads.arduino.cc/Edison_help_files-1.6.2.zip"; 30 + sha256 = "1x25rivmh0zpa6lr8dafyxvim34wl3wnz3r9msfxg45hnbjqqwan"; 31 + }; 32 + "build/Firmata-2.5.2.zip" = fetchurl { 33 + url = "https://github.com/arduino-libraries/Firmata/archive/2.5.2.zip"; 34 + sha256 = "1r75bxvpr17kwhpks9nxxpm5d5qbw0qnhygakv06whan9s0dc5cz"; 35 + }; 36 + "build/Bridge-1.6.2.zip" = fetchurl { 37 + url = "https://github.com/arduino-libraries/Bridge/archive/1.6.2.zip"; 38 + sha256 = "10v557bsxasq8ya09m9157nlk50cbkb0wlzrm54cznzmwc0gx49a"; 39 + }; 40 + "build/Robot_Control-1.0.2.zip" = fetchurl { 41 + url = "https://github.com/arduino-libraries/Robot_Control/archive/1.0.2.zip"; 42 + sha256 = "1wdpz3ilnza3lfd5a628dryic46j72h4a89y8vp0qkbscvifcvdk"; 43 + }; 44 + "build/Robot_Motor-1.0.2.zip" = fetchurl { 45 + url = "https://github.com/arduino-libraries/Robot_Motor/archive/1.0.2.zip"; 46 + sha256 = "0da21kfzy07kk2qnkprs3lj214fgkcjxlkk3hdp306jfv8ilmvy2"; 47 + }; 48 + "build/RobotIRremote-1.0.2.zip" = fetchurl { 49 + url = "https://github.com/arduino-libraries/RobotIRremote/archive/1.0.2.zip"; 50 + sha256 = "0wkya7dy4x0xyi7wn5aghmr1gj0d0wszd61pq18zgfdspz1gi6xn"; 51 + }; 52 + "build/SpacebrewYun-1.0.0.zip" = fetchurl { 53 + url = "https://github.com/arduino-libraries/SpacebrewYun/archive/1.0.0.zip"; 54 + sha256 = "1sklyp92m8i31rfb9b9iw0zvvab1zd7jdmg85fr908xn6k05qhmp"; 55 + }; 56 + "build/Temboo-1.1.5.zip" = fetchurl { 57 + url = "https://github.com/arduino-libraries/Temboo/archive/1.1.5.zip"; 58 + sha256 = "1ak9b2wrd42n3ak7kcqwg28ianq01acsi5jv4cc031wr0kpq4507"; 59 + }; 60 + "build/Esplora-1.0.4.zip" = fetchurl { 61 + url = "https://github.com/arduino-libraries/Esplora/archive/1.0.4.zip"; 62 + sha256 = "1dflfrg38f0312nxn6wkkgq1ql4hx3y9kplalix6mkqmzwrdvna4"; 63 + }; 64 + "build/Mouse-1.0.1.zip" = fetchurl { 65 + url = "https://github.com/arduino-libraries/Mouse/archive/1.0.1.zip"; 66 + sha256 = "106jjqxzpf5lrs9akwvamqsblj5w2fb7vd0wafm9ihsikingiypr"; 67 + }; 68 + "build/Keyboard-1.0.1.zip" = fetchurl { 69 + url = "https://github.com/arduino-libraries/Keyboard/archive/1.0.1.zip"; 70 + sha256 = "1spv73zhjbrb0vgpzjnh6wr3bddlbyzv78d21dbn8z2l0aqv2sac"; 71 + }; 72 + "build/libastylej-2.05.1-3.zip" = fetchurl { 73 + url = "http://downloads.arduino.cc/libastylej-2.05.1-3.zip"; 74 + sha256 = "0a1xy2cdl0xls5r21vy5d2j1dapn1jsdw0vbimlwnzfx7r84mxa6"; 75 + }; 76 + "build/liblistSerials-1.1.0.zip" = fetchurl { 77 + url = "http://downloads.arduino.cc/liblistSerials/liblistSerials-1.1.0.zip"; 78 + sha256 = "12n3y9y3gfi7i3x6llbwvi59jram02v8yyilv2kd38dm7wrqpw16"; 79 + }; 80 + "build/arduino-builder-linux64-1.3.18.tar.bz2" = fetchurl { 81 + url = "http://downloads.arduino.cc/tools/arduino-builder-linux64-1.3.18.tar.bz2"; 82 + sha256 = "0xbzcmvfa1h22dlvym8v4s68w4r1vdq8pj086sk1iwlkfiq0y4zq"; 83 + }; 84 + "build/linux/avr-gcc-4.8.1-arduino5-x86_64-pc-linux-gnu.tar.bz2" = fetchurl { 85 + url = "http://downloads.arduino.cc/tools/avr-gcc-4.8.1-arduino5-x86_64-pc-linux-gnu.tar.bz2"; 86 + sha256 = "1k793qsv1jdc0m4i9k40l2k7blnarfzy2k3clndl2yirfk0zqm4h"; 87 + }; 88 + "build/linux/avrdude-6.0.1-arduino5-x86_64-pc-linux-gnu.tar.bz2" = fetchurl { 89 + url = "http://downloads.arduino.cc/tools/avrdude-6.0.1-arduino5-x86_64-pc-linux-gnu.tar.bz2"; 90 + sha256 = "0xm4hfr4binny9f5affnmyrrq3lhrxr66s6ymplgfq9l72kwq9nq"; 91 + }; 92 + }
-1
pkgs/top-level/all-packages.nix
··· 408 409 arduino-core = callPackage ../development/arduino/arduino-core { 410 jdk = jdk; 411 - jre = jdk; 412 withGui = false; 413 }; 414
··· 408 409 arduino-core = callPackage ../development/arduino/arduino-core { 410 jdk = jdk; 411 withGui = false; 412 }; 413