├── .gitignore ├── README.md ├── circle-ci-key-rotation.py ├── debian └── install-debian-dependencies.sh ├── install-archlinux-dependencies.sh ├── install-fedora-dependencies.sh ├── install-opensuse-dependencies.sh ├── install-osx.sh ├── ocbootstrap ├── ocfeedbot ├── ocpkg ├── octool-wip ├── octool_rpi.sh └── opencog-installer.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.tags 2 | *.swp 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Collection of scripts 2 | 3 | #### ocpkg 4 | * This script installs an OpenCog development environment on a fresh 5 | installation of Ubuntu >= 14.04 . It has options to selectively 6 | download, build, test, install OpenCog projects. 7 | 8 | For a quick start using Ubuntu version >= 14.04, run 9 | ``` 10 | sudo curl -L http://raw.github.com/opencog/ocpkg/master/ocpkg -o /usr/local/bin/octool &&\ 11 | sudo chmod +x /usr/local/bin/octool &&\ 12 | octool 13 | ``` 14 | 15 | For details, see the 16 | [instructions on the OpenCog wiki](http://wiki.opencog.org/wikihome/index.php/Building_OpenCog#octool_for_ubuntu). 17 | 18 | #### octool-wip 19 | Work-in-progress (abandoned). 20 | The separate octool script is not yet ready. Use the above. 21 | 22 | #### ocbootstrap 23 | (This hasn't been tested for a while) 24 | A script to create an OpenCog build environment on ''any'' Linux system. 25 | 26 | #### ocfeedbot 27 | An IRC bot of some sort, purpose not clear. 28 | 29 | Uses debootstrap. Requires ocpkg. 30 | 31 | #### octool_rpi 32 | For installing opencog on a Raspberry Pi Computer running Raspbian. 33 | The readme [here](https://github.com/opencog/opencog_rpi/blob/master/README.md) will be helpful. 34 | 35 | May be out of date. 36 | 37 | #### Example Usage 38 | * To install all dependencies necessary to build OpenCog: 39 | ``` 40 | ./octool -rdpcav -l default 41 | # Optional: Add -s for installing dependencies for haskell binding. 42 | # Optional: Add -n for installing dependencies and kernels for jupyter notebooks. 43 | ``` 44 | 45 | * To install all dependencies necessary to build AtomSpace and AS-MOSES: 46 | ``` 47 | ./octool -rdcv 48 | ``` 49 | 50 | * To install all dependencies necessary to build Cogutil: 51 | ``` 52 | ./octool -rdv 53 | ``` 54 | -------------------------------------------------------------------------------- /circle-ci-key-rotation.py: -------------------------------------------------------------------------------- 1 | from pprint import pprint 2 | from typing import Dict 3 | 4 | import requests 5 | 6 | # Steps to undertake before running this script 7 | # 1. Revoke access to circleci application by going to 'Authorized OAuth Apps' 8 | # at https://github.com/settings/applications of your personal account, or 9 | # https://github.com/octool. This will remove all ssh-keys from all repos. 10 | # 2. Update the repo list below by going to circleci.com. 11 | # 3. Create a circleci personal api token and update the variable below 12 | # 4. Run the script 13 | # 5. Delete the personal api toke you created in step 3. 14 | # 6. Rerun the circleci jobs to ensure everything is ok. 15 | 16 | # CircleCI Personal API Tokens. See the following link on how to create one 17 | # https://circleci.com/docs/managing-api-tokens#creating-a-personal-api-token 18 | circleci_token = "" 19 | circleci_headers = {"Circle-Token": circleci_token} 20 | 21 | repos = [ 22 | "asmoses", 23 | "atomspace", 24 | "attention", 25 | "cogserver", 26 | "cogutil", 27 | "lg-atomese", 28 | "miner", 29 | "moses", 30 | "opencog", 31 | "pln", 32 | "spacetime", 33 | "ure", 34 | ] 35 | org = "opencog" 36 | 37 | 38 | class CircleCiProject: 39 | """See https://circleci.com/docs/api/v2/index.html#tag/Project for api 40 | details""" 41 | 42 | def __init__(self, org: str, repo: str): 43 | self.project_slug = f"gh/{org}/{repo}" 44 | self.api_prefix = "https://circleci.com/api/v2/project" 45 | 46 | def deploy_keys(self) -> Dict: 47 | url = f"{self.api_prefix}/{self.project_slug}/checkout-key" 48 | response = requests.get(url, headers=circleci_headers) 49 | return response.json() 50 | 51 | def delete_deploy_keys(self): 52 | keys = self.deploy_keys()["items"] 53 | 54 | responses = [] 55 | for key in keys: 56 | url = ( 57 | f"{self.api_prefix}/{self.project_slug}/checkout-key" 58 | + f"/{key['fingerprint']}" 59 | ) 60 | response = requests.delete(url, headers=circleci_headers) 61 | responses.extend(response.json()) 62 | return responses 63 | 64 | def add_deploy_key(self): 65 | url = f"{self.api_prefix}/{self.project_slug}/checkout-key" 66 | response = requests.post( 67 | url, headers=circleci_headers, data={"type": "deploy-key"} 68 | ) 69 | return response.json() 70 | 71 | 72 | for repo in repos: 73 | print("---------------------------------------------------------") 74 | print(f"Starting replacing deploy keys used for github.com/{org}/{repo}") 75 | print("---------------------------------------------------------\n") 76 | project = CircleCiProject(org, repo) 77 | old_keys = project.deploy_keys()["items"] 78 | print("Old keys: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 79 | pprint(old_keys) 80 | # Delete old keys 81 | project.delete_deploy_keys() 82 | # Add new key 83 | project.add_deploy_key() 84 | new_key = project.deploy_keys()["items"] 85 | print("\nNew keys: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") 86 | pprint(new_key) 87 | print("\n---------------------------------------------------------") 88 | print(f"Finished replacing deploy keys used for github.com/{org}/{repo}") 89 | print("---------------------------------------------------------\n\n") 90 | -------------------------------------------------------------------------------- /debian/install-debian-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | #Script is designed to interactively install opencog dependencies on a clean Debian Jessie environment. 4 | #Last Edit 5/28/2016 by Noah Bliss. Major edit. Script is now part of a pair. 5 | #Removed cogutil/atomspace build/install. They are now handled by opencog-installer.sh 6 | # If I break. Fix me on github! 7 | 8 | #Prompt for root since we are installing stuff. 9 | [ "$UID" -eq 0 ] || exec sudo bash "$0" "$@" 10 | 11 | # DEFINE PACKAGES TO INSTALL: 12 | 13 | # General System Utilities 14 | PACKAGES_TOOLS=" 15 | git \ 16 | python-pip \ 17 | wget \ 18 | sudo \ 19 | " 20 | 21 | # Packages for building opencog 22 | PACKAGES_BUILD=" 23 | build-essential \ 24 | cmake \ 25 | cxxtest \ 26 | rlwrap \ 27 | guile-2.0-dev \ 28 | libiberty-dev \ 29 | libicu-dev \ 30 | libbz2-dev \ 31 | cython \ 32 | python-dev \ 33 | python-zmq \ 34 | python-simplejson \ 35 | libboost-date-time-dev \ 36 | libboost-filesystem-dev \ 37 | libboost-math-dev \ 38 | libboost-program-options-dev \ 39 | libboost-regex-dev \ 40 | libboost-serialization-dev \ 41 | libboost-thread-dev \ 42 | libboost-system-dev \ 43 | libzmq3-dev \ 44 | libtbb-dev \ 45 | binutils-dev \ 46 | unixodbc-dev \ 47 | uuid-dev \ 48 | libprotoc-dev \ 49 | protobuf-compiler \ 50 | libsdl-gfx1.2-dev \ 51 | libssl-dev \ 52 | tcl-dev \ 53 | tcsh \ 54 | libfreetype6-dev \ 55 | libatlas-base-dev \ 56 | gfortran \ 57 | " 58 | 59 | # Packages required for integrating opencog with other services 60 | PACKAGES_RUNTIME=" 61 | unixodbc \ 62 | odbc-postgresql \ 63 | postgresql-client \ 64 | " 65 | 66 | #Install the Deps. 67 | apt-get update 68 | if ! (apt-get install -y $PACKAGES_TOOLS $PACKAGES_BUILD $PACKAGES_RUNTIME) 69 | then 70 | echo "Installing packages from the Debian repo failed. It's probably your internet, apt sources.list, or we devs need to update a package name." 71 | exit 1 72 | fi 73 | #Install the Python Deps. 74 | cd /tmp 75 | rm requirements.txt 76 | #Fix for sslv3 Debian error 77 | sudo easy_install --upgrade pip 78 | wget https://raw.githubusercontent.com/opencog/opencog/master/opencog/python/requirements.txt 79 | sudo pip install -U -r /tmp/requirements.txt 80 | rm requirements.txt 81 | 82 | printf '\n \n' 83 | echo "Prerequisite software installed. We should have everything we need to build OpenCog." 84 | -------------------------------------------------------------------------------- /install-archlinux-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script is used for installing the dependencies required for 4 | # building opencog on archlinux.The script has been tested using docker 5 | # image pritunl/archlinux. 6 | # It is provided for those on 32-bit system or don't want to use 7 | # If you encounter an issue don't hesitate to supply a patch on github. 8 | # TODO : Add function for installing haskell dependencies. 9 | # trap errors 10 | set -e 11 | 12 | # Environment Variables 13 | SELF_NAME=$(basename $0) 14 | 15 | PACKAGES_TOOLS=" 16 | git \ 17 | python-pip \ 18 | wget \ 19 | sudo \ 20 | pkg-config \ 21 | " 22 | 23 | # Packages for building opencog 24 | PACKAGES_BUILD=" 25 | gcc \ 26 | make \ 27 | cmake \ 28 | cxxtest \ 29 | rlwrap \ 30 | guile \ 31 | icu 32 | bzip2 \ 33 | cython \ 34 | python2 \ 35 | python2-pyzmq \ 36 | python2-simplejson \ 37 | boost \ 38 | zeromq \ 39 | intel-tbb \ 40 | binutils \ 41 | gsl \ 42 | unixodbc \ 43 | protobuf \ 44 | protobuf-c \ 45 | sdl_gfx \ 46 | openssl \ 47 | tcl \ 48 | tcsh \ 49 | freetype2 \ 50 | blas \ 51 | lapack \ 52 | gcc-fortran \ 53 | " 54 | 55 | PACKAGES_RUNTIME=" 56 | unixodbc \ 57 | psqlodbc \ 58 | libpqxx \ 59 | " 60 | 61 | # Template for messages printed. 62 | message() { 63 | echo -e "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m" 64 | } 65 | 66 | # Install json-spirit (4.05) 67 | install_json_spirit(){ 68 | MESSAGE="Installing json-spirit library...." ; message 69 | cd /tmp 70 | # cleaning up remnants from previous install failures, if any. 71 | rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05 72 | export BOOST_ROOT=/usr/include/boost/ 73 | wget http://http.debian.net/debian/pool/main/j/json-spirit/json-spirit_4.05.orig.tar.gz 74 | tar -xvf json-spirit_4.05.orig.tar.gz 75 | cd json_spirit_v4_05 76 | mkdir build 77 | cd build/ 78 | cmake .. 79 | make -j$(nproc) 80 | sudo make install 81 | cd ../.. 82 | rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05 83 | } 84 | 85 | # Install cogutil 86 | install_cogutil(){ 87 | MESSAGE="Installing cogutil...." ; message 88 | cd /tmp/ 89 | # cleaning up remnants from previous install failures, if any. 90 | rm -rf master.tar.gz cogutil-master/ 91 | wget https://github.com/opencog/cogutil/archive/master.tar.gz 92 | tar -xvf master.tar.gz 93 | cd cogutil-master/ 94 | mkdir build 95 | cd build/ 96 | cmake .. 97 | make -j"$(nproc)" 98 | sudo make install 99 | cd ../.. 100 | rm -rf master.tar.gz cogutil-master/ 101 | } 102 | 103 | # Install Python Packages 104 | install_opencog_python_packages(){ 105 | MESSAGE="Installing python packages...." ; message 106 | cd /tmp 107 | # cleaning up remnants from previous install failures, if any. 108 | rm requirements.txt 109 | wget https://raw.githubusercontent.com/opencog/opencog/master/opencog/python/requirements.txt 110 | sudo pip install -v -U -r /tmp/requirements.txt 111 | rm requirements.txt 112 | } 113 | 114 | # Install AtomSpace 115 | install_atomspace(){ 116 | MESSAGE="Installing atomspace...." ; message 117 | cd /tmp/ 118 | # cleaning up remnants from previous install failures, if any. 119 | rm -rf master.tar.gz atomspace-master/ 120 | wget https://github.com/opencog/atomspace/archive/master.tar.gz 121 | tar -xvf master.tar.gz 122 | cd atomspace-master/ 123 | mkdir build 124 | cd build/ 125 | cmake .. 126 | make -j$(nproc) 127 | sudo make install 128 | cd ../.. 129 | rm -rf master.tar.gz atomspace-master/ 130 | } 131 | 132 | # Function for installing all required dependenceis for building OpenCog, 133 | # as well as dependencies required for running opencog with other services. 134 | install_dependencies() { 135 | MESSAGE="Installing OpenCog build dependencies...." ; message 136 | if ! pacman -S --noconfirm $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_TOOLS; then 137 | MESSAGE="Error installing some of dependencies... :( :(" ; message 138 | exit 1 139 | fi 140 | 141 | install_json_spirit 142 | } 143 | 144 | # Install Link-Grammar 145 | install_link_grammar(){ 146 | MESSAGE="Installing Link-Grammar...." ; message 147 | cd /tmp/ 148 | # cleaning up remnants from previous install failures, if any. 149 | rm -rf link-grammar-5.*/ 150 | wget -r --no-parent -nH --cut-dirs=2 http://www.abisource.com/downloads/link-grammar/current/ 151 | tar -zxf current/link-grammar-5*.tar.gz 152 | rm -r current 153 | cd link-grammar-5.*/ 154 | mkdir build 155 | cd build 156 | ../configure 157 | make -j"$(nproc)" 158 | sudo make install 159 | sudo ldconfig 160 | cd /tmp/ 161 | rm -rf link-grammar-5.*/ 162 | cd $CURRENT_DIR 163 | } 164 | 165 | usage() { 166 | echo "Usage: $SELF_NAME OPTION" 167 | echo " -d Install base/system build dependencies" 168 | echo " -p Install opencog python build dependencies" 169 | echo " -c Install Cogutil" 170 | echo " -a Install Atomspace" 171 | echo " -l Install Link Grammar" 172 | echo " -h This help message" 173 | } 174 | 175 | # Main Program 176 | if [ $# -eq 0 ] ; then NO_ARGS=true ; fi 177 | 178 | while getopts "dpcalsh" flag ; do 179 | case $flag in 180 | d) INSTALL_DEPENDENCIES=true ;; #base development packages 181 | p) INSTALL_OPENCOG_PYTHON_PACKAGES=true ;; 182 | c) INSTALL_COGUTIL=true ;; 183 | a) INSTALL_ATOMSPACE=true ;; 184 | l) INSTALL_LINK_GRAMMAR=true ;; 185 | h) usage ;; 186 | \?) usage ;; 187 | *) UNKNOWN_FLAGS=true ;; 188 | esac 189 | done 190 | 191 | if [ $INSTALL_DEPENDENCIES ] ; then install_dependencies ; fi 192 | if [ $INSTALL_OPENCOG_PYTHON_PACKAGES ] ; then 193 | install_opencog_python_packages 194 | fi 195 | if [ $INSTALL_COGUTIL ] ; then install_cogutil ; fi 196 | if [ $INSTALL_ATOMSPACE ] ; then install_atomspace ; fi 197 | if [ $INSTALL_LINK_GRAMMAR ] ; then install_link_grammar ; fi 198 | if [ $UNKNOWN_FLAGS ] ; then usage ; fi 199 | if [ $NO_ARGS ] ; then usage ; fi 200 | -------------------------------------------------------------------------------- /install-fedora-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script is used for installing the dependencies required for 4 | # building opencog on fedora.The script has been tested using docker 5 | # image fedora:21. 6 | # It is provided for those on 32-bit system or don't want to use 7 | # If you encounter an issue don't hesitate to supply a patch on github. 8 | 9 | # trap errors 10 | set -e 11 | 12 | # Environment Variables 13 | SELF_NAME=$(basename $0) 14 | 15 | # Fedora version 16 | FEDORA_VERSION=$(cat /etc/issue | head -n 1 | cut -d " " -f 3) 17 | 18 | # Some tools 19 | PACKAGES_TOOLS=" 20 | git \ 21 | python-pip \ 22 | wget \ 23 | tar \ 24 | sudo \ 25 | curl \ 26 | " 27 | 28 | # Packages for building opencog 29 | PACKAGES_BUILD=" 30 | make \ 31 | gcc \ 32 | gcc-c++ \ 33 | cmake \ 34 | cxxtest \ 35 | rlwrap \ 36 | guile-devel \ 37 | libicu-devel \ 38 | bzip2-devel \ 39 | Cython \ 40 | python-devel \ 41 | python-zmq \ 42 | boost-devel \ 43 | zeromq-devel \ 44 | cppzmq-devel \ 45 | tbb-devel \ 46 | binutils-devel \ 47 | unixODBC-devel \ 48 | uuid-devel \ 49 | protobuf-c \ 50 | protobuf-compiler \ 51 | SDL_gfx-devel \ 52 | openssl-devel \ 53 | tcl-devel \ 54 | tcsh \ 55 | freetype-devel \ 56 | atlas-devel \ 57 | gcc-gfortran \ 58 | " 59 | 60 | # Packages required for integrating opencog with other services 61 | PACKAGES_RUNTIME=" 62 | unixODBC \ 63 | postgresql-odbc \ 64 | postgresql-devel \ 65 | " 66 | 67 | # Template for messages printed. 68 | message() { 69 | echo -e "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m" 70 | } 71 | 72 | # Install json-spirit (4.05) 73 | install_json_spirit(){ 74 | MESSAGE="Installing json-spirit library...." ; message 75 | cd /tmp 76 | # cleaning up remnants from previous install failures, if any. 77 | rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05 78 | export BOOST_ROOT=/usr/include/boost/ 79 | wget http://http.debian.net/debian/pool/main/j/json-spirit/json-spirit_4.05.orig.tar.gz 80 | tar -xvf json-spirit_4.05.orig.tar.gz 81 | cd json_spirit_v4_05 82 | mkdir build 83 | cd build/ 84 | cmake .. 85 | make -j"$(nproc)" 86 | sudo make install 87 | cd ../.. 88 | rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05 89 | } 90 | 91 | # Install Python Packages 92 | install_opencog_python_packages(){ 93 | MESSAGE="Installing python packages...." ; message 94 | cd /tmp 95 | # cleaning up remnants from previous install failures, if any. 96 | rm requirements.txt 97 | wget https://raw.githubusercontent.com/opencog/opencog/master/opencog/python/requirements.txt 98 | sudo pip install -U -r /tmp/requirements.txt 99 | rm requirements.txt 100 | } 101 | 102 | # Install cogutil 103 | install_cogutil(){ 104 | MESSAGE="Installing cogutil...." ; message 105 | cd /tmp/ 106 | # cleaning up remnants from previous install failures, if any. 107 | rm -rf master.tar.gz cogutil-master/ 108 | wget https://github.com/opencog/cogutil/archive/master.tar.gz 109 | tar -xvf master.tar.gz 110 | cd cogutil-master/ 111 | mkdir build 112 | cd build/ 113 | cmake .. 114 | make -j"$(nproc)" 115 | sudo make install 116 | cd ../.. 117 | rm -rf master.tar.gz cogutil-master/ 118 | } 119 | 120 | # Install Link-Grammar 121 | install_link_grammar(){ 122 | MESSAGE="Installing Link-Grammar...." ; message 123 | cd /tmp/ 124 | # cleaning up remnants from previous install failures, if any. 125 | rm -rf link-grammar-5.*/ 126 | wget -r --no-parent -nH --cut-dirs=2 http://www.abisource.com/downloads/link-grammar/current/ 127 | tar -zxf current/link-grammar-5*.tar.gz 128 | rm -r current 129 | cd link-grammar-5.*/ 130 | mkdir build 131 | cd build 132 | ../configure 133 | make -j"$(nproc)" 134 | sudo make install 135 | sudo ldconfig 136 | cd /tmp/ 137 | rm -rf link-grammar-5.*/ 138 | cd $CURRENT_DIR 139 | } 140 | 141 | # Install AtomSpace 142 | install_atomspace(){ 143 | MESSAGE="Installing atomspace...." ; message 144 | cd /tmp/ 145 | # cleaning up remnants from previous install failures, if any. 146 | rm -rf master.tar.gz atomspace-master/ 147 | wget https://github.com/opencog/atomspace/archive/master.tar.gz 148 | tar -xvf master.tar.gz 149 | cd atomspace-master/ 150 | mkdir build 151 | cd build/ 152 | cmake .. 153 | make -j"$(nproc)" 154 | sudo make install 155 | cd ../.. 156 | rm -rf master.tar.gz atomspace-master/ 157 | } 158 | 159 | # Function for installing all required dependenceis for building OpenCog, 160 | # as well as dependencies required for running opencog with other services. 161 | install_dependencies() { 162 | MESSAGE="Updating Package db...." ; message 163 | $PM updateinfo 164 | 165 | MESSAGE="Installing OpenCog build dependencies...." ; message 166 | if ! (sudo $PM -y install $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_TOOLS) 167 | then 168 | MESSAGE="Error installing some of dependencies... :( :(" ; message 169 | exit 1 170 | fi 171 | install_json_spirit 172 | } 173 | 174 | # Install Haskell Dependencies 175 | install_haskell_dependencies(){ 176 | MESSAGE="Installing haskell dependencies in user space...." ; message 177 | # Install stack. 178 | if [ "$FEDORA_VERSION" == "22" ]; then 179 | curl -sSL https://s3.amazonaws.com/download.fpcomplete.com/fedora/22/fpco.repo | sudo tee /etc/yum.repos.d/fpco.repo 180 | elif [ "$FEDORA_VERSION" == "21" ]; then 181 | curl -sSL https://s3.amazonaws.com/download.fpcomplete.com/fedora/21/fpco.repo | sudo tee /etc/yum.repos.d/fpco.repo 182 | fi 183 | sudo $PM -y install stack 184 | 185 | # Notes 186 | # 1. Stack setup must me run in user space: 187 | # "stack setup" looks for proper ghc version in the system according to the 188 | # information provided by stack.yaml. If it is not installed, it attempts to 189 | # install proper ghc version on user space (~/.stack/...). Because of that, 190 | # it must not be run as root. 191 | 192 | # 2. Difference b/n .cabal and stack.yaml: 193 | # The .cabal file contains package metadata, in this case 194 | # "opencog-atomspace.cabal" contains information of the opencog-atomspace 195 | # package (autor, license, dependencies, etc.). The stack.yaml file contains 196 | # configuration options for the stack building tool, we use it to set the 197 | # proper "long term support" snapshot that we are using, which determines the 198 | # proper ghc version to use, etc. In this case, it doesn't make sense to 199 | # require the .cabal file, because we are not using that information to build 200 | # the hscolour package, but it looks like stack always looks for a .cabal 201 | # file when building, even though, in this case, it doesn't use it. 202 | if [ "$EUID" -ne 0 ] ; then 203 | cd /tmp 204 | wget https://raw.githubusercontent.com/opencog/atomspace/master/opencog/haskell/stack.yaml 205 | wget https://raw.githubusercontent.com/opencog/atomspace/master/opencog/haskell/opencog-atomspace.cabal 206 | stack setup 207 | 208 | # hscolour is necessary for haddock documentation. 209 | stack build hscolour --copy-bins 210 | rm stack.yaml opencog-atomspace.cabal 211 | cd $CURRENT_DIR 212 | else 213 | echo "Please run without sudo. Stack need to be run in non-root user space." 214 | fi 215 | } 216 | 217 | usage() { 218 | echo "Usage: $SELF_NAME OPTION" 219 | echo " -d Install base/system build dependencies" 220 | echo " -p Install opencog python build dependencies" 221 | echo " -s Install haskell build dependencies in user space. Don't use sudo" 222 | echo " -c Install Cogutil" 223 | echo " -a Install Atomspace" 224 | echo " -l Install Link Grammar" 225 | echo " -h This help message" 226 | } 227 | 228 | # Main Program 229 | # Choose package manager 230 | if [ "$FEDORA_VERSION" == "22" ]; then 231 | PM=dnf 232 | elif [ "$FEDORA_VERSION" == "21" ]; then 233 | PM=yum 234 | fi 235 | 236 | if [ $# -eq 0 ] ; then NO_ARGS=true ; fi 237 | 238 | while getopts "dpcalsh" flag ; do 239 | case $flag in 240 | d) INSTALL_DEPENDENCIES=true ;; #base development packages 241 | p) INSTALL_OPENCOG_PYTHON_PACKAGES=true ;; 242 | c) INSTALL_COGUTIL=true ;; 243 | a) INSTALL_ATOMSPACE=true ;; 244 | l) INSTALL_LINK_GRAMMAR=true ;; 245 | s) HASKELL_STACK_SETUP=true;; 246 | h) usage ;; 247 | \?) usage ;; 248 | *) UNKNOWN_FLAGS=true ;; 249 | esac 250 | done 251 | 252 | if [ $INSTALL_DEPENDENCIES ] ; then install_dependencies ; fi 253 | if [ $HASKELL_STACK_SETUP ] ; then install_haskell_dependencies ; fi 254 | if [ $INSTALL_OPENCOG_PYTHON_PACKAGES ] ; then 255 | install_opencog_python_packages 256 | fi 257 | if [ $INSTALL_COGUTIL ] ; then install_cogutil ; fi 258 | if [ $INSTALL_ATOMSPACE ] ; then install_atomspace ; fi 259 | if [ $INSTALL_LINK_GRAMMAR ] ; then install_link_grammar ; fi 260 | if [ $UNKNOWN_FLAGS ] ; then usage ; fi 261 | if [ $NO_ARGS ] ; then usage ; fi 262 | -------------------------------------------------------------------------------- /install-opensuse-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script is used for installing the dependencies required for 4 | # building opencog on openSUSE.The script has been tested using docker 5 | # image opensuse:13.2 6 | # It is provided for those on 32-bit system or don't want to use 7 | # If you encounter an issue don't hesitate to supply a patch on github. 8 | 9 | # TODO Make it work 10 | 11 | # trap errors 12 | set -e 13 | 14 | # Environment Variables 15 | SELF_NAME=$(basename $0) 16 | 17 | # Some tools 18 | PACKAGES_TOOLS=" 19 | git \ 20 | python-pip \ 21 | wget \ 22 | " 23 | 24 | # Packages for building opencog 25 | # FIXME cxxtest and tbb are not installaed 26 | PACKAGES_BUILD=" 27 | gcc \ 28 | make \ 29 | cmake \ 30 | cxxtest \ 31 | rlwrap \ 32 | guile \ 33 | libicu-devel \ 34 | libzip2 \ 35 | python-Cython \ 36 | python-devel \ 37 | python-pyzmq \ 38 | python-simplejson \ 39 | boost-devel \ 40 | libzmq3 \ 41 | zeromq-devel \ 42 | binutils-devel \ 43 | libgsl0 gsl-devel \ 44 | unixodbc-devel \ 45 | uuid-devel \ 46 | libprotobuf-c-devel \ 47 | libSDL_gfx-devel \ 48 | libssl27 \ 49 | tcl \ 50 | tcsh \ 51 | freetype2-devel \ 52 | libatlas3 \ 53 | gcc-fortran \ 54 | " 55 | 56 | # Packages required for integrating opencog with other services 57 | PACKAGES_RUNTIME=" 58 | unixODBC-devel \ 59 | psqlODBC \ 60 | postgresql \ 61 | " 62 | 63 | # Template for messages printed. 64 | message() { 65 | echo -e "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m" 66 | } 67 | 68 | # Install json-spirit (4.05) 69 | install_json_spirit(){ 70 | MESSAGE="Installing json-spirit library...." ; message 71 | cd /tmp 72 | export BOOST_ROOT=/usr/include/boost/ 73 | wget http://http.debian.net/debian/pool/main/j/json-spirit/json-spirit_4.05.orig.tar.gz 74 | tar -xvf json-spirit_4.05.orig.tar.gz 75 | cd json_spirit_v4_05 76 | mkdir build 77 | cd build/ 78 | cmake .. 79 | make -j$(nproc) 80 | sudo make install 81 | cd ../.. 82 | rm -rf json-spirit_4.05.orig.tar.gz json_spirit_v4_05 83 | } 84 | 85 | # Install cogutil 86 | install_cogutil(){ 87 | MESSAGE="Installing cogutil...." ; message 88 | cd /tmp/ 89 | wget https://github.com/opencog/cogutil/archive/master.tar.gz 90 | tar -xvf master.tar.gz 91 | cd cogutil-master/ 92 | mkdir build 93 | cd build/ 94 | cmake .. 95 | make -j$(nproc) 96 | sudo make install 97 | cd ../.. 98 | rm -rf master.tar.gz cogutil-master/ 99 | } 100 | 101 | # Install Python Packages 102 | install_python_packages(){ 103 | MESSAGE="Installing python packages...." ; message 104 | cd /tmp 105 | wget https://raw.githubusercontent.com/opencog/opencog/master/opencog/python/requirements.txt 106 | sudo pip install -U -r /tmp/requirements.txt 107 | rm requirements.txt 108 | } 109 | 110 | # Install AtomSpace 111 | install_atomspace(){ 112 | MESSAGE="Installing atomspace...." ; message 113 | cd /tmp/ 114 | wget https://github.com/opencog/atomspace/archive/master.tar.gz 115 | tar -xvf master.tar.gz 116 | cd atomspace-master/ 117 | mkdir build 118 | cd build/ 119 | cmake .. 120 | make -j$(nproc) 121 | sudo make install 122 | cd ../.. 123 | rm -rf master.tar.gz atomspace-master/ 124 | } 125 | 126 | # Function for installing all required dependenceis for building OpenCog, 127 | # as well as dependencies required for running opencog with other services. 128 | install_dependencies() { 129 | MESSAGE="Installing OpenCog build dependencies...." ; message 130 | # FIXME Haven't figured out which package is making this check fail. 131 | if ! (zypper --no-refresh install $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_TOOLS); 132 | then 133 | MESSAGE="Error installing some of dependencies... :( :(" ; message 134 | exit 1 135 | fi 136 | install_json_spirit 137 | install_python_packages 138 | install_cogutil 139 | install_atomspace 140 | } 141 | 142 | # Main Program 143 | install_dependencies 144 | -------------------------------------------------------------------------------- /install-osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | build_repo() 4 | { 5 | cd $1 6 | mkdir build 7 | cd build 8 | cmake .. 9 | make && sudo make install 10 | cd ../.. 11 | } 12 | 13 | report() 14 | { 15 | printf "\n\n$log\n\n" 16 | } 17 | 18 | # Install the homebrew package 19 | 20 | log="----------Installing/Updating Homebrew----------"; report 21 | check = $(which brew) 22 | if [ "$check" = "brew not found" ] 23 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 24 | else 25 | brew update 26 | fi 27 | 28 | # Install all the dependencies 29 | 30 | log="----------Installing dependencies----------"; report 31 | brew install gcc 32 | brew install cmake 33 | brew install boost 34 | brew install gsl 35 | brew install guile 36 | 37 | # Editing the bash_profile 38 | 39 | echo 'alias g++="g++-5 --std=c++1y -fext-numeric-literals"' >> ~/.bash_profile 40 | echo 'alias gcc="/usr/local/Cellar/gcc/5.1.0/bin/gcc-5"' >> ~/.bash_profile 41 | echo 'export CC="/usr/local/Cellar/gcc/5.1.0/bin/gcc-5"' >> ~/.bash_profile 42 | echo 'export CXX="g++-5 --std=c++1y -fext-numeric-literals"' >> ~/.bash_profile 43 | source ~/.bash_profile 44 | 45 | # Fetch OpenCog source repositories 46 | 47 | log="----------Fetching repositories from git----------"; report 48 | git clone git://github.com/opencog/cogutil 49 | git clone git://github.com/opencog/atomspace 50 | git clone git://github.com/opencog/moses 51 | git clone git://github.com/opencog/opencog 52 | 53 | # Set environment path variables 54 | 55 | export DYLD_LIBRARY_PATH="/usr/local/lib/opencog/modules:/usr/local/lib/opencog/" 56 | export PYTHONPATH="/usr/local/share/opencog/python:/opencog/opencog/python/:/opencog/build/opencog/cython:/opencog/opencog/nlp/anaphora:$PYTHONPATH" 57 | cp /usr/local/lib/opencog/* /usr/local/lib/ 58 | 59 | # Define TCP_IDLETIME, edit IRC.cc 60 | file="./opencog/opencog/nlp/irc/IRC.cc" 61 | sed -i '1i\ 62 | #define TCP_KEEPIDLE 14400\ 63 | ' $file 64 | 65 | # Edit PyMindAgent.cc to make OS X compatible 66 | file="./opencog/opencog/cogserver/modules/python/PyMindAgent.cc" 67 | sed -i '1i\ 68 | #include \ 69 | ' $file 70 | sed -i '0,/if __GNUC__/s/if __GNUC__/if __GNUC__ \&\& INIT_PRIORITY \&\& ((GCC_VERSION >= 40300) || (CLANG_VERSION >= 20900))/' $file 71 | 72 | # Make and build repositories 73 | 74 | log="----------Building Cogutil----------"; report 75 | build_repo cogutil 76 | log="----------Building atomspace----------"; report 77 | build_repo atomspace 78 | log="----------Building MOSES----------"; report 79 | build_repo moses 80 | log="----------Building OpenCog----------"; report 81 | build_repo opencog 82 | log="----------Successfully Built----------"; report 83 | -------------------------------------------------------------------------------- /ocbootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | ## @file ocbootstrap 4 | ## @copyright OpenCog Foundation (2012) 5 | ## @author David Hart 6 | ## @section DESCRIPTION A script to create a chroot environment in which to run ocpkg 7 | ## @section LICENSE Permission to copy and modify is granted under the GPL 8 | ## @section REQUIREMENT Any Linux distribution, run as root 9 | 10 | DISTRO_MIRROR=http://archive.ubuntu.com/ubuntu 11 | CHROOT_DISTRO=precise 12 | ARCH=amd64 13 | SELF_NAME=$(basename $0) 14 | PROCESSORS=$(grep "^processor" /proc/cpuinfo | wc -l) 15 | MAKE_JOBS=$(($PROCESSORS+0)) 16 | 17 | usage() { 18 | echo "Usage: $SELF_NAME [-a ARCH] [-p DISTRO_MIRROR] [DISTRO_NAME]" 19 | } 20 | 21 | while getopts ":a:p:j:" flag ; do 22 | case $flag in 23 | a) ARCH="$OPTARG" ;; 24 | p) DISTRO_MIRROR="$OPTARG" ;; 25 | j) MAKE_JOBS="$OPTARG" ;; #override auto-detected MAKE_JOBS 26 | \?) usage ;; 27 | esac 28 | done 29 | 30 | shift $((OPTIND-1)) 31 | 32 | if [ $1 ] ; then CHROOT_DISTRO=$1 ; fi 33 | 34 | CHROOT_DIR=/var/$CHROOT_DISTRO 35 | 36 | if [ ! $(which debootstrap) ] ; then 37 | if [ $(which dpkg) ] ; then 38 | wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.48_all.deb 39 | dpkg -i debootstrap_1.0.48_all.deb 40 | else 41 | wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.48.tar.gz 42 | tar zxvf debootstrap_1.0.48.tar.gz 43 | cd debootstrap-1.0.48/ 44 | make devices.tar.gz 45 | export DEBOOTSTRAP_DIR=$(pwd) 46 | export PATH=$PATH:$DEBOOTSTRAP_DIR 47 | fi 48 | fi 49 | 50 | if [ ! -d "$CHROOT_DIR" ] ; then 51 | mkdir -p $CHROOT_DIR 52 | # --variant=buildd installs the build-essential packages (this option is useful when building packages) 53 | # This option closely imitates the environment of the official build machines (https://launchpad.net/builders/) 54 | debootstrap --variant=buildd --arch $ARCH $CHROOT_DISTRO $CHROOT_DIR $DISTRO_MIRROR 55 | fi 56 | 57 | mkdir -p $CHROOT_DIR/usr/local/bin 58 | mkdir -p $CHROOT_DIR/usr/local/src/opencog 59 | 60 | ln -f -P /etc/mtab $CHROOT_DIR/etc/mtab 61 | 62 | mount -o bind /dev $CHROOT_DIR/dev 63 | mount -o bind /proc $CHROOT_DIR/proc 64 | mount -o bind /sys $CHROOT_DIR/sys 65 | mount -o bind /tmp $CHROOT_DIR/tmp 66 | mount -o bind /dev/pts $CHROOT_DIR/dev/pts 67 | mount -o bind /var/cache/apt/archives $CHROOT_DIR/var/cache/apt/archives 68 | mount -o bind /var/lib/apt/lists $CHROOT_DIR/var/lib/apt/lists 69 | mount -o bind /usr/local/src/opencog $CHROOT_DIR/usr/local/src/opencog 70 | 71 | echo "deb $DISTRO_MIRROR $CHROOT_DISTRO main universe" > $CHROOT_DIR/etc/apt/sources.list 72 | 73 | chroot $CHROOT_DIR /usr/bin/apt-get update 74 | chroot $CHROOT_DIR /usr/bin/apt-get -y install python-software-properties git sudo 75 | chroot $CHROOT_DIR /bin/mkdir -p /usr/local/lib/opencog/ocpkg 76 | chroot $CHROOT_DIR /usr/bin/git clone git://github.com/opencog/ocpkg /usr/local/lib/opencog/ocpkg 77 | chroot $CHROOT_DIR /bin/chmod ugo+rx /usr/local/lib/opencog/ocpkg/* 78 | chroot $CHROOT_DIR ln -s /usr/local/lib/opencog/ocpkg/ocpkg /usr/local/bin 79 | chroot $CHROOT_DIR /usr/local/bin/ocpkg -j$MAKE_JOBS 80 | -------------------------------------------------------------------------------- /ocfeedbot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # IRC b0t that keeps track of RSS feeds 4 | # 5 | # Licensed under the GNU General Public License v3 6 | # 7 | # Copyright (2009) by Akarsh Simha 8 | 9 | import irclib 10 | import feedparser 11 | import os 12 | import threading 13 | import time 14 | 15 | irc = irclib.IRC() 16 | server = irc.server() 17 | 18 | channels = [ "#opencog" ] 19 | feeds = [ "http://wiki.opencog.org/wikihome/index.php?title=Special:RecentChanges&feed=atom", 20 | "http://feeds.launchpad.net/opencog/revisions.atom", 21 | "http://search.twitter.com/search.atom?q=%23opencog" ] 22 | old_entries_file = os.environ.get("HOME") + "/.ocfeedbot.history" 23 | 24 | server.connect( "irc.freenode.org", 6667, "ocfeedbot" ) 25 | 26 | msgqueue = [] 27 | 28 | def feed_refresh(): 29 | FILE = open( old_entries_file, "r" ) 30 | filetext = FILE.read() 31 | FILE.close() 32 | for feed in feeds: 33 | NextFeed = False 34 | d = feedparser.parse( feed ) 35 | for entry in d.entries: 36 | id = entry.link.encode('utf-8')+entry.title.encode('utf-8') 37 | if id in filetext: 38 | NextFeed = True 39 | else: 40 | FILE = open( old_entries_file, "a" ) 41 | FILE.write( id + "\n" ) 42 | FILE.close() 43 | msgqueue.append( entry.title.encode('utf-8') + " : " + entry.link.encode('utf-8') ) 44 | if NextFeed: 45 | break; 46 | 47 | t = threading.Timer( 900.0, feed_refresh ) 48 | t.start() 49 | 50 | for channel in channels: 51 | server.join( channel ) 52 | 53 | feed_refresh() 54 | 55 | while 1: 56 | while len(msgqueue) > 0: 57 | msg = msgqueue.pop() 58 | for channel in channels: 59 | server.privmsg( channel, msg ) 60 | time.sleep(1) 61 | irc.process_once() 62 | -------------------------------------------------------------------------------- /ocpkg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | ## @file ocpkg 4 | ## @copyright OpenCog Foundation (2012,2013,2014,2015) 5 | ## @author David Hart 6 | ## @section DESCRIPTION A script to download, build, test, install and package OpenCog 7 | ## @section LICENSE Permission to copy and modify is granted under the GPL 8 | ## @section REQUIREMENT Ubuntu Linux 14.04 "Trusty Tahr". See opencog/ocpkg repo for 12.04 version 9 | ## @section SEEALSO Dockerfile - compile and run OpenCog in a Linux container 10 | 11 | # This bash script is organized in sections 12 | # SECTION 1. Global variable setting 13 | # SECTION 2. Command line option handling 14 | # SECTION 3. Error handling & cleanup 15 | # SECTION 4. Function definitions 16 | # SECTION 5. Main program 17 | 18 | # Notes 19 | # 5 minute LiveCD creation is possible with a minimum of 4GB RAM, 4GB SWAP, and /tmp on 4GB tmpfs 20 | # test CD/DVD images using: 21 | # testdrive -u OpenCogLive.iso 22 | # kvm -cdrom OpenCogLive.iso -boot d -m 2048 23 | 24 | # To do 25 | # Debian/Ubuntu packaging abilities http://developer.ubuntu.com/packaging/html/ 26 | # incremental builds 27 | # manifest rebuild to LiveCD/DVD 28 | 29 | # trap errors 30 | set -e 31 | 32 | # SECTION 1: GLOBAL VARIABLES 33 | 34 | declare -A PACKAGE_DESCRIPTION=( 35 | [local]="Local install with no packaging (default)" 36 | [demo]="LiveCD ISO image ~700MB with OpenCog Demo (auto-starting)" 37 | [min]="LiveCD ISO image ~700MB with OpenCog Server" 38 | [dev]="LiveDVD ISO image ~900MB with OpenCog Developement Environment" 39 | [kvm]="TBD Ubuntu KVM image with OpenCog Server" 40 | [demovm]="TBD Ubuntu VirtualBox image with OpenCog Unity3D proxy for demo" 41 | [debs]="TBD Ubuntu packages (deb files)" 42 | [docker]="TBD Docker Images" 43 | ) 44 | 45 | PATH_PREFIX=/usr/local 46 | CURRENT_DIR=$(pwd) 47 | SOURCE_DIR="" 48 | BUILD_DIR="" 49 | 50 | if [ "$USER" == "root" ] ; then 51 | HOST_SOURCE_BRANCH=$PATH_PREFIX/src/opencog 52 | HOST_BUILD_DIR=/tmp/opencog_build 53 | else 54 | HOST_SOURCE_BRANCH=$CURRENT_DIR/opencog/src 55 | HOST_BUILD_DIR=$CURRENT_DIR/opencog/build 56 | fi 57 | 58 | SLEEP_TIME=0 59 | 60 | OUTPUT_ISO_NAME=OpenCogLive.iso 61 | OUTPUT_ISO_LOCATION=$CURRENT_DIR 62 | 63 | DEFAULT_PACKAGE_TYPE=local 64 | DEFAULT_ADD_REPOSITORIES=true 65 | DEFAULT_INSTALL_DEPENDENCIES=true 66 | DEFAULT_UPDATE_OPENCOG=true 67 | DEFAULT_BUILD_OPENCOG=false 68 | DEFAULT_TEST_OPENCOG=false 69 | 70 | UBUNTU_ISO=ubuntu-20.04.3-desktop-amd64.iso 71 | UBUNTU_URL=http://releases.ubuntu.com/20.04/ 72 | UBUNTU_MD5SUM=5fdebc435ded46ae99136ca875afc6f05bde217be7dd018e1841924f71db46b5 73 | UBUNTU_ISO_IMAGE=$CURRENT_DIR/$UBUNTU_ISO #default location 74 | 75 | SELF_NAME=$(basename $0) 76 | TOOL_NAME=octool 77 | 78 | GUILEVERSION=3.0.10 79 | 80 | PROCESSORS=$(grep "^processor" /proc/cpuinfo | wc -l) 81 | MAKE_JOBS=$(($PROCESSORS+0)) 82 | 83 | SQUASHFS_OPTIONS="-noDataCompression -noappend" #faster 84 | SQUASHFS_OPTIONS="-noappend" 85 | 86 | LIVE_SOURCE_BRANCH=$HOST_SOURCE_BRANCH 87 | LIVE_BUILD_DIR=$HOST_BUILD_DIR 88 | 89 | VERBOSE="-v" #for mount, umount, rm, etc. 90 | #QUIET="-qq" #for apt-get 91 | 92 | LIVE_DESKTOP_SOURCE="OpenCog Source Code" 93 | 94 | REPOSITORIES="" 95 | # ppa:opencog-dev/ppa \ 96 | # opencog-dev: cxxtest 97 | # gandelman: python-flask-restful 98 | # ppa:chris-lea/zeromq \ 99 | # ppa:chris-lea/python-flask \ 100 | # ppa:chris-lea/python-itsdangerous \ 101 | # ppa:chris-lea/python-simplejson \ 102 | # ppa:gandelman-a/test-catalog \ 103 | 104 | PACKAGES_TOOLS=" 105 | squashfs-tools \ 106 | genisoimage \ 107 | " 108 | #aria2 \ 109 | #qemu-kvm \ 110 | #testdrive \ 111 | 112 | PACKAGES_FETCH=" 113 | git \ 114 | curl \ 115 | wget \ 116 | " 117 | #bzr-rewrite \ 118 | 119 | PACKAGES_ADMIN=" 120 | apt-rdepends \ 121 | synaptic \ 122 | gdebi \ 123 | epiphany-browser \ 124 | " 125 | 126 | # The opencv-dev package is needed for vision processing. Unfortunately 127 | # it sucks in vast numbers of junk packages as depdencies, including 128 | # parts of X11, libgtk-3-common, ubuntu-mono, unixodbc-common, libtk8.6 129 | # and more. Sidelining this one package could reduce a lot of cruft. 130 | # 131 | # I think the following are no longer needed: 132 | # libicu-dev gfortran libfreetype6-dev libatlas-base-dev 133 | PACKAGES_BUILD=" build-essential \ 134 | cmake \ 135 | rlwrap \ 136 | binutils-dev \ 137 | libiberty-dev \ 138 | libltdl-dev \ 139 | libicu-dev \ 140 | libbz2-dev \ 141 | libboost-date-time-dev \ 142 | libboost-filesystem-dev \ 143 | libboost-math-dev \ 144 | libboost-program-options-dev \ 145 | libboost-regex-dev \ 146 | libboost-serialization-dev \ 147 | libboost-thread-dev \ 148 | libboost-system-dev \ 149 | libboost-random-dev \ 150 | libedit-dev \ 151 | libpcre2-dev \ 152 | libpq-dev \ 153 | libtbb-dev \ 154 | uuid-dev \ 155 | libssl-dev \ 156 | libfreetype6-dev \ 157 | libatlas-base-dev \ 158 | gfortran \ 159 | ccache \ 160 | cxxtest \ 161 | libgsasl-dev \ 162 | libldap2-dev \ 163 | krb5-multidev \ 164 | gperf \ 165 | libatomic-ops-dev \ 166 | libgmp-dev \ 167 | libffi-dev \ 168 | libreadline-dev \ 169 | libunistring-dev \ 170 | m4 \ 171 | autoconf-archive \ 172 | autoconf automake autopoint \ 173 | libtool \ 174 | swig \ 175 | flex \ 176 | librocksdb-dev \ 177 | libopencv-dev \ 178 | less \ 179 | vim \ 180 | " 181 | 182 | # AtomSpace OCaML no longer builds in Ubuntu 22.04, and so disable here, 183 | # until it is fixed. 184 | #ocaml \ 185 | #ocaml-findlib \ 186 | 187 | PACKAGES_RUNTIME=" 188 | postgresql-client \ 189 | netcat-openbsd \ 190 | " 191 | 192 | PACKAGES_DOC=" 193 | ubuntu-docs \ 194 | #libglib2.0-doc \ 195 | #libpango1.0-doc \ 196 | #libgtk-3-doc \ 197 | texlive-latex-base-doc \ 198 | python-doc \ 199 | devhelp-common \ 200 | texlive-doc-base \ 201 | doxygen \ 202 | dot2tex \ 203 | " 204 | 205 | PACKAGES_REMOVE=" 206 | ubuntu-desktop \ 207 | example-content \ 208 | software-center \ 209 | app-install-data \ 210 | locales \ 211 | python-twisted-core \ 212 | ubiquity \ 213 | rhythmbox \ 214 | rhythmbox-data \ 215 | empathy \ 216 | empathy-common \ 217 | libtelepathy-glib0 \ 218 | firefox \ 219 | thunderbird \ 220 | libreoffice-core \ 221 | evolution-data-server \ 222 | gnome-games-common \ 223 | gnome-games-data \ 224 | aisleriot \ 225 | deja-dup \ 226 | gwibber \ 227 | oneconf \ 228 | shotwell \ 229 | ubuntuone-client \ 230 | python-ubuntuone-client \ 231 | gnome-orca \ 232 | libgweather-common \ 233 | simple-scan \ 234 | sane-utils \ 235 | printer-driver-hpcups \ 236 | printer-driver-hpijs \ 237 | hplip \ 238 | hplip-data \ 239 | libgutenprint2 \ 240 | foo2zjs \ 241 | colord \ 242 | libsane \ 243 | samba-common \ 244 | gnome-user-guide \ 245 | ure \ 246 | smbclient \ 247 | indicator-messages \ 248 | ubuntuone-client-gnome \ 249 | geoip-database \ 250 | libopencc1 \ 251 | fonts-nanum \ 252 | ttf-indic-fonts-core \ 253 | ttf-wqy-microhei \ 254 | fonts-takao-pgothic \ 255 | libpurple0 \ 256 | brltty \ 257 | liblouis-data \ 258 | " 259 | #ubuntu-wallpapers \ 260 | #this stuff is for Unity 2D, but Ubuntu fails to login without it 261 | #libqtgui4 \ 262 | #libqt4-core \ 263 | #libqt4-xmlpatterns \ 264 | #libwebkitgtk-3.0-0 \ 265 | #language-pack-pt-base \ 266 | #language-pack-es-base \ 267 | #language-pack-xh-base \ 268 | #language-pack-zh-hans \ 269 | #language-pack-de-base \ 270 | #language-pack-fr-base \ 271 | #language-pack-ca-base \ 272 | #language-pack-el-base \ 273 | #language-pack-sv-base \ 274 | #language-pack-ru-base \ 275 | #language-pack-gnome-zh-hans-base \ 276 | #language-pack-kde-zh-hans-base \ 277 | # NOTES 278 | # apps listed first, then libraries that they depend upon which will 279 | # also uninstall other stuff 280 | # ubiquity - graphical Ubuntu installer that runs on boot 281 | # 23MB app-install-data (ubuntu software center) 282 | # 22MB ubuntu-docs (desktop docs) 283 | # 44MB thunderbird 284 | # 26MB amarok 285 | # 200MB libreoffice 286 | # 45MB smbclient 287 | 288 | # Below is a list of packages that will be *removed* when building 289 | # the demo and minimal packages. I dunno, I suspect many of these 290 | # will fail, because they do not exist any more... 291 | PACKAGES_EXDEV=" 292 | autoconf automake autotools-dev \ 293 | blt \ 294 | comerr-dev \ 295 | dpkg-dev \ 296 | emacsen-common \ 297 | fakeroot \ 298 | gettext \ 299 | gdb \ 300 | g++ \ 301 | gcc \ 302 | krb5-multidev \ 303 | libc6-dev \ 304 | libdpkg-perl \ 305 | libgcrypt11-dev \ 306 | libgnutls-dev \ 307 | libgpg-error-dev \ 308 | libgssrpc4 \ 309 | libidn11-dev \ 310 | libalgorithm-diff-perl \ 311 | libalgorithm-diff-xs-perl \ 312 | libalgorithm-merge-perl \ 313 | libkadm5clnt-mit8 \ 314 | libkadm5srv-mit8 \ 315 | libkrb5-dev \ 316 | libldap2-dev \ 317 | libltdl-dev \ 318 | libstdc++-dev \ 319 | libtasn1-3-dev \ 320 | libtimedate-perl \ 321 | libtool \ 322 | libxss1 \ 323 | make \ 324 | manpages-dev \ 325 | m4 \ 326 | patch \ 327 | ttf-lyx \ 328 | zlib1g-dev \ 329 | python-bzrlib \ 330 | linux-headers-generic \ 331 | # libcpprest \ 332 | # libzmq3-dev \ 333 | # libsdl-gfx1.2-dev \ 334 | # tcl-dev \ 335 | # tcsh \ 336 | # libprotoc-dev \ 337 | # protobuf-compiler \ 338 | # wordnet \ 339 | # wordnet-dev \ 340 | # wordnet-sense-index \ 341 | # liblua5.1-0-dev \ 342 | # libxmlrpc-c3-dev \ 343 | # python-flask \ 344 | # python-flask-restful \ 345 | # libglade2-0 \ 346 | # python-glade2 \ 347 | # python-tk \ 348 | # tcl8.5 \ 349 | # tk8.5 \ 350 | " 351 | 352 | # SECTION 2: Command line option handling 353 | 354 | usage() { 355 | if [ "$SELF_NAME" == "$TOOL_NAME" ] ; then 356 | echo "Usage: $SELF_NAME OPTION" 357 | echo " -r Add software repositories" 358 | echo " -d Install base/system build dependencies" 359 | echo " -p Install python build dependencies" 360 | echo " -s Install haskell build dependencies in user space. Don't use sudo" 361 | echo " -i Install build-job artifacts" 362 | echo " -c Install CogUtil" 363 | echo " -a Install AtomSpace" 364 | echo " -f Install from opencog github repo. Pass the name of the repo as an argument" 365 | echo " -o Install OpenCog" 366 | echo " -n Install notebook" 367 | echo " -l [master|java] Install Link Grammar release tarball; else master branch" 368 | echo " -m Install ASMOSES" 369 | echo " -z Install the language subsystem" 370 | echo " -g Install Guile $GUILEVERSION" 371 | echo " -b Build source code in git worktree found @ $PWD" 372 | echo " -e Build examples in git worktree found @ $PWD" 373 | echo " -t Run tests of source code in git worktree found @ $PWD" 374 | echo " -j [jobs] override number of auto-detected make jobs" 375 | echo " -w download data for the opencog repo" 376 | echo " -v Verbose output for 'apt-get' commands" 377 | echo " -h This help message" 378 | else 379 | echo "Usage: $SELF_NAME [OPTIONS] [PACKAGE-TYPE]" 380 | echo " PACKAGE-TYPES:" 381 | for key in ${!PACKAGE_DESCRIPTION[@]}; do 382 | echo " " ${key} $'\t' "${PACKAGE_DESCRIPTION[$key]}" 383 | done 384 | echo " (Live CD: Ubuntu ISO image ~700MB will be downloaded if none found.)" 385 | echo " OPTIONS:" 386 | echo " -i [filename] ISO input filename" 387 | echo " -o [filename] ISO output filename" 388 | echo " -j [jobs] override number of auto-detected make jobs" 389 | echo " -n supress git updates" 390 | fi 391 | } 392 | 393 | 394 | # TODO: change octool usage to 'octool project command' format. Where projects 395 | # are opencog, atomspace, cogutil... & commands are setup(for workspace), 396 | # package(for docker,deb, rpm). Each will have various options/sub-commands. 397 | #if [ $1 ] && [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 398 | 399 | if [ $# -eq 0 ] ; then NO_ARGS=true ; fi 400 | 401 | if [ "$SELF_NAME" == "$TOOL_NAME" ] ; then 402 | while getopts "abdef:gipcrstl:mhvj:ownz" flag ; do 403 | case $flag in 404 | r) ADD_REPOSITORIES=true ;; 405 | d) INSTALL_DEPENDENCIES=true ;; #base development packages 406 | w) DOWNLOAD_DATA=true ;; 407 | p) INSTALL_OPENCOG_PYTHON_PACKAGES=true ;; 408 | c) INSTALL_COGUTIL=true ;; 409 | a) INSTALL_ATOMSPACE=true ;; 410 | f) INSTALL_FROM_REPO="$OPTARG" ;; 411 | o) INSTALL_OPENCOG=true ;; 412 | l) INSTALL_LINK_GRAMMAR=true ; 413 | if [ "$OPTARG" == "master" ]; then 414 | INSTALL_LG_MASTER=true 415 | elif [ "$OPTARG" == "java" ]; then 416 | INSTALL_JAVA_LINK_GRAMMAR=true 417 | fi ;; 418 | m) INSTALL_ASMOSES=true ;; 419 | n) INSTALL_NOTEBOOKS=true;; 420 | g) INSTALL_GUILE=true ;; 421 | b) BUILD_SOURCE=true ;; 422 | e) BUILD_EXAMPLES=true ;; 423 | t) TEST_SOURCE=true ;; 424 | v) unset QUIET ;; 425 | z) INSTALL_LANGUAGE=true ;; 426 | j) MAKE_JOBS="$OPTARG" ;; 427 | s) HASKELL_STACK_SETUP=true;; 428 | i) INSTALL_BUILD=true ;; 429 | h) usage ;; 430 | \?) usage; exit 1 ;; 431 | *) UNKNOWN_FLAGS=true ;; 432 | esac 433 | done 434 | else 435 | while getopts ":i:o:j:s:c:l:r:adubtnxrvh" flag ; do 436 | case $flag in 437 | i) INPUT_ISO_NAME="$OPTARG" ;; 438 | o) OUTPUT_ISO_NAME="$OPTARG" ;; 439 | j) MAKE_JOBS="$OPTARG" ;; #override auto-detected MAKE_JOBS 440 | s) HOST_SOURCE_BRANCH="$OPTARG" ;; 441 | c) HOST_BUILD_DIR="$OPTARG" ;; #local cached build dir 442 | l) LIVE_BUILD_DIR="$OPTARG" ;; #live build directory 443 | r) BZR_REVISION="$OPTARG" ;; 444 | a) ADD_REPOSITORIES=true ;; 445 | d) INSTALL_DEPENDENCIES=true ;; #ALL, none 446 | u) UPDATE_OPENCOG=true ;; #git pull 447 | b) BUILD_OPENCOG=true ;; #build opencog 448 | t) TEST_OPENCOG=true ;; #test opencog 449 | n) unset DEFAULT_UPDATE_OPENCOG ;; #suppress git update 450 | x) unset DEFAULT_BUILD_OPENCOG ;; #suppress build 451 | p) REINSTALL_PACKAGES=true ;; 452 | v) unset QUIET ;; 453 | h) usage ;; 454 | \?) usage ;; 455 | *) UNKNOWN_FLAGS=true ;; 456 | esac 457 | done 458 | fi 459 | 460 | shift $((OPTIND-1)) 461 | 462 | message() { 463 | echo -e "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m" 464 | } 465 | 466 | PACKAGE_TYPE=$DEFAULT_PACKAGE_TYPE 467 | 468 | # This handles ./ocpkg runs, for e.g. `./ocpkg debs` 469 | if [ $1 ] && [ "$SELF_NAME" != "ocpkg" ] ; then 470 | case $1 in 471 | debs) PACKAGE_TYPE=$1 ;; 472 | dev) PACKAGE_TYPE=$1 ;; 473 | demo) PACKAGE_TYPE=$1 ;; 474 | kvm) PACKAGE_TYPE=$1 ;; 475 | min) PACKAGE_TYPE=$1 ;; 476 | local) PACKAGE_TYPE=$1 ;; 477 | docker) PACKAGE_TYPE=$1 ;; 478 | *) MESSAGE="Package type not recognized."; message ; usage ; exit 1 ;; 479 | esac 480 | MESSAGE="Package type: $PACKAGE_TYPE : ${PACKAGE_DESCRIPTION[$PACKAGE_TYPE]}" ; message 481 | fi 482 | 483 | #echo "[otheropts]==> $@" 484 | 485 | # SECTION 3: Error handling & cleanup 486 | 487 | debug() { 488 | MESSAGE="Dropping to debugging chroot prompt..." ; message 489 | chroot $LIVE_SQUASH_UNION /bin/bash -l 490 | } 491 | 492 | cleanup_squash() { 493 | if [ -n "$LIVE_SQUASH_UNION" ]; then 494 | MESSAGE="Cleaning up squash temp space..." ; message 495 | fuser $VERBOSE --mount $LIVE_SQUASH_UNION -kill 496 | sleep $SLEEP_TIME 497 | umount $VERBOSE $LIVE_SQUASH_UNION/var/lib/apt/lists || true 498 | umount $VERBOSE $LIVE_SQUASH_UNION/var/cache/apt/archives || true 499 | umount $VERBOSE $LIVE_SQUASH_UNION/proc || true 500 | umount $VERBOSE $LIVE_SQUASH_UNION/sys || true 501 | umount $VERBOSE $LIVE_SQUASH_UNION/dev/pts || true 502 | umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_BUILD_DIR || true 503 | umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_SOURCE_BRANCH || true 504 | MESSAGE="Killing processes..." ; message 505 | fuser $VERBOSE --mount $LIVE_SQUASH_UNION -kill 506 | sleep $SLEEP_TIME 507 | umount -v -f $VERBOSE $LIVE_SQUASH_UNION || true 508 | rmdir $VERBOSE $LIVE_SQUASH_UNION || true 509 | fi 510 | 511 | if [ -n "$LIVE_SQUASH_DELTA" ]; then 512 | echo " $LIVE_SQUASH_DELTA" 513 | rm -rf $LIVE_SQUASH_DELTA || true 514 | fi 515 | 516 | if [ -n "$UBUNTU_SQUASH_FILES" ]; then 517 | echo " $UBUNTU_SQUASH_FILES" 518 | umount $VERBOSE $UBUNTU_SQUASH_FILES || true 519 | rmdir $VERBOSE $UBUNTU_SQUASH_FILES || true 520 | fi 521 | } 522 | 523 | cleanup_iso() { 524 | if [ -n "$LIVE_ISO_UNION" ] ; then 525 | MESSAGE="Cleaning up ISO temp space..." ; message 526 | echo " $LIVE_ISO_UNION" 527 | umount $VERBOSE $LIVE_ISO_UNION || true 528 | rmdir $LIVE_ISO_UNION || true 529 | df -m $LIVE_ISO_UNION || true 530 | fi 531 | 532 | if [ -n "$LIVE_ISO_DELTA" ] ; then 533 | echo " $LIVE_ISO_DELTA" 534 | rm -rf $LIVE_ISO_DELTA || true 535 | fi 536 | 537 | if [ -n "$UBUNTU_ISO_FILES" ] ; then 538 | echo " $UBUNTU_ISO_FILES" 539 | umount $VERBOSE $UBUNTU_ISO_FILES || true 540 | rmdir $UBUNTU_ISO_FILES || true 541 | df -m $UBUNTU_ISO_FILES || true 542 | fi 543 | } 544 | 545 | exit_trap() { 546 | if [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 547 | MESSAGE="Exiting $SELF_NAME normally..." ; message 548 | cleanup_squash 549 | cleanup_iso 550 | fi 551 | } 552 | 553 | quit_trap() { 554 | if [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 555 | MESSAGE="Exiting $SELF_NAME by request..." ; message 556 | cleanup_squash 557 | cleanup_iso 558 | fi 559 | } 560 | 561 | error_trap() { 562 | if [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 563 | MESSAGE="Error trapped while running $SELF_NAME." ; message 564 | 565 | MESSAGE="Cleanup will run after debug." ; message 566 | debug 567 | cleanup_squash 568 | cleanup_iso 569 | fi 570 | } 571 | 572 | trap error_trap ERR 573 | trap exit_trap EXIT 574 | trap quit_trap INT HUP QUIT TERM 575 | 576 | # SECTION 4: Function Definitions 577 | 578 | is_x68_64() { 579 | ARCH=$(uname -m); 580 | if [ "$ARCH" == "x86_64" ]; then 581 | return 0 582 | else 583 | return 1 584 | fi 585 | } 586 | 587 | get_distro_version() { 588 | cat /etc/os-release | grep "^VERSION_ID=" | cut -d "=" -f 2 589 | } 590 | 591 | UBUNTU_VERSION=$(get_distro_version) 592 | 593 | add_repositories() { 594 | MESSAGE="Adding software repositories..." ; message 595 | for REPO in $REPOSITORIES ; do 596 | sudo apt-add-repository -y $REPO 597 | done 598 | 599 | sudo apt-get $QUIET --assume-yes update 600 | } 601 | 602 | get_github_latest_release() { 603 | local _user="$1" 604 | local _repo="$2" 605 | local _file_name="$3" 606 | 607 | # Getting the version and also accepting the file-name means that the 608 | # download will fail if the release is updated and the file-name has a 609 | # reference to the previous release, a hacky annoying reminder. If the 610 | # file-name has no reference to the version then all will go well. 611 | # TODO: Handle failure gracefully. 612 | local _version=$(curl https://github.com/"$_user"/"$_repo"/releases/latest \ 613 | | cut -d "\"" -f 2 | cut -d "/" -f 8) 614 | echo $_user $_repo $_version 615 | rm -f $_file_name 616 | wget https://github.com/"$_user"/"$_repo"/releases/download/"$_version"/"$_file_name" 617 | } 618 | 619 | install_admin() { 620 | MESSAGE="Installing sysadmin tools...." ; message 621 | if ! sudo apt-get $QUIET --no-upgrade --assume-yes install $PACKAGES_ADMIN ; then 622 | MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 623 | exit 1 624 | fi 625 | } 626 | 627 | # Install given opencog github repo 628 | install_opencog_github_repo() { 629 | local REPO="$1" 630 | MESSAGE="Installing ${REPO}...." ; message 631 | cd /tmp/ 632 | # cleaning up remnants from previous install failures, if any. 633 | rm -rf master.tar.gz* ${REPO}-master 634 | rm -rf master.tar.gz* ${REPO}-main 635 | wget https://github.com/opencog/${REPO}/archive/master.tar.gz 636 | tar -xvf master.tar.gz 637 | 638 | # Newer git repos call them `main` not `master`, cause #RacialJustice 639 | if [ -d ${REPO}-master/ ] 640 | then 641 | cd ${REPO}-master/ 642 | fi 643 | if [ -d ${REPO}-main/ ] 644 | then 645 | cd ${REPO}-main/ 646 | fi 647 | 648 | mkdir build 649 | cd build/ 650 | cmake .. 651 | make -j$(nproc) 652 | sudo make install 653 | sudo ldconfig 654 | cd /tmp/ 655 | rm -rf master.tar.gz ${REPO}-master/ 656 | rm -rf master.tar.gz ${REPO}-main/ 657 | cd $CURRENT_DIR 658 | } 659 | 660 | # Install cogutil 661 | install_cogutil() { 662 | install_opencog_github_repo cogutil 663 | } 664 | 665 | # Install notebooks 666 | install_notebooks() { 667 | MESSAGE="Installing notebooks...." ; message 668 | 669 | 670 | #####INSTALLING pip3 AND jupyter notebook 671 | install_python_pip 672 | cd 673 | sudo pip3 install ipython jupyter 674 | 675 | #####INSTALLING GUILE KERNEL##### 676 | # Check if site folder exits 677 | if [ ! -d "/usr/local/share/guile/site" ] 678 | then 679 | cd /usr/local/share/guile/ 680 | sudo mkdir site 681 | cd 682 | fi 683 | 684 | # Install ZeroMQ library 685 | # ??? Really? Is this really needed? 686 | ## Clean up remenants of previous installations## 687 | rm -rf zeromq-4.2.1* 688 | wget https://github.com/zeromq/libzmq/releases/download/v4.2.1/zeromq-4.2.1.tar.gz 689 | tar xvf zeromq-4.2.1.tar.gz 690 | cd zeromq-4.2.1/ 691 | ./configure 692 | make 693 | sudo make install 694 | cd 695 | 696 | # Install guile-json library 697 | ## Clean up remenants of previous installations## 698 | rm -rf guile-json-0.6.0* 699 | wget http://download.savannah.gnu.org/releases/guile-json/guile-json-0.6.0.tar.gz 700 | tar xvf guile-json-0.6.0.tar.gz 701 | cd guile-json-0.6.0 702 | ./configure --prefix=/usr/local/ 703 | make 704 | sudo make install 705 | cd 706 | 707 | cd `guile -c "(display (%global-site-dir))"` 708 | # Place guile-simple-zmq library to the guile library folder 709 | sudo rm -rf simple-zmq.scm* 710 | sudo wget https://raw.githubusercontent.com/jerry40/guile-simple-zmq/master/src/simple-zmq.scm 711 | #edit simple-zmq.scm => set BUF-SIZE to 8192. 712 | sudo sed -i 's/(define BUF-SIZE.*)/(define BUF-SIZE 8192)/' simple-zmq.scm 713 | cd 714 | 715 | #Kernel setup 716 | if [ ! -d "/home/$USER/.local/share/jupyter/kernels/guile" ] 717 | then 718 | sudo mkdir /home/$USER/.local/share/jupyter/kernels/guile 719 | fi 720 | 721 | cd /home/$USER/.local/share/jupyter/kernels/guile 722 | sudo rm -rf guile-jupyter-kernel.scm hmac.scm kernel.json tools.scm 723 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/guile-jupyter-kernel.scm 724 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/hmac.scm 725 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/kernel.json 726 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/tools.scm 727 | sudo sed -i 's,\/home.*local,'$HOME/.local',' kernel.json 728 | 729 | echo "export PATH=$PATH:/home/$USER/.local/bin" >> /home/$USER/.bashrc 730 | echo "source $HOME/.bashrc" 731 | cd $CURRENT_DIR 732 | } 733 | 734 | # Install additional Python packages 735 | # Except that there aren't any at this time.... 736 | install_opencog_python_packages() { 737 | MESSAGE="Installing base python packages...." ; message 738 | install_python 739 | } 740 | 741 | # Install Haskell Dependencies 742 | install_haskell_dependencies(){ 743 | MESSAGE="Installing haskell dependencies in user space...." ; message 744 | sudo wget -qO- https://get.haskellstack.org/ | sh 745 | 746 | cd /tmp 747 | rm -rf patchelf* 748 | wget "https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2" 749 | tar -jxf patchelf-0.9.tar.bz2 750 | rm patchelf-0.9.tar.bz2 751 | cd patchelf-0.9 752 | ./configure 753 | sudo make install 754 | cd /tmp 755 | rm -rf patchelf-0.9 756 | cd $CURRENT_DIR 757 | } 758 | 759 | # The following sets the source & build directory for a project 760 | set_source_and_build_dir() { 761 | if [ "$(git rev-parse --is-inside-work-tree)" == true ] ; then 762 | SOURCE_DIR=$(git rev-parse --show-toplevel) 763 | MESSAGE="Source Directory is set to $SOURCE_DIR" ; message 764 | if [ -d $SOURCE_DIR/build ]; then 765 | BUILD_DIR=$SOURCE_DIR/build 766 | MESSAGE="Build Directory is set to $SOURCE_DIR/build" ; message 767 | else 768 | mkdir $SOURCE_DIR/build 769 | BUILD_DIR=$SOURCE_DIR/build 770 | MESSAGE="Build Directory is set to $SOURCE_DIR/build" ; message 771 | fi 772 | else 773 | MESSAGE="Exiting $SELF_NAME as git worktree is not detected run inside \ 774 | a git worktree" ; message 775 | exit 1 776 | fi 777 | } 778 | 779 | # Build function for cogutil, atomspace & asmoses repos 780 | build_source() { 781 | set_source_and_build_dir 782 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 783 | rm $BUILD_DIR/CMakeCache.txt 784 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 785 | fi 786 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 787 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 788 | cmake -B$BUILD_DIR -H$SOURCE_DIR 789 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS" ; message 790 | make -C $BUILD_DIR -j$MAKE_JOBS 791 | MESSAGE="Finished building source" ; message 792 | } 793 | 794 | # Build examples function for atomspace & asmoses repos 795 | build_examples() { 796 | set_source_and_build_dir 797 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 798 | rm $BUILD_DIR/CMakeCache.txt 799 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 800 | fi 801 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 802 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 803 | cmake -B$BUILD_DIR -H$SOURCE_DIR 804 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS examples" ; message 805 | make -C $BUILD_DIR -j$MAKE_JOBS examples 806 | MESSAGE="Finished building examples" ; message 807 | } 808 | 809 | # Run tests function for cogutil, atomspace & asmoses repos 810 | test_source() { 811 | set_source_and_build_dir 812 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 813 | rm $BUILD_DIR/CMakeCache.txt 814 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 815 | fi 816 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 817 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 818 | cmake -B$BUILD_DIR -H$SOURCE_DIR 819 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS test" ; message 820 | make -C $BUILD_DIR -j$MAKE_JOBS test #ARGS=-j$MAKE_JOBS 821 | MESSAGE="Finished building & running tests" ; message 822 | } 823 | 824 | # Install build job artifacts 825 | install_build() { 826 | set_source_and_build_dir 827 | MESSAGE="Starting installation" ; message 828 | cd $BUILD_DIR 829 | sudo make install 830 | sudo ldconfig 831 | cd $CURRENT_DIR 832 | MESSAGE="Finished installation" ; message 833 | } 834 | 835 | # Install Core AtomSpace 836 | install_atomspace(){ 837 | install_opencog_github_repo atomspace 838 | install_opencog_github_repo atomspace-storage 839 | install_opencog_github_repo atomspace-pgres 840 | install_opencog_github_repo atomspace-rocks 841 | install_opencog_github_repo atomspace-cog 842 | install_opencog_github_repo cogserver 843 | install_opencog_github_repo unify 844 | install_opencog_github_repo sensory 845 | install_opencog_github_repo motor 846 | } 847 | 848 | # Install Language components 849 | # This requires a re-install of Link Grammar, after the AtomSpace 850 | # and after lg-atomese have been installed, because Link Grammar 851 | # now uses the AtomSpace to hold dictionaries, and the lg-atomese 852 | # Atom types to do it. 853 | install_language() { 854 | install_opencog_github_repo lg-atomese 855 | install_link_grammar 856 | install_opencog_github_repo matrix 857 | install_opencog_github_repo learn 858 | install_opencog_github_repo generate 859 | install_opencog_github_repo vision 860 | } 861 | 862 | # Install all of OpenCog 863 | install_opencog() { 864 | install_language 865 | install_opencog_github_repo ure 866 | install_opencog_github_repo attention 867 | install_opencog_github_repo spacetime 868 | install_opencog_github_repo pln 869 | install_opencog_github_repo miner 870 | install_opencog_github_repo asmoses 871 | install_opencog_github_repo opencog 872 | install_opencog_github_repo agi-bio 873 | install_opencog_github_repo benchmark 874 | } 875 | 876 | # Install ASMOSES 877 | install_asmoses() { 878 | install_opencog_github_repo asmoses 879 | } 880 | 881 | # Install Link-Grammar 882 | install_link_grammar(){ 883 | # This uses the archive created by github to build and install link-grammar 884 | # The release at https://www.abisource.com/downloads/link-grammar isn't used 885 | # because the only additional value it provides is it gives a pre configured 886 | # tar ball, and its tls certificate breaks often. Such tar-bar can be released 887 | # by following instructions at 888 | # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release 889 | MESSAGE="Installing Link-Grammar...." ; message 890 | cd /tmp/ 891 | 892 | # cleaning up remnants from previous install failures, if any. 893 | rm -rf link-grammar* 894 | rm -rf master.tar.gz 895 | 896 | # Get install version from command line 897 | if [ $# -eq 1 ]; then 898 | local _version=${1} 899 | wget https://github.com/opencog/link-grammar/archive/link-grammar-${_version}.tar.gz 900 | tar -zxf link-grammar-${_version}.tar.gz 901 | cd link-grammar-link-grammar-${_version}/ 902 | 903 | elif [ $INSTALL_LG_MASTER ]; then 904 | 905 | # Master version fails to follow naming convention 906 | local _version="master" 907 | wget https://github.com/opencog/link-grammar/archive/master.tar.gz 908 | tar -zxf master.tar.gz 909 | cd link-grammar-${_version}/ 910 | else 911 | 912 | # Hunt down the latest tarball version. Abisource is dead. 913 | # local _version=$(wget -O - http://www.abisource.com/downloads/link-grammar/current/ \ 914 | # | grep md5 | awk 'match($0, /[5-9]\.[0-9]+\.[0-9]+/) {print substr($0, RSTART, RLENGTH)}') 915 | local _version=$(git ls-remote -t \ 916 | https://github.com/opencog/link-grammar "link-grammar-5*" \ 917 | | grep -v "\^"| cut -d "-" -f 3 | sort -V |tail -n 1 ) 918 | wget https://github.com/opencog/link-grammar/archive/link-grammar-${_version}.tar.gz 919 | tar -zxf link-grammar-${_version}.tar.gz 920 | cd link-grammar-link-grammar-${_version}/ 921 | fi 922 | ./autogen.sh --no-configure 923 | mkdir build 924 | cd build 925 | if [ $INSTALL_JAVA_LINK_GRAMMAR ]; then 926 | ../configure 927 | else 928 | ../configure --disable-java-bindings 929 | fi 930 | make -j$(nproc) 931 | sudo make install 932 | sudo ldconfig 933 | cd /tmp/ 934 | rm -rf link-grammar* 935 | rm -rf master.tar.gz 936 | cd $CURRENT_DIR 937 | } 938 | 939 | install_bdwgc() { 940 | MESSAGE="Installing latest bdwgc ...." ; message 941 | # This used to work, but not any longer...!? 942 | # Apparently, the newest versions of curl behave differently!? 943 | # local _version=$(curl https://github.com/ivmai/bdwgc/releases/latest \ 944 | # | cut -d "\"" -f 2 | cut -d "/" -f 8) 945 | local _version=$(curl --silent -w %{redirect_url} https://github.com/ivmai/bdwgc/releases/latest \ 946 | | cut -d "\"" -f 2 | cut -d "/" -f 8) 947 | 948 | local _dir_name="gc-${_version:1}" 949 | 950 | # Apparently, the github download URL's have changed. 951 | local _file_name="${_dir_name}.tar.gz" 952 | local _download_name="${_version}/${_dir_name}.tar.gz" 953 | 954 | cd /tmp/ 955 | rm -rf ${_dir_name}* 956 | get_github_latest_release ivmai bdwgc ${_download_name} 957 | tar -xvf ${_file_name} 958 | cd ${_dir_name} 959 | ./configure --enable-large-config 960 | make -j$(nproc) 961 | sudo make install 962 | sudo ldconfig 963 | cd /tmp/ 964 | rm -rf ${_dir_name}* 965 | } 966 | 967 | install_python() { 968 | MESSAGE="Installing python3 ...." ; message 969 | sudo apt-get install -y --no-install-recommends python3-dev python3-dev 970 | 971 | if [[ "$UBUNTU_VERSION" = "\"20.04\"" ]]; then 972 | sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2 973 | sudo apt-get install -y --no-install-recommends python3-nose cython3 974 | fi 975 | if [[ "$UBUNTU_VERSION" = "\"22.04\"" ]]; then 976 | sudo apt-get install -y --no-install-recommends python3-nose cython3 977 | fi 978 | if [[ "$UBUNTU_VERSION" = "\"24.04\"" ]]; then 979 | sudo apt-get install -y --no-install-recommends python3-nose cython3 980 | fi 981 | } 982 | 983 | # Install pip seperately. The problem here is that installing pip 984 | # breaks python in ways that I cannot figure out. So punt, until some 985 | # python guru shows up and fixes this stuff. 986 | install_python_pip() { 987 | MESSAGE="Installing python3 pip...." ; message 988 | sudo apt-get install -y --no-install-recommends python3-pip 989 | sudo pip3 install -U pip setuptools 990 | } 991 | 992 | 993 | install_guile() { 994 | install_bdwgc 995 | MESSAGE="Installing guile-$GUILEVERSION...." ; message 996 | cd /tmp/ 997 | # Clean up remnants from previous install failures, if any. 998 | rm -rf guile-${GUILEVERSION}* 999 | wget https://ftp.gnu.org/gnu/guile/guile-$GUILEVERSION.tar.gz 1000 | tar -xvf guile-$GUILEVERSION.tar.gz 1001 | cd guile-$GUILEVERSION 1002 | mkdir build 1003 | cd build 1004 | ../configure 1005 | make -j$(nproc) 1006 | sudo make install 1007 | sudo mv /usr/local/lib/libguile-*.so.*-gdb.scm /usr/share/gdb/auto-load/ 1008 | sudo ldconfig 1009 | cd /tmp/ 1010 | rm -rf guile-${GUILEVERSION}* 1011 | } 1012 | 1013 | # atomspace unit tests have UTF-8 test cases 1014 | # link-grammar needs a smattering of locales 1015 | ensure_UTF_installed() { 1016 | if locale -a | grep -q en_US.utf8 1017 | then 1018 | echo UTF-8 locale enabled already 1019 | else 1020 | sudo sh -c 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' 1021 | sudo sh -c 'echo "ar_AE.UTF-8 UTF-8" >> /etc/locale.gen' 1022 | sudo sh -c 'echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen' 1023 | sudo sh -c 'echo "fa_IR.UTF-8 UTF-8" >> /etc/locale.gen' 1024 | sudo sh -c 'echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen' 1025 | sudo sh -c 'echo "he_IL.UTF-8 UTF-8" >> /etc/locale.gen' 1026 | sudo sh -c 'echo "id_ID.UTF-8 UTF-8" >> /etc/locale.gen' 1027 | sudo sh -c 'echo "kk_KZ.UTF-8 UTF-8" >> /etc/locale.gen' 1028 | sudo sh -c 'echo "lt_LT.UTF-8 UTF-8" >> /etc/locale.gen' 1029 | sudo sh -c 'echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen' 1030 | sudo sh -c 'echo "th_TH.UTF-8 UTF-8" >> /etc/locale.gen' 1031 | sudo sh -c 'echo "tr_TR.UTF-8 UTF-8" >> /etc/locale.gen' 1032 | sudo sh -c 'echo "vi_VN.UTF-8 UTF-8" >> /etc/locale.gen' 1033 | sudo sh -c 'echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen' 1034 | sudo sh -c 'echo "zh_HK.UTF-8 UTF-8" >> /etc/locale.gen' 1035 | sudo locale-gen 1036 | fi 1037 | } 1038 | 1039 | # In Ubuntu 18.04 some links are absent when build-essential and ccache 1040 | # packages are installed by same apt-get command 1041 | update_ccache_links() { 1042 | sudo update-ccache-symlinks 1043 | } 1044 | 1045 | # Install system dependencies 1046 | install_dependencies() { 1047 | # Install the latest python3 version before everything else 1048 | install_python 1049 | 1050 | MESSAGE="Installing OpenCog build dependencies...." ; message 1051 | if ! sudo apt-get $QUIET --no-upgrade --assume-yes --no-install-recommends install $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_FETCH liboctomap-dev locales ; then 1052 | exit 1 1053 | fi 1054 | ensure_UTF_installed 1055 | 1056 | # Update ccache links 1057 | update_ccache_links 1058 | 1059 | # Install guile >3.0.0 also install bdwgc for language-learning 1060 | install_guile 1061 | } 1062 | 1063 | # Download data 1064 | download_data() { 1065 | DOWNLOAD_DIR="$HOME/.opencog/data" 1066 | MESSAGE="Downloading OpenCog's datasets to $DOWNLOAD_DIR ...." ; message 1067 | if [ ! -d "$DOWNLOAD_DIR" ]; then 1068 | mkdir -p "$DOWNLOAD_DIR" 1069 | fi 1070 | 1071 | if [ ! -f "$DOWNLOAD_DIR/gtwc-en-333333-words.scm" ]; then 1072 | wget -O "$DOWNLOAD_DIR/gtwc-en-333333-words.scm" \ 1073 | https://raw.githubusercontent.com/opencog/test-datasets/master/concept_nodes/gtwc-en-333333-words.scm 1074 | fi 1075 | } 1076 | 1077 | update_opencog_source() { 1078 | if sudo apt-get --no-upgrade --assume-yes $QUIET install $PACKAGES_FETCH ; then 1079 | echo -n 1080 | else 1081 | MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 1082 | exit 1 1083 | fi 1084 | OPENCOG_SOURCE_DIR=$LIVE_SOURCE_BRANCH 1085 | mkdir -p $OPENCOG_SOURCE_DIR || true 1086 | if [ ! "$(ls -A $OPENCOG_SOURCE_DIR/.git)" ]; then 1087 | MESSAGE="Fetching OpenCog source at $OPENCOG_SOURCE_DIR..." ; message 1088 | git clone https://github.com/opencog/opencog $OPENCOG_SOURCE_DIR 1089 | else 1090 | if [ $UPDATE_OPENCOG ] ; then 1091 | MESSAGE="Updating OpenCog source at $OPENCOG_SOURCE_DIR..." ; message 1092 | cd $OPENCOG_SOURCE_DIR 1093 | git pull 1094 | cd - 1095 | fi 1096 | fi 1097 | } 1098 | 1099 | build_opencog() { 1100 | mkdir -p -v $LIVE_BUILD_DIR || true 1101 | cd $LIVE_BUILD_DIR 1102 | MESSAGE="cmake $LIVE_SOURCE_BRANCH" ; message 1103 | cmake $LIVE_SOURCE_BRANCH 1104 | MESSAGE="make -j$MAKE_JOBS" ; message 1105 | make -j$MAKE_JOBS 1106 | 1107 | if [ $TEST_OPENCOG ] ; then 1108 | make test 1109 | fi 1110 | 1111 | case $PACKAGE_TYPE in 1112 | min) MESSAGE="Installing OpenCog..." ; message 1113 | make install; exit 0;; 1114 | demo) MESSAGE="Installing OpenCog..." ; message 1115 | make install; exit 0;; 1116 | dev) exit 0;; 1117 | esac 1118 | 1119 | } 1120 | 1121 | locate_live_iso() { 1122 | if [ $INPUT_ISO_NAME ]; then 1123 | MESSAGE="Using Ubuntu image specified at $INPUT_ISO_NAME" ; message 1124 | UBUNTU_ISO_IMAGE=$INPUT_ISO_NAME 1125 | else 1126 | UBUNTU_LOCATIONS=$(locate --existing --basename "\\$UBUNTU_ISO" | grep $HOME) 1127 | for LOC in $UBUNTU_LOCATIONS ; do 1128 | MESSAGE="Ubuntu image found at $LOC. Checksumming, please wait..." ; message 1129 | LOC_MD5SUM=$(md5sum $LOC | awk '{print $1}') 1130 | if [ "$LOC_MD5SUM" == "$UBUNTU_MD5SUM" ] ; then 1131 | UBUNTU_ISO_IMAGE=$LOC 1132 | MESSAGE="Using image found at $UBUNTU_ISO_IMAGE." ; message 1133 | break 1134 | else 1135 | MESSAGE="...checksum failed." ; message 1136 | fi 1137 | done 1138 | fi 1139 | if [ ! -f $UBUNTU_ISO_IMAGE ] ; then 1140 | #aria2c --seed-time=0 ${UBUNTU_URL}${UBUNTU_ISO}.torrent 1141 | UBUNTU_ISO_IMAGE=${UBUNTU_ISO} 1142 | fi 1143 | } 1144 | 1145 | remove_packages() { 1146 | MESSAGE="$PACKAGE_TYPE install type: Removing unecessary packages..." ; message 1147 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes $QUIET purge $PACKAGES_REMOVE --auto-remove 1148 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes $QUIET autoremove 1149 | # stupid stupid stupid hack 1150 | chroot $LIVE_SQUASH_UNION service cups stop 1151 | } 1152 | 1153 | reinstall_removed() { 1154 | MESSAGE="Re-installing removed packages..." ; message 1155 | apt-get --no-upgrade --assume-yes $QUIET install $PACKAGES_REMOVE 1156 | } 1157 | 1158 | keep_source() { 1159 | MESSAGE="$PACKAGE_TYPE install type: Keeping source code..." ; message 1160 | chroot $LIVE_SQUASH_UNION chown -R 999 $LIVE_SOURCE_BRANCH $LIVE_BUILD_DIR || true 1161 | chroot $LIVE_SQUASH_UNION mkdir -p /home/$LIVE_USERNAME/Desktop/ || true 1162 | chroot $LIVE_SQUASH_UNION ln -s "$LIVE_SOURCE_BRANCH" "/home/$LIVE_USERNAME/Desktop/$LIVE_DESKTOP_SOURCE" || true 1163 | } 1164 | 1165 | remove_source() { 1166 | MESSASGE="$PACKAGE_TYPE install type: Removing source code..." ; message 1167 | chroot $LIVE_SQUASH_UNION umount $VERBOSE $LIVE_SOURCE_BRANCH 1168 | } 1169 | 1170 | remove_build() { 1171 | MESSAGE="$PACKAGE_TYPE install type: Removing build files..." ; message 1172 | echo umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_BUILD_DIR 1173 | umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_BUILD_DIR || true 1174 | rm -rf $LIVE_SQUASH_UNION$LIVE_BUILD_DIR || true 1175 | } 1176 | 1177 | remove_dev_debs() { 1178 | MESSAGE="$PACKAGE_TYPE install type: Removing development packages..." ; message 1179 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes purge $PACKAGES_BUILD $PACKAGES_EXDEV --auto-remove 1180 | chroot $LIVE_SQUASH_UNION apt-get $QUIET autoremove --assume-yes 1181 | } 1182 | 1183 | remove_doc_debs() { 1184 | MESSAGE="$PACKAGE_TYPE install type: Removing documentation packages..." ; message 1185 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes purge $PACKAGES_DOC --auto-remove 1186 | chroot $LIVE_SQUASH_UNION apt-get $QUIET autoremove --assume-yes 1187 | } 1188 | 1189 | install_package_tools() { 1190 | MESSAGE="Installing packaging tools..." ; message 1191 | if sudo apt-get --no-upgrade --assume-yes $QUIET -y install $PACKAGES_TOOLS ; then 1192 | echo -n 1193 | else 1194 | MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 1195 | exit 1 1196 | fi 1197 | } 1198 | 1199 | mount_live_iso() { 1200 | MESSAGE="Mounting Ubuntu ISO image..." ; message 1201 | 1202 | UBUNTU_ISO_FILES=$(mktemp -d --suffix=.UBUNTU_ISO_FILES) 1203 | mount $VERBOSE -o ro -o loop -t iso9660 $UBUNTU_ISO_IMAGE $UBUNTU_ISO_FILES 1204 | 1205 | MESSAGE="Mounting Ubuntu compressed filesystem..." ; message 1206 | 1207 | UBUNTU_SQUASH_BLOB="$UBUNTU_ISO_FILES/casper/filesystem.squashfs" 1208 | 1209 | if ! [ -e "$UBUNTU_SQUASH_BLOB" ] ; then 1210 | MESSAGE="Could not find the Ubuntu squashfs at '$UBUNTU_SQUASH_BLOB'." ; message 1211 | umount $VERBOSE $UBUNTU_ISO_FILES || true 1212 | exit 1 1213 | fi 1214 | 1215 | LIVE_ISO_DELTA=$(mktemp -d --suffix=.LIVE_ISO_DELTA) 1216 | LIVE_ISO_UNION=$(mktemp -d --suffix=.LIVE_ISO_UNION) 1217 | mount $VERBOSE -t overlayfs -o upperdir=$LIVE_ISO_DELTA,lowerdir=$UBUNTU_ISO_FILES none $LIVE_ISO_UNION 1218 | 1219 | #MESSAGE="Mounting read-only Ubuntu compressed filesystem..." ; message 1220 | 1221 | UBUNTU_SQUASH_FILES=$(mktemp -d --suffix=.UBUNTU_SQUASH_FILES) 1222 | mount $VERBOSE -o loop -t squashfs $UBUNTU_SQUASH_BLOB $UBUNTU_SQUASH_FILES 1223 | 1224 | #MESSAGE="Creating temporary workplace for remastering new compressed files..." ; message 1225 | 1226 | LIVE_SQUASH_DELTA=$(mktemp -d --suffix=.LIVE_SQUASH_DELTA) 1227 | LIVE_SQUASH_UNION=$(mktemp -d --suffix=.LIVE_SQUASH_UNION) 1228 | mount $VERBOSE -t overlayfs -o upperdir=$LIVE_SQUASH_DELTA,lowerdir=$UBUNTU_SQUASH_FILES none $LIVE_SQUASH_UNION 1229 | chmod +rx $LIVE_SQUASH_UNION 1230 | 1231 | MESSAGE="Setting up chroot environment..." ; message 1232 | 1233 | DISTRIB_ID=$(awk '/DISTRIB_ID=/' $LIVE_SQUASH_UNION/etc/lsb-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]') 1234 | DISTRIB_CODENAME=$(awk '/DISTRIB_CODENAME=/' $LIVE_SQUASH_UNION/etc/lsb-release | sed 's/DISTRIB_CODENAME=//' | tr '[:upper:]' '[:lower:]') 1235 | LIVE_USERNAME=$DISTRIB_ID 1236 | LIVE_BUILD_DIR=/home/$LIVE_USERNAME/build 1237 | 1238 | cp $LIVE_SQUASH_UNION/etc/resolv.conf $LIVE_SQUASH_UNION/etc/resolv.conf.bak || true 1239 | cp $LIVE_SQUASH_UNION/etc/apt/sources.list $LIVE_SQUASH_UNION/etc/apt/sources.list.bak || true 1240 | cp /etc/resolv.conf $LIVE_SQUASH_UNION/etc 1241 | cp /etc/apt/sources.list $LIVE_SQUASH_UNION/etc/apt 1242 | if [ -f /etc/apt/apt.conf.d/01apt-cacher-ng-proxy ] ; then 1243 | cp /etc/apt/apt.conf.d/01apt-cacher-ng-proxy $LIVE_SQUASH_UNION/etc/apt/apt.conf.d/01apt-cacher-ng-proxy 1244 | fi 1245 | 1246 | cp $0 $LIVE_SQUASH_UNION$PATH_PREFIX/bin/$SELF_NAME ; chmod ugo+rx $LIVE_SQUASH_UNION$PATH_PREFIX/bin/$SELF_NAME 1247 | cd $LIVE_SQUASH_UNION$PATH_PREFIX/bin 1248 | ln -s $SELF_NAME $TOOL_NAME 1249 | cd $CURRENT_DIR 1250 | 1251 | MESSAGE="Mounting filesystems..." ; message 1252 | 1253 | chroot $LIVE_SQUASH_UNION mount $VERBOSE -t proc none /proc 1254 | chroot $LIVE_SQUASH_UNION mount $VERBOSE -t sysfs none /sys 1255 | chroot $LIVE_SQUASH_UNION mount $VERBOSE -t devpts none /dev/pts 1256 | 1257 | mkdir -p $LIVE_SQUASH_UNION/var/cache/apt/archives 1258 | mkdir -p $LIVE_SQUASH_UNION/var/lib/apt/lists 1259 | mkdir -p $HOST_SOURCE_BRANCH 1260 | mkdir -p $LIVE_SQUASH_UNION/$LIVE_SOURCE_BRANCH 1261 | 1262 | mount $VERBOSE -o bind /var/cache/apt/archives $LIVE_SQUASH_UNION/var/cache/apt/archives 1263 | mount $VERBOSE -o bind /var/lib/apt/lists $LIVE_SQUASH_UNION/var/lib/apt/lists 1264 | mount $VERBOSE -o bind $HOST_SOURCE_BRANCH $LIVE_SQUASH_UNION/$LIVE_SOURCE_BRANCH 1265 | } 1266 | 1267 | prepare_live_iso() { 1268 | 1269 | fuser $VERBOSE --mount $LIVE_SQUASH_UNION -kill 1270 | sleep $SLEEP_TIME 1271 | umount $VERBOSE $LIVE_SQUASH_UNION/proc || true 1272 | umount $VERBOSE $LIVE_SQUASH_UNION/sys || true 1273 | umount $VERBOSE $LIVE_SQUASH_UNION/dev/pts|| true 1274 | umount $VERBOSE $LIVE_SQUASH_UNION/var/lib/apt/lists || true 1275 | umount $VERBOSE $LIVE_SQUASH_UNION/var/cache/apt/archives || true 1276 | 1277 | #replace original config files 1278 | cp $LIVE_SQUASH_UNION/etc/resolv.conf.bak $LIVE_SQUASH_UNION/etc/resolv.conf || true 1279 | cp $LIVE_SQUASH_UNION/etc/apt/sources.list.bak $LIVE_SQUASH_UNION/etc/apt/sources.list || true 1280 | 1281 | if [ -f $LIVE_SQUASH_UNION/etc/apt/apt.conf.d/01apt-cacher-ng-proxy ]; then 1282 | rm $LIVE_SQUASH_UNION/etc/apt/apt.conf.d/01apt-cacher-ng-proxy 1283 | fi 1284 | } 1285 | 1286 | write_live_media() { 1287 | MESSAGE="Creating new compressed filesystem..." ; message 1288 | mksquashfs $LIVE_SQUASH_UNION $LIVE_ISO_UNION/casper/filesystem.squashfs $SQUASHFS_OPTIONS 1289 | printf $(sudo du -sx --block-size=1 $LIVE_SQUASH_UNION | cut -f1) > $LIVE_ISO_UNION/casper/filesystem.size 1290 | MESSAGE="Creating new bootable ISO image..." ; message 1291 | mkisofs -D -r -V $OUTPUT_ISO_LOCATION/$OUTPUT_ISO_NAME -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o "$OUTPUT_ISO_LOCATION/$OUTPUT_ISO_NAME" $LIVE_ISO_UNION 1292 | MESSAGE="Wrote $(du -sm $OUTPUT_ISO_LOCATION/$OUTPUT_ISO_NAME)MB ..." ; message 1293 | chown $VERBOSE $SUDO_USER $OUTPUT_ISO_LOCATION/$OUTPUT_ISO_NAME 1294 | cleanup_squash 1295 | cleanup_iso 1296 | } 1297 | 1298 | # SECTION 5: Main Program (MAIN main) 1299 | 1300 | # This is mainly for configuring workspaces depending on the type 1301 | # of project being worked on. The order here matters. 1302 | if [ "$SELF_NAME" == "$TOOL_NAME" ] ; then 1303 | if [ $UNKNOWN_FLAGS ] ; then usage; exit 1 ; fi 1304 | if [ $NO_ARGS ] ; then usage; exit 1 ; fi 1305 | if [ $ADD_REPOSITORIES ] ; then add_repositories ; fi 1306 | if [ $INSTALL_DEPENDENCIES ] ; then install_dependencies ; fi 1307 | if [ $DOWNLOAD_DATA ] ; then download_data ; fi 1308 | if [ $HASKELL_STACK_SETUP ] ; then install_haskell_dependencies ; fi 1309 | if [ $INSTALL_OPENCOG_PYTHON_PACKAGES ] ; then install_opencog_python_packages ; fi 1310 | if [ $INSTALL_COGUTIL ] ; then install_cogutil ; fi 1311 | if [ $INSTALL_ATOMSPACE ] ; then install_atomspace ; fi 1312 | if [ $INSTALL_LANGUAGE ] ; then install_language ; fi 1313 | if [ $INSTALL_FROM_REPO ] ; then install_opencog_github_repo "$INSTALL_FROM_REPO" ; fi 1314 | if [ $INSTALL_NOTEBOOKS ] ; then install_notebooks ; fi 1315 | if [ $INSTALL_OPENCOG ] ; then install_opencog ; fi 1316 | if [ $INSTALL_LINK_GRAMMAR ] ; then install_link_grammar ; fi 1317 | if [ $INSTALL_ASMOSES ] ; then install_asmoses ; fi 1318 | if [ $INSTALL_GUILE ] ; then install_guile ; fi 1319 | if [ $BUILD_SOURCE ] ; then build_source ; fi 1320 | if [ $INSTALL_NOTEBOOKS ] ; then install_notebooks ; fi 1321 | if [ $BUILD_EXAMPLES ] ; then build_examples ; fi 1322 | if [ $TEST_SOURCE ] ; then test_source ; fi 1323 | if [ $INSTALL_BUILD ] ; then install_build ; fi 1324 | exit 0 1325 | fi 1326 | 1327 | # option flag conditionals are finished, so set defaults 1328 | 1329 | if [ ! $ADD_REPOSITORIES ] ; then ADD_REPOSITORIES=$DEFAULT_ADD_REPOSITORIES; fi 1330 | if [ ! $INSTALL_DEPENDENCIES ] ; then INSTALL_DEPENDENCIES=$DEFAULT_INSTALL_DEPENDENCIES; fi 1331 | if [ ! $UPDATE_OPENCOG ] ; then UPDATE_OPENCOG=$DEFAULT_UPDATE_OPENCOG; fi 1332 | if [ ! $BUILD_OPENCOG ] ; then BUILD_OPENCOG=$DEFAULT_BUILD_OPENCOG; fi 1333 | if [ ! $TEST_OPENCOG ] ; then TEST_OPENCOG=$DEFAULT_TEST_OPENCOG; fi 1334 | 1335 | # package type selected when invoked as 'ocpkg' 1336 | 1337 | case $PACKAGE_TYPE in 1338 | demo) install_package_tools; locate_live_iso ; mount_live_iso ; remove_packages ;; 1339 | min) install_package_tools; locate_live_iso ; mount_live_iso ; remove_packages ;; 1340 | dev) install_package_tools; locate_live_iso ; mount_live_iso 1341 | MESSAGE="$PACKAGE_TYPE install type: Keeping all Ubuntu packages..." ; message ;; 1342 | esac 1343 | 1344 | case $PACKAGE_TYPE in 1345 | local) add_repositories ; install_dependencies ;; 1346 | demo) chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -a -d ;; 1347 | min) chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -a -d ;; 1348 | dev) chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -a -d ;; 1349 | esac 1350 | 1351 | case $PACKAGE_TYPE in 1352 | local) if [ $UPDATE_OPENCOG ] ; then update_opencog_source ; fi ;; 1353 | demo) if [ $UPDATE_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -u ; fi ;; 1354 | min) if [ $UPDATE_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -u ; fi ;; 1355 | dev) if [ $UPDATE_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -u ; fi ;; 1356 | esac 1357 | 1358 | case $PACKAGE_TYPE in 1359 | local) if [ $BUILD_OPENCOG ] ; then build_opencog ; fi ;; 1360 | demo) if [ $BUILD_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -b ; fi ;; 1361 | min) if [ $BUILD_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -b ; fi ;; 1362 | dev) if [ $BUILD_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -b ; fi ;; 1363 | esac 1364 | 1365 | case $PACKAGE_TYPE in 1366 | min) remove_dev_debs ; remove_doc_debs ; remove_source ; remove_build ;; 1367 | demo) remove_dev_debs ; remove_doc_debs ; remove_source ; remove_build ;; 1368 | dev) keep_source ;; 1369 | esac 1370 | 1371 | case $PACKAGE_TYPE in 1372 | min) prepare_live_iso ; write_live_media ;; 1373 | demo) prepare_live_iso ; write_live_media ;; 1374 | dev) prepare_live_iso ; write_live_media ;; 1375 | esac 1376 | -------------------------------------------------------------------------------- /octool-wip: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | ## @file octool 4 | ## @copyright OpenCog Foundation 2016 5 | ## @section DESCRIPTION A script to download, build, test, install and 6 | ## configure OpenCog projects 7 | 8 | # trap errors 9 | set -e 10 | 11 | SELF_NAME=$(basename $0) 12 | PROCESSORS=$(grep "^processor" /proc/cpuinfo | wc -l) 13 | MAKE_JOBS=$(($PROCESSORS+0)) 14 | 15 | VERBOSE="-v" 16 | QUIET="-qq" 17 | 18 | REPOSITORIES="" 19 | 20 | PACKAGES_FETCH=" 21 | python-pip \ 22 | git \ 23 | wget \ 24 | " 25 | 26 | PACKAGES_BUILD=" 27 | build-essential \ 28 | cmake \ 29 | cxxtest \ 30 | rlwrap \ 31 | guile-2.0-dev \ 32 | libiberty-dev \ 33 | libicu-dev \ 34 | libbz2-dev \ 35 | cython \ 36 | python-dev \ 37 | python-zmq \ 38 | python-simplejson \ 39 | libboost-date-time-dev \ 40 | libboost-filesystem-dev \ 41 | libboost-math-dev \ 42 | libboost-program-options-dev \ 43 | libboost-regex-dev \ 44 | libboost-serialization-dev \ 45 | libboost-thread-dev \ 46 | libboost-system-dev \ 47 | libboost-random-dev \ 48 | libjson-spirit-dev \ 49 | libzmq3-dev \ 50 | libtbb-dev \ 51 | binutils-dev \ 52 | unixodbc-dev \ 53 | libpq-dev\ 54 | uuid-dev \ 55 | libprotoc-dev \ 56 | protobuf-compiler \ 57 | libsdl-gfx1.2-dev \ 58 | libssl-dev \ 59 | tcl-dev \ 60 | tcsh \ 61 | libfreetype6-dev \ 62 | libatlas-base-dev \ 63 | gfortran \ 64 | libgearman-dev \ 65 | ros-indigo-octomap \ 66 | ccache \ 67 | libgsasl7 \ 68 | libldap2-dev \ 69 | krb5-multidev \ 70 | " 71 | 72 | PACKAGES_RUNTIME=" 73 | unixodbc \ 74 | odbc-postgresql \ 75 | postgresql-client \ 76 | gearman \ 77 | " 78 | 79 | # OpenCog's cmake configured projects. These are mainly C++ projects. 80 | OPENCOG_CMAKE_PROJECTS=(cogutil atomspace opencog moses ros-behavior-scripting) 81 | 82 | message() { 83 | printf "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m \n" 84 | } 85 | 86 | is_x68_64() { 87 | ARCH=$(uname -m); 88 | if [ "$ARCH" == "x86_64" ]; then 89 | return 0 90 | else 91 | return 1 92 | fi 93 | } 94 | 95 | add_stack_repository() { 96 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 575159689BEFB442 97 | echo 'deb http://download.fpcomplete.com/ubuntu trusty main'|sudo tee /etc/apt/sources.list.d/fpco.list 98 | } 99 | 100 | add_repositories() { 101 | MESSAGE="Adding software repositories..." ; message 102 | for REPO in $REPOSITORIES ; do 103 | sudo apt-add-repository -y $REPO 104 | done 105 | 106 | # Ros repository for opencog/opencog repo 107 | sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list' 108 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B01FA116 109 | sudo apt-get $QUIET --assume-yes update 110 | } 111 | 112 | # Install Python Packages 113 | install_opencog_python_packages(){ 114 | MESSAGE="Installing python packages...." ; message 115 | cd /tmp 116 | # cleaning up remnants from previous install failures, if any. 117 | rm -f requirements.txt* 118 | wget https://raw.githubusercontent.com/opencog/opencog/master/opencog/python/requirements.txt 119 | # scipy, numpy & matplotlib if installed using python-pip will take a 120 | # long time as they have to be built before being installed. And the 121 | # arrifacts of the build occupies a lot of space blotting the docker image. 122 | # Thus instead a system instllation is made. 123 | sudo pip install -U $(awk '!/scipy/&&!/numpy/&&!/matplotlib/' requirements.txt) 124 | sudo apt-get install -y python-matplotlib python-numpy python-scipy 125 | rm -f requirements.txt* 126 | cd $CURRENT_DIR 127 | } 128 | 129 | # Install Haskell Dependencies 130 | install_haskell_dependencies(){ 131 | if ! is_x68_64; then 132 | MESSAGE="Installing stack for haskell "; message 133 | # Just in case curl isn't installed 134 | sudo apt-get install -y curl 135 | cd /tmp 136 | rm -rf stack* 137 | wget $(curl -s https://api.github.com/repos/commercialhaskell/stack/releases/latest | awk '/browser_download_url/&&/i386-linux.tar.gz/' | head -n 1 | cut -d '"' -f 4) 138 | tar xfz stack*i386-linux.tar.gz 139 | rm stack*i386-linux.tar.gz 140 | mv stack* stack 141 | chmod 755 stack 142 | sudo mv stack /usr/bin/stack 143 | rm -f stack* 144 | cd $CURRENT_DIR 145 | else 146 | MESSAGE="Installing haskell dependencies in user space...." ; message 147 | # Install stack. 148 | add_stack_repository 149 | sudo apt-get update && sudo apt-get $QUIET -y install stack 150 | fi 151 | 152 | cd /tmp 153 | rm -rf patchelf* 154 | wget "https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2" 155 | tar -jxf patchelf-0.9.tar.bz2 156 | rm patchelf-0.9.tar.bz2 157 | cd patchelf-0.9 158 | ./configure 159 | sudo make install 160 | cd /tmp 161 | rm -rf patchelf-0.9 162 | cd $CURRENT_DIR 163 | 164 | # Notes 165 | # 1. Stack setup must me run in user space: 166 | # "stack setup" looks for proper ghc version in the system according to 167 | # the information provided by stack.yaml. If it is not installed, it 168 | # attempts to install proper ghc version on user space (~/.stack/...). 169 | # Because of that, it must not be run as root. 170 | # 2. Difference b/n .cabal and stack.yaml: 171 | # The .cabal file contains package metadata, in this case 172 | # "opencog-atomspace.cabal" contains information of the opencog-atomspace 173 | # package (autor, license, dependencies, etc.). The stack.yaml file 174 | # contains configuration options for the stack building tool, we use it 175 | # to set the proper "long term support" snapshot that we are using, 176 | # which determines the proper ghc version to use, etc. In this case, it 177 | # doesn't make sense to require the .cabal file, because we are not 178 | # using that information to build the hscolour package, but it looks 179 | # like stack always looks for a .cabal file when building, even though, 180 | # in this case, it doesn't use it. 181 | if [ "$EUID" -ne 0 ] ; then 182 | cd /tmp 183 | wget https://raw.githubusercontent.com/opencog/atomspace/master/opencog/haskell/stack.yaml 184 | wget https://raw.githubusercontent.com/opencog/atomspace/master/opencog/haskell/opencog-atomspace.cabal 185 | stack --allow-different-user setup 186 | 187 | # hscolour is necessary for haddock documentation. 188 | stack --allow-different-user build hscolour --copy-bins 189 | rm stack.yaml opencog-atomspace.cabal 190 | cd $CURRENT_DIR 191 | else 192 | printf "Please run without sudo. Stack need to be run in non-root user space." 193 | exit 1 194 | fi 195 | } 196 | 197 | # Checks if the given argument is a name one of opencog's c++ projects. 198 | # 199 | # $1 = project name 200 | is_opencog_cmake_project() { 201 | for i in "${OPENCOG_CMAKE_PROJECTS[@]}" ; do 202 | if [ "$i" == "$1" ] ; then 203 | return 0 204 | fi 205 | done 206 | 207 | return 1 208 | } 209 | 210 | # Checks if the given argument is a path to the root of one of opencog's c++ 211 | # projects. 212 | # 213 | # $1 = path to a directory 214 | is_opencog_cmake_project_root() { 215 | local DIR_NAME=${1##*/} 216 | local DIR_NAME=${DIR_NAME%-master} 217 | 218 | for i in "${OPENCOG_CMAKE_PROJECTS[@]}" ; do 219 | if [ "$i" == "$DIR_NAME" ] && 220 | ([ -d "$1/opencog" ] || [ -d "$1/moses" ]); then 221 | return 0 222 | fi 223 | done 224 | 225 | return 1 226 | } 227 | 228 | # Checks if the $PWD is a part of a git repo or the tar extract of OpenCog's 229 | # cmake configured source codes from github. 230 | set_source_and_build_dir() { 231 | # Set source directory path 232 | if is_opencog_cmake_project_root $PWD ; then 233 | SOURCE_DIR=$PWD 234 | MESSAGE="Source Directory is set to $SOURCE_DIR" ; message 235 | elif [ "$(git rev-parse --is-inside-work-tree)" == true ] ; then 236 | local GIT_ROOT_DIR=$(git rev-parse --show-toplevel) 237 | if is_opencog_cmake_project_root $GIT_ROOT_DIR ; then 238 | SOURCE_DIR=$GIT_ROOT_DIR 239 | # IS_GIT_WORKTREE is used to differentiate git version controled 240 | # directories from tar-balled download of source. 241 | IS_GIT_WORKTREE="yes" 242 | MESSAGE="Source Directory is set to $SOURCE_DIR" ; message 243 | fi 244 | fi 245 | 246 | # Check if the SOURCE_DIR is set. 247 | if [ -z "$SOURCE_DIR" ]; then 248 | MESSAGE="Is not yet known as an OpenCog project" ; message 249 | exit 1 250 | fi 251 | 252 | # Set build directory path 253 | if [ -d $SOURCE_DIR/build ]; then 254 | BUILD_DIR=$SOURCE_DIR/build 255 | MESSAGE="Build Directory is set to $SOURCE_DIR/build" ; message 256 | else 257 | mkdir $SOURCE_DIR/build 258 | BUILD_DIR=$SOURCE_DIR/build 259 | MESSAGE="Build Directory is set to $SOURCE_DIR/build" ; message 260 | fi 261 | } 262 | 263 | # Build function for opencog, atomspace, moses & cogutil repos 264 | build_source() { 265 | set_source_and_build_dir 266 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 267 | rm $BUILD_DIR/CMakeCache.txt 268 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 269 | fi 270 | 271 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 272 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 273 | cmake -B$BUILD_DIR -H$SOURCE_DIR 274 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS" ; message 275 | make -C $BUILD_DIR -j$MAKE_JOBS 276 | MESSAGE="Finished building source" ; message 277 | } 278 | 279 | # Build examples function for opencog, atomspace, moses & cogutil repos 280 | build_examples() { 281 | set_source_and_build_dir 282 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 283 | rm $BUILD_DIR/CMakeCache.txt 284 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 285 | fi 286 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 287 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 288 | cmake -B$BUILD_DIR -H$SOURCE_DIR 289 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS examples" ; message 290 | make -C $BUILD_DIR -j$MAKE_JOBS examples 291 | MESSAGE="Finished building examples" ; message 292 | } 293 | 294 | # Build tests function for opencog, atomspace, moses & cogutil repos 295 | build_tests() { 296 | set_source_and_build_dir 297 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 298 | rm $BUILD_DIR/CMakeCache.txt 299 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 300 | fi 301 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 302 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 303 | cmake -B$BUILD_DIR -H$SOURCE_DIR 304 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS tests" ; message 305 | make -C $BUILD_DIR -j$MAKE_JOBS tests 306 | MESSAGE="Finished building tests" ; message 307 | } 308 | 309 | # Run tests function for opencog, atomspace, moses & cogutil repos 310 | run_tests() { 311 | #check if gearman service is running, start it if not 312 | if (( $(ps -ef | grep -v grep | grep gearman-job-server | wc -l) > 0 )) 313 | # TODO: This should be done in cmake 314 | then 315 | MESSAGE="gearman-job-server is running!!!";message 316 | else 317 | sudo /etc/init.d/gearman-job-server start 318 | fi 319 | 320 | set_source_and_build_dir 321 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 322 | rm $BUILD_DIR/CMakeCache.txt 323 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 324 | fi 325 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 326 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 327 | cmake -B$BUILD_DIR -H$SOURCE_DIR 328 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS test ARGS=-j$MAKE_JOBS" ; message 329 | make -C $BUILD_DIR -j$MAKE_JOBS test ARGS=-j$MAKE_JOBS 330 | MESSAGE="Finished building & running tests" ; message 331 | } 332 | 333 | # Install build job artifacts 334 | install_build() { 335 | set_source_and_build_dir 336 | MESSAGE="Starting installation" ; message 337 | cd $BUILD_DIR 338 | sudo make install 339 | sudo ldconfig 340 | cd $CURRENT_DIR 341 | MESSAGE="Finished installation" ; message 342 | } 343 | 344 | # Builds and installs the project, with the name of the given argument, if 345 | # it is on of OpenCog's c++ projects. 346 | # 347 | # $1 = project name 348 | install_opencog_cmake_project() { 349 | if is_opencog_cmake_project "$1"; then 350 | MESSAGE="Installing $1 ...." ; message 351 | cd /tmp/ 352 | # cleaning up remnants from previous install failures, if any. 353 | rm -rf master.tar.gz* "$1-master" 354 | wget https://github.com/opencog/$1/archive/master.tar.gz 355 | tar -xvf master.tar.gz 356 | cd "$1-master/" 357 | build_source 358 | install_build 359 | cd /tmp/ 360 | rm -rf master.tar.gz "$1-master" 361 | cd $CURRENT_DIR 362 | else 363 | MESSAGE="Is not yet known as an OpenCog project" ; message 364 | fi 365 | 366 | } 367 | 368 | # Install Link-Grammar 369 | install_link_grammar(){ 370 | MESSAGE="Installing Link-Grammar...." ; message 371 | cd /tmp/ 372 | # cleaning up remnants from previous install failures, if any. 373 | rm -rf link-grammar-5.*/ 374 | wget -r --no-parent -nH --cut-dirs=2 http://www.abisource.com/downloads/link-grammar/current/ 375 | tar -zxf current/link-grammar-5*.tar.gz 376 | rm -r current 377 | cd link-grammar-5.*/ 378 | mkdir build 379 | cd build 380 | ../configure 381 | make -j$(nproc) 382 | sudo make install 383 | sudo ldconfig 384 | cd /tmp/ 385 | rm -rf link-grammar-5.*/ 386 | cd $CURRENT_DIR 387 | } 388 | 389 | # Installs cpprest that is needed by pattern-miner 390 | # https://github.com/Microsoft/cpprestsdk/wiki/How-to-build-for-Linux 391 | # TODO: Remove this when a move is made to Ubuntu >= 15.10 392 | install_cpprest(){ 393 | MESSAGE="Installing cpprest...." ; message 394 | cd /tmp/ 395 | # cleaning up remnants from previous install failures, if any. 396 | rm -rf master.tar.gz* cpprestsdk-master 397 | wget https://github.com/Microsoft/cpprestsdk/archive/master.tar.gz 398 | tar -xvf master.tar.gz 399 | cd cpprestsdk-master/Release 400 | mkdir build.release 401 | cd build.release 402 | CXX=g++-4.8 cmake .. -DCMAKE_BUILD_TYPE=Release 403 | make -j$(nproc) 404 | sudo make install 405 | sudo ldconfig 406 | cd /tmp/ 407 | rm -rf master.tar.gz* cpprestsdk-master 408 | cd $CURRENT_DIR 409 | } 410 | 411 | # Install system dependencies 412 | install_dependencies() { 413 | MESSAGE="Installing OpenCog build dependencies...." ; message 414 | if ! sudo apt-get $QUIET --no-upgrade --assume-yes install $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_FETCH; then 415 | # commented out the message b/c it is displayed on ctrl + c 416 | # MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 417 | exit 1 418 | fi 419 | install_cpprest 420 | } 421 | 422 | # Updates a git source directory if it is one of the opencog cmake projects. 423 | update_source() { 424 | set_source_and_build_dir 425 | if [ "$IS_GIT_WORKTREE" == "yes" ] ; then 426 | cd $SOURCE_DIR 427 | REPO="$(git remote -v | head -1 | cut -d "/" -f 2 | cut -d "." -f 1)" 428 | INITIAL_BRANCH="$(git describe --contains --all HEAD)" 429 | 430 | MESSAGE="Updating $REPO source at $SOURCE_DIR..." ; message 431 | git stash 432 | git checkout master 433 | git pull upstream master 434 | git checkout $INITIAL_BRANCH 435 | cd - 436 | fi 437 | } 438 | 439 | # This is for fast updating the octool behavior in docker images instead of 440 | # waiting for rebuilding the docker images, as the system dependencies rarely 441 | # change. 442 | # TODO: make it path/symlink independent 443 | update_octool() { 444 | if [ "${BASH_SOURCE[0]}" == "/tmp/octool" ] && 445 | wget -q --spider https://github.com/opencog/ocpkg/blob/master/octool 446 | then 447 | MESSAGE="Updating octool ...." ; message 448 | sudo rm /tmp/octool 449 | wget -pO /tmp/octool \ 450 | https://raw.githubusercontent.com/opencog/ocpkg/master/octool 451 | fi 452 | } 453 | 454 | # This is used for setting the file that is used for storing commit sha 455 | # 456 | # $1 = project name 457 | set_opencog_setup_file() { 458 | # Don't set config file if the effective uid is root. 459 | # TODO: Figure out where is the linux file structure appropriate directory 460 | # to keep the config files for all users. And add the option to store 461 | # in that directory. 462 | if [ "$EUID" -eq 0 ] ; then 463 | MESSAGE="Config directory isn't created as root user ...." ; message 464 | exit 1 465 | fi 466 | 467 | # Check if it an opencog cmake project 468 | if ! is_opencog_cmake_project "$1" ; then 469 | MESSAGE="$1 is not yet known as an OpenCog project" ; message 470 | exit 1 471 | fi 472 | 473 | # Set the config directory 474 | local CONFIG_DIR="$HOME/.config/opencog" 475 | CONFIG_FILE="$CONFIG_DIR/$1" 476 | if [ -a "$CONFIG_FILE" ] ; then 477 | MESSAGE="Config file being used is $CONFIG_FILE" ; message 478 | else 479 | mkdir -p "$CONFIG_DIR" 480 | touch "$CONFIG_FILE" 481 | MESSAGE="Config file being used is $CONFIG_FILE" ; message 482 | fi 483 | } 484 | 485 | # This is used for update install one of opencog's c++ projects, provided 486 | # the given argument is a project name for one of opencog's c++ projects. 487 | # NOTE: github has a limit on the number on unauthenticated hourly api calls. 488 | # 489 | # $1 = project name 490 | update_cmake_project() { 491 | if is_opencog_cmake_project "$1" ; then 492 | local CURRENT_COMMIT_SHA=$(curl \ 493 | https://api.github.com/repos/opencog/$1/git/refs/heads/master \ 494 | | grep https://api.github.com/repos/opencog/$1/git/commits \ 495 | | cut -d "/" -f 9) 496 | else 497 | MESSAGE="$1 is not yet known as an OpenCog project" ; message 498 | exit 1 499 | fi 500 | 501 | # Check if update is needed and then update 502 | set_opencog_setup_file "$1" 503 | INSTALLED_COMMIT_SHA=$(cat "$CONFIG_FILE") 504 | if [ "$CURRENT_COMMIT_SHA" == "$INSTALLED_COMMIT_SHA" ] ; then 505 | MESSAGE="$1 installation is up-to-date" ; message 506 | else 507 | MESSAGE="Updating $1 installation" ; message 508 | install_opencog_cmake_project "$1" 509 | echo "$CURRENT_COMMIT_SHA" > "$CONFIG_FILE" 510 | fi 511 | } 512 | 513 | run_cogserver() { 514 | CWD=$PWD 515 | if [ "$OPENCOG_SOURCE_DIR" != "" ] ; then 516 | BRANCH_DIR="$OPENCOG_SOURCE_DIR" 517 | if [[ $# == 0 ]]; then # No argument 518 | BUILD_DIR_NAME=build 519 | elif [[ $# == 1 ]]; then # One argument 520 | BUILD_DIR_NAME="$1" 521 | else # More than one command line arguments 522 | echo "Usage: $0 [BUILD_DIR_NAME=build]" 523 | exit 1 524 | fi 525 | 526 | BUILD_DIR="${BRANCH_DIR}/${BUILD_DIR_NAME}" 527 | cd $BUILD_DIR 528 | 529 | "./opencog/cogserver/server/cogserver" \ 530 | -c "${BRANCH_DIR}/lib/development.conf" 531 | else 532 | echo "OPENCOG_SOURCE_DIR environment variable is not set." 533 | fi 534 | cd $CWD 535 | } 536 | 537 | ci_help() { 538 | printf "Usage: %s %s [OPTIONS] \n\n" $SELF_NAME $COMMAND_MODE_CHOSEN 539 | printf "Options: \n" 540 | printf " -r Add software repositories \n" 541 | printf " -d Install base/system build dependencies \n" 542 | printf " -p Install python build dependencies \n" 543 | printf " -s Install haskell build dependencies in user space \n" 544 | printf " -i Install build-job artifacts \n" 545 | printf " -c Install Cogutil \n" 546 | printf " -a Install Atomspace \n" 547 | printf " -l Install Link Grammar \n" 548 | printf " -m Install MOSES \n" 549 | printf " -b Build source code in git worktree found @ %s \n" $PWD 550 | printf " -e Build examples in git worktree found @ %s \n" $PWD 551 | printf " -t Run tests of source code in git worktree found @ %s \n" $PWD 552 | printf " -j [jobs] override number of auto-detected make jobs \n" 553 | printf " -v Verbose output for 'apt-get' commands \n" 554 | printf " -h This help message \n" 555 | } 556 | 557 | # Help 558 | octool_help() { 559 | printf "Usage: %s [ -h | --help ] [OPTIONS] \n\n" $SELF_NAME 560 | printf "Options: \n" 561 | printf " -h, --help Print this help \n\n" 562 | printf "Available COMMANDS are: \n" 563 | 564 | for i in "${!COMMAND_DESCRIPTIONS[@]}" ; do 565 | printf " %s %s \n" "$i" "${COMMAND_DESCRIPTIONS[$i]}" 566 | done 567 | } 568 | 569 | usage() { 570 | echo "wip :-)" 571 | } 572 | 573 | ######################## 574 | ## Main Program ## 575 | ######################## 576 | # TODO: change octool usage to 'octool project command' format. Where projects 577 | # are opencog, atomspace, cogutil... & commands are setup(for workspace), 578 | # package(for docker,deb, rpm). Each will have various options/sub-commands. 579 | # 580 | declare -A COMMAND_DESCRIPTIONS=( 581 | [build]="This is for building sources" 582 | # 'ci' is compatible with previous octool 583 | [ci]=" Intended for continuese integration." 584 | # TODO 'dev' should be distro aware, that is, arch vs debian vs fedora 585 | # shouldn't be an issue. If a dependancy doesn't exist through the distro 586 | # then it should build from source. 587 | [dev]=" This mode is for configuring development space" 588 | [run]=" Run test or cogserver or some other thing" 589 | ) 590 | 591 | 592 | # Choose command mode. 593 | if [ $# -eq 0 ] ; then 594 | octool_help 595 | exit 0 596 | else 597 | case $1 in 598 | ci) COMMAND_MODE_CHOSEN=ci ;; 599 | dev) COMMAND_MODE_CHOSEN=dev ;; 600 | build) COMMAND_MODE_CHOSEN=build ;; 601 | run) COMMAND_MODE_CHOSEN=run ;; 602 | --help | -h) octool_help ; exit 0 ;; 603 | *) COMMAND_MODE_CHOSEN=ci ;; 604 | # TODO: Replace with the following when full migration is done. 605 | # *) MESSAGE="Modes available are: ${!COMMAND_MODE_DESCRIPTION[@]}" 606 | # message 607 | # exit 0 ;; 608 | esac 609 | fi 610 | 611 | # Print what mode the script is running in 612 | MESSAGE="Using '$COMMAND_MODE_CHOSEN' command mode" ; message 613 | shift 614 | 615 | case $COMMAND_MODE_CHOSEN in 616 | ci) if [ $# -eq 0 ] ; then ci_help ; exit 0 ; fi 617 | update_octool 618 | while getopts "abdeipcrstlmhvj:" flag ; do 619 | case $flag in 620 | r) ADD_REPOSITORIES=true ;; 621 | d) INSTALL_DEPENDENCIES=true ;; 622 | p) INSTALL_OPENCOG_PYTHON_PACKAGES=true ;; 623 | c) INSTALL_COGUTIL=true ;; 624 | a) INSTALL_ATOMSPACE=true ;; 625 | l) INSTALL_LINK_GRAMMAR=true ;; 626 | m) INSTALL_MOSES=true ;; 627 | b) BUILD_SOURCE=true ;; 628 | e) BUILD_EXAMPLES=true ;; 629 | t) RUN_TESTS=true ;; 630 | v) unset QUIET ;; 631 | j) MAKE_JOBS="$OPTARG" ;; 632 | s) HASKELL_STACK_SETUP=true;; 633 | i) INSTALL_BUILD=true ;; 634 | h) ci_help ;; 635 | \?) ci_help ;; 636 | *) UNKNOWN_FLAGS=true ;; 637 | esac 638 | done 639 | ;; 640 | build) if [ $# -eq 0 ] ; then ci_help ; exit 0 ; fi 641 | while getopts "aehstj:" flag ; do 642 | case $flag in 643 | a) BUILD_ALL=true ;; 644 | s) BUILD_SOURCE=true ;; 645 | e) BUILD_EXAMPLES=true ;; 646 | t) BUILD_TESTS=true ;; 647 | j) MAKE_JOBS="$OPTARG" ;; 648 | h) usage ;; 649 | \?) usage ;; 650 | *) UNKNOWN_FLAGS=true ;; 651 | esac 652 | done 653 | ;; 654 | dev) printf "WIP comming soon :-) \n" ;; 655 | run) if [ $# -eq 0 ] ; then ci_help ; exit 0 ; fi 656 | case $1 in 657 | cogserver) run_cogserver ;; 658 | tests) run_tests ;; 659 | *) MESSAGE="Only option is 'cogserver'" ; message 660 | exit 0 ;; 661 | esac 662 | ;; 663 | *) echo "There is a bug in the script please report." ; exit 1;; 664 | esac 665 | 666 | 667 | # This is mainly for configuring workspaces depending on the type 668 | # of project being worked on. The order here matters. 669 | if [ $ADD_REPOSITORIES ] ; then add_repositories ; fi 670 | if [ $INSTALL_DEPENDENCIES ] ; then install_dependencies ; fi 671 | if [ $HASKELL_STACK_SETUP ] ; then install_haskell_dependencies ; fi 672 | if [ $INSTALL_OPENCOG_PYTHON_PACKAGES ] ; then 673 | install_opencog_python_packages 674 | fi 675 | if [ $INSTALL_COGUTIL ] ; then 676 | install_opencog_cmake_project cogutil 677 | fi 678 | if [ $INSTALL_ATOMSPACE ] ; then 679 | install_opencog_cmake_project atomspace 680 | fi 681 | if [ $INSTALL_LINK_GRAMMAR ] ; then install_link_grammar ; fi 682 | if [ $INSTALL_MOSES ] ; then 683 | install_opencog_cmake_project moses 684 | fi 685 | if [ $BUILD_ALL ] ; then 686 | BUILD_SOURCE=true 687 | BUILD_EXAMPLES=true 688 | BUILD_TESTS=true 689 | fi 690 | if [ $BUILD_SOURCE ] ; then build_source ; fi 691 | if [ $BUILD_EXAMPLES ] ; then build_examples ; fi 692 | if [ $BUILD_TESTS ] ; then build_tests ; fi 693 | if [ $RUN_TESTS ] ; then run_tests ; fi 694 | if [ $INSTALL_BUILD ] ; then install_build ; fi 695 | if [ $UNKNOWN_FLAGS ] ; then usage ; fi 696 | exit 0 697 | -------------------------------------------------------------------------------- /octool_rpi.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 3 | ## @file octool_rpi 4 | ## @author Dagim Sisay 5 | ## @licence AGPL 6 | 7 | #Octool for Raspbian 8 | 9 | #CONSTANTS 10 | 11 | set -e 12 | 13 | GOOD_COLOR='\033[32m' #GREEN 14 | OKAY_COLOR='\033[33m' #YELLOW 15 | BAD_COLOR='\033[31m' #RED 16 | NORMAL_COLOR='\033[0m' 17 | 18 | INSTALL_PACKAGES=" 19 | build-essential \ 20 | autoconf-archive \ 21 | autogen \ 22 | libtool \ 23 | bison \ 24 | flex \ 25 | cmake \ 26 | rlwrap \ 27 | libiberty-dev \ 28 | libicu-dev \ 29 | libbz2-dev \ 30 | cython \ 31 | python3-dev \ 32 | python3-simplejson \ 33 | libjson-spirit-dev \ 34 | binutils-dev \ 35 | unixodbc-dev \ 36 | libpq-dev \ 37 | uuid-dev \ 38 | libprotoc-dev \ 39 | protobuf-compiler \ 40 | libssl-dev \ 41 | tcl-dev \ 42 | tcsh \ 43 | libfreetype6-dev \ 44 | libatlas-base-dev \ 45 | gfortran \ 46 | gearman \ 47 | libgearman-dev \ 48 | ccache \ 49 | libgsasl7 \ 50 | libldap2-dev \ 51 | krb5-multidev \ 52 | libatomic-ops-dev \ 53 | libunistring-dev \ 54 | libffi-dev \ 55 | libreadline-dev \ 56 | liboctomap-dev 57 | " 58 | 59 | INSTALL_RELEX_DEPS=" 60 | swig \ 61 | zlib1g-dev \ 62 | wordnet-dev \ 63 | wordnet-sense-index \ 64 | libatomic-ops-dev \ 65 | libgmp-dev \ 66 | libffi-dev \ 67 | oracle-java8-jdk \ 68 | ant \ 69 | libcommons-logging-java \ 70 | libgetopt-java " 71 | 72 | 73 | 74 | 75 | INSTALL_CC_PACKAGES=" python chrpath " 76 | 77 | 78 | SELF_NAME=$(basename $0) 79 | TOOL_NAME=octool_rpi 80 | 81 | export DISTRO_RELEASE=$(lsb_release --codename | awk {' print $2 '}) 82 | export DISTRO_JESSIE="jessie" 83 | export DISTRO_STRETCH="stretch" 84 | 85 | export CC_TC_DIR_NAME="RPI_OC_TC" #RPI Opencog Toolchain Container 86 | export CC_TC_ROOT="$HOME/$CC_TC_DIR_NAME" 87 | export CC_TC_SRC_DIR="$CC_TC_ROOT/opencog" 88 | export CC_TC_DIR="$CC_TC_ROOT/opencog_rpi_toolchain" 89 | export CC_TC_LIBS_PATH_1="$CC_TC_DIR/opencog_rasp" 90 | export CC_TC_LIBS_PATH_2="$CC_TC_DIR/tools-master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot" 91 | 92 | export CC_TC_BOOST_1_55_LIBS="$CC_TC_LIBS_PATH_2/opt/boost_1.55_armhf" 93 | export CC_TC_BOOST_1_62_LIBS="$CC_TC_LIBS_PATH_2/opt/boost_1.62_armhf" 94 | 95 | export COGUTIL_COMMIT="0" 96 | export ATOMSPACE_COMMIT="0" 97 | export OPENCOG_COMMIT="0" 98 | export DPKG__V="1.0-1" 99 | 100 | J_BDWGC_DEB="http://144.76.153.5/opencog/jessie/bdwgc-7.6.4-1_armhf.deb" 101 | S_BDWGC_DEB="http://144.76.153.5/opencog/stretch/bdwgc-dev_1.0-2_armhf.deb" 102 | J_GUILE_DEB="http://144.76.153.5/opencog/jessie/guile-2.2.3-1_armhf.deb" 103 | S_GUILE_DEB="http://144.76.153.5/opencog/stretch/guile-dev_2.2.3-2_armhf.deb" 104 | 105 | GUILE_V="2.2.3" # https://ftp.gnu.org/gnu/guile/guile-2.2.3.tar.xz 106 | TBB_V="2017_U7" # https://github.com/01org/tbb/archive/2017_U7.tar.gz 107 | LG_V="5.4.3" # https://github.com/opencog/link-grammar/archive/link-grammar-5.4.3.tar.gz 108 | RELEX_V="1.6.3" # https://github.com/Dagiopia/relex/archive/1.6.3.tar.gz 109 | BDWGC_V="7.6.4" # https://github.com/ivmai/bdwgc/archive/v7.6.4.tar.gz 110 | 111 | 112 | 113 | if [ $(uname -m) == "armv7l" ] ; then 114 | if [ $DISTRO_RELEASE == $DISTRO_JESSIE ] ; then 115 | printf "${OKAY_COLOR}Version Jessie ${NORMAL_COLOR}\n" 116 | export DEB_PKG_NAME="opencog-dev_1.0-1_armhf" 117 | export BDWGC_DEB="bdwgc-7.6.4-1_armhf.deb" 118 | export BDWGC_DEB_URL=$J_BDWGC_DEB 119 | export GUILE_DEB="guile-2.2.3-1_armhf.deb" 120 | export GUILE_DEB_URL=$J_GUILE_DEB 121 | elif [ $DISTRO_RELEASE == $DISTRO_STRETCH ] ; then 122 | printf "${OKAY_COLOR}Version Stretch ${NORMAL_COLOR}\n" 123 | export DEB_PKG_NAME="opencog-dev_1.0-2_armhf" 124 | export BDWGC_DEB="bdwgc-dev_1.0-2_armhf.deb" 125 | export BDWGC_DEB_URL=$S_BDWGC_DEB 126 | export GUILE_DEB="guile-dev_2.2.3-2_armhf.deb" 127 | export GUILE_DEB_URL=$S_GUILE_DEB 128 | else 129 | printf "${OKAY_COLOR}Version Unanticipated :) going with jessie ${NORMAL_COLOR}\n" 130 | export DEB_PKG_NAME="opencog-dev_1.0-1_armhf" 131 | export BDWGC_DEB_URL=$J_BDWGC_DEB 132 | export GUILE_DEB_URL=$J_GUILE_DEB 133 | fi 134 | fi 135 | 136 | 137 | 138 | usage() { 139 | echo "Usage: $SELF_NAME OPTION" 140 | echo "Tool for installing necessary packages and preparing environment" 141 | echo "for OpenCog on a Raspberry PI computer running Raspbian OS." 142 | echo " -d Install base/system dependancies." 143 | echo " -o Install OpenCog (precompilled: may be outdated)" 144 | echo " -t Download and Install Cross-Compilling Toolchain" 145 | echo " -c Cross Compile OpenCog (Run on PC!)" 146 | echo " -s Cross Compile for Raspbian Stretch (boost 1.62)" 147 | echo " -v Verbose output" 148 | echo -e " -h This help message\n" 149 | exit 150 | } 151 | 152 | 153 | download_install_oc () { 154 | wget 144.76.153.5/opencog/$DEB_PKG_NAME.deb 155 | sudo dpkg -i $DEB_PKG_NAME.deb 156 | rm $DEB_PKG_NAME.deb 157 | } 158 | 159 | 160 | setup_sys_for_cc () { 161 | #downloading cogutil, atomspace and opencog source code 162 | if [ -d $CC_TC_ROOT ] ; then 163 | sudo rm -rf $CC_TC_ROOT/* 164 | fi 165 | mkdir -p $CC_TC_SRC_DIR 166 | cd $CC_TC_SRC_DIR 167 | rm -rf * 168 | wget https://github.com/opencog/cogutil/archive/master.tar.gz 169 | COGUTIL_COMMIT=$(curl https://api.github.com/repos/opencog/cogutil/commits/master | jq -r '.sha') 170 | tar $VERBOSE -xf master.tar.gz 171 | rm master.tar.gz 172 | wget https://github.com/opencog/atomspace/archive/master.tar.gz 173 | ATOMSPACE_COMMIT=$(curl https://api.github.com/repos/opencog/atomspace/commits/master | jq -r '.sha') 174 | tar $VERBOSE -xf master.tar.gz 175 | rm master.tar.gz 176 | wget https://github.com/opencog/opencog/archive/master.tar.gz 177 | OPENCOG_COMMIT=$(curl https://api.github.com/repos/opencog/opencog/commits/master | jq -r '.sha') 178 | tar $VERBOSE -xf master.tar.gz 179 | rm master.tar.gz 180 | for d in * ; do echo $d ; mkdir $d/build_hf ; done 181 | cd $CC_TC_ROOT 182 | #downloading compiler and libraries 183 | wget https://github.com/opencog/opencog_rpi/archive/master.tar.gz 184 | tar $VERBOSE -xf master.tar.gz 185 | mv opencog_rpi-master opencog_rpi_toolchain 186 | mv $CC_TC_DIR/arm_gnueabihf_toolchain.cmake $CC_TC_SRC_DIR 187 | rm master.tar.gz 188 | } 189 | 190 | 191 | do_cc_for_rpi () { 192 | if [ -d $CC_TC_ROOT -a -d $CC_TC_DIR -a -d $CC_TC_SRC_DIR ] ; then 193 | printf "${GOOD_COLOR}Everything seems to be in order.${NORMAL_COLOR}\n" 194 | else 195 | 196 | printf "${BAD_COLOR}You do not seem to have the compiler toolchain.\n \ 197 | Please run:\n\t\t$SELF_NAME -tc \n${NORMAL_COLOR}\n" 198 | exit 199 | fi 200 | 201 | if [ $FOR_STRETCH ] ; then 202 | printf "${OKAY_COLOR}Compiling with Boost 1.62${NORMAL_COLOR}\n" 203 | tar -xf $CC_TC_BOOST_1_62_LIBS.tar.gz -C $CC_TC_LIBS_PATH_2/opt 204 | cp -Prf $VERBOSE $CC_TC_BOOST_1_62_LIBS/include/boost $CC_TC_LIBS_PATH_2/usr/include 205 | cp -Prf $VERBOSE $CC_TC_BOOST_1_62_LIBS/lib/arm-linux-gnueabihf/* $CC_TC_LIBS_PATH_2/usr/lib 206 | # boost 1.62 needs stdc++ 6.0.22 207 | cd $CC_TC_LIBS_PATH_2/../lib 208 | ln -sf $CC_TC_LIBS_PATH_2/opt/libstdc++.so.6.0.22 libstdc++.so.6 209 | export DEB_PKG_NAME="opencog-dev_1.0-2_armhf" 210 | export DPKG__V="1.0-2" 211 | else 212 | printf "${OKAY_COLOR}Compiling with Boost 1.55${NORMAL_COLOR}\n" 213 | tar -xf $CC_TC_BOOST_1_55_LIBS.tar.gz -C $CC_TC_LIBS_PATH_2/opt 214 | cp -Prf $VERBOSE $CC_TC_BOOST_1_55_LIBS/include/boost $CC_TC_LIBS_PATH_2/usr/include 215 | cp -Prf $VERBOSE $CC_TC_BOOST_1_55_LIBS/lib/arm-linux-gnueabihf/* $CC_TC_LIBS_PATH_2/usr/lib 216 | # boost 1.55 needs stdc++ 6.0.20 217 | cd $CC_TC_LIBS_PATH_2/../lib 218 | ln -sf $CC_TC_LIBS_PATH_2/opt/libstdc++.so.6.0.20 libstdc++.so.6 219 | export DEB_PKG_NAME="opencog-dev_1.0-1_armhf" 220 | fi 221 | 222 | export PATH=$PATH:$CC_TC_DIR/tools-master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin 223 | 224 | cp -f $CC_TC_DIR/cmake/* $CC_TC_SRC_DIR/opencog-master/lib 225 | 226 | #compiling cogutil 227 | cd $CC_TC_SRC_DIR/cogutil-master/build_hf 228 | rm -rf $CC_TC_SRC_DIR/cogutil-master/build_hf/* 229 | cmake -DCMAKE_TOOLCHAIN_FILE=$CC_TC_SRC_DIR/arm_gnueabihf_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$CC_TC_LIBS_PATH_1/usr/local -DCMAKE_BUILD_TYPE=Release .. 230 | make -j$(nproc) 231 | make install 232 | 233 | #compiling atomspace 234 | cd $CC_TC_SRC_DIR/atomspace-master/build_hf 235 | rm -rf $CC_TC_SRC_DIR/atomspace-master/build_hf/* 236 | 237 | #till we can cross compile with stack 238 | rm -f $CC_TC_SRC_DIR/atomspace-master/lib/FindStack.cmake 239 | 240 | cmake -DCMAKE_TOOLCHAIN_FILE=$CC_TC_SRC_DIR/arm_gnueabihf_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$CC_TC_LIBS_PATH_1/usr/local -DCMAKE_BUILD_TYPE=Release .. 241 | make -j$(nproc) 242 | make install 243 | 244 | #compiling opencog 245 | cd $CC_TC_SRC_DIR/opencog-master/build_hf 246 | rm -rf $CC_TC_SRC_DIR/opencog-master/build_hf/* 247 | cmake -DCMAKE_TOOLCHAIN_FILE=$CC_TC_SRC_DIR/arm_gnueabihf_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$CC_TC_LIBS_PATH_1/usr/local -DCMAKE_BUILD_TYPE=Release .. 248 | make -j$(nproc) 249 | make install 250 | 251 | #correct RPATHS 252 | cd $CC_TC_ROOT 253 | wget https://raw.githubusercontent.com/Dagiopia/my_helpers/master/batch_chrpath/batch_chrpath.py 254 | python batch_chrpath.py $CC_TC_LIBS_PATH_1/usr/local $CC_TC_LIBS_PATH_1 $CC_TC_LIBS_PATH_2 255 | rm batch_chrpath.py 256 | 257 | #package into deb 258 | cd $CC_TC_DIR 259 | sudo rm -rf $DEB_PKG_NAME 260 | cp -ur opencog_rasp $DEB_PKG_NAME 261 | cd $CC_TC_DIR/$DEB_PKG_NAME 262 | mkdir ./usr/local/lib/pkgconfig DEBIAN 263 | echo """Package: opencog-dev 264 | Priority: optional 265 | Section: universe/opencog 266 | Maintainer: Dagim Sisay 267 | Architecture: armhf 268 | Version: $DPKG__V 269 | Homepage: wiki.opencog.org 270 | Description: Artificial General Inteligence Engine for Linux 271 | Opencog is a gigantic software that is being built with the ambition 272 | to one day create human like intelligence that can be conscious and 273 | emotional. 274 | This is hopefully the end of task-specific narrow AI. 275 | This package includes the files necessary for running opencog on RPI3. 276 | Cogutil: $COGUTIL_COMMIT 277 | Atomspace: $ATOMSPACE_COMMIT 278 | Opencog: $OPENCOG_COMMIT""" > DEBIAN/control 279 | 280 | echo """#Manually written pkgconfig file for opencog - START 281 | prefix=/usr/local 282 | exec_prefix=\${prefix} 283 | libdir=\${exec_prefix}/lib 284 | includedir=\${prefix}/include 285 | Name: opencog 286 | Description: Artificial General Intelligence Software 287 | Version: 1.0 288 | Cogutil: $COGUTIL_COMMIT 289 | Atomspace: $ATOMSPACE_COMMIT 290 | Opencog: $OPENCOG_COMMIT 291 | Cflags: -I\${includedir} 292 | Libs: -L\${libdir} 293 | #Manually written pkgconfig file for opencog - END""" > ./usr/local/lib/pkgconfig/opencog.pc 294 | cd .. 295 | sudo chown -R root:staff $DEB_PKG_NAME 296 | sudo dpkg-deb --build $DEB_PKG_NAME 297 | } 298 | 299 | 300 | install_guile () { 301 | # install guile 302 | printf "${OKAY_COLOR}Installing Guile from source $GUILE_V ${NORMAL_COLOR}\n" 303 | cd /tmp 304 | mkdir $VERBOSE -p /tmp/guile_temp_ 305 | rm $VERBOSE -rf /tmp/guile_temp_/* 306 | cd /tmp/guile_temp_ 307 | wget https://ftp.gnu.org/gnu/guile/guile-$GUILE_V.tar.xz 308 | tar $VERBOSE -xf guile-$GUILE_V.tar.xz 309 | cd guile-$GUILE_V 310 | ./configure 311 | make -j2 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib 312 | sudo make install 313 | sudo ldconfig 314 | cd $HOME 315 | rm $VERBOSE -rf /tmp/guile_temp_ 316 | } 317 | 318 | install_guile_deb () { 319 | printf "${OKAY_COLOR}Installing Guile from deb pkg $GUILE_V ${NORMAL_COLOR}\n" 320 | wget $GUILE_DEB_URL 321 | sudo dpkg -i $GUILE_DEB 322 | sudo apt-get -f install 323 | rm $GUILE_DEB 324 | } 325 | 326 | 327 | install_tbb () { 328 | #download, compile and install TBB 329 | printf "${OKAY_COLOR}Installing Threading Building Blocks (TBB)${NORMAL_COLOR}\n" 330 | cd /tmp 331 | mkdir -p /tmp/tbb_temp_ 332 | rm -rf $VERBOSE /tmp/tbb_temp_/* 333 | cd /tmp/tbb_temp_ 334 | wget https://github.com/01org/tbb/archive/$TBB_V.tar.gz 335 | tar $VERBOSE -xf $TBB_V.tar.gz 336 | cd tbb-$TBB_V 337 | make tbb CXXFLAGS+="-DTBB_USE_GCC_BUILTINS=1 -D__TBB_64BIT_ATOMICS=0" 338 | sudo cp $VERBOSE -r include/serial include/tbb /usr/local/include 339 | sudo cp $VERBOSE build/linux_armv7*_release/libtbb.so.2 /usr/local/lib/ 340 | cd /usr/local/lib 341 | sudo ln $VERBOSE -sf libtbb.so.2 libtbb.so 342 | sudo ldconfig 343 | cd $HOME 344 | rm $VERBOSE -rf /tmp/tbb_temp_ 345 | } 346 | 347 | install_lg () { 348 | #download, compile and instal link-grammar 349 | printf "${OKAY_COLOR}Installing Link Grammar${NORMAL_COLOR}\n" 350 | cd /tmp 351 | mkdir $VERBOSE -p /tmp/lg_temp_ 352 | cd /tmp/lg_temp_ 353 | rm $VERBOSE -rf $HOME/lg_temp_/* 354 | wget https://github.com/opencog/link-grammar/archive/link-grammar-$LG_V.tar.gz 355 | tar $VERBOSE -xf link-grammar-$LG_V.tar.gz 356 | cd link-grammar-link-grammar-$LG_V 357 | ./autogen.sh 358 | ./configure 359 | make -j2 360 | sudo make install 361 | cd /usr/lib/ 362 | sudo ln $VERBOSE -sf ../local/lib/liblink-grammar.so.5 liblink-grammar.so.5 363 | sudo ldconfig 364 | cd $HOME/ 365 | rm $VERBOSE -rf /tmp/lg_temp_ 366 | } 367 | 368 | install_relex () { 369 | #Java wordnet library 370 | printf "${OKAY_COLOR}Installing Relex${NORMAL_COLOR}\n" 371 | cd /tmp 372 | mkdir $VERBOSE -p /tmp/relex_temp_ 373 | cd /tmp/relex_temp_ 374 | rm $VERBOSE -rf /tmp/relex_temp_/* 375 | wget http://downloads.sourceforge.net/project/jwordnet/jwnl/JWNL%201.4/jwnl14-rc2.zip 376 | unzip jwnl14-rc2.zip jwnl14-rc2/jwnl.jar 377 | sudo mv $VERBOSE jwnl14-rc2/jwnl.jar /usr/local/share/java/ 378 | sudo chmod $VERBOSE 0644 /usr/local/share/java/jwnl.jar 379 | 380 | #installing relex 381 | export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 382 | wget https://github.com/Dagiopia/relex/archive/$RELEX_V.tar.gz 383 | tar $VERBOSE -xf $RELEX_V.tar.gz 384 | cd relex-$RELEX_V 385 | export CLASSPATH=/usr/local/share/java 386 | ant build 387 | sudo ant install 388 | cd $HOME 389 | rm $VERBOSE -rf /tmp/relex_temp_ 390 | } 391 | 392 | install_bdwgc_deb () { 393 | printf "${OKAY_COLOR}Installing bdwgc from deb pkg${NORMAL_COLOR}\n" 394 | wget $BDWGC_DEB_URL 395 | sudo dpkg -i $BDWGC_DEB 396 | sudo apt-get -f install 397 | rm $BDWGC_DEB 398 | } 399 | 400 | install_bdwgc () { 401 | # install bdwgc garbage collector 402 | printf "${OKAY_COLOR}Installing bdwgc from source${NORMAL_COLOR}\n" 403 | cd /tmp 404 | mkdir $VERBOSE -p /tmp/bdwgc_temp_ 405 | rm -rf /tmp/bdwgc_temp_/* 406 | cd /tmp/bdwgc_temp_ 407 | wget https://github.com/ivmai/bdwgc/archive/v$BDWGC_V.tar.gz 408 | tar $VERBOSE -xf v$BDWGC_V.tar.gz 409 | cd bdwgc-$BDWGC_V 410 | ./autogen.sh 411 | ./configure 412 | make -j2 413 | sudo make install 414 | sudo ldconfig 415 | cd $HOME 416 | rm $VERBOSE -rf /tmp/bdwgc_temp_ 417 | } 418 | 419 | 420 | 421 | if [ $# -eq 0 ] ; then 422 | printf "${BAD_COLOR}ERROR!! Please specify what to do\n${NORMAL_COLOR}" 423 | usage 424 | else 425 | while getopts "drotcsvh:" switch ; do 426 | case $switch in 427 | d) INSTALL_DEPS=true ;; 428 | o) INSTALL_OC=true ;; 429 | t) SETUP_TC=true ;; 430 | c) CC_OPENCOG=true ;; 431 | s) FOR_STRETCH=true ;; 432 | v) SHOW_VERBOSE=true ;; 433 | h) usage ;; 434 | *) printf "ERROR!! UNKNOWN ARGUMENT!!\n"; usage ;; 435 | esac 436 | done 437 | fi 438 | 439 | 440 | if [ $SHOW_VERBOSE ] ; then 441 | printf "${OKAY_COLOR}I will be verbose${NORMAL_COLOR}\n" 442 | APT_ARGS=" -V " 443 | VERBOSE=" -v " 444 | else 445 | APT_ARGS=" -qq " 446 | fi 447 | 448 | if [ $INSTALL_DEPS ] ; then 449 | echo "Install Deps" 450 | 451 | #only allow installation for arm device (RPI) 452 | if [ $(uname -m) == "armv7l" ] ; then 453 | printf "${GOOD_COLOR}okay it's an ARM7... \ 454 | Installing packages${NORMAL_COLOR}\n" 455 | sudo apt-get install -y $APT_ARGS $INSTALL_PACKAGES 456 | if [ "$DISTRO_RELEASE" == "$DISTRO_STRETCH" ] ; then 457 | sudo apt-get install -y $APT_ARGS libboost1.62-all-dev 458 | else 459 | sudo apt-get install -y $APT_ARGS libboost1.55-all-dev 460 | fi 461 | 462 | install_bdwgc_deb # install bdwgc from deb pkg 463 | install_guile_deb # install guile from a deb pkg 464 | install_tbb # install TBB 465 | 466 | sudo apt-get -y install $APT_ARGS $INSTALL_RELEX_DEPS 467 | sudo update-alternatives --auto java 468 | sudo update-alternatives --auto javac 469 | export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt 470 | export LC_ALL=en_US.UTF8 471 | install_lg # install link-grammar 472 | install_relex # install relex 473 | 474 | printf "${GOOD_COLOR}Done Installing Dependancies!${NORMAL_COLOR}\n" 475 | 476 | else 477 | printf "${BAD_COLOR}Your Machine is Not ARM7!\n \ 478 | The dependancy installation is for RPI running raspbian only. \ 479 | ${NORMAL_COLOR}\n" 480 | exit 481 | fi 482 | 483 | fi 484 | 485 | if [ $INSTALL_OC ] ; then 486 | printf "${OKAY_COLOR}Get Compiled files from somewhere${NORMAL_COLOR}\n" 487 | download_install_oc 488 | fi 489 | 490 | if [ $SETUP_TC ] ; then 491 | if [ $(uname -m) == "armv7l" ] ; then 492 | printf "${BAD_COLOR}Your Machine is ARM! \n \ 493 | Let's Cross Compile on a bigger machine.${NORMAL_COLOR}\n" 494 | exit 495 | else 496 | printf "${GOOD_COLOR}okay it's not an ARM machine... \ 497 | Installing CC packages${NORMAL_COLOR}\n" 498 | printf "${OKAY_COLOR}Downloading Necessary CC Packages${NORMAL_COLOR}\n" 499 | #make the appropriate directories and git clone the toolchain 500 | setup_sys_for_cc 501 | fi 502 | fi 503 | 504 | if [ $CC_OPENCOG ] ; then 505 | echo "Cross Compile OpenCog" 506 | #check if not running on an arm7 computer 507 | if [ $(uname -m) == "armv7l" ] ; then 508 | printf "${BAD_COLOR}Your Machine is ARM! \n \ 509 | Let's Cross Compile on a bigger machine.${NORMAL_COLOR}\n" 510 | exit 511 | else 512 | printf "${GOOD_COLOR}okay it's not an ARM machine... Installing CC packages${NORMAL_COLOR}\n" 513 | PROCEED_CC=true 514 | sudo apt-get install -y $APT_ARGS $INSTALL_CC_PACKAGES 515 | do_cc_for_rpi 516 | fi 517 | fi 518 | 519 | -------------------------------------------------------------------------------- /opencog-installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | #A streamlined and interactive method for installing OpenCog in Linux. 4 | #This script installs dependencies, downloads OpenCog from Github, compiles and installs it, or if unable to do so, hands-off to the proper program to accomplish those steps. 5 | #Last editor: Noah Bliss 6 | #Last updated on: 5/29/2016 7 | #A few variables quick... 8 | gauthor=opencog 9 | rtdr=ocpkg 10 | branch=master 11 | 12 | #Let's start by cleaning off our desk... 13 | clear 14 | 15 | echo " 16 | 17 | Welcome to the OpenCog installer! 18 | 19 | This program is designed to help you install OpenCog on your system. 20 | For additional info or help, please check GitHub. 21 | 22 | What Linux Distribution are you on? 23 | *Additional options if Debian is selected. 24 | 25 | " 26 | until [ "$vdist" == "1" ] 27 | do 28 | read -p "I am running... [ubuntu|debian|fedora|arch|opensuse]: " dist 29 | #Enumerate valid choices. 30 | if [[ "$dist" == @(ubuntu|debian|fedora|arch|opensuse) ]] 31 | then 32 | #Choice is valid. 33 | vdist=1 34 | else 35 | echo "Try Again." 36 | fi 37 | done 38 | 39 | #Here we evaluate what distro is running. We either hand-off or process any unique prerequisites that distro has. 40 | 41 | #ubuntu 42 | if [ "$dist" == "ubuntu" ] 43 | then 44 | wget https://raw.githubusercontent.com/opencog/ocpkg/master/ocpkg && chmod 755 ./ocpkg 45 | echo "Downloaded ockpg. Run it with ./ocpkg" 46 | #Since we aren't installing for Ubuntu via this script, we exit here. 47 | exit 0 48 | #debian 49 | elif [ "$dist" == "debian" ] 50 | then 51 | echo > /dev/null 52 | #Nothing weird for Debian. We will continue to the universal install menu. 53 | elif [ "$dist" == "fedora" ] 54 | then 55 | wget https://raw.githubusercontent.com/opencog/ocpkg/master/install-fedora-dependencies.sh && chmod 755 ./install-fedora-dependencies.sh 56 | echo "Downloaded install-fedora-dependencies.sh. Run it with ./install-fedora-dependencies.sh" 57 | #Since we aren't installing for Fedora via this script, we exit here. (This would be easy to implement though if Debian testing goes well.) 58 | exit 0 59 | elif [ "$dist" == "arch" ] 60 | then 61 | wget https://raw.githubusercontent.com/opencog/ocpkg/master/install-archlinux-dependencies.sh && chmod 755 ./install-archlinux-dependencies.sh 62 | echo "Downloaded install-archlinux-dependencies.sh. Run it with ./install-archlinux-dependencies.sh" 63 | #Since we aren't installing for Arch via this script, we exit here. 64 | exit 0 65 | elif [ "$dist" == "opensuse" ] 66 | then 67 | wget https://raw.githubusercontent.com/opencog/ocpkg/master/install-opensuse-dependencies.sh && chmod 755 ./install-opensuse-dependencies.sh 68 | echo "Downloaded install-opensuse-dependencies.sh. Run it with ./install-opensuse-dependencies.sh" 69 | #Since we aren't installing for openSUSE via this script, we exit here. 70 | exit 0 71 | fi 72 | 73 | #Clean the screen 74 | clear 75 | 76 | #Universal Install menu. 77 | echo " 78 | 79 | Choose an option below. 80 | Items marked with an X are still in development. 81 | 82 | #1.) Just install dependencies. 83 | #2.) Dependencies, then install OpenCog. (AmeBel method) 84 | #3.) Dependencies, then install OpenCog. (L3vi47h4N method - WIP) 85 | #X.) Dependencies, OpenCog with MOSES. **not yet implemented 86 | 87 | " 88 | until [ "$vchoice" == "1" ] 89 | do 90 | read -p "I choose door number... " choice 91 | if [[ "$choice" == @(1|2|3) ]] 92 | then 93 | vchoice=1 94 | else 95 | echo "Try Again." 96 | fi 97 | done 98 | 99 | #Just the dependencies. 100 | if [ "$choice" == "1" ] 101 | then 102 | #Fetch the dependency script using the dist variable as part of the path. 103 | wget https://raw.githubusercontent.com/"$gauthor"/"$rtdr"/"$branch"/"$dist"/install-"$dist"-dependencies.sh && chmod 755 ./install-"$dist"-dependencies.sh && sudo ./install-"$dist"-dependencies.sh && rm install-"$dist"-dependencies.sh 104 | exit 0 105 | #Dependencies, then install OpenCog. (AmeBel method) 106 | elif [ "$choice" == "2" ] 107 | then 108 | #Fetch the dependency script using the dist variable as part of the path. 109 | wget https://raw.githubusercontent.com/"$gauthor"/"$rtdr"/"$branch"/"$dist"/install-"$dist"-dependencies.sh && chmod 755 ./install-"$dist"-dependencies.sh && sudo ./install-"$dist"-dependencies.sh && rm install-"$dist"-dependencies.sh 110 | read -p "Do not continue if there were errors in fetching the dependencies. Press [ENTER] to continue..." 111 | #I need to put a menu-driven selection program here which prompts for which elements of OpenCog a user wants. 112 | read -p "Install Cogutil? (y/n) " cogutil 113 | read -p "Install AtomSpace? (y/n) " atomspace 114 | read -p "UNTESTED: Install LinkGrammar? (y/n) " linkgram 115 | #read -p "UNTESTED: Install Haskell (may error if run as root)? (y/n) " haskell 116 | 117 | #COGUTIL 118 | if [ "$cogutil" == "y" ] || [ "$cogutil" == "Y" ] 119 | then 120 | cd /tmp/ 121 | # cleaning up remnants from previous install failures, if any. 122 | rm -rf master.tar.gz cogutil-master/ 123 | wget https://github.com/opencog/cogutil/archive/master.tar.gz 124 | tar -xvf master.tar.gz 125 | cd cogutil-master/ 126 | mkdir build 127 | cd build/ 128 | cmake .. 129 | make -j"$(nproc)" 130 | sudo make install 131 | cd ../.. 132 | rm -rf master.tar.gz cogutil-master/ 133 | fi 134 | if [ "$atomspace" == "y" ] || [ "$atomspace" == "Y" ] 135 | then 136 | cd /tmp/ 137 | # cleaning up remnants from previous install failures, if any. 138 | rm -rf master.tar.gz atomspace-master/ 139 | wget https://github.com/opencog/atomspace/archive/master.tar.gz 140 | tar -xvf master.tar.gz 141 | cd atomspace-master/ 142 | mkdir build 143 | cd build/ 144 | cmake .. 145 | make -j"$(nproc)" 146 | sudo make install 147 | cd ../.. 148 | rm -rf master.tar.gz atomspace-master/ 149 | fi 150 | if [ "$linkgram" == "y" ] || [ "$linkgram" == "Y" ] 151 | then 152 | cd /tmp/ 153 | # cleaning up remnants from previous install failures, if any. 154 | rm -rf link-grammar-5.*/ 155 | wget -r --no-parent -nH --cut-dirs=2 http://www.abisource.com/downloads/link-grammar/current/ 156 | tar -zxf current/link-grammar-5*.tar.gz 157 | rm -r current 158 | cd link-grammar-5.*/ 159 | mkdir build 160 | cd build 161 | ../configure 162 | make -j"$(nproc)" 163 | sudo make install 164 | sudo ldconfig 165 | cd /tmp/ 166 | rm -rf link-grammar-5.*/ 167 | cd $CURRENT_DIR 168 | fi 169 | #if [ "$haskell" == "y" ] || [ "$haskell" == "Y" ] 170 | #then 171 | 172 | #Dependencies, then install OpenCog. (L3vi47h4N method) 173 | elif [ "$choice" == "3" ] 174 | then 175 | #Fetch the dependency script using the dist variable as part of the path. 176 | wget https://raw.githubusercontent.com/"$gauthor"/"$rtdr"/"$branch"/"$dist"/install-"$dist"-dependencies.sh && chmod 755 ./install-"$dist"-dependencies.sh && sudo ./install-"$dist"-dependencies.sh && rm install-"$dist"-dependencies.sh 177 | read -p "Do not continue if there were errors in fetching the dependencies. Press [ENTER] to continue..." 178 | echo "This is still in development. Pressing enter will use git pull to download opencog/atomspace/cogutil to current directory." 179 | read -p "Download Opencog source to current path? (y/n) " gitclone 180 | if [ "$gitclone" == "y" ] || [ "$gitclone" == "Y" ] 181 | then 182 | git clone https://github.com/opencog/opencog.git 183 | git clone https://github.com/opencog/atomspace.git 184 | git clone https://github.com/opencog/cogutil.git 185 | echo "You should now be able to build according to the OpenCog for noobs instructions. Good luck!" 186 | else 187 | echo "Download of OpenCog aborted." 188 | exit 189 | fi 190 | elif [ "$choice" == "4" ] 191 | then 192 | echo "You broke the code if you can read this." 193 | fi 194 | --------------------------------------------------------------------------------