freedombone-utils-lisp 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # lisp functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. COMMON_LISP_VERSION='1.11'
  31. function install_common_lisp {
  32. # http://ccl.clozure.com
  33. lisp_base=/usr/local/src
  34. if [ $1 ]; then
  35. lisp_base=$1
  36. fi
  37. if [ ! -d $lisp_base ]; then
  38. mkdir -p $lisp_base
  39. fi
  40. cd $lisp_base
  41. check_architecture=$(uname -a)
  42. if [[ "$check_architecture" == *"arm"* ]]; then
  43. svn co http://svn.clozure.com/publicsvn/openmcl/release/${COMMON_LISP_VERSION}/linuxarm/ccl
  44. else
  45. svn co http://svn.clozure.com/publicsvn/openmcl/release/${COMMON_LISP_VERSION}/linuxx86/ccl
  46. fi
  47. if [ ! -d $lisp_base/ccl/scripts ]; then
  48. echo $'Unable to clone ccl repo'
  49. exit 728245
  50. fi
  51. if [ ! -f $lisp_base/ccl/scripts/ccl ]; then
  52. echo $'ccl not found'
  53. exit 5825422
  54. fi
  55. cp $lisp_base/ccl/scripts/ccl /usr/bin
  56. sed -i 's|CCL_DEFAULT_DIRECTORY=.*|CCL_DEFAULT_DIRECTORY=/usr/local/src/ccl|g' /usr/bin/ccl
  57. if [ -f $lisp_base/ccl/scripts/ccl64 ]; then
  58. cp $lisp_base/ccl/scripts/ccl64 /usr/bin
  59. sed -i 's|CCL_DEFAULT_DIRECTORY=.*|CCL_DEFAULT_DIRECTORY=/usr/local/src/ccl|g' /usr/bin/ccl64
  60. fi
  61. }
  62. function remove_common_lisp {
  63. if [ -f /usr/bin/ccl ]; then
  64. rm /usr/bin/ccl
  65. fi
  66. if [ -f /usr/bin/ccl64 ]; then
  67. rm /usr/bin/ccl64
  68. fi
  69. if [ -d /usr/local/src/ccl ]; then
  70. rm -rf /usr/local/src/ccl
  71. fi
  72. if [ -d $INSTALL_DIR/lisp ]; then
  73. rm -rf $INSTALL_DIR/lisp
  74. fi
  75. }
  76. function install_quicklisp {
  77. quicklisp_base=/usr/local/src
  78. if [ $1 ]; then
  79. quicklisp_base=$1
  80. fi
  81. if [ ! -d $quicklisp_base ]; then
  82. mkdir -p $quicklisp_base
  83. fi
  84. cd $quicklisp_base
  85. if [ ! -f asdf.lisp ]; then
  86. wget https://common-lisp.net/project/asdf/asdf.lisp
  87. fi
  88. if [ ! -f asdf.lisp ]; then
  89. echo $'Unable to download asdf.lisp'
  90. exit 17529
  91. fi
  92. if [ ! -f quicklisp.lisp ]; then
  93. curl -O https://beta.quicklisp.org/quicklisp.lisp
  94. fi
  95. if [ ! -f quicklisp.lisp ]; then
  96. echo $'Unable to download quicklisp.lisp'
  97. exit 80253
  98. fi
  99. echo '(load (compile-file "asdf.lisp"))' > install.lisp
  100. echo '(load (compile-file "quicklisp.lisp"))' >> install.lisp
  101. echo '(quicklisp-quickstart:install)' >> install.lisp
  102. echo '(ql:add-to-init-file)' >> install.lisp
  103. check_architecture=$(uname -a)
  104. if [[ "$check_architecture" == *"64"* && "$check_architecture" != *"arm"* ]]; then
  105. if [ ! $2 ]; then
  106. ccl64 --load install.lisp
  107. else
  108. su -c 'ccl64 --load install.lisp' - $2
  109. fi
  110. else
  111. if [ ! $2 ]; then
  112. ccl --load install.lisp
  113. else
  114. su -c 'ccl --load install.lisp' - $2
  115. fi
  116. fi
  117. }
  118. # NOTE: deliberately no exit 0