├── .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 | # libpq-dev is needed by the postgres storage node. 132 | # nlohmann-json3-dev is needed by the cogserver. 133 | PACKAGES_BUILD=" build-essential \ 134 | cmake \ 135 | rlwrap \ 136 | binutils-dev \ 137 | libiberty-dev \ 138 | libltdl-dev \ 139 | libbz2-dev \ 140 | libboost-date-time-dev \ 141 | libboost-filesystem-dev \ 142 | libboost-math-dev \ 143 | libboost-program-options-dev \ 144 | libboost-regex-dev \ 145 | libboost-serialization-dev \ 146 | libboost-thread-dev \ 147 | libboost-system-dev \ 148 | libboost-random-dev \ 149 | libedit-dev \ 150 | libpcre2-dev \ 151 | libpq-dev \ 152 | uuid-dev \ 153 | libssl-dev \ 154 | ccache \ 155 | cxxtest \ 156 | libgsasl-dev \ 157 | libldap2-dev \ 158 | krb5-multidev \ 159 | gperf \ 160 | libatomic-ops-dev \ 161 | libgmp-dev \ 162 | libffi-dev \ 163 | libreadline-dev \ 164 | libunistring-dev \ 165 | m4 \ 166 | autoconf-archive \ 167 | autoconf automake autopoint \ 168 | libtool \ 169 | swig \ 170 | flex \ 171 | librocksdb-dev \ 172 | libopencv-dev \ 173 | nlohmann-json3-dev \ 174 | less \ 175 | vim \ 176 | " 177 | 178 | # AtomSpace OCaML no longer builds in Ubuntu 22.04, and so disable here, 179 | # until it is fixed. 180 | #ocaml \ 181 | #ocaml-findlib \ 182 | 183 | PACKAGES_RUNTIME=" 184 | postgresql-client \ 185 | netcat-openbsd \ 186 | " 187 | 188 | PACKAGES_DOC=" 189 | ubuntu-docs \ 190 | #libglib2.0-doc \ 191 | #libpango1.0-doc \ 192 | #libgtk-3-doc \ 193 | texlive-latex-base-doc \ 194 | python-doc \ 195 | devhelp-common \ 196 | texlive-doc-base \ 197 | doxygen \ 198 | dot2tex \ 199 | " 200 | 201 | PACKAGES_REMOVE=" 202 | ubuntu-desktop \ 203 | example-content \ 204 | software-center \ 205 | app-install-data \ 206 | locales \ 207 | python-twisted-core \ 208 | ubiquity \ 209 | rhythmbox \ 210 | rhythmbox-data \ 211 | empathy \ 212 | empathy-common \ 213 | libtelepathy-glib0 \ 214 | firefox \ 215 | thunderbird \ 216 | libreoffice-core \ 217 | evolution-data-server \ 218 | gnome-games-common \ 219 | gnome-games-data \ 220 | aisleriot \ 221 | deja-dup \ 222 | gwibber \ 223 | oneconf \ 224 | shotwell \ 225 | ubuntuone-client \ 226 | python-ubuntuone-client \ 227 | gnome-orca \ 228 | libgweather-common \ 229 | simple-scan \ 230 | sane-utils \ 231 | printer-driver-hpcups \ 232 | printer-driver-hpijs \ 233 | hplip \ 234 | hplip-data \ 235 | libgutenprint2 \ 236 | foo2zjs \ 237 | colord \ 238 | libsane \ 239 | samba-common \ 240 | gnome-user-guide \ 241 | ure \ 242 | smbclient \ 243 | indicator-messages \ 244 | ubuntuone-client-gnome \ 245 | geoip-database \ 246 | libopencc1 \ 247 | fonts-nanum \ 248 | ttf-indic-fonts-core \ 249 | ttf-wqy-microhei \ 250 | fonts-takao-pgothic \ 251 | libpurple0 \ 252 | brltty \ 253 | liblouis-data \ 254 | " 255 | #ubuntu-wallpapers \ 256 | #this stuff is for Unity 2D, but Ubuntu fails to login without it 257 | #libqtgui4 \ 258 | #libqt4-core \ 259 | #libqt4-xmlpatterns \ 260 | #libwebkitgtk-3.0-0 \ 261 | #language-pack-pt-base \ 262 | #language-pack-es-base \ 263 | #language-pack-xh-base \ 264 | #language-pack-zh-hans \ 265 | #language-pack-de-base \ 266 | #language-pack-fr-base \ 267 | #language-pack-ca-base \ 268 | #language-pack-el-base \ 269 | #language-pack-sv-base \ 270 | #language-pack-ru-base \ 271 | #language-pack-gnome-zh-hans-base \ 272 | #language-pack-kde-zh-hans-base \ 273 | # NOTES 274 | # apps listed first, then libraries that they depend upon which will 275 | # also uninstall other stuff 276 | # ubiquity - graphical Ubuntu installer that runs on boot 277 | # 23MB app-install-data (ubuntu software center) 278 | # 22MB ubuntu-docs (desktop docs) 279 | # 44MB thunderbird 280 | # 26MB amarok 281 | # 200MB libreoffice 282 | # 45MB smbclient 283 | 284 | # Below is a list of packages that will be *removed* when building 285 | # the demo and minimal packages. I dunno, I suspect many of these 286 | # will fail, because they do not exist any more... 287 | PACKAGES_EXDEV=" 288 | autoconf automake autotools-dev \ 289 | blt \ 290 | comerr-dev \ 291 | dpkg-dev \ 292 | emacsen-common \ 293 | fakeroot \ 294 | gettext \ 295 | gdb \ 296 | g++ \ 297 | gcc \ 298 | krb5-multidev \ 299 | libc6-dev \ 300 | libdpkg-perl \ 301 | libgcrypt11-dev \ 302 | libgnutls-dev \ 303 | libgpg-error-dev \ 304 | libgssrpc4 \ 305 | libidn11-dev \ 306 | libalgorithm-diff-perl \ 307 | libalgorithm-diff-xs-perl \ 308 | libalgorithm-merge-perl \ 309 | libkadm5clnt-mit8 \ 310 | libkadm5srv-mit8 \ 311 | libkrb5-dev \ 312 | libldap2-dev \ 313 | libltdl-dev \ 314 | libstdc++-dev \ 315 | libtasn1-3-dev \ 316 | libtimedate-perl \ 317 | libtool \ 318 | libxss1 \ 319 | make \ 320 | manpages-dev \ 321 | m4 \ 322 | patch \ 323 | ttf-lyx \ 324 | zlib1g-dev \ 325 | python-bzrlib \ 326 | linux-headers-generic \ 327 | # libcpprest \ 328 | # libzmq3-dev \ 329 | # libsdl-gfx1.2-dev \ 330 | # tcl-dev \ 331 | # tcsh \ 332 | # libprotoc-dev \ 333 | # protobuf-compiler \ 334 | # wordnet \ 335 | # wordnet-dev \ 336 | # wordnet-sense-index \ 337 | # liblua5.1-0-dev \ 338 | # libxmlrpc-c3-dev \ 339 | # python-flask \ 340 | # python-flask-restful \ 341 | # libglade2-0 \ 342 | # python-glade2 \ 343 | # python-tk \ 344 | # tcl8.5 \ 345 | # tk8.5 \ 346 | " 347 | 348 | # SECTION 2: Command line option handling 349 | 350 | usage() { 351 | if [ "$SELF_NAME" == "$TOOL_NAME" ] ; then 352 | echo "Usage: $SELF_NAME OPTION" 353 | echo " -r Add software repositories" 354 | echo " -d Install base/system build dependencies" 355 | echo " -p Install python build dependencies" 356 | echo " -s Install haskell build dependencies in user space. Don't use sudo" 357 | echo " -i Install build-job artifacts" 358 | echo " -c Install CogUtil" 359 | echo " -a Install AtomSpace" 360 | echo " -f Install from opencog github repo. Pass the name of the repo as an argument" 361 | echo " -o Install OpenCog" 362 | echo " -n Install notebook" 363 | echo " -l [master|java] Install Link Grammar release tarball; else master branch" 364 | echo " -m Install ASMOSES" 365 | echo " -z Install the language subsystem" 366 | echo " -g Install Guile $GUILEVERSION" 367 | echo " -b Build source code in git worktree found @ $PWD" 368 | echo " -e Build examples in git worktree found @ $PWD" 369 | echo " -t Run tests of source code in git worktree found @ $PWD" 370 | echo " -j [jobs] override number of auto-detected make jobs" 371 | echo " -w download data for the opencog repo" 372 | echo " -v Verbose output for 'apt-get' commands" 373 | echo " -h This help message" 374 | else 375 | echo "Usage: $SELF_NAME [OPTIONS] [PACKAGE-TYPE]" 376 | echo " PACKAGE-TYPES:" 377 | for key in ${!PACKAGE_DESCRIPTION[@]}; do 378 | echo " " ${key} $'\t' "${PACKAGE_DESCRIPTION[$key]}" 379 | done 380 | echo " (Live CD: Ubuntu ISO image ~700MB will be downloaded if none found.)" 381 | echo " OPTIONS:" 382 | echo " -i [filename] ISO input filename" 383 | echo " -o [filename] ISO output filename" 384 | echo " -j [jobs] override number of auto-detected make jobs" 385 | echo " -n supress git updates" 386 | fi 387 | } 388 | 389 | 390 | # TODO: change octool usage to 'octool project command' format. Where projects 391 | # are opencog, atomspace, cogutil... & commands are setup(for workspace), 392 | # package(for docker,deb, rpm). Each will have various options/sub-commands. 393 | #if [ $1 ] && [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 394 | 395 | if [ $# -eq 0 ] ; then NO_ARGS=true ; fi 396 | 397 | if [ "$SELF_NAME" == "$TOOL_NAME" ] ; then 398 | while getopts "abdef:gipcrstl:mhvj:ownz" flag ; do 399 | case $flag in 400 | r) ADD_REPOSITORIES=true ;; 401 | d) INSTALL_DEPENDENCIES=true ;; #base development packages 402 | w) DOWNLOAD_DATA=true ;; 403 | p) INSTALL_OPENCOG_PYTHON_PACKAGES=true ;; 404 | c) INSTALL_COGUTIL=true ;; 405 | a) INSTALL_ATOMSPACE=true ;; 406 | f) INSTALL_FROM_REPO="$OPTARG" ;; 407 | o) INSTALL_OPENCOG=true ;; 408 | l) INSTALL_LINK_GRAMMAR=true ; 409 | if [ "$OPTARG" == "master" ]; then 410 | INSTALL_LG_MASTER=true 411 | elif [ "$OPTARG" == "java" ]; then 412 | INSTALL_JAVA_LINK_GRAMMAR=true 413 | fi ;; 414 | m) INSTALL_ASMOSES=true ;; 415 | n) INSTALL_NOTEBOOKS=true;; 416 | g) INSTALL_GUILE=true ;; 417 | b) BUILD_SOURCE=true ;; 418 | e) BUILD_EXAMPLES=true ;; 419 | t) TEST_SOURCE=true ;; 420 | v) unset QUIET ;; 421 | z) INSTALL_LANGUAGE=true ;; 422 | j) MAKE_JOBS="$OPTARG" ;; 423 | s) HASKELL_STACK_SETUP=true;; 424 | i) INSTALL_BUILD=true ;; 425 | h) usage ;; 426 | \?) usage; exit 1 ;; 427 | *) UNKNOWN_FLAGS=true ;; 428 | esac 429 | done 430 | else 431 | while getopts ":i:o:j:s:c:l:r:adubtnxrvh" flag ; do 432 | case $flag in 433 | i) INPUT_ISO_NAME="$OPTARG" ;; 434 | o) OUTPUT_ISO_NAME="$OPTARG" ;; 435 | j) MAKE_JOBS="$OPTARG" ;; #override auto-detected MAKE_JOBS 436 | s) HOST_SOURCE_BRANCH="$OPTARG" ;; 437 | c) HOST_BUILD_DIR="$OPTARG" ;; #local cached build dir 438 | l) LIVE_BUILD_DIR="$OPTARG" ;; #live build directory 439 | r) BZR_REVISION="$OPTARG" ;; 440 | a) ADD_REPOSITORIES=true ;; 441 | d) INSTALL_DEPENDENCIES=true ;; #ALL, none 442 | u) UPDATE_OPENCOG=true ;; #git pull 443 | b) BUILD_OPENCOG=true ;; #build opencog 444 | t) TEST_OPENCOG=true ;; #test opencog 445 | n) unset DEFAULT_UPDATE_OPENCOG ;; #suppress git update 446 | x) unset DEFAULT_BUILD_OPENCOG ;; #suppress build 447 | p) REINSTALL_PACKAGES=true ;; 448 | v) unset QUIET ;; 449 | h) usage ;; 450 | \?) usage ;; 451 | *) UNKNOWN_FLAGS=true ;; 452 | esac 453 | done 454 | fi 455 | 456 | shift $((OPTIND-1)) 457 | 458 | message() { 459 | echo -e "\e[1;34m[$SELF_NAME] $MESSAGE\e[0m" 460 | } 461 | 462 | PACKAGE_TYPE=$DEFAULT_PACKAGE_TYPE 463 | 464 | # This handles ./ocpkg runs, for e.g. `./ocpkg debs` 465 | if [ $1 ] && [ "$SELF_NAME" != "ocpkg" ] ; then 466 | case $1 in 467 | debs) PACKAGE_TYPE=$1 ;; 468 | dev) PACKAGE_TYPE=$1 ;; 469 | demo) PACKAGE_TYPE=$1 ;; 470 | kvm) PACKAGE_TYPE=$1 ;; 471 | min) PACKAGE_TYPE=$1 ;; 472 | local) PACKAGE_TYPE=$1 ;; 473 | docker) PACKAGE_TYPE=$1 ;; 474 | *) MESSAGE="Package type not recognized."; message ; usage ; exit 1 ;; 475 | esac 476 | MESSAGE="Package type: $PACKAGE_TYPE : ${PACKAGE_DESCRIPTION[$PACKAGE_TYPE]}" ; message 477 | fi 478 | 479 | #echo "[otheropts]==> $@" 480 | 481 | # SECTION 3: Error handling & cleanup 482 | 483 | debug() { 484 | MESSAGE="Dropping to debugging chroot prompt..." ; message 485 | chroot $LIVE_SQUASH_UNION /bin/bash -l 486 | } 487 | 488 | cleanup_squash() { 489 | if [ -n "$LIVE_SQUASH_UNION" ]; then 490 | MESSAGE="Cleaning up squash temp space..." ; message 491 | fuser $VERBOSE --mount $LIVE_SQUASH_UNION -kill 492 | sleep $SLEEP_TIME 493 | umount $VERBOSE $LIVE_SQUASH_UNION/var/lib/apt/lists || true 494 | umount $VERBOSE $LIVE_SQUASH_UNION/var/cache/apt/archives || true 495 | umount $VERBOSE $LIVE_SQUASH_UNION/proc || true 496 | umount $VERBOSE $LIVE_SQUASH_UNION/sys || true 497 | umount $VERBOSE $LIVE_SQUASH_UNION/dev/pts || true 498 | umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_BUILD_DIR || true 499 | umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_SOURCE_BRANCH || true 500 | MESSAGE="Killing processes..." ; message 501 | fuser $VERBOSE --mount $LIVE_SQUASH_UNION -kill 502 | sleep $SLEEP_TIME 503 | umount -v -f $VERBOSE $LIVE_SQUASH_UNION || true 504 | rmdir $VERBOSE $LIVE_SQUASH_UNION || true 505 | fi 506 | 507 | if [ -n "$LIVE_SQUASH_DELTA" ]; then 508 | echo " $LIVE_SQUASH_DELTA" 509 | rm -rf $LIVE_SQUASH_DELTA || true 510 | fi 511 | 512 | if [ -n "$UBUNTU_SQUASH_FILES" ]; then 513 | echo " $UBUNTU_SQUASH_FILES" 514 | umount $VERBOSE $UBUNTU_SQUASH_FILES || true 515 | rmdir $VERBOSE $UBUNTU_SQUASH_FILES || true 516 | fi 517 | } 518 | 519 | cleanup_iso() { 520 | if [ -n "$LIVE_ISO_UNION" ] ; then 521 | MESSAGE="Cleaning up ISO temp space..." ; message 522 | echo " $LIVE_ISO_UNION" 523 | umount $VERBOSE $LIVE_ISO_UNION || true 524 | rmdir $LIVE_ISO_UNION || true 525 | df -m $LIVE_ISO_UNION || true 526 | fi 527 | 528 | if [ -n "$LIVE_ISO_DELTA" ] ; then 529 | echo " $LIVE_ISO_DELTA" 530 | rm -rf $LIVE_ISO_DELTA || true 531 | fi 532 | 533 | if [ -n "$UBUNTU_ISO_FILES" ] ; then 534 | echo " $UBUNTU_ISO_FILES" 535 | umount $VERBOSE $UBUNTU_ISO_FILES || true 536 | rmdir $UBUNTU_ISO_FILES || true 537 | df -m $UBUNTU_ISO_FILES || true 538 | fi 539 | } 540 | 541 | exit_trap() { 542 | if [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 543 | MESSAGE="Exiting $SELF_NAME normally..." ; message 544 | cleanup_squash 545 | cleanup_iso 546 | fi 547 | } 548 | 549 | quit_trap() { 550 | if [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 551 | MESSAGE="Exiting $SELF_NAME by request..." ; message 552 | cleanup_squash 553 | cleanup_iso 554 | fi 555 | } 556 | 557 | error_trap() { 558 | if [ "$SELF_NAME" != "$TOOL_NAME" ] ; then 559 | MESSAGE="Error trapped while running $SELF_NAME." ; message 560 | 561 | MESSAGE="Cleanup will run after debug." ; message 562 | debug 563 | cleanup_squash 564 | cleanup_iso 565 | fi 566 | } 567 | 568 | trap error_trap ERR 569 | trap exit_trap EXIT 570 | trap quit_trap INT HUP QUIT TERM 571 | 572 | # SECTION 4: Function Definitions 573 | 574 | is_x68_64() { 575 | ARCH=$(uname -m); 576 | if [ "$ARCH" == "x86_64" ]; then 577 | return 0 578 | else 579 | return 1 580 | fi 581 | } 582 | 583 | get_distro_version() { 584 | cat /etc/os-release | grep "^VERSION_ID=" | cut -d "=" -f 2 585 | } 586 | 587 | UBUNTU_VERSION=$(get_distro_version) 588 | 589 | add_repositories() { 590 | MESSAGE="Adding software repositories..." ; message 591 | for REPO in $REPOSITORIES ; do 592 | sudo apt-add-repository -y $REPO 593 | done 594 | 595 | sudo apt-get $QUIET --assume-yes update 596 | } 597 | 598 | get_github_latest_release() { 599 | local _user="$1" 600 | local _repo="$2" 601 | local _file_name="$3" 602 | 603 | # Getting the version and also accepting the file-name means that the 604 | # download will fail if the release is updated and the file-name has a 605 | # reference to the previous release, a hacky annoying reminder. If the 606 | # file-name has no reference to the version then all will go well. 607 | # TODO: Handle failure gracefully. 608 | local _version=$(curl https://github.com/"$_user"/"$_repo"/releases/latest \ 609 | | cut -d "\"" -f 2 | cut -d "/" -f 8) 610 | echo $_user $_repo $_version 611 | rm -f $_file_name 612 | wget https://github.com/"$_user"/"$_repo"/releases/download/"$_version"/"$_file_name" 613 | } 614 | 615 | install_admin() { 616 | MESSAGE="Installing sysadmin tools...." ; message 617 | if ! sudo apt-get $QUIET --no-upgrade --assume-yes install $PACKAGES_ADMIN ; then 618 | MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 619 | exit 1 620 | fi 621 | } 622 | 623 | # Install given opencog github repo 624 | install_opencog_github_repo() { 625 | local REPO="$1" 626 | MESSAGE="Installing ${REPO}...." ; message 627 | cd /tmp/ 628 | # cleaning up remnants from previous install failures, if any. 629 | rm -rf master.tar.gz* ${REPO}-master 630 | rm -rf master.tar.gz* ${REPO}-main 631 | wget https://github.com/opencog/${REPO}/archive/master.tar.gz 632 | tar -xvf master.tar.gz 633 | 634 | # Newer git repos call them `main` not `master`, cause #RacialJustice 635 | if [ -d ${REPO}-master/ ] 636 | then 637 | cd ${REPO}-master/ 638 | fi 639 | if [ -d ${REPO}-main/ ] 640 | then 641 | cd ${REPO}-main/ 642 | fi 643 | 644 | mkdir build 645 | cd build/ 646 | cmake .. 647 | make -j$(nproc) 648 | sudo make install 649 | sudo ldconfig 650 | cd /tmp/ 651 | rm -rf master.tar.gz ${REPO}-master/ 652 | rm -rf master.tar.gz ${REPO}-main/ 653 | cd $CURRENT_DIR 654 | } 655 | 656 | # Install cogutil 657 | install_cogutil() { 658 | install_opencog_github_repo cogutil 659 | } 660 | 661 | # Install notebooks 662 | install_notebooks() { 663 | MESSAGE="Installing notebooks...." ; message 664 | 665 | 666 | #####INSTALLING pip3 AND jupyter notebook 667 | install_python_pip 668 | cd 669 | sudo pip3 install ipython jupyter 670 | 671 | #####INSTALLING GUILE KERNEL##### 672 | # Check if site folder exits 673 | if [ ! -d "/usr/local/share/guile/site" ] 674 | then 675 | cd /usr/local/share/guile/ 676 | sudo mkdir site 677 | cd 678 | fi 679 | 680 | # Install ZeroMQ library 681 | # ??? Really? Is this really needed? 682 | ## Clean up remenants of previous installations## 683 | rm -rf zeromq-4.2.1* 684 | wget https://github.com/zeromq/libzmq/releases/download/v4.2.1/zeromq-4.2.1.tar.gz 685 | tar xvf zeromq-4.2.1.tar.gz 686 | cd zeromq-4.2.1/ 687 | ./configure 688 | make 689 | sudo make install 690 | cd 691 | 692 | # Install guile-json library 693 | ## Clean up remenants of previous installations## 694 | rm -rf guile-json-0.6.0* 695 | wget http://download.savannah.gnu.org/releases/guile-json/guile-json-0.6.0.tar.gz 696 | tar xvf guile-json-0.6.0.tar.gz 697 | cd guile-json-0.6.0 698 | ./configure --prefix=/usr/local/ 699 | make 700 | sudo make install 701 | cd 702 | 703 | cd `guile -c "(display (%global-site-dir))"` 704 | # Place guile-simple-zmq library to the guile library folder 705 | sudo rm -rf simple-zmq.scm* 706 | sudo wget https://raw.githubusercontent.com/jerry40/guile-simple-zmq/master/src/simple-zmq.scm 707 | #edit simple-zmq.scm => set BUF-SIZE to 8192. 708 | sudo sed -i 's/(define BUF-SIZE.*)/(define BUF-SIZE 8192)/' simple-zmq.scm 709 | cd 710 | 711 | #Kernel setup 712 | if [ ! -d "/home/$USER/.local/share/jupyter/kernels/guile" ] 713 | then 714 | sudo mkdir /home/$USER/.local/share/jupyter/kernels/guile 715 | fi 716 | 717 | cd /home/$USER/.local/share/jupyter/kernels/guile 718 | sudo rm -rf guile-jupyter-kernel.scm hmac.scm kernel.json tools.scm 719 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/guile-jupyter-kernel.scm 720 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/hmac.scm 721 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/kernel.json 722 | sudo wget https://github.com/jerry40/guile-kernel/raw/master/src/tools.scm 723 | sudo sed -i 's,\/home.*local,'$HOME/.local',' kernel.json 724 | 725 | echo "export PATH=$PATH:/home/$USER/.local/bin" >> /home/$USER/.bashrc 726 | echo "source $HOME/.bashrc" 727 | cd $CURRENT_DIR 728 | } 729 | 730 | # Install additional Python packages 731 | # Except that there aren't any at this time.... 732 | install_opencog_python_packages() { 733 | MESSAGE="Installing base python packages...." ; message 734 | install_python 735 | } 736 | 737 | # Install Haskell Dependencies 738 | install_haskell_dependencies(){ 739 | MESSAGE="Installing haskell dependencies in user space...." ; message 740 | sudo wget -qO- https://get.haskellstack.org/ | sh 741 | 742 | cd /tmp 743 | rm -rf patchelf* 744 | wget "https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2" 745 | tar -jxf patchelf-0.9.tar.bz2 746 | rm patchelf-0.9.tar.bz2 747 | cd patchelf-0.9 748 | ./configure 749 | sudo make install 750 | cd /tmp 751 | rm -rf patchelf-0.9 752 | cd $CURRENT_DIR 753 | } 754 | 755 | # The following sets the source & build directory for a project 756 | set_source_and_build_dir() { 757 | if [ "$(git rev-parse --is-inside-work-tree)" == true ] ; then 758 | SOURCE_DIR=$(git rev-parse --show-toplevel) 759 | MESSAGE="Source Directory is set to $SOURCE_DIR" ; message 760 | if [ -d $SOURCE_DIR/build ]; then 761 | BUILD_DIR=$SOURCE_DIR/build 762 | MESSAGE="Build Directory is set to $SOURCE_DIR/build" ; message 763 | else 764 | mkdir $SOURCE_DIR/build 765 | BUILD_DIR=$SOURCE_DIR/build 766 | MESSAGE="Build Directory is set to $SOURCE_DIR/build" ; message 767 | fi 768 | else 769 | MESSAGE="Exiting $SELF_NAME as git worktree is not detected run inside \ 770 | a git worktree" ; message 771 | exit 1 772 | fi 773 | } 774 | 775 | # Build function for cogutil, atomspace & asmoses repos 776 | build_source() { 777 | set_source_and_build_dir 778 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 779 | rm $BUILD_DIR/CMakeCache.txt 780 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 781 | fi 782 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 783 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 784 | cmake -B$BUILD_DIR -H$SOURCE_DIR 785 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS" ; message 786 | make -C $BUILD_DIR -j$MAKE_JOBS 787 | MESSAGE="Finished building source" ; message 788 | } 789 | 790 | # Build examples function for atomspace & asmoses repos 791 | build_examples() { 792 | set_source_and_build_dir 793 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 794 | rm $BUILD_DIR/CMakeCache.txt 795 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 796 | fi 797 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 798 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 799 | cmake -B$BUILD_DIR -H$SOURCE_DIR 800 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS examples" ; message 801 | make -C $BUILD_DIR -j$MAKE_JOBS examples 802 | MESSAGE="Finished building examples" ; message 803 | } 804 | 805 | # Run tests function for cogutil, atomspace & asmoses repos 806 | test_source() { 807 | set_source_and_build_dir 808 | if [ -a $BUILD_DIR/CMakeCache.txt ]; then 809 | rm $BUILD_DIR/CMakeCache.txt 810 | MESSAGE="Removed cmake cache file: rm $BUILD_DIR/CMakeCache.txt" ; message 811 | fi 812 | MESSAGE="cmake -B$BUILD_DIR -H$SOURCE_DIR" ; message 813 | #stackoverflow.com/questions/20610255/how-to-tell-cmake-where-to-put-build-files 814 | cmake -B$BUILD_DIR -H$SOURCE_DIR 815 | MESSAGE="make -C $BUILD_DIR -j$MAKE_JOBS test" ; message 816 | make -C $BUILD_DIR -j$MAKE_JOBS test #ARGS=-j$MAKE_JOBS 817 | MESSAGE="Finished building & running tests" ; message 818 | } 819 | 820 | # Install build job artifacts 821 | install_build() { 822 | set_source_and_build_dir 823 | MESSAGE="Starting installation" ; message 824 | cd $BUILD_DIR 825 | sudo make install 826 | sudo ldconfig 827 | cd $CURRENT_DIR 828 | MESSAGE="Finished installation" ; message 829 | } 830 | 831 | # Install Core AtomSpace 832 | install_atomspace(){ 833 | install_opencog_github_repo atomspace 834 | install_opencog_github_repo atomspace-storage 835 | install_opencog_github_repo atomspace-pgres 836 | install_opencog_github_repo atomspace-rocks 837 | install_opencog_github_repo atomspace-cog 838 | install_opencog_github_repo cogserver 839 | install_opencog_github_repo unify 840 | install_opencog_github_repo sensory 841 | install_opencog_github_repo motor 842 | } 843 | 844 | # Install Language components 845 | # This requires a re-install of Link Grammar, after the AtomSpace 846 | # and after lg-atomese have been installed, because Link Grammar 847 | # now uses the AtomSpace to hold dictionaries, and the lg-atomese 848 | # Atom types to do it. 849 | install_language() { 850 | install_opencog_github_repo lg-atomese 851 | install_link_grammar 852 | install_opencog_github_repo matrix 853 | install_opencog_github_repo learn 854 | install_opencog_github_repo generate 855 | install_opencog_github_repo vision 856 | } 857 | 858 | # Install all of OpenCog 859 | install_opencog() { 860 | install_language 861 | install_opencog_github_repo ure 862 | install_opencog_github_repo attention 863 | install_opencog_github_repo spacetime 864 | install_opencog_github_repo pln 865 | install_opencog_github_repo miner 866 | install_opencog_github_repo asmoses 867 | install_opencog_github_repo opencog 868 | install_opencog_github_repo agi-bio 869 | install_opencog_github_repo benchmark 870 | } 871 | 872 | # Install ASMOSES 873 | install_asmoses() { 874 | install_opencog_github_repo asmoses 875 | } 876 | 877 | # Install Link-Grammar 878 | install_link_grammar(){ 879 | # This uses the archive created by github to build and install link-grammar 880 | # The release at https://www.abisource.com/downloads/link-grammar isn't used 881 | # because the only additional value it provides is it gives a pre configured 882 | # tar ball, and its tls certificate breaks often. Such tar-bar can be released 883 | # by following instructions at 884 | # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release 885 | MESSAGE="Installing Link-Grammar...." ; message 886 | cd /tmp/ 887 | 888 | # cleaning up remnants from previous install failures, if any. 889 | rm -rf link-grammar* 890 | rm -rf master.tar.gz 891 | 892 | # Get install version from command line 893 | if [ $# -eq 1 ]; then 894 | local _version=${1} 895 | wget https://github.com/opencog/link-grammar/archive/link-grammar-${_version}.tar.gz 896 | tar -zxf link-grammar-${_version}.tar.gz 897 | cd link-grammar-link-grammar-${_version}/ 898 | 899 | elif [ $INSTALL_LG_MASTER ]; then 900 | 901 | # Master version fails to follow naming convention 902 | local _version="master" 903 | wget https://github.com/opencog/link-grammar/archive/master.tar.gz 904 | tar -zxf master.tar.gz 905 | cd link-grammar-${_version}/ 906 | else 907 | 908 | # Hunt down the latest tarball version. Abisource is dead. 909 | # local _version=$(wget -O - http://www.abisource.com/downloads/link-grammar/current/ \ 910 | # | grep md5 | awk 'match($0, /[5-9]\.[0-9]+\.[0-9]+/) {print substr($0, RSTART, RLENGTH)}') 911 | local _version=$(git ls-remote -t \ 912 | https://github.com/opencog/link-grammar "link-grammar-5*" \ 913 | | grep -v "\^"| cut -d "-" -f 3 | sort -V |tail -n 1 ) 914 | wget https://github.com/opencog/link-grammar/archive/link-grammar-${_version}.tar.gz 915 | tar -zxf link-grammar-${_version}.tar.gz 916 | cd link-grammar-link-grammar-${_version}/ 917 | fi 918 | ./autogen.sh --no-configure 919 | mkdir build 920 | cd build 921 | if [ $INSTALL_JAVA_LINK_GRAMMAR ]; then 922 | ../configure 923 | else 924 | ../configure --disable-java-bindings 925 | fi 926 | make -j$(nproc) 927 | sudo make install 928 | sudo ldconfig 929 | cd /tmp/ 930 | rm -rf link-grammar* 931 | rm -rf master.tar.gz 932 | cd $CURRENT_DIR 933 | } 934 | 935 | install_bdwgc() { 936 | MESSAGE="Installing latest bdwgc ...." ; message 937 | # This used to work, but not any longer...!? 938 | # Apparently, the newest versions of curl behave differently!? 939 | # local _version=$(curl https://github.com/ivmai/bdwgc/releases/latest \ 940 | # | cut -d "\"" -f 2 | cut -d "/" -f 8) 941 | local _version=$(curl --silent -w %{redirect_url} https://github.com/ivmai/bdwgc/releases/latest \ 942 | | cut -d "\"" -f 2 | cut -d "/" -f 8) 943 | 944 | local _dir_name="gc-${_version:1}" 945 | 946 | # Apparently, the github download URL's have changed. 947 | local _file_name="${_dir_name}.tar.gz" 948 | local _download_name="${_version}/${_dir_name}.tar.gz" 949 | 950 | cd /tmp/ 951 | rm -rf ${_dir_name}* 952 | get_github_latest_release ivmai bdwgc ${_download_name} 953 | tar -xvf ${_file_name} 954 | cd ${_dir_name} 955 | ./configure --enable-large-config 956 | make -j$(nproc) 957 | sudo make install 958 | sudo ldconfig 959 | cd /tmp/ 960 | rm -rf ${_dir_name}* 961 | } 962 | 963 | install_python() { 964 | MESSAGE="Installing python3 ...." ; message 965 | sudo apt-get install -y --no-install-recommends python3-dev python3-dev 966 | 967 | if [[ "$UBUNTU_VERSION" = "\"20.04\"" ]]; then 968 | sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2 969 | sudo apt-get install -y --no-install-recommends python3-nose cython3 970 | fi 971 | if [[ "$UBUNTU_VERSION" = "\"22.04\"" ]]; then 972 | sudo apt-get install -y --no-install-recommends python3-nose cython3 973 | fi 974 | if [[ "$UBUNTU_VERSION" = "\"24.04\"" ]]; then 975 | sudo apt-get install -y --no-install-recommends python3-nose cython3 976 | fi 977 | } 978 | 979 | # Install pip seperately. The problem here is that installing pip 980 | # breaks python in ways that I cannot figure out. So punt, until some 981 | # python guru shows up and fixes this stuff. 982 | install_python_pip() { 983 | MESSAGE="Installing python3 pip...." ; message 984 | sudo apt-get install -y --no-install-recommends python3-pip 985 | sudo pip3 install -U pip setuptools 986 | } 987 | 988 | 989 | install_guile() { 990 | install_bdwgc 991 | MESSAGE="Installing guile-$GUILEVERSION...." ; message 992 | cd /tmp/ 993 | # Clean up remnants from previous install failures, if any. 994 | rm -rf guile-${GUILEVERSION}* 995 | wget https://ftp.gnu.org/gnu/guile/guile-$GUILEVERSION.tar.gz 996 | tar -xvf guile-$GUILEVERSION.tar.gz 997 | cd guile-$GUILEVERSION 998 | mkdir build 999 | cd build 1000 | ../configure 1001 | make -j$(nproc) 1002 | sudo make install 1003 | sudo mv /usr/local/lib/libguile-*.so.*-gdb.scm /usr/share/gdb/auto-load/ 1004 | sudo ldconfig 1005 | cd /tmp/ 1006 | rm -rf guile-${GUILEVERSION}* 1007 | } 1008 | 1009 | # atomspace unit tests have UTF-8 test cases 1010 | # link-grammar needs a smattering of locales 1011 | ensure_UTF_installed() { 1012 | if locale -a | grep -q en_US.utf8 1013 | then 1014 | echo UTF-8 locale enabled already 1015 | else 1016 | sudo sh -c 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' 1017 | sudo sh -c 'echo "ar_AE.UTF-8 UTF-8" >> /etc/locale.gen' 1018 | sudo sh -c 'echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen' 1019 | sudo sh -c 'echo "fa_IR.UTF-8 UTF-8" >> /etc/locale.gen' 1020 | sudo sh -c 'echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen' 1021 | sudo sh -c 'echo "he_IL.UTF-8 UTF-8" >> /etc/locale.gen' 1022 | sudo sh -c 'echo "id_ID.UTF-8 UTF-8" >> /etc/locale.gen' 1023 | sudo sh -c 'echo "kk_KZ.UTF-8 UTF-8" >> /etc/locale.gen' 1024 | sudo sh -c 'echo "lt_LT.UTF-8 UTF-8" >> /etc/locale.gen' 1025 | sudo sh -c 'echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen' 1026 | sudo sh -c 'echo "th_TH.UTF-8 UTF-8" >> /etc/locale.gen' 1027 | sudo sh -c 'echo "tr_TR.UTF-8 UTF-8" >> /etc/locale.gen' 1028 | sudo sh -c 'echo "vi_VN.UTF-8 UTF-8" >> /etc/locale.gen' 1029 | sudo sh -c 'echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen' 1030 | sudo sh -c 'echo "zh_HK.UTF-8 UTF-8" >> /etc/locale.gen' 1031 | sudo locale-gen 1032 | fi 1033 | } 1034 | 1035 | # In Ubuntu 18.04 some links are absent when build-essential and ccache 1036 | # packages are installed by same apt-get command 1037 | update_ccache_links() { 1038 | sudo update-ccache-symlinks 1039 | } 1040 | 1041 | # Install system dependencies 1042 | install_dependencies() { 1043 | # Install the latest python3 version before everything else 1044 | install_python 1045 | 1046 | MESSAGE="Installing OpenCog build dependencies...." ; message 1047 | if ! sudo apt-get $QUIET --no-upgrade --assume-yes --no-install-recommends install $PACKAGES_BUILD $PACKAGES_RUNTIME $PACKAGES_FETCH liboctomap-dev locales ; then 1048 | exit 1 1049 | fi 1050 | ensure_UTF_installed 1051 | 1052 | # Update ccache links 1053 | update_ccache_links 1054 | 1055 | # Install guile >3.0.0 also install bdwgc for language-learning 1056 | install_guile 1057 | } 1058 | 1059 | # Download data 1060 | download_data() { 1061 | DOWNLOAD_DIR="$HOME/.opencog/data" 1062 | MESSAGE="Downloading OpenCog's datasets to $DOWNLOAD_DIR ...." ; message 1063 | if [ ! -d "$DOWNLOAD_DIR" ]; then 1064 | mkdir -p "$DOWNLOAD_DIR" 1065 | fi 1066 | 1067 | if [ ! -f "$DOWNLOAD_DIR/gtwc-en-333333-words.scm" ]; then 1068 | wget -O "$DOWNLOAD_DIR/gtwc-en-333333-words.scm" \ 1069 | https://raw.githubusercontent.com/opencog/test-datasets/master/concept_nodes/gtwc-en-333333-words.scm 1070 | fi 1071 | } 1072 | 1073 | update_opencog_source() { 1074 | if sudo apt-get --no-upgrade --assume-yes $QUIET install $PACKAGES_FETCH ; then 1075 | echo -n 1076 | else 1077 | MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 1078 | exit 1 1079 | fi 1080 | OPENCOG_SOURCE_DIR=$LIVE_SOURCE_BRANCH 1081 | mkdir -p $OPENCOG_SOURCE_DIR || true 1082 | if [ ! "$(ls -A $OPENCOG_SOURCE_DIR/.git)" ]; then 1083 | MESSAGE="Fetching OpenCog source at $OPENCOG_SOURCE_DIR..." ; message 1084 | git clone https://github.com/opencog/opencog $OPENCOG_SOURCE_DIR 1085 | else 1086 | if [ $UPDATE_OPENCOG ] ; then 1087 | MESSAGE="Updating OpenCog source at $OPENCOG_SOURCE_DIR..." ; message 1088 | cd $OPENCOG_SOURCE_DIR 1089 | git pull 1090 | cd - 1091 | fi 1092 | fi 1093 | } 1094 | 1095 | build_opencog() { 1096 | mkdir -p -v $LIVE_BUILD_DIR || true 1097 | cd $LIVE_BUILD_DIR 1098 | MESSAGE="cmake $LIVE_SOURCE_BRANCH" ; message 1099 | cmake $LIVE_SOURCE_BRANCH 1100 | MESSAGE="make -j$MAKE_JOBS" ; message 1101 | make -j$MAKE_JOBS 1102 | 1103 | if [ $TEST_OPENCOG ] ; then 1104 | make test 1105 | fi 1106 | 1107 | case $PACKAGE_TYPE in 1108 | min) MESSAGE="Installing OpenCog..." ; message 1109 | make install; exit 0;; 1110 | demo) MESSAGE="Installing OpenCog..." ; message 1111 | make install; exit 0;; 1112 | dev) exit 0;; 1113 | esac 1114 | 1115 | } 1116 | 1117 | locate_live_iso() { 1118 | if [ $INPUT_ISO_NAME ]; then 1119 | MESSAGE="Using Ubuntu image specified at $INPUT_ISO_NAME" ; message 1120 | UBUNTU_ISO_IMAGE=$INPUT_ISO_NAME 1121 | else 1122 | UBUNTU_LOCATIONS=$(locate --existing --basename "\\$UBUNTU_ISO" | grep $HOME) 1123 | for LOC in $UBUNTU_LOCATIONS ; do 1124 | MESSAGE="Ubuntu image found at $LOC. Checksumming, please wait..." ; message 1125 | LOC_MD5SUM=$(md5sum $LOC | awk '{print $1}') 1126 | if [ "$LOC_MD5SUM" == "$UBUNTU_MD5SUM" ] ; then 1127 | UBUNTU_ISO_IMAGE=$LOC 1128 | MESSAGE="Using image found at $UBUNTU_ISO_IMAGE." ; message 1129 | break 1130 | else 1131 | MESSAGE="...checksum failed." ; message 1132 | fi 1133 | done 1134 | fi 1135 | if [ ! -f $UBUNTU_ISO_IMAGE ] ; then 1136 | #aria2c --seed-time=0 ${UBUNTU_URL}${UBUNTU_ISO}.torrent 1137 | UBUNTU_ISO_IMAGE=${UBUNTU_ISO} 1138 | fi 1139 | } 1140 | 1141 | remove_packages() { 1142 | MESSAGE="$PACKAGE_TYPE install type: Removing unecessary packages..." ; message 1143 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes $QUIET purge $PACKAGES_REMOVE --auto-remove 1144 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes $QUIET autoremove 1145 | # stupid stupid stupid hack 1146 | chroot $LIVE_SQUASH_UNION service cups stop 1147 | } 1148 | 1149 | reinstall_removed() { 1150 | MESSAGE="Re-installing removed packages..." ; message 1151 | apt-get --no-upgrade --assume-yes $QUIET install $PACKAGES_REMOVE 1152 | } 1153 | 1154 | keep_source() { 1155 | MESSAGE="$PACKAGE_TYPE install type: Keeping source code..." ; message 1156 | chroot $LIVE_SQUASH_UNION chown -R 999 $LIVE_SOURCE_BRANCH $LIVE_BUILD_DIR || true 1157 | chroot $LIVE_SQUASH_UNION mkdir -p /home/$LIVE_USERNAME/Desktop/ || true 1158 | chroot $LIVE_SQUASH_UNION ln -s "$LIVE_SOURCE_BRANCH" "/home/$LIVE_USERNAME/Desktop/$LIVE_DESKTOP_SOURCE" || true 1159 | } 1160 | 1161 | remove_source() { 1162 | MESSASGE="$PACKAGE_TYPE install type: Removing source code..." ; message 1163 | chroot $LIVE_SQUASH_UNION umount $VERBOSE $LIVE_SOURCE_BRANCH 1164 | } 1165 | 1166 | remove_build() { 1167 | MESSAGE="$PACKAGE_TYPE install type: Removing build files..." ; message 1168 | echo umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_BUILD_DIR 1169 | umount $VERBOSE $LIVE_SQUASH_UNION$LIVE_BUILD_DIR || true 1170 | rm -rf $LIVE_SQUASH_UNION$LIVE_BUILD_DIR || true 1171 | } 1172 | 1173 | remove_dev_debs() { 1174 | MESSAGE="$PACKAGE_TYPE install type: Removing development packages..." ; message 1175 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes purge $PACKAGES_BUILD $PACKAGES_EXDEV --auto-remove 1176 | chroot $LIVE_SQUASH_UNION apt-get $QUIET autoremove --assume-yes 1177 | } 1178 | 1179 | remove_doc_debs() { 1180 | MESSAGE="$PACKAGE_TYPE install type: Removing documentation packages..." ; message 1181 | chroot $LIVE_SQUASH_UNION apt-get --no-upgrade --assume-yes purge $PACKAGES_DOC --auto-remove 1182 | chroot $LIVE_SQUASH_UNION apt-get $QUIET autoremove --assume-yes 1183 | } 1184 | 1185 | install_package_tools() { 1186 | MESSAGE="Installing packaging tools..." ; message 1187 | if sudo apt-get --no-upgrade --assume-yes $QUIET -y install $PACKAGES_TOOLS ; then 1188 | echo -n 1189 | else 1190 | MESSAGE="Please enable 'universe' repositories and re-run this script." ; message 1191 | exit 1 1192 | fi 1193 | } 1194 | 1195 | mount_live_iso() { 1196 | MESSAGE="Mounting Ubuntu ISO image..." ; message 1197 | 1198 | UBUNTU_ISO_FILES=$(mktemp -d --suffix=.UBUNTU_ISO_FILES) 1199 | mount $VERBOSE -o ro -o loop -t iso9660 $UBUNTU_ISO_IMAGE $UBUNTU_ISO_FILES 1200 | 1201 | MESSAGE="Mounting Ubuntu compressed filesystem..." ; message 1202 | 1203 | UBUNTU_SQUASH_BLOB="$UBUNTU_ISO_FILES/casper/filesystem.squashfs" 1204 | 1205 | if ! [ -e "$UBUNTU_SQUASH_BLOB" ] ; then 1206 | MESSAGE="Could not find the Ubuntu squashfs at '$UBUNTU_SQUASH_BLOB'." ; message 1207 | umount $VERBOSE $UBUNTU_ISO_FILES || true 1208 | exit 1 1209 | fi 1210 | 1211 | LIVE_ISO_DELTA=$(mktemp -d --suffix=.LIVE_ISO_DELTA) 1212 | LIVE_ISO_UNION=$(mktemp -d --suffix=.LIVE_ISO_UNION) 1213 | mount $VERBOSE -t overlayfs -o upperdir=$LIVE_ISO_DELTA,lowerdir=$UBUNTU_ISO_FILES none $LIVE_ISO_UNION 1214 | 1215 | #MESSAGE="Mounting read-only Ubuntu compressed filesystem..." ; message 1216 | 1217 | UBUNTU_SQUASH_FILES=$(mktemp -d --suffix=.UBUNTU_SQUASH_FILES) 1218 | mount $VERBOSE -o loop -t squashfs $UBUNTU_SQUASH_BLOB $UBUNTU_SQUASH_FILES 1219 | 1220 | #MESSAGE="Creating temporary workplace for remastering new compressed files..." ; message 1221 | 1222 | LIVE_SQUASH_DELTA=$(mktemp -d --suffix=.LIVE_SQUASH_DELTA) 1223 | LIVE_SQUASH_UNION=$(mktemp -d --suffix=.LIVE_SQUASH_UNION) 1224 | mount $VERBOSE -t overlayfs -o upperdir=$LIVE_SQUASH_DELTA,lowerdir=$UBUNTU_SQUASH_FILES none $LIVE_SQUASH_UNION 1225 | chmod +rx $LIVE_SQUASH_UNION 1226 | 1227 | MESSAGE="Setting up chroot environment..." ; message 1228 | 1229 | DISTRIB_ID=$(awk '/DISTRIB_ID=/' $LIVE_SQUASH_UNION/etc/lsb-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]') 1230 | DISTRIB_CODENAME=$(awk '/DISTRIB_CODENAME=/' $LIVE_SQUASH_UNION/etc/lsb-release | sed 's/DISTRIB_CODENAME=//' | tr '[:upper:]' '[:lower:]') 1231 | LIVE_USERNAME=$DISTRIB_ID 1232 | LIVE_BUILD_DIR=/home/$LIVE_USERNAME/build 1233 | 1234 | cp $LIVE_SQUASH_UNION/etc/resolv.conf $LIVE_SQUASH_UNION/etc/resolv.conf.bak || true 1235 | cp $LIVE_SQUASH_UNION/etc/apt/sources.list $LIVE_SQUASH_UNION/etc/apt/sources.list.bak || true 1236 | cp /etc/resolv.conf $LIVE_SQUASH_UNION/etc 1237 | cp /etc/apt/sources.list $LIVE_SQUASH_UNION/etc/apt 1238 | if [ -f /etc/apt/apt.conf.d/01apt-cacher-ng-proxy ] ; then 1239 | cp /etc/apt/apt.conf.d/01apt-cacher-ng-proxy $LIVE_SQUASH_UNION/etc/apt/apt.conf.d/01apt-cacher-ng-proxy 1240 | fi 1241 | 1242 | cp $0 $LIVE_SQUASH_UNION$PATH_PREFIX/bin/$SELF_NAME ; chmod ugo+rx $LIVE_SQUASH_UNION$PATH_PREFIX/bin/$SELF_NAME 1243 | cd $LIVE_SQUASH_UNION$PATH_PREFIX/bin 1244 | ln -s $SELF_NAME $TOOL_NAME 1245 | cd $CURRENT_DIR 1246 | 1247 | MESSAGE="Mounting filesystems..." ; message 1248 | 1249 | chroot $LIVE_SQUASH_UNION mount $VERBOSE -t proc none /proc 1250 | chroot $LIVE_SQUASH_UNION mount $VERBOSE -t sysfs none /sys 1251 | chroot $LIVE_SQUASH_UNION mount $VERBOSE -t devpts none /dev/pts 1252 | 1253 | mkdir -p $LIVE_SQUASH_UNION/var/cache/apt/archives 1254 | mkdir -p $LIVE_SQUASH_UNION/var/lib/apt/lists 1255 | mkdir -p $HOST_SOURCE_BRANCH 1256 | mkdir -p $LIVE_SQUASH_UNION/$LIVE_SOURCE_BRANCH 1257 | 1258 | mount $VERBOSE -o bind /var/cache/apt/archives $LIVE_SQUASH_UNION/var/cache/apt/archives 1259 | mount $VERBOSE -o bind /var/lib/apt/lists $LIVE_SQUASH_UNION/var/lib/apt/lists 1260 | mount $VERBOSE -o bind $HOST_SOURCE_BRANCH $LIVE_SQUASH_UNION/$LIVE_SOURCE_BRANCH 1261 | } 1262 | 1263 | prepare_live_iso() { 1264 | 1265 | fuser $VERBOSE --mount $LIVE_SQUASH_UNION -kill 1266 | sleep $SLEEP_TIME 1267 | umount $VERBOSE $LIVE_SQUASH_UNION/proc || true 1268 | umount $VERBOSE $LIVE_SQUASH_UNION/sys || true 1269 | umount $VERBOSE $LIVE_SQUASH_UNION/dev/pts|| true 1270 | umount $VERBOSE $LIVE_SQUASH_UNION/var/lib/apt/lists || true 1271 | umount $VERBOSE $LIVE_SQUASH_UNION/var/cache/apt/archives || true 1272 | 1273 | #replace original config files 1274 | cp $LIVE_SQUASH_UNION/etc/resolv.conf.bak $LIVE_SQUASH_UNION/etc/resolv.conf || true 1275 | cp $LIVE_SQUASH_UNION/etc/apt/sources.list.bak $LIVE_SQUASH_UNION/etc/apt/sources.list || true 1276 | 1277 | if [ -f $LIVE_SQUASH_UNION/etc/apt/apt.conf.d/01apt-cacher-ng-proxy ]; then 1278 | rm $LIVE_SQUASH_UNION/etc/apt/apt.conf.d/01apt-cacher-ng-proxy 1279 | fi 1280 | } 1281 | 1282 | write_live_media() { 1283 | MESSAGE="Creating new compressed filesystem..." ; message 1284 | mksquashfs $LIVE_SQUASH_UNION $LIVE_ISO_UNION/casper/filesystem.squashfs $SQUASHFS_OPTIONS 1285 | printf $(sudo du -sx --block-size=1 $LIVE_SQUASH_UNION | cut -f1) > $LIVE_ISO_UNION/casper/filesystem.size 1286 | MESSAGE="Creating new bootable ISO image..." ; message 1287 | 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 1288 | MESSAGE="Wrote $(du -sm $OUTPUT_ISO_LOCATION/$OUTPUT_ISO_NAME)MB ..." ; message 1289 | chown $VERBOSE $SUDO_USER $OUTPUT_ISO_LOCATION/$OUTPUT_ISO_NAME 1290 | cleanup_squash 1291 | cleanup_iso 1292 | } 1293 | 1294 | # SECTION 5: Main Program (MAIN main) 1295 | 1296 | # This is mainly for configuring workspaces depending on the type 1297 | # of project being worked on. The order here matters. 1298 | if [ "$SELF_NAME" == "$TOOL_NAME" ] ; then 1299 | if [ $UNKNOWN_FLAGS ] ; then usage; exit 1 ; fi 1300 | if [ $NO_ARGS ] ; then usage; exit 1 ; fi 1301 | if [ $ADD_REPOSITORIES ] ; then add_repositories ; fi 1302 | if [ $INSTALL_DEPENDENCIES ] ; then install_dependencies ; fi 1303 | if [ $DOWNLOAD_DATA ] ; then download_data ; fi 1304 | if [ $HASKELL_STACK_SETUP ] ; then install_haskell_dependencies ; fi 1305 | if [ $INSTALL_OPENCOG_PYTHON_PACKAGES ] ; then install_opencog_python_packages ; fi 1306 | if [ $INSTALL_COGUTIL ] ; then install_cogutil ; fi 1307 | if [ $INSTALL_ATOMSPACE ] ; then install_atomspace ; fi 1308 | if [ $INSTALL_LANGUAGE ] ; then install_language ; fi 1309 | if [ $INSTALL_FROM_REPO ] ; then install_opencog_github_repo "$INSTALL_FROM_REPO" ; fi 1310 | if [ $INSTALL_NOTEBOOKS ] ; then install_notebooks ; fi 1311 | if [ $INSTALL_OPENCOG ] ; then install_opencog ; fi 1312 | if [ $INSTALL_LINK_GRAMMAR ] ; then install_link_grammar ; fi 1313 | if [ $INSTALL_ASMOSES ] ; then install_asmoses ; fi 1314 | if [ $INSTALL_GUILE ] ; then install_guile ; fi 1315 | if [ $BUILD_SOURCE ] ; then build_source ; fi 1316 | if [ $INSTALL_NOTEBOOKS ] ; then install_notebooks ; fi 1317 | if [ $BUILD_EXAMPLES ] ; then build_examples ; fi 1318 | if [ $TEST_SOURCE ] ; then test_source ; fi 1319 | if [ $INSTALL_BUILD ] ; then install_build ; fi 1320 | exit 0 1321 | fi 1322 | 1323 | # option flag conditionals are finished, so set defaults 1324 | 1325 | if [ ! $ADD_REPOSITORIES ] ; then ADD_REPOSITORIES=$DEFAULT_ADD_REPOSITORIES; fi 1326 | if [ ! $INSTALL_DEPENDENCIES ] ; then INSTALL_DEPENDENCIES=$DEFAULT_INSTALL_DEPENDENCIES; fi 1327 | if [ ! $UPDATE_OPENCOG ] ; then UPDATE_OPENCOG=$DEFAULT_UPDATE_OPENCOG; fi 1328 | if [ ! $BUILD_OPENCOG ] ; then BUILD_OPENCOG=$DEFAULT_BUILD_OPENCOG; fi 1329 | if [ ! $TEST_OPENCOG ] ; then TEST_OPENCOG=$DEFAULT_TEST_OPENCOG; fi 1330 | 1331 | # package type selected when invoked as 'ocpkg' 1332 | 1333 | case $PACKAGE_TYPE in 1334 | demo) install_package_tools; locate_live_iso ; mount_live_iso ; remove_packages ;; 1335 | min) install_package_tools; locate_live_iso ; mount_live_iso ; remove_packages ;; 1336 | dev) install_package_tools; locate_live_iso ; mount_live_iso 1337 | MESSAGE="$PACKAGE_TYPE install type: Keeping all Ubuntu packages..." ; message ;; 1338 | esac 1339 | 1340 | case $PACKAGE_TYPE in 1341 | local) add_repositories ; install_dependencies ;; 1342 | demo) chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -a -d ;; 1343 | min) chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -a -d ;; 1344 | dev) chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -a -d ;; 1345 | esac 1346 | 1347 | case $PACKAGE_TYPE in 1348 | local) if [ $UPDATE_OPENCOG ] ; then update_opencog_source ; fi ;; 1349 | demo) if [ $UPDATE_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -u ; fi ;; 1350 | min) if [ $UPDATE_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -u ; fi ;; 1351 | dev) if [ $UPDATE_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -u ; fi ;; 1352 | esac 1353 | 1354 | case $PACKAGE_TYPE in 1355 | local) if [ $BUILD_OPENCOG ] ; then build_opencog ; fi ;; 1356 | demo) if [ $BUILD_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -b ; fi ;; 1357 | min) if [ $BUILD_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -b ; fi ;; 1358 | dev) if [ $BUILD_OPENCOG ] ; then chroot $LIVE_SQUASH_UNION $PATH_PREFIX/bin/$TOOL_NAME $VERBOSE -b ; fi ;; 1359 | esac 1360 | 1361 | case $PACKAGE_TYPE in 1362 | min) remove_dev_debs ; remove_doc_debs ; remove_source ; remove_build ;; 1363 | demo) remove_dev_debs ; remove_doc_debs ; remove_source ; remove_build ;; 1364 | dev) keep_source ;; 1365 | esac 1366 | 1367 | case $PACKAGE_TYPE in 1368 | min) prepare_live_iso ; write_live_media ;; 1369 | demo) prepare_live_iso ; write_live_media ;; 1370 | dev) prepare_live_iso ; write_live_media ;; 1371 | esac 1372 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------