Ver código fonte

Function to install guix

Bob Mottram 7 anos atrás
pai
commit
3edcda63d3
1 arquivos alterados com 133 adições e 0 exclusões
  1. 133
    0
      src/freedombone-utils-guile

+ 133
- 0
src/freedombone-utils-guile Ver arquivo

@@ -34,6 +34,9 @@ GUILE_HASH='c707b9cf6f97ecca3a4e3e704e62b83f95f1aec28ed1535f5d0a1d36af07a015'
34 34
 EIGHTSYNC_REPO="git://git.savannah.gnu.org/8sync.git"
35 35
 EIGHTSYNC_COMMIT='8cbb7f22227c0afdd3b0bd758ebec0efba2fa1e1'
36 36
 
37
+GUIX_VERSION='0.13.0'
38
+GUIX_DOWNLOAD_URL='ftp://alpha.gnu.org/gnu/guix'
39
+
37 40
 function install_8sync {
38 41
     apt-get -qy install flex libunistring-dev libgc-dev autoconf texinfo
39 42
 
@@ -92,4 +95,134 @@ function install_guile {
92 95
     echo 'export PATH=$PATH:$GUILE_PATH' >> ~/.bashrc
93 96
 }
94 97
 
98
+function install_guix_get_architecture {
99
+    read_config_param ARCHITECTURE
100
+
101
+    if [[ ${ARCHITECTURE} == *"386" || ${ARCHITECTURE} == *"686" ]]; then
102
+        CURR_ARCH='i686'
103
+    fi
104
+    if [[ ${ARCHITECTURE} == *"amd64" || ${ARCHITECTURE} == "x86_64" ]]; then
105
+        CURR_ARCH='x86_64'
106
+    fi
107
+    if [[ ${ARCHITECTURE} == *"arm"* ]]; then
108
+        CURR_ARCH='armhf'
109
+    fi
110
+    if [ ! ${CURR_ARCH} ]; then
111
+        echo $'No architecture specified'
112
+        ARCHITECTURE=$(uname -m)
113
+        if [[ ${ARCHITECTURE} == "arm"* ]]; then
114
+            CURR_ARCH='armhf'
115
+            echo $"Using $CURR_ARCH"
116
+        fi
117
+        if [[ ${ARCHITECTURE} == "amd"* || ${ARCHITECTURE} == "x86_64" ]]; then
118
+            CURR_ARCH='x86_64'
119
+            echo $"Using $CURR_ARCH"
120
+        fi
121
+        if [[ ${ARCHITECTURE} == *"386" || ${ARCHITECTURE} == *"686" ]]; then
122
+            CURR_ARCH='i686'
123
+            echo $"Using $CURR_ARCH"
124
+        fi
125
+    fi
126
+}
127
+
128
+
129
+function install_guix {
130
+    if [[ $(app_is_installed install_guix) == "1" ]]; then
131
+        return
132
+    fi
133
+
134
+    apt-get -qy install wget xz-utils
135
+
136
+    read_config_param MY_USERNAME
137
+    install_guix_get_architecture
138
+
139
+    if [ ! -d $INSTALL_DIR/guix ]; then
140
+        mkdir -p $INSTALL_DIR/guix
141
+    fi
142
+    cd $INSTALL_DIR/guix
143
+    if [ ! -f guix-binary-${GUIX_VERSION}.${CURR_ARCH}-linux.tar.xz ]; then
144
+        wget $GUIX_DOWNLOAD_URL/guix-binary-${GUIX_VERSION}.${CURR_ARCH}-linux.tar.xz
145
+    fi
146
+    if [ ! -f guix-binary-${GUIX_VERSION}.${CURR_ARCH}-linux.tar.xz ]; then
147
+        echo $"Unable to download guix from $GUIX_DOWNLOAD_URL"
148
+        exit 73826
149
+    fi
150
+    tar --warning=no-timestamp -xf guix-binary-${GUIX_VERSION}.${CURR_ARCH}-linux.tar.xz
151
+    if [ ! -d var/guix ]; then
152
+        echo $'guix directory var/guix not found'
153
+        exit 8726325
154
+    fi
155
+    mv var/guix /var/
156
+    if [ ! -d gnu ]; then
157
+        echo $'guix gnu directory not found'
158
+        exit 743383235
159
+    fi
160
+    mv gnu /
161
+
162
+    ln -sf /var/guix/profiles/per-user/root/guix-profile /root/.guix-profile
163
+    export GUIX_PROFILE=$HOME/.guix-profile
164
+    source $GUIX_PROFILE/etc/profile
165
+
166
+    # add build users
167
+    groupadd --system guixbuild
168
+    for i in `seq -w 1 10`;
169
+    do
170
+        useradd -g guixbuild -G guixbuild           \
171
+                -d /var/empty -s `which nologin`    \
172
+                -c "Guix build user $i" --system    \
173
+                guixbuilder$i;
174
+    done
175
+
176
+    if [ ! -f /root/.guix-profile/lib/systemd/system/guix-daemon.service ]; then
177
+        echo $'No guix systemd daemon found'
178
+        exit 78225548
179
+    fi
180
+    cp /root/.guix-profile/lib/systemd/system/guix-daemon.service \
181
+       /etc/systemd/system/
182
+    systemctl enable guix-daemon
183
+    systemctl start guix-daemon
184
+
185
+    if [ ! -d /usr/local/bin ]; then
186
+        mkdir -p /usr/local/bin
187
+    fi
188
+    cd /usr/local/bin
189
+    ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
190
+
191
+    if [ ! -d /usr/local/share/info ]; then
192
+        mkdir -p /usr/local/share/info
193
+    fi
194
+    cd /usr/local/share/info
195
+    if [ ! -d /var/guix/profiles/per-user/root/guix-profile/share/info ]; then
196
+        echo $'Directory not found /var/guix/profiles/per-user/root/guix-profile/share/info'
197
+        exit 7835202
198
+    fi
199
+    for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ;
200
+    do ln -s $i ; done
201
+
202
+    if ! grep -q 'GUIX_LOCPATH' /root/.bashrc; then
203
+        echo 'export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale' >> /root/.bashrc
204
+    fi
205
+    if ! grep -q 'GUIX_LOCPATH' /etc/skel/.bashrc; then
206
+        echo 'export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale' >> /etc/skel/.bashrc
207
+    fi
208
+    if ! grep -q 'GUIX_LOCPATH' /home/$MY_USERNAME/.bashrc; then
209
+        echo 'export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale' >> /home/$MY_USERNAME/.bashrc
210
+    fi
211
+    if ! grep -q 'GUIX_PROFILE' /root/.bashrc; then
212
+        echo 'export GUIX_PROFILE=$HOME/.guix-profile' >> /root/.bashrc
213
+        echo 'source $GUIX_PROFILE/etc/profile' >> /root/.bashrc
214
+    fi
215
+    if ! grep -q 'GUIX_PROFILE' /etc/skel/.bashrc; then
216
+        echo 'export GUIX_PROFILE=$HOME/.guix-profile' >> /etc/skel/.bashrc
217
+        echo 'source $GUIX_PROFILE/etc/profile' >> /etc/skel/.bashrc
218
+    fi
219
+    if ! grep -q 'GUIX_PROFILE' /home/$MY_USERNAME/.bashrc; then
220
+        echo 'export GUIX_PROFILE=$HOME/.guix-profile' >> /home/$MY_USERNAME/.bashrc
221
+        echo 'source $GUIX_PROFILE/etc/profile' >> /home/$MY_USERNAME/.bashrc
222
+    fi
223
+    guix package -i glibc-locales
224
+
225
+    install_completed install_guix
226
+}
227
+
95 228
 # NOTE: deliberately no exit 0