freedombone-utils-elixir 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # Elixir functions
  10. #
  11. # There's a problem with installing this onto mesh images, which is
  12. # that qemu appears to run out of RAM when using yarn to add webpack.
  13. #
  14. # License
  15. # =======
  16. #
  17. # Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
  18. #
  19. # This program is free software: you can redistribute it and/or modify
  20. # it under the terms of the GNU Affero General Public License as published by
  21. # the Free Software Foundation, either version 3 of the License, or
  22. # (at your option) any later version.
  23. #
  24. # This program is distributed in the hope that it will be useful,
  25. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. # GNU Affero General Public License for more details.
  28. #
  29. # You should have received a copy of the GNU Affero General Public License
  30. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. erlang_package='erlang-solutions_1.0_all.deb'
  32. function remove_elixir {
  33. apt-get -yq remove elixir erlang-xmerl erlang-dev erlang-parsetools
  34. apt-get -yq remove esl-erlang
  35. }
  36. function install_elixir {
  37. if [ -f /usr/local/bin/mix ]; then
  38. return
  39. fi
  40. apt-get -yq install wget build-essential
  41. if [ ! -d "$INSTALL_DIR" ]; then
  42. mkdir -p "$INSTALL_DIR"
  43. fi
  44. cd "$INSTALL_DIR" || exit 768345274
  45. wget https://packages.erlang-solutions.com/$erlang_package
  46. if [ ! -f "$INSTALL_DIR/$erlang_package" ]; then
  47. exit 72853
  48. fi
  49. dpkg -i $erlang_package
  50. apt-get -yq update
  51. apt-get -yq install esl-erlang
  52. apt-get -yq install elixir erlang-xmerl erlang-dev erlang-parsetools
  53. if [ ! -f /usr/local/bin/mix ]; then
  54. echo $'/usr/local/bin/mix not found after elixir installation'
  55. exit 629352
  56. fi
  57. }
  58. function image_install_elixir {
  59. if [[ $VARIANT == "mesh"* ]]; then
  60. return
  61. fi
  62. # shellcheck disable=SC2154
  63. chroot "$rootdir" apt-get -yq install wget build-essential
  64. if [ ! -d "$rootdir$INSTALL_DIR" ]; then
  65. mkdir -p "$rootdir$INSTALL_DIR"
  66. fi
  67. { echo '#!/bin/bash';
  68. echo "cd $INSTALL_DIR || exit 1";
  69. echo "erlang_package=$erlang_package";
  70. echo "wget https://packages.erlang-solutions.com/\$erlang_package";
  71. echo "if [ ! -f \"$INSTALL_DIR/\$erlang_package\" ]; then";
  72. echo ' exit 2';
  73. echo 'fi';
  74. echo "dpkg -i \$erlang_package"; } > "$rootdir/usr/bin/install_elixir"
  75. chmod +x "$rootdir/usr/bin/install_elixir"
  76. chroot "$rootdir" /usr/bin/install_elixir
  77. chroot "$rootdir" apt-get -yq update
  78. chroot "$rootdir" apt-get -yq install esl-erlang
  79. chroot "$rootdir" apt-get -yq install elixir erlang-xmerl erlang-dev erlang-parsetools
  80. if [ ! -f "$rootdir/usr/local/bin/mix" ]; then
  81. echo $'/usr/local/bin/mix not found after elixir installation'
  82. exit 629352
  83. fi
  84. }
  85. # NOTE: deliberately no exit 0