Pārlūkot izejas kodu

Install elixir within images

Bob Mottram 7 gadus atpakaļ
vecāks
revīzija
fb57a56435
2 mainītis faili ar 39 papildinājumiem un 1 dzēšanām
  1. 1
    0
      src/freedombone-image-customise
  2. 38
    1
      src/freedombone-utils-elixir

+ 1
- 0
src/freedombone-image-customise Parādīt failu

2157
 atheros_wifi
2157
 atheros_wifi
2158
 continue_installation
2158
 continue_installation
2159
 image_install_nodejs
2159
 image_install_nodejs
2160
+image_install_elixir
2160
 initialise_mesh
2161
 initialise_mesh
2161
 configure_wifi
2162
 configure_wifi
2162
 configure_user_interface
2163
 configure_user_interface

+ 38
- 1
src/freedombone-utils-elixir Parādīt failu

31
 # You should have received a copy of the GNU Affero General Public License
31
 # You should have received a copy of the GNU Affero General Public License
32
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
32
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
33
 
33
 
34
+erlang_package='erlang-solutions_1.0_all.deb'
35
+
34
 function remove_elixir {
36
 function remove_elixir {
35
     apt-get -yq remove elixir erlang-xmerl erlang-dev erlang-parsetools
37
     apt-get -yq remove elixir erlang-xmerl erlang-dev erlang-parsetools
36
     apt-get -yq remove esl-erlang
38
     apt-get -yq remove esl-erlang
37
 }
39
 }
38
 
40
 
39
 function install_elixir {
41
 function install_elixir {
42
+    if [ -f /usr/local/bin/mix ]; then
43
+        return
44
+    fi
45
+
40
     apt-get -yq install wget build-essential
46
     apt-get -yq install wget build-essential
41
 
47
 
42
     if [ ! -d "$INSTALL_DIR" ]; then
48
     if [ ! -d "$INSTALL_DIR" ]; then
44
     fi
50
     fi
45
 
51
 
46
     cd "$INSTALL_DIR" || exit 768345274
52
     cd "$INSTALL_DIR" || exit 768345274
47
-    erlang_package=erlang-solutions_1.0_all.deb
48
     wget https://packages.erlang-solutions.com/$erlang_package
53
     wget https://packages.erlang-solutions.com/$erlang_package
49
     if [ ! -f "$INSTALL_DIR/$erlang_package" ]; then
54
     if [ ! -f "$INSTALL_DIR/$erlang_package" ]; then
50
         exit 72853
55
         exit 72853
60
     fi
65
     fi
61
 }
66
 }
62
 
67
 
68
+function image_install_elixir {
69
+    if [[ $VARIANT == "mesh"* ]]; then
70
+        return
71
+    fi
72
+
73
+    # shellcheck disable=SC2154
74
+    chroot "$rootdir" apt-get -yq install wget build-essential
75
+
76
+    if [ ! -d "$rootdir$INSTALL_DIR" ]; then
77
+        mkdir -p "$rootdir$INSTALL_DIR"
78
+    fi
79
+
80
+    { echo '#!/bin/bash';
81
+      echo "cd $INSTALL_DIR";
82
+      echo "erlang_package=$erlang_package";
83
+      echo "wget https://packages.erlang-solutions.com/\$erlang_package";
84
+      echo "if [ ! -f \"\$INSTALL_DIR/\$erlang_package\" ]; then";
85
+      echo '    exit 1';
86
+      echo 'fi';
87
+      echo "dpkg -i \$erlang_package"; } > "$rootdir/usr/bin/install_elixir"
88
+    chmod +x "$rootdir/usr/bin/install_elixir"
89
+    chroot "$rootdir" /usr/bin/install_elixir
90
+    chroot "$rootdir" apt-get -yq update
91
+    chroot "$rootdir" apt-get -yq install esl-erlang
92
+    chroot "$rootdir" apt-get -yq install elixir erlang-xmerl erlang-dev erlang-parsetools
93
+
94
+    if [ ! -f "$rootdir/usr/local/bin/mix" ]; then
95
+        echo $'/usr/local/bin/mix not found after elixir installation'
96
+        exit 629352
97
+    fi
98
+}
99
+
63
 # NOTE: deliberately no exit 0
100
 # NOTE: deliberately no exit 0