ソースを参照

Install elixir within images

Bob Mottram 7 年 前
コミット
fb57a56435
共有2 個のファイルを変更した39 個の追加1 個の削除を含む
  1. 1
    0
      src/freedombone-image-customise
  2. 38
    1
      src/freedombone-utils-elixir

+ 1
- 0
src/freedombone-image-customise ファイルの表示

@@ -2157,6 +2157,7 @@ create_generic_image
2157 2157
 atheros_wifi
2158 2158
 continue_installation
2159 2159
 image_install_nodejs
2160
+image_install_elixir
2160 2161
 initialise_mesh
2161 2162
 configure_wifi
2162 2163
 configure_user_interface

+ 38
- 1
src/freedombone-utils-elixir ファイルの表示

@@ -31,12 +31,18 @@
31 31
 # You should have received a copy of the GNU Affero General Public License
32 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 36
 function remove_elixir {
35 37
     apt-get -yq remove elixir erlang-xmerl erlang-dev erlang-parsetools
36 38
     apt-get -yq remove esl-erlang
37 39
 }
38 40
 
39 41
 function install_elixir {
42
+    if [ -f /usr/local/bin/mix ]; then
43
+        return
44
+    fi
45
+
40 46
     apt-get -yq install wget build-essential
41 47
 
42 48
     if [ ! -d "$INSTALL_DIR" ]; then
@@ -44,7 +50,6 @@ function install_elixir {
44 50
     fi
45 51
 
46 52
     cd "$INSTALL_DIR" || exit 768345274
47
-    erlang_package=erlang-solutions_1.0_all.deb
48 53
     wget https://packages.erlang-solutions.com/$erlang_package
49 54
     if [ ! -f "$INSTALL_DIR/$erlang_package" ]; then
50 55
         exit 72853
@@ -60,4 +65,36 @@ function install_elixir {
60 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 100
 # NOTE: deliberately no exit 0