#!/bin/bash # # .---. . . # | | | # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-' # ' ' --' --' -' - -' ' ' -' -' -' ' - --' # # Freedom in the Cloud # # lisp functions # # License # ======= # # Copyright (C) 2016 Bob Mottram # # 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 . COMMON_LISP_VERSION='1.11' function install_common_lisp { # http://ccl.clozure.com lisp_base=/usr/local/src if [ $1 ]; then lisp_base=$1 fi if [ ! -d $lisp_base ]; then mkdir -p $lisp_base fi cd $lisp_base check_architecture=$(uname -a) if [[ "$check_architecture" == *"arm"* ]]; then svn co http://svn.clozure.com/publicsvn/openmcl/release/${COMMON_LISP_VERSION}/linuxarm/ccl else svn co http://svn.clozure.com/publicsvn/openmcl/release/${COMMON_LISP_VERSION}/linuxx86/ccl fi if [ ! -d $lisp_base/ccl/scripts ]; then echo $'Unable to clone ccl repo' exit 728245 fi if [ ! -f $lisp_base/ccl/scripts/ccl ]; then echo $'ccl not found' exit 5825422 fi cp $lisp_base/ccl/scripts/ccl /usr/bin sed -i 's|CCL_DEFAULT_DIRECTORY=.*|CCL_DEFAULT_DIRECTORY=/usr/local/src/ccl|g' /usr/bin/ccl if [ -f $lisp_base/ccl/scripts/ccl64 ]; then cp $lisp_base/ccl/scripts/ccl64 /usr/bin sed -i 's|CCL_DEFAULT_DIRECTORY=.*|CCL_DEFAULT_DIRECTORY=/usr/local/src/ccl|g' /usr/bin/ccl64 fi } function remove_common_lisp { if [ -f /usr/bin/ccl ]; then rm /usr/bin/ccl fi if [ -f /usr/bin/ccl64 ]; then rm /usr/bin/ccl64 fi if [ -d /usr/local/src/ccl ]; then rm -rf /usr/local/src/ccl fi if [ -d $INSTALL_DIR/lisp ]; then rm -rf $INSTALL_DIR/lisp fi } function install_quicklisp { quicklisp_base=/usr/local/src if [ $1 ]; then quicklisp_base=$1 fi if [ ! -d $quicklisp_base ]; then mkdir -p $quicklisp_base fi cd $quicklisp_base if [ ! -f asdf.lisp ]; then wget https://common-lisp.net/project/asdf/asdf.lisp fi if [ ! -f asdf.lisp ]; then echo $'Unable to download asdf.lisp' exit 17529 fi if [ ! -f quicklisp.lisp ]; then curl -O https://beta.quicklisp.org/quicklisp.lisp fi if [ ! -f quicklisp.lisp ]; then echo $'Unable to download quicklisp.lisp' exit 80253 fi echo '(load (compile-file "asdf.lisp"))' > install.lisp echo '(load (compile-file "quicklisp.lisp"))' >> install.lisp echo '(quicklisp-quickstart:install)' >> install.lisp echo '(ql:add-to-init-file)' >> install.lisp check_architecture=$(uname -a) if [[ "$check_architecture" == *"64"* && "$check_architecture" != *"arm"* ]]; then if [ ! $2 ]; then ccl64 --load install.lisp else su -c 'ccl64 --load install.lisp' - $2 fi else if [ ! $2 ]; then ccl --load install.lisp else su -c 'ccl --load install.lisp' - $2 fi fi } # NOTE: deliberately no exit 0