Skip to content
Snippets Groups Projects
freedombone-utils-guile 3.29 KiB
Newer Older
Bob Mottram's avatar
Bob Mottram committed
#!/bin/bash
Bob Mottram's avatar
Bob Mottram committed
#  _____               _           _
# |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# |   __|  _| -_| -_| . | . |     | . | . |   | -_|
# |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
Bob Mottram's avatar
Bob Mottram committed
#                              Freedom in the Cloud
Bob Mottram's avatar
Bob Mottram committed
#
# Recent version of guile
#
# License
# =======
#
Bob Mottram's avatar
Bob Mottram committed
# Copyright (C) 2017-2019 Bob Mottram <bob@freedombone.net>
Bob Mottram's avatar
Bob Mottram committed
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

GUILE_VERSION='2.2.0'
GUILE_HASH='c707b9cf6f97ecca3a4e3e704e62b83f95f1aec28ed1535f5d0a1d36af07a015'

EIGHTSYNC_REPO="git://git.savannah.gnu.org/8sync.git"
Bob Mottram's avatar
Bob Mottram committed
EIGHTSYNC_COMMIT='8cbb7f22227c0afdd3b0bd758ebec0efba2fa1e1'
Bob Mottram's avatar
Bob Mottram committed

function install_8sync {
    $INSTALL_PACKAGES flex libunistring-dev libgc-dev autoconf texinfo
Bob Mottram's avatar
Bob Mottram committed
    if [ ! -d "$INSTALL_DIR" ]; then
        mkdir "$INSTALL_DIR"
    cd "$INSTALL_DIR" || exit 67
Bob Mottram's avatar
Bob Mottram committed
    git_clone "$EIGHTSYNC_REPO" "$INSTALL_DIR/eightsync"
    cd "$INSTALL_DIR/eightsync" || exit 23
Bob Mottram's avatar
Bob Mottram committed
    git checkout "${EIGHTSYNC_COMMIT}" -b "${EIGHTSYNC_COMMIT}"
Bob Mottram's avatar
Bob Mottram committed
    export GUILE_BASE_PATH=/opt/guile-${GUILE_VERSION}
    export GUILE_CFLAGS="-I${GUILE_BASE_PATH}/include"
    export GUILE_LIBS="-L${GUILE_BASE_PATH}/lib -lguile -lqthreads -ldl -ltermcap -lsocket -lnsl -lm"
Bob Mottram's avatar
Bob Mottram committed
    ./bootstrap.sh
Bob Mottram's avatar
Bob Mottram committed
    sed -i 's|PKG_CHECK_MODULES|##PKG_CHECK_MODULES|g' configure
Bob Mottram's avatar
Bob Mottram committed
    configure
    make
    make install
    export GUILE_LOAD_COMPILED_PATH="$INSTALL_DIR/8sync"
Bob Mottram's avatar
Bob Mottram committed
}

function install_guile {
    # Currently this only works for x86_64
    read_config_param ARCHITECTURE
    if [[ ${ARCHITECTURE} != "x86_64" ]]; then
        return
    fi
    GUILE_ARCH='x86_64'

    $INSTALL_PACKAGES flex libunistring-dev libgc-dev autoconf texinfo lzip wget
Bob Mottram's avatar
Bob Mottram committed
    if [ ! -d "$INSTALL_DIR" ]; then
        mkdir "$INSTALL_DIR"
    cd "$INSTALL_DIR" || exit 42
Bob Mottram's avatar
Bob Mottram committed
    if [ ! -f "guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz" ]; then
        wget "https://ftp.gnu.org/gnu/guile/guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz"
Bob Mottram's avatar
Bob Mottram committed
    if [ ! -f "guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz" ]; then
Bob Mottram's avatar
Bob Mottram committed
        echo 'Unable to download guile pack'
Bob Mottram's avatar
Bob Mottram committed
    CURR_GUILE_HASH=$(sha256sum "guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz" | awk -F ' ' '{print $1}')
Bob Mottram's avatar
Bob Mottram committed
    if [[ "$CURR_GUILE_HASH" != "$GUILE_HASH" ]]; then
        echo 'Guile hash does not match'
Bob Mottram's avatar
Bob Mottram committed
    tar xvf "$INSTALL_DIR/guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz"
    if [ ! -d "/opt/guile-${GUILE_VERSION}/bin" ]; then
Bob Mottram's avatar
Bob Mottram committed
        echo 'Guile was not installed'
Bob Mottram's avatar
Bob Mottram committed
    fi
    echo "export GUILE_PATH=/opt/guile-${GUILE_VERSION}/bin" >> ~/.bashrc
Bob Mottram's avatar
Bob Mottram committed
    echo "export PATH=\$PATH:\$GUILE_PATH" >> ~/.bashrc
Bob Mottram's avatar
Bob Mottram committed
}

# NOTE: deliberately no exit 0