diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d1cf3d6a94a..648b5dfc696 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,57 +1,29 @@ steps: - - command: | - echo "--- Creating symbolic link to job directory :file_folder:" && \ - sleep 5 && ln -s "$(pwd)" /data/job && cd /data/job && \ - echo "+++ Building :hammer:" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ - echo "--- Compressing build directory :compression:" && \ - tar -pczf build.tar.gz build/ - label: ":darwin: High Sierra Build" - agents: - - "role=macos-builder" - artifact_paths: "build.tar.gz" - timeout: 60 - - - command: | - echo "--- Creating symbolic link to job directory :file_folder:" && \ - sleep 5 && ln -s "$(pwd)" /data/job && cd /data/job && \ - echo "+++ Building :hammer:" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ - echo "--- Compressing build directory :compression:" && \ - tar -pczf build.tar.gz build/ - label: ":darwin: Mojave Build" - agents: - - "role=builder" - - "os=mojave" - artifact_paths: "build.tar.gz" - timeout: 60 - command: | echo "+++ :hammer: Building" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ + echo 1 | ./scripts/eosio_build.sh && \ echo "--- :compression: Compressing build directory" && \ tar -pczf build.tar.gz build/ - label: ":ubuntu: Build" + label: ":ubuntu: 16.04 Build" agents: queue: "automation-large-builder-fleet" artifact_paths: "build.tar.gz" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16" workdir: /data/job timeout: 60 - + - command: | echo "+++ :hammer: Building" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ + echo 1 | ./scripts/eosio_build.sh && \ echo "--- :compression: Compressing build directory" && \ tar -pczf build.tar.gz build/ label: ":ubuntu: 18.04 Build" @@ -59,144 +31,228 @@ steps: queue: "automation-large-builder-fleet" artifact_paths: "build.tar.gz" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu18" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18" workdir: /data/job timeout: 60 - command: | echo "+++ :hammer: Building" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ + echo 1 | ./scripts/eosio_build.sh && \ echo "--- :compression: Compressing build directory" && \ tar -pczf build.tar.gz build/ - label: ":fedora: Build" + label: ":centos: 7 Build" agents: queue: "automation-large-builder-fleet" artifact_paths: "build.tar.gz" plugins: - docker#v1.4.0: - image: "eosio/ci:fedora" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7" workdir: /data/job timeout: 60 - + - command: | echo "+++ :hammer: Building" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ + echo 1 | ./scripts/eosio_build.sh && \ echo "--- :compression: Compressing build directory" && \ tar -pczf build.tar.gz build/ - label: ":centos: Build" + label: ":aws: 1 Build" agents: queue: "automation-large-builder-fleet" artifact_paths: "build.tar.gz" plugins: - docker#v1.4.0: - image: "eosio/ci:centos" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux1" workdir: /data/job timeout: 60 - command: | echo "+++ :hammer: Building" && \ - echo 1 | ./eosio_build.sh && \ - echo "+++ Validating:" && \ - echo 1 | ./tools/validate_reflection.py plugins/ programs/ libraries/ --recurse --extension "cpp" --extension "hpp" -e && \ + echo 1 | ./scripts/eosio_build.sh && \ echo "--- :compression: Compressing build directory" && \ tar -pczf build.tar.gz build/ - label: ":aws: Build" + label: ":fedora: 27 Build" agents: queue: "automation-large-builder-fleet" artifact_paths: "build.tar.gz" plugins: - docker#v1.4.0: - image: "eosio/ci:amazonlinux" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:fedora27" workdir: /data/job timeout: 60 + - command: | + echo "--- Creating symbolic link to job directory :file_folder:" && \ + sleep 5 && ln -s "$(pwd)" /data/job && cd /data/job && \ + echo "+++ Building :hammer:" && \ + echo 1 | ./scripts/eosio_build.sh && \ + echo "--- Compressing build directory :compression:" && \ + tar -pczf build.tar.gz build/ + label: ":darwin: Mojave Build" + agents: + - "role=builder-v2" + - "os=mojave" + artifact_paths: "build.tar.gz" + timeout: 60 + + - command: | + echo "--- Creating symbolic link to job directory :file_folder:" && \ + sleep 5 && ln -s "$(pwd)" /data/job && cd /data/job && \ + echo "+++ Building :hammer:" && \ + echo 1 | ./scripts/eosio_build.sh && \ + echo "--- Compressing build directory :compression:" && \ + tar -pczf build.tar.gz build/ + label: ":darwin: High Sierra Build" + agents: + - "role=builder-v2" + - "os=high-sierra" + artifact_paths: "build.tar.gz" + timeout: 60 + - wait - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":darwin: High Sierra Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 16.04 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - ln -s "$(pwd)" /data/job && cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":darwin: High Sierra Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -j8 -LE _tests --output-on-failure + label: ":ubuntu: 16.04 Tests" agents: - - "role=macos-tester" - - "os=high-sierra" + queue: "automation-large-builder-fleet" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" + plugins: + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16" + workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":darwin: High Sierra Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 16.04 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - ln -s "$(pwd)" /data/job && cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":darwin: High Sierra NP Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -L nonparallelizable_tests --output-on-failure + label: ":ubuntu: 16.04 NP Tests" agents: - - "role=macos-tester" + queue: "automation-large-builder-fleet" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" + plugins: + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16" + workdir: /data/job timeout: 60 - + - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":darwin: Mojave Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 18.04 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - ln -s "$(pwd)" /data/job && cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":darwin: Mojave Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -j8 -LE _tests --output-on-failure + label: ":ubuntu: 18.04 Tests" agents: - - "role=tester" - - "os=mojave" + queue: "automation-large-builder-fleet" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" + plugins: + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18" + workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":darwin: Mojave Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 18.04 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - ln -s "$(pwd)" /data/job && cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":darwin: Mojave NP Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -L nonparallelizable_tests --output-on-failure + label: ":ubuntu: 18.04 NP Tests" agents: - - "role=tester" - - "os=mojave" + queue: "automation-large-builder-fleet" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" + plugins: + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18" + workdir: /data/job timeout: 60 - + + - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":centos: 7 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":ubuntu: Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -j8 -LE _tests --output-on-failure + label: ":centos: 7 Tests" agents: queue: "automation-large-builder-fleet" artifact_paths: @@ -204,20 +260,26 @@ steps: - "build/genesis.json" - "build/config.ini" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7" workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":centos: 7 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":ubuntu: NP Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -L nonparallelizable_tests --output-on-failure + label: ":centos: 7 NP Tests" agents: queue: "automation-large-builder-fleet" artifact_paths: @@ -225,20 +287,26 @@ steps: - "build/genesis.json" - "build/config.ini" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7" workdir: /data/job timeout: 60 - + - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 18.04 Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":aws: 1 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":ubuntu: 18.04 Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -j8 -LE _tests --output-on-failure + label: ":aws: 1 Tests" agents: queue: "automation-large-builder-fleet" artifact_paths: @@ -246,20 +314,26 @@ steps: - "build/genesis.json" - "build/config.ini" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu18" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux1" workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 18.04 Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":aws: 1 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":ubuntu: 18.04 NP Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -L nonparallelizable_tests --output-on-failure + label: ":aws: 1 NP Tests" agents: queue: "automation-large-builder-fleet" artifact_paths: @@ -267,20 +341,26 @@ steps: - "build/genesis.json" - "build/config.ini" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu18" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux1" workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":fedora: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":fedora: 27 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":fedora: Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -j8 -LE _tests --output-on-failure + label: ":fedora: 27 Tests" agents: queue: "automation-large-builder-fleet" artifact_paths: @@ -288,20 +368,26 @@ steps: - "build/genesis.json" - "build/config.ini" plugins: - docker#v1.4.0: - image: "eosio/ci:fedora" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:fedora27" workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":fedora: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":fedora: 27 Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":fedora: NP Tests" + cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ~/bin/ctest -L nonparallelizable_tests --output-on-failure + label: ":fedora: 27 NP Tests" agents: queue: "automation-large-builder-fleet" artifact_paths: @@ -309,95 +395,89 @@ steps: - "build/genesis.json" - "build/config.ini" plugins: - docker#v1.4.0: - image: "eosio/ci:fedora" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:fedora27" workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":centos: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":darwin: High Sierra Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":centos: Tests" + ln -s "$(pwd)" /data/job && cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ctest -j8 -LE _tests --output-on-failure + label: ":darwin: High Sierra Tests" agents: - queue: "automation-large-builder-fleet" + - "role=tester-v2" + - "os=high-sierra" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" - plugins: - docker#v1.4.0: - image: "eosio/ci:centos" - workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":centos: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":darwin: High Sierra Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":centos: NP Tests" + ln -s "$(pwd)" /data/job && cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ctest -L nonparallelizable_tests --output-on-failure + label: ":darwin: High Sierra NP Tests" agents: - queue: "automation-large-builder-fleet" + - "role=tester-v2" + - "os=high-sierra" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" - plugins: - docker#v1.4.0: - image: "eosio/ci:centos" - workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":aws: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":darwin: Mojave Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -j8 -LE _tests --output-on-failure - label: ":aws: Tests" + ln -s "$(pwd)" /data/job && cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ctest -j8 -LE _tests --output-on-failure + label: ":darwin: Mojave Tests" agents: - queue: "automation-large-builder-fleet" + - "role=tester-v2" + - "os=mojave" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" - plugins: - docker#v1.4.0: - image: "eosio/ci:amazonlinux" - workdir: /data/job timeout: 60 - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":aws: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":darwin: Mojave Build" && \ tar -zxf build.tar.gz && \ echo "--- :m: Starting MongoDB" && \ - $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + ~/bin/mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log && \ echo "+++ :microscope: Running tests" && \ - cd /data/job/build && ctest -L nonparallelizable_tests --output-on-failure - label: ":aws: NP Tests" + ln -s "$(pwd)" /data/job && cd /data/job/build && PATH=\$PATH:~/opt/mongodb/bin ctest -L nonparallelizable_tests --output-on-failure + label: ":darwin: Mojave NP Tests" agents: - queue: "automation-large-builder-fleet" + - "role=tester-v2" + - "os=mojave" artifact_paths: - "mongod.log" - "build/genesis.json" - "build/config.ini" - plugins: - docker#v1.4.0: - image: "eosio/ci:amazonlinux" - workdir: /data/job timeout: 60 - + - wait - command: | @@ -408,7 +488,7 @@ steps: ln -s "$(pwd)" /data/job && cd /data/job/build/packages && bash generate_package.sh brew label: ":darwin: High Sierra Package Builder" agents: - - "role=macos-builder" + - "role=builder-v2" - "os=high-sierra" artifact_paths: - "build/packages/*.tar.gz" @@ -423,7 +503,7 @@ steps: ln -s "$(pwd)" /data/job && cd /data/job/build/packages && bash generate_package.sh brew label: ":darwin: Mojave Package Builder" agents: - - "role=builder" + - "role=builder-v2" - "os=mojave" artifact_paths: - "build/packages/*.tar.gz" @@ -432,18 +512,24 @@ steps: - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 16.04 Build" && \ tar -zxf build.tar.gz && \ echo "+++ :microscope: Starting package build" && \ cd /data/job/build/packages && bash generate_package.sh deb - label: ":ubuntu: Package builder" + label: ":ubuntu: 16.04 Package builder" agents: queue: "automation-large-builder-fleet" artifact_paths: - "build/packages/*.deb" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16" workdir: /data/job env: OS: "ubuntu-16.04" @@ -462,8 +548,14 @@ steps: artifact_paths: - "build/packages/*.deb" plugins: - docker#v1.4.0: - image: "eosio/ci:ubuntu18" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18" workdir: /data/job env: OS: "ubuntu-18.04" @@ -472,7 +564,7 @@ steps: - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":fedora: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":fedora: 27 Build" && \ tar -zxf build.tar.gz && \ echo "+++ :microscope: Starting package build" && \ yum install -y rpm-build && \ @@ -483,14 +575,20 @@ steps: mkdir -p /root/rpmbuild/SPECS && \ mkdir -p /root/rpmbuild/SRPMS && \ cd /data/job/build/packages && bash generate_package.sh rpm - label: ":fedora: Package builder" + label: ":fedora: 27 Package builder" agents: queue: "automation-large-builder-fleet" artifact_paths: - - "build/packages/x86_64/*.rpm" + - "build/packages/*.rpm" plugins: - docker#v1.4.0: - image: "eosio/ci:fedora" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:fedora27" workdir: /data/job env: OS: "fc27" @@ -499,7 +597,7 @@ steps: - command: | echo "--- :arrow_down: Downloading build directory" && \ - buildkite-agent artifact download "build.tar.gz" . --step ":centos: Build" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":centos: 7 Build" && \ tar -zxf build.tar.gz && \ echo "+++ :microscope: Starting package build" && \ yum install -y rpm-build && \ @@ -510,14 +608,20 @@ steps: mkdir -p /root/rpmbuild/SPECS && \ mkdir -p /root/rpmbuild/SRPMS && \ cd /data/job/build/packages && bash generate_package.sh rpm - label: ":centos: Package builder" + label: ":centos: 7 Package builder" agents: queue: "automation-large-builder-fleet" artifact_paths: - - "build/packages/x86_64/*.rpm" + - "build/packages/*.rpm" plugins: - docker#v1.4.0: - image: "eosio/ci:centos" + ecr#v1.1.4: + login: true + account_ids: "436617320021" + no-include-email: true + region: "us-west-2" + docker#v2.1.0: + debug: true + image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7" workdir: /data/job env: OS: "el7" diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e4653750fb..c05866bcc9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,12 +19,17 @@ if (UNIX) execute_process(COMMAND xcrun --show-sdk-path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE) - if (LLVM_DIR STREQUAL "" OR NOT LLVM_DIR) - set(LLVM_DIR "/usr/local/Cellar/llvm@4/4.0.1/lib/cmake/llvm") - endif() endif() endif() +if (LLVM_DIR STREQUAL "" OR NOT LLVM_DIR) + set(LLVM_DIR "$ENV{HOME}/opt/llvm/lib/cmake/llvm") +endif() + +if (BOOST_ROOT STREQUAL "" OR NOT BOOST_ROOT) + set(BOOST_ROOT "$ENV{HOME}/opt/boost") +endif() + include( GNUInstallDirs ) include( VersionMacros ) include( SetupTargetMacros ) diff --git a/CMakeModules/EosioTester.cmake.in b/CMakeModules/EosioTester.cmake.in index d767251cf54..d95b7cc1a29 100644 --- a/CMakeModules/EosioTester.cmake.in +++ b/CMakeModules/EosioTester.cmake.in @@ -1,6 +1,8 @@ cmake_minimum_required( VERSION 3.5 ) message(STATUS "Setting up Eosio Tester @VERSION_FULL@ at @EOS_ROOT_DIR@") +SET(CMAKE_INSTALL_RPATH "${HOME}/lib;${HOME}/lib64") + set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@) set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@) @@ -8,15 +10,10 @@ set(EOSIO_VERSION "@VERSION_FULL@") enable_testing() -if (UNIX) - if (APPLE) - if (LLVM_DIR STREQUAL "" OR NOT LLVM_DIR) - set(LLVM_DIR "/usr/local/opt/llvm@4/lib/cmake/llvm") - endif() - endif() +if (LLVM_DIR STREQUAL "" OR NOT LLVM_DIR) + set(LLVM_DIR @LLVM_DIR@) endif() - find_package( Gperftools QUIET ) if( GPERFTOOLS_FOUND ) message( STATUS "Found gperftools; compiling tests with TCMalloc") @@ -31,13 +28,12 @@ set( CMAKE_CXX_STANDARD 14 ) set( CMAKE_CXX_EXTENSIONS ON ) set( CXX_STANDARD_REQUIRED ON ) +set( BOOST_ROOT @BOOST_ROOT@ ) if ( APPLE ) set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" ) - set( BOOST_ROOT "/usr/local/boost" ) else ( APPLE ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") - set( BOOST_ROOT "~/opt/boost" ) endif ( APPLE ) set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) diff --git a/CMakeModules/EosioTesterBuild.cmake.in b/CMakeModules/EosioTesterBuild.cmake.in index 290cefa576c..f31408c764e 100644 --- a/CMakeModules/EosioTesterBuild.cmake.in +++ b/CMakeModules/EosioTesterBuild.cmake.in @@ -8,15 +8,10 @@ set(EOSIO_VERSION "@VERSION_FULL@") enable_testing() -if (UNIX) - if (APPLE) - if (LLVM_DIR STREQUAL "" OR NOT LLVM_DIR) - set(LLVM_DIR "/usr/local/opt/llvm@4/lib/cmake/llvm") - endif() - endif() +if (LLVM_DIR STREQUAL "" OR NOT LLVM_DIR) + set(LLVM_DIR @LLVM_DIR@) endif() - find_package( Gperftools QUIET ) if( GPERFTOOLS_FOUND ) message( STATUS "Found gperftools; compiling tests with TCMalloc") @@ -31,13 +26,13 @@ set( CMAKE_CXX_STANDARD 14 ) set( CMAKE_CXX_EXTENSIONS ON ) set( CXX_STANDARD_REQUIRED ON ) +set( BOOST_ROOT @BOOST_ROOT@ ) + if ( APPLE ) set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" ) - set( BOOST_ROOT "/usr/local/boost" ) else ( APPLE ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") - set( BOOST_ROOT "~/opt/boost" ) endif ( APPLE ) set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) diff --git a/README.md b/README.md index 454d3ed56d7..5caddfc53b0 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,4 @@ EOSIO currently supports the following operating systems: ## Getting Started Instructions detailing the process of getting the software, building it, running a simple test network that produces blocks, account creation and uploading a sample contract to the blockchain can be found in [Getting Started](https://developers.eos.io/eosio-home/docs) on the [EOSIO Developer Portal](https://developers.eos.io). + diff --git a/eosio_build.sh b/eosio_build.sh deleted file mode 100755 index b37942a78ab..00000000000 --- a/eosio_build.sh +++ /dev/null @@ -1,307 +0,0 @@ -#!/bin/bash -########################################################################## -# This is the EOSIO automated install script for Linux and Mac OS. -# This file was downloaded from https://github.com/EOSIO/eos -# -# Copyright (c) 2017, Respective Authors all rights reserved. -# -# After June 1, 2018 this software is available under the following terms: -# -# The MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# https://github.com/EOSIO/eos/blob/master/LICENSE -########################################################################## - - SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - - function usage() - { - printf "\\tUsage: %s \\n\\t[Build Option -o ] \\n\\t[CodeCoverage -c] \\n\\t[Doxygen -d] \\n\\t[CoreSymbolName -s <1-7 characters>] \\n\\t[Avoid Compiling -a]\\n\\n" "$0" 1>&2 - exit 1 - } - - ARCH=$( uname ) - if [ "${SOURCE_DIR}" == "${PWD}" ]; then - BUILD_DIR="${PWD}/build" - else - BUILD_DIR="${PWD}" - fi - CMAKE_BUILD_TYPE=Release - DISK_MIN=20 - DOXYGEN=false - ENABLE_COVERAGE_TESTING=false - CORE_SYMBOL_NAME="SYS" - # Use current directory's tmp directory if noexec is enabled for /tmp - if (mount | grep "/tmp " | grep --quiet noexec); then - mkdir -p $SOURCE_DIR/tmp - TEMP_DIR="${SOURCE_DIR}/tmp" - rm -rf $SOURCE_DIR/tmp/* - else # noexec wasn't found - TEMP_DIR="/tmp" - fi - START_MAKE=true - TIME_BEGIN=$( date -u +%s ) - VERSION=1.2 - - txtbld=$(tput bold) - bldred=${txtbld}$(tput setaf 1) - txtrst=$(tput sgr0) - - if [ $# -ne 0 ]; then - while getopts ":cdo:s:ah" opt; do - case "${opt}" in - o ) - options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" ) - if [[ "${options[*]}" =~ "${OPTARG}" ]]; then - CMAKE_BUILD_TYPE="${OPTARG}" - else - printf "\\n\\tInvalid argument: %s\\n" "${OPTARG}" 1>&2 - usage - exit 1 - fi - ;; - c ) - ENABLE_COVERAGE_TESTING=true - ;; - d ) - DOXYGEN=true - ;; - s) - if [ "${#OPTARG}" -gt 7 ] || [ -z "${#OPTARG}" ]; then - printf "\\n\\tInvalid argument: %s\\n" "${OPTARG}" 1>&2 - usage - exit 1 - else - CORE_SYMBOL_NAME="${OPTARG}" - fi - ;; - a) - START_MAKE=false - ;; - h) - usage - exit 1 - ;; - \? ) - printf "\\n\\tInvalid Option: %s\\n" "-${OPTARG}" 1>&2 - usage - exit 1 - ;; - : ) - printf "\\n\\tInvalid Option: %s requires an argument.\\n" "-${OPTARG}" 1>&2 - usage - exit 1 - ;; - * ) - usage - exit 1 - ;; - esac - done - fi - - if [ ! -d "${SOURCE_DIR}/.git" ]; then - printf "\\n\\tThis build script only works with sources cloned from git\\n" - printf "\\tPlease clone a new eos directory with 'git clone https://github.com/EOSIO/eos --recursive'\\n" - printf "\\tSee the wiki for instructions: https://github.com/EOSIO/eos/wiki\\n" - exit 1 - fi - - pushd "${SOURCE_DIR}" &> /dev/null - - STALE_SUBMODS=$(( $(git submodule status --recursive | grep -c "^[+\-]") )) - if [ $STALE_SUBMODS -gt 0 ]; then - printf "\\n\\tgit submodules are not up to date.\\n" - printf "\\tPlease run the command 'git submodule update --init --recursive'.\\n" - exit 1 - fi - - printf "\\n\\tBeginning build version: %s\\n" "${VERSION}" - printf "\\t%s\\n" "$( date -u )" - printf "\\tUser: %s\\n" "$( whoami )" - printf "\\tgit head id: %s\\n" "$( cat .git/refs/heads/master )" - printf "\\tCurrent branch: %s\\n" "$( git rev-parse --abbrev-ref HEAD )" - printf "\\n\\tARCHITECTURE: %s\\n" "${ARCH}" - - popd &> /dev/null - - if [ "$ARCH" == "Linux" ]; then - - if [ ! -e /etc/os-release ]; then - printf "\\n\\tEOSIO currently supports Amazon, Centos, Fedora, Mint & Ubuntu Linux only.\\n" - printf "\\tPlease install on the latest version of one of these Linux distributions.\\n" - printf "\\thttps://aws.amazon.com/amazon-linux-ami/\\n" - printf "\\thttps://www.centos.org/\\n" - printf "\\thttps://start.fedoraproject.org/\\n" - printf "\\thttps://linuxmint.com/\\n" - printf "\\thttps://www.ubuntu.com/\\n" - printf "\\tExiting now.\\n" - exit 1 - fi - - OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) - - case "$OS_NAME" in - "Amazon Linux AMI"|"Amazon Linux") - FILE="${SOURCE_DIR}/scripts/eosio_build_amazon.sh" - CXX_COMPILER=g++ - C_COMPILER=gcc - MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf - export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm - export CMAKE=${HOME}/opt/cmake/bin/cmake - export PATH=${HOME}/opt/mongodb/bin:$PATH - ;; - "CentOS Linux") - FILE="${SOURCE_DIR}/scripts/eosio_build_centos.sh" - CXX_COMPILER=g++ - C_COMPILER=gcc - MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf - export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm - export CMAKE=${HOME}/opt/cmake/bin/cmake - export PATH=${HOME}/opt/mongodb/bin:$PATH - ;; - "elementary OS") - FILE="${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh" - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf - export PATH=${HOME}/opt/mongodb/bin:$PATH - ;; - "Fedora") - FILE="${SOURCE_DIR}/scripts/eosio_build_fedora.sh" - CXX_COMPILER=g++ - C_COMPILER=gcc - MONGOD_CONF=/etc/mongod.conf - export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm - ;; - "Linux Mint") - FILE="${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh" - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf - export PATH=${HOME}/opt/mongodb/bin:$PATH - ;; - "Ubuntu") - FILE="${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh" - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf - export PATH=${HOME}/opt/mongodb/bin:$PATH - ;; - "Debian GNU/Linux") - FILE=${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf - export PATH=${HOME}/opt/mongodb/bin:$PATH - ;; - *) - printf "\\n\\tUnsupported Linux Distribution. Exiting now.\\n\\n" - exit 1 - esac - - export BOOST_ROOT="${HOME}/opt/boost" - OPENSSL_ROOT_DIR=/usr/include/openssl - fi - - if [ "$ARCH" == "Darwin" ]; then - FILE="${SOURCE_DIR}/scripts/eosio_build_darwin.sh" - CXX_COMPILER=clang++ - C_COMPILER=clang - MONGOD_CONF=/usr/local/etc/mongod.conf - OPENSSL_ROOT_DIR=/usr/local/opt/openssl - fi - - ${SOURCE_DIR}/scripts/clean_old_install.sh - if [ $? -ne 0 ]; then - printf "\\n\\tError occurred while trying to remove old installation!\\n\\n" - exit -1 - fi - - . "$FILE" - - printf "\\n\\n>>>>>>>> ALL dependencies successfully found or installed . Installing EOSIO\\n\\n" - printf ">>>>>>>> CMAKE_BUILD_TYPE=%s\\n" "${CMAKE_BUILD_TYPE}" - printf ">>>>>>>> ENABLE_COVERAGE_TESTING=%s\\n" "${ENABLE_COVERAGE_TESTING}" - printf ">>>>>>>> DOXYGEN=%s\\n\\n" "${DOXYGEN}" - - if [ ! -d "${BUILD_DIR}" ]; then - if ! mkdir -p "${BUILD_DIR}" - then - printf "Unable to create build directory %s.\\n Exiting now.\\n" "${BUILD_DIR}" - exit 1; - fi - fi - - if ! cd "${BUILD_DIR}" - then - printf "Unable to enter build directory %s.\\n Exiting now.\\n" "${BUILD_DIR}" - exit 1; - fi - - if [ -z "$CMAKE" ]; then - CMAKE=$( command -v cmake ) - fi - - if ! "${CMAKE}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \ - -DCMAKE_C_COMPILER="${C_COMPILER}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \ - -DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \ - -DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \ - -DCMAKE_INSTALL_PREFIX="/usr/local/eosio" ${LOCAL_CMAKE_FLAGS} "${SOURCE_DIR}" - then - printf "\\n\\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\\n\\n" - exit -1 - fi - - if [ "${START_MAKE}" == "false" ]; then - printf "\\n\\t>>>>>>>>>>>>>>>>>>>> EOSIO has been successfully configured but not yet built.\\n\\n" - exit 0 - fi - - if [ -z ${JOBS} ]; then JOBS=$CPU_CORE; fi # Future proofing: Ensure $JOBS is set (usually set in scripts/eosio_build_*.sh scripts) - if ! make -j"${JOBS}" - then - printf "\\n\\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\\n\\n" - exit -1 - fi - - TIME_END=$(( $(date -u +%s) - ${TIME_BEGIN} )) - - printf "\n\n${bldred}\t _______ _______ _______ _________ _______\n" - printf '\t( ____ \( ___ )( ____ \\\\__ __/( ___ )\n' - printf "\t| ( \/| ( ) || ( \/ ) ( | ( ) |\n" - printf "\t| (__ | | | || (_____ | | | | | |\n" - printf "\t| __) | | | |(_____ ) | | | | | |\n" - printf "\t| ( | | | | ) | | | | | | |\n" - printf "\t| (____/\| (___) |/\____) |___) (___| (___) |\n" - printf "\t(_______/(_______)\_______)\_______/(_______)\n${txtrst}" - - printf "\\n\\tEOSIO has been successfully built. %02d:%02d:%02d\\n\\n" $(($TIME_END/3600)) $(($TIME_END%3600/60)) $(($TIME_END%60)) - printf "\\tTo verify your installation run the following commands:\\n" - - print_instructions - - printf "\\tFor more information:\\n" - printf "\\tEOSIO website: https://eos.io\\n" - printf "\\tEOSIO Telegram channel @ https://t.me/EOSProject\\n" - printf "\\tEOSIO resources: https://eos.io/resources/\\n" - printf "\\tEOSIO Stack Exchange: https://eosio.stackexchange.com\\n" - printf "\\tEOSIO wiki: https://github.com/EOSIO/eos/wiki\\n\\n\\n" diff --git a/eosio_install.sh b/eosio_install.sh deleted file mode 100755 index d68a28a2d38..00000000000 --- a/eosio_install.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -########################################################################## -# This is the EOSIO automated install script for Linux and Mac OS. -# This file was downloaded from https://github.com/EOSIO/eos -# -# Copyright (c) 2017, Respective Authors all rights reserved. -# -# After June 1, 2018 this software is available under the following terms: -# -# The MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# https://github.com/EOSIO/eos/blob/master/LICENSE.txt -########################################################################## - -if [ "$(id -u)" -ne 0 ]; then - printf "\n\tThis requires sudo. Please run with sudo.\n\n" - exit -1 -fi - - CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - if [ "${CWD}" != "${PWD}" ]; then - printf "\\n\\tPlease cd into directory %s to run this script.\\n \\tExiting now.\\n\\n" "${CWD}" - exit 1 - fi - - BUILD_DIR="${PWD}/build" - CMAKE_BUILD_TYPE=Release - TIME_BEGIN=$( date -u +%s ) - INSTALL_PREFIX="/usr/local/eosio" - VERSION=1.2 - - txtbld=$(tput bold) - bldred=${txtbld}$(tput setaf 1) - txtrst=$(tput sgr0) - - create_symlink() { - pushd /usr/local/bin &> /dev/null - ln -sf ../eosio/bin/$1 $1 - popd &> /dev/null - } - - create_cmake_symlink() { - mkdir -p /usr/local/lib/cmake/eosio - pushd /usr/local/lib/cmake/eosio &> /dev/null - ln -sf ../../../eosio/lib/cmake/eosio/$1 $1 - popd &> /dev/null - } - - install_symlinks() { - printf "\\n\\tInstalling EOSIO Binary Symlinks\\n\\n" - create_symlink "cleos" - create_symlink "eosio-launcher" - create_symlink "keosd" - create_symlink "nodeos" - } - - if [ ! -d "${BUILD_DIR}" ]; then - printf "\\n\\tError, eosio_build.sh has not ran. Please run ./eosio_build.sh first!\\n\\n" - exit -1 - fi - - ${PWD}/scripts/clean_old_install.sh - if [ $? -ne 0 ]; then - printf "\\n\\tError occurred while trying to remove old installation!\\n\\n" - exit -1 - fi - - if ! pushd "${BUILD_DIR}" - then - printf "Unable to enter build directory %s.\\n Exiting now.\\n" "${BUILD_DIR}" - exit 1; - fi - - if ! make install - then - printf "\\n\\t>>>>>>>>>>>>>>>>>>>> MAKE installing EOSIO has exited with the above error.\\n\\n" - exit -1 - fi - popd &> /dev/null - - install_symlinks - create_cmake_symlink "eosio-config.cmake" - - printf "\n\n${bldred}\t _______ _______ _______ _________ _______\n" - printf '\t( ____ \( ___ )( ____ \\\\__ __/( ___ )\n' - printf "\t| ( \/| ( ) || ( \/ ) ( | ( ) |\n" - printf "\t| (__ | | | || (_____ | | | | | |\n" - printf "\t| __) | | | |(_____ ) | | | | | |\n" - printf "\t| ( | | | | ) | | | | | | |\n" - printf "\t| (____/\| (___) |/\____) |___) (___| (___) |\n" - printf "\t(_______/(_______)\_______)\_______/(_______)\n${txtrst}" - - printf "\\tFor more information:\\n" - printf "\\tEOSIO website: https://eos.io\\n" - printf "\\tEOSIO Telegram channel @ https://t.me/EOSProject\\n" - printf "\\tEOSIO resources: https://eos.io/resources/\\n" - printf "\\tEOSIO Stack Exchange: https://eosio.stackexchange.com\\n" - printf "\\tEOSIO wiki: https://github.com/EOSIO/eos/wiki\\n\\n\\n" diff --git a/eosio_uninstall.sh b/eosio_uninstall.sh deleted file mode 100755 index b080176a139..00000000000 --- a/eosio_uninstall.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/bash - -binaries=(cleos - eosio-launcher - keosd - nodeos) - -if [ -d "/usr/local/eosio" ]; then - printf "\tDo you wish to remove this install? (requires sudo)\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - if [ "$(id -u)" -ne 0 ]; then - printf "\n\tThis requires sudo, please run ./eosio_uninstall.sh with sudo\n\n" - exit -1 - fi - - pushd /usr/local &> /dev/null - rm -rf eosio - pushd bin &> /dev/null - for binary in ${binaries[@]}; do - rm ${binary} - done - # Handle cleanup of directories created from installation - if [ "$1" == "--full" ]; then - if [ -d ~/Library/Application\ Support/eosio ]; then rm -rf ~/Library/Application\ Support/eosio; fi # Mac OS - if [ -d ~/.local/share/eosio ]; then rm -rf ~/.local/share/eosio; fi # Linux - fi - popd &> /dev/null - break;; - [Nn]* ) - printf "\tAborting uninstall\n\n" - exit -1;; - esac - done -fi diff --git a/plugins/mongo_db_plugin/CMakeLists.txt b/plugins/mongo_db_plugin/CMakeLists.txt index 926aca78414..dc76525f3a2 100644 --- a/plugins/mongo_db_plugin/CMakeLists.txt +++ b/plugins/mongo_db_plugin/CMakeLists.txt @@ -1,8 +1,4 @@ if(BUILD_MONGO_DB_PLUGIN) - file(GLOB HEADERS "include/eosio/mongo_db_plugin/*.hpp") - add_library( mongo_db_plugin - mongo_db_plugin.cpp - ${HEADERS} ) find_package(libmongoc-1.0 1.8) @@ -48,24 +44,15 @@ if(BUILD_MONGO_DB_PLUGIN) message(STATUS "Found mongocxx library: ${EOS_LIBMONGOCXX}") else() message("Could NOT find MongoDB. mongo_db_plugin with MongoDB support will not be included.") - # sudo apt-get install pkg-config libssl-dev libsasl2-dev - # wget https://github.com/mongodb/mongo-c-driver/releases/download/1.8.0/mongo-c-driver-1.8.0.tar.gz - # tar xzf mongo-c-driver-1.8.0.tar.gz - # cd mongo-c-driver-1.8.0 - # ./configure --disable-automatic-init-and-cleanup --enable-static - # make - # sudo make install - # - # git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 - # cd mongo-cxx-driver/build - # cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=OFF .. - # sudo make EP_mnmlstc_core - # make - # sudo make install - # - # sudo apt-get install mongodb + return() endif() + # This needs to be after the else/return in the situation that libmongoc isn't found and we need to avoid building mongo :: 'bsoncxx/builder/basic/kvp.hpp' file not found + file(GLOB HEADERS "include/eosio/mongo_db_plugin/*.hpp") + add_library( mongo_db_plugin + mongo_db_plugin.cpp + ${HEADERS} ) + target_include_directories(mongo_db_plugin PRIVATE ${LIBMONGOCXX_STATIC_INCLUDE_DIRS} ${LIBBSONCXX_STATIC_INCLUDE_DIRS} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" @@ -79,6 +66,7 @@ if(BUILD_MONGO_DB_PLUGIN) PUBLIC chain_plugin eosio_chain appbase ${EOS_LIBMONGOCXX} ${EOS_LIBBSONCXX} ) + else() message("mongo_db_plugin not selected and will be omitted.") endif() diff --git a/scripts/clean_old_install.sh b/scripts/clean_old_install.sh deleted file mode 100755 index 6e04edf92d5..00000000000 --- a/scripts/clean_old_install.sh +++ /dev/null @@ -1,70 +0,0 @@ -#! /bin/bash - -if [ -d "/usr/local/include/eosio" ]; then - printf "\n\tOld eosio install needs to be removed.\n\n" - printf "\tDo you wish to remove this install? (requires sudo)\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - if [ "$(id -u)" -ne 0 ]; then - printf "\n\tThis requires sudo, please run ./scripts/clean_old_install.sh with sudo\n\n" - exit -1 - fi - pushd /usr/local &> /dev/null - - pushd include &> /dev/null - rm -rf appbase chainbase eosio eosio.system eosiolib fc libc++ musl &> /dev/null - popd &> /dev/null - - pushd bin &> /dev/null - rm cleos eosio-abigen eosio-applesedemo eosio-launcher eosio-s2wasm eosio-wast2wasm eosiocpp keosd nodeos &> /dev/null - popd &> /dev/null - - libraries=(libeosio_testing - libeosio_chain - libfc - libbinaryen - libWAST - libWASM - libRuntime - libPlatform - libIR - libLogging - libsoftfloat - libchainbase - libappbase - libbuiltins) - pushd lib &> /dev/null - for lib in ${libraries[@]}; do - rm ${lib}.a ${lib}.dylib ${lib}.so &> /dev/null - done - popd &> /dev/null - - pushd etc &> /dev/null - rm eosio &> /dev/null - popd &> /dev/null - - pushd share &> /dev/null - rm eosio &> /dev/null - popd &> /dev/null - - pushd usr/share &> /dev/null - rm eosio &> /dev/null - popd &> /dev/null - - pushd var/lib &> /dev/null - rm eosio &> /dev/null - popd &> /dev/null - - pushd var/log &> /dev/null - rm eosio &> /dev/null - popd &> /dev/null - - popd &> /dev/null - break;; - [Nn]* ) - printf "\tAborting uninstall\n\n" - exit -1;; - esac - done -fi diff --git a/scripts/dep_uninstaller.sh b/scripts/dep_uninstaller.sh new file mode 100755 index 00000000000..be8245c07dd --- /dev/null +++ b/scripts/dep_uninstaller.sh @@ -0,0 +1,94 @@ +#! /bin/bash + +if [ -d "/usr/local/include/eosio" ] || [ -d "$HOME/opt/eosio" ] || [[ $1 =~ force-* ]]; then # use force for running the script directly + printf "\nEOSIO installation (AND DEPENDENCIES) already found...\n" + printf "Do you wish to remove this install (this includes dependencies)?\n" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + if [ -d "$HOME/opt/eosio" ] || [[ $1 == "force-new" ]]; then + if [ $( uname ) == "Darwin" ]; then + # gettext and other brew packages are not modified as they can be dependencies for things other than eosio + brew uninstall llvm@4 --force + fi + rm -rf $HOME/opt/eosio + rm -f $HOME/bin/eosio-launcher + rm -rf $HOME/lib/cmake/eosios + rm -rf $HOME/opt/llvm + rm -f $HOME/opt/boost + rm -rf $HOME/src/boost_* + rm -rf $HOME/src/cmake-* + rm -rf $HOME/share/cmake-* + rm -rf $HOME/share/aclocal/cmake* + rm -rf $HOME/doc/cmake* + rm -f $HOME/bin/nodeos $HOME/bin/keosd $HOME/bin/cleos $HOME/bin/ctest $HOME/bin/*cmake* $HOME/bin/cpack + rm -rf $HOME/src/mongo* + fi + + if [ -d "/usr/local/include/eosio" ] || [[ $1 == "force-old" ]]; then + if [ "$(id -u)" -ne 0 ]; then + printf "\nCleanup requires sudo... Please manually run ./scripts/clean_old_install.sh with sudo.\n" + exit -1 + fi + pushd /usr/local &> /dev/null + rm -rf wasm + pushd include &> /dev/null + rm -rf libbson-1.0 libmongoc-1.0 mongocxx bsoncxx appbase chainbase eosio.system eosiolib fc libc++ musl secp256k* 2>/dev/null + rm -rf eosio 2>/dev/null + popd &> /dev/null + pushd bin &> /dev/null + rm cleos eosio-abigen eosio-applesedemo eosio-launcher eosio-s2wasm eosio-wast2wasm eosiocpp keosd nodeos 2>/dev/null + popd &> /dev/null + libraries=( + libeosio_testing + libeosio_chain + libfc + libbinaryen + libWAST + libWASM + libRuntime + libPlatform + libIR + libLogging + libsoftfloat + libchainbase + libappbase + libbuiltins + libbson-1.0 + libbson-static-1.0.a + libbsoncxx-static + libmongoc-1.0 + libmongoc-static-1.0.a + libmongocxx-static + libsecp256k* + ) + pushd lib &> /dev/null + for lib in ${libraries[@]}; do + rm ${lib}.a ${lib}.dylib ${lib}.so 2>/dev/null + rm pkgconfig/${lib}.pc 2>/dev/null + rm cmake/${lib} 2>/dev/null + done + popd &> /dev/null + pushd etc &> /dev/null + rm eosio 2>/dev/null + popd &> /dev/null + pushd share &> /dev/null + rm eosio 2>/dev/null + popd &> /dev/null + pushd usr/share &> /dev/null + rm eosio 2>/dev/null + popd &> /dev/null + pushd var/lib &> /dev/null + rm eosio 2>/dev/null + popd &> /dev/null + pushd var/log &> /dev/null + rm eosio 2>/dev/null + popd &> /dev/null + fi + break;; + [Nn]* ) + printf "Skipping\n\n" + exit 0 + esac + done +fi diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh new file mode 100755 index 00000000000..39071959699 --- /dev/null +++ b/scripts/eosio_build.sh @@ -0,0 +1,318 @@ +#!/bin/bash +########################################################################## +# This is the EOSIO automated install script for Linux and Mac OS. +# This file was downloaded from https://github.com/EOSIO/eos +# +# Copyright (c) 2017, Respective Authors all rights reserved. +# +# After June 1, 2018 this software is available under the following terms: +# +# The MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# https://github.com/EOSIO/eos/blob/master/LICENSE +########################################################################## + +VERSION=2.1 # Build script version +CMAKE_BUILD_TYPE=Release +export DISK_MIN=20 +DOXYGEN=false +ENABLE_COVERAGE_TESTING=false +CORE_SYMBOL_NAME="SYS" +START_MAKE=true + +TIME_BEGIN=$( date -u +%s ) +txtbld=$(tput bold) +bldred=${txtbld}$(tput setaf 1) +txtrst=$(tput sgr0) + +export SRC_LOCATION=${HOME}/src +export OPT_LOCATION=${HOME}/opt +export VAR_LOCATION=${HOME}/var +export ETC_LOCATION=${HOME}/etc +export BIN_LOCATION=${HOME}/bin +export DATA_LOCATION=${HOME}/data +export CMAKE_VERSION_MAJOR=3 +export CMAKE_VERSION_MINOR=13 +export CMAKE_VERSION_PATCH=2 +export CMAKE_VERSION=${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH} +export MONGODB_VERSION=3.6.3 +export MONGODB_ROOT=${OPT_LOCATION}/mongodb-${MONGODB_VERSION} +export MONGODB_CONF=${ETC_LOCATION}/mongod.conf +export MONGODB_LOG_LOCATION=${VAR_LOCATION}/log/mongodb +export MONGODB_LINK_LOCATION=${OPT_LOCATION}/mongodb +export MONGODB_DATA_LOCATION=${DATA_LOCATION}/mongodb +export MONGO_C_DRIVER_VERSION=1.13.0 +export MONGO_C_DRIVER_ROOT=${SRC_LOCATION}/mongo-c-driver-${MONGO_C_DRIVER_VERSION} +export MONGO_CXX_DRIVER_VERSION=3.4.0 +export MONGO_CXX_DRIVER_ROOT=${SRC_LOCATION}/mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION} +export BOOST_VERSION_MAJOR=1 +export BOOST_VERSION_MINOR=67 +export BOOST_VERSION_PATCH=0 +export BOOST_VERSION=${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_PATCH} +export BOOST_ROOT=${SRC_LOCATION}/boost_${BOOST_VERSION} +export BOOST_LINK_LOCATION=${OPT_LOCATION}/boost +export LLVM_VERSION=release_40 +export LLVM_ROOT=${OPT_LOCATION}/llvm +export LLVM_DIR=${LLVM_ROOT}/lib/cmake/llvm +export DOXYGEN_VERSION=1_8_14 +export DOXYGEN_ROOT=${SRC_LOCATION}/doxygen-${DOXYGEN_VERSION} +export TINI_VERSION=0.18.0 + +# Setup directories +mkdir -p $SRC_LOCATION +mkdir -p $OPT_LOCATION +mkdir -p $VAR_LOCATION +mkdir -p $BIN_LOCATION +mkdir -p $VAR_LOCATION/log +mkdir -p $ETC_LOCATION +mkdir -p $MONGODB_LOG_LOCATION +mkdir -p $MONGODB_DATA_LOCATION + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +REPO_ROOT="${SCRIPT_DIR}/.." +BUILD_DIR="${REPO_ROOT}/build" + +# Use current directory's tmp directory if noexec is enabled for /tmp +if (mount | grep "/tmp " | grep --quiet noexec); then + mkdir -p $REPO_ROOT/tmp + TEMP_DIR="${REPO_ROOT}/tmp" + rm -rf $REPO_ROOT/tmp/* +else # noexec wasn't found + TEMP_DIR="/tmp" +fi + +function usage() +{ + printf "Usage: %s \\n[Build Option -o ] \\n[CodeCoverage -c] \\n[Doxygen -d] \\n[CoreSymbolName -s <1-7 characters>] \\n[Avoid Compiling -a]\\n\\n" "$0" 1>&2 + exit 1 +} + +if [[ $1 == "noninteractive" ]]; then + NONINTERACTIVE=1 +else + NONINTERACTIVE=0 +fi + +if [ $# -ne 0 ]; then + while getopts ":cdo:s:ah" opt; do + case "${opt}" in + o ) + options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" ) + if [[ "${options[*]}" =~ "${OPTARG}" ]]; then + CMAKE_BUILD_TYPE="${OPTARG}" + else + printf "\\nInvalid argument: %s\\n" "${OPTARG}" 1>&2 + usage + exit 1 + fi + ;; + c ) + ENABLE_COVERAGE_TESTING=true + ;; + d ) + DOXYGEN=true + ;; + s) + if [ "${#OPTARG}" -gt 7 ] || [ -z "${#OPTARG}" ]; then + printf "\\nInvalid argument: %s\\n" "${OPTARG}" 1>&2 + usage + exit 1 + else + CORE_SYMBOL_NAME="${OPTARG}" + fi + ;; + a) + START_MAKE=false + ;; + h) + usage + exit 1 + ;; + \? ) + printf "\\nInvalid Option: %s\\n" "-${OPTARG}" 1>&2 + usage + exit 1 + ;; + : ) + printf "\\nInvalid Option: %s requires an argument.\\n" "-${OPTARG}" 1>&2 + usage + exit 1 + ;; + * ) + usage + exit 1 + ;; + esac + done +fi + +if [ ! -d "${REPO_ROOT}/.git" ]; then + printf "\\nThis build script only works with sources cloned from git\\n" + printf "Please clone a new eos directory with 'git clone https://github.com/EOSIO/eos --recursive'\\n" + printf "See the wiki for instructions: https://github.com/EOSIO/eos/wiki\\n" + exit 1 +fi + +cd $REPO_ROOT + +STALE_SUBMODS=$(( $(git submodule status --recursive | grep -c "^[+\-]") )) +if [ $STALE_SUBMODS -gt 0 ]; then + printf "\\ngit submodules are not up to date.\\n" + printf "Please run the command 'git submodule update --init --recursive'.\\n" + exit 1 +fi + +printf "\\nBeginning build version: %s\\n" "${VERSION}" +printf "%s\\n" "$( date -u )" +printf "User: %s\\n" "$( whoami )" +# printf "git head id: %s\\n" "$( cat .git/refs/heads/master )" +printf "Current branch: %s\\n" "$( git rev-parse --abbrev-ref HEAD )" + +ARCH=$( uname ) +printf "\\nARCHITECTURE: %s\\n" "${ARCH}" + +# Find and use existing CMAKE +export CMAKE=$(command -v cmake 2>/dev/null) + +if [ "$ARCH" == "Linux" ]; then + # Check if cmake is already installed or not and use source install location + if [ -z $CMAKE ]; then export CMAKE=$HOME/bin/cmake; fi + export OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) + OPENSSL_ROOT_DIR=/usr/include/openssl + if [ ! -e /etc/os-release ]; then + printf "\\nEOSIO currently supports Amazon, Centos, Fedora, Mint & Ubuntu Linux only.\\n" + printf "Please install on the latest version of one of these Linux distributions.\\n" + printf "https://aws.amazon.com/amazon-linux-ami/\\n" + printf "https://www.centos.org/\\n" + printf "https://start.fedoraproject.org/\\n" + printf "https://linuxmint.com/\\n" + printf "https://www.ubuntu.com/\\n" + printf "Exiting now.\\n" + exit 1 + fi + case "$OS_NAME" in + "Amazon Linux AMI"|"Amazon Linux") + FILE="${REPO_ROOT}/scripts/eosio_build_amazon.sh" + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + "CentOS Linux") + FILE="${REPO_ROOT}/scripts/eosio_build_centos.sh" + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + "elementary OS") + FILE="${REPO_ROOT}/scripts/eosio_build_ubuntu.sh" + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + "Fedora") + export CPATH=/usr/include/llvm4.0:$CPATH # llvm4.0 for fedora package path inclusion + FILE="${REPO_ROOT}/scripts/eosio_build_fedora.sh" + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + "Linux Mint") + FILE="${REPO_ROOT}/scripts/eosio_build_ubuntu.sh" + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + "Ubuntu") + FILE="${REPO_ROOT}/scripts/eosio_build_ubuntu.sh" + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + "Debian GNU/Linux") + FILE="${REPO_ROOT}/scripts/eosio_build_ubuntu.sh" + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + *) + printf "\\nUnsupported Linux Distribution. Exiting now.\\n\\n" + exit 1 + esac +fi + +if [ "$ARCH" == "Darwin" ]; then + # Check if cmake is already installed or not and use source install location + if [ -z $CMAKE ]; then export CMAKE=/usr/local/bin/cmake; fi + export OS_NAME=MacOSX + # opt/gettext: cleos requires Intl, which requires gettext; it's keg only though and we don't want to force linking: https://github.com/EOSIO/eos/issues/2240#issuecomment-396309884 + # HOME/lib/cmake: mongo_db_plugin.cpp:25:10: fatal error: 'bsoncxx/builder/basic/kvp.hpp' file not found + LOCAL_CMAKE_FLAGS="-DCMAKE_PREFIX_PATH=/usr/local/opt/gettext;$HOME/lib/cmake ${LOCAL_CMAKE_FLAGS}" + FILE="${REPO_ROOT}/scripts/eosio_build_darwin.sh" + CXX_COMPILER=clang++ + C_COMPILER=clang + OPENSSL_ROOT_DIR=/usr/local/opt/openssl +fi + +# Cleanup old installation +(. ./scripts/dep_uninstaller.sh) +if [ $? -ne 0 ]; then exit -1; fi # Stop if exit from script is not 0 + +pushd $SRC_LOCATION &> /dev/null +. "$FILE" $NONINTERACTIVE # Execute OS specific build file +popd &> /dev/null + +printf "\\n========================================================================\\n" +printf "======================= Starting EOSIO Build =======================\\n" +printf "## CMAKE_BUILD_TYPE=%s\\n" "${CMAKE_BUILD_TYPE}" +printf "## ENABLE_COVERAGE_TESTING=%s\\n" "${ENABLE_COVERAGE_TESTING}" + +mkdir -p $BUILD_DIR +cd $BUILD_DIR + +$CMAKE -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \ + -DCMAKE_C_COMPILER="${C_COMPILER}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \ + -DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \ + -DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \ + -DCMAKE_INSTALL_PREFIX=$OPT_LOCATION/eosio $LOCAL_CMAKE_FLAGS "${REPO_ROOT}" +if [ $? -ne 0 ]; then exit -1; fi +make -j"${JOBS}" +if [ $? -ne 0 ]; then exit -1; fi + +cd $REPO_ROOT + +TIME_END=$(( $(date -u +%s) - $TIME_BEGIN )) + +printf "${bldred}\n\n _______ _______ _______ _________ _______\n" +printf '( ____ \( ___ )( ____ \\\\__ __/( ___ )\n' +printf "| ( \/| ( ) || ( \/ ) ( | ( ) |\n" +printf "| (__ | | | || (_____ | | | | | |\n" +printf "| __) | | | |(_____ ) | | | | | |\n" +printf "| ( | | | | ) | | | | | | |\n" +printf "| (____/\| (___) |/\____) |___) (___| (___) |\n" +printf "(_______/(_______)\_______)\_______/(_______)\n\n${txtrst}" + +printf "\\nEOSIO has been successfully built. %02d:%02d:%02d\\n" $(($TIME_END/3600)) $(($TIME_END%3600/60)) $(($TIME_END%60)) +printf "==============================================================================================\\n${bldred}" +printf "(Optional) Testing Instructions:\\n" +print_instructions +printf "${BIN_LOCATION}/mongod --dbpath ${MONGODB_DATA_LOCATION} -f ${MONGODB_CONF} --logpath ${MONGODB_LOG_LOCATION}/mongod.log &\\n" +printf "cd ./build && PATH=\$PATH:$HOME/opt/mongodb/bin make test\\n" # PATH is set as currently 'mongo' binary is required for the mongodb test +printf "${txtrst}==============================================================================================\\n" +printf "For more information:\\n" +printf "EOSIO website: https://eos.io\\n" +printf "EOSIO Telegram channel @ https://t.me/EOSProject\\n" +printf "EOSIO resources: https://eos.io/resources/\\n" +printf "EOSIO Stack Exchange: https://eosio.stackexchange.com\\n" +printf "EOSIO wiki: https://github.com/EOSIO/eos/wiki\\n\\n\\n" + diff --git a/scripts/eosio_build_amazon.sh b/scripts/eosio_build_amazon.sh index 1c96024b847..e857246c33e 100644 --- a/scripts/eosio_build_amazon.sh +++ b/scripts/eosio_build_amazon.sh @@ -1,631 +1,243 @@ - OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' | cut -d'.' -f1 ) - - MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 ) - CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) - CPU_CORE=$( lscpu -pCPU | grep -v "#" | wc -l ) - MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) - JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) - - DISK_TOTAL=$( df -h . | grep /dev | tr -s ' ' | cut -d\ -f2 | sed 's/[^0-9]//' ) - DISK_AVAIL=$( df -h . | grep /dev | tr -s ' ' | cut -d\ -f4 | sed 's/[^0-9]//' ) - - printf "\\n\\tOS name: %s\\n" "${OS_NAME}" - printf "\\tOS Version: %s\\n" "${OS_VER}" - printf "\\tCPU speed: %sMhz\\n" "${CPU_SPEED}" - printf "\\tCPU cores: %s\\n" "${CPU_CORE}" - printf "\\tPhysical Memory: %sMgb\\n" "${MEM_MEG}" - printf "\\tDisk space total: %sGb\\n" "${DISK_TOTAL}" - printf "\\tDisk space available: %sG\\n" "${DISK_AVAIL}" - - if [ "${MEM_MEG}" -lt 7000 ]; then - printf "\\tYour system must have 7 or more Gigabytes of physical memory installed.\\n" - printf "\\texiting now.\\n" - exit 1 - fi - - if [[ "${OS_NAME}" == "Amazon Linux AMI" && "${OS_VER}" -lt 2017 ]]; then - printf "\\tYou must be running Amazon Linux 2017.09 or higher to install EOSIO.\\n" - printf "\\texiting now.\\n" - exit 1 - fi - - if [ "${DISK_AVAIL}" -lt "${DISK_MIN}" ]; then - printf "\\tYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" - printf "\\texiting now.\\n" - exit 1 - fi - - printf "\\n\\tChecking Yum installation.\\n" - if ! YUM=$( command -v yum 2>/dev/null ) - then - printf "\\n\\tYum must be installed to compile EOS.IO.\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - - printf "\\tYum installation found at %s.\\n" "${YUM}" - printf "\\tUpdating YUM.\\n" - if ! UPDATE=$( sudo "$YUM" -y update ) - then - printf "\\n\\tYUM update failed.\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - printf "\\t%s\\n" "${UPDATE}" - - if [[ "${OS_NAME}" == "Amazon Linux AMI" ]]; then - DEP_ARRAY=( git gcc72.x86_64 gcc72-c++.x86_64 autoconf automake libtool make bzip2 \ - bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 libstdc++72.x86_64 \ - python27.x86_64 python36-devel.x86_64 libedit-devel.x86_64 doxygen.x86_64 graphviz.x86_64) - else - DEP_ARRAY=( git gcc gcc-c++ autoconf automake libtool make bzip2 \ - bzip2-devel openssl-devel gmp-devel libstdc++ \ - python3 python3-devel libedit-devel doxygen graphviz) - fi - COUNT=1 - DISPLAY="" - DEP="" - - printf "\\n\\tChecking YUM for installed dependencies.\\n\\n" - - for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); - do - pkg=$("$YUM" info "${DEP_ARRAY[$i]}" 2>/dev/null | grep Repo | tr -s ' ' | cut -d: -f2 | sed 's/ //g' ) +if [ $1 == 1 ]; then answer=1; fi # NONINTERACTIVE + +OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' | cut -d'.' -f1 ) + +MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 ) +CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) +CPU_CORE=$( nproc ) +MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) +export JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) + +DISK_INSTALL=$( df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 ) +DISK_TOTAL_KB=$( df . | tail -1 | awk '{print $2}' ) +DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' ) +DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) +DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) + +DEP_ARRAY=( + sudo procps which gcc72 gcc72-c++ autoconf automake libtool make doxygen graphviz \ + bzip2 bzip2-devel openssl-devel gmp gmp-devel libstdc++72 python27 python27-devel python34 python34-devel \ + libedit-devel ncurses-devel swig wget file +) +COUNT=1 +DISPLAY="" +DEP="" + +printf "\\nOS name: %s\\n" "${OS_NAME}" +printf "OS Version: %s\\n" "${OS_VER}" +printf "CPU speed: %sMhz\\n" "${CPU_SPEED}" +printf "CPU cores: %s\\n" "${CPU_CORE}" +printf "Physical Memory: %sMgb\\n" "${MEM_MEG}" +printf "Disk space total: %sGb\\n" "${DISK_TOTAL}" +printf "Disk space available: %sG\\n" "${DISK_AVAIL}" + +if [ "${MEM_MEG}" -lt 7000 ]; then + printf "Your system must have 7 or more Gigabytes of physical memory installed.\\n" + printf "exiting now.\\n" + exit 1 +fi - if [ "$pkg" != "installed" ]; then - DEP=$DEP" ${DEP_ARRAY[$i]} " - DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n\\t" - printf "\\tPackage %s ${bldred} NOT ${txtrst} found.\\n" "${DEP_ARRAY[$i]}" - (( COUNT++ )) - else - printf "\\tPackage %s found.\\n" "${DEP_ARRAY[$i]}" - continue - fi - done +if [[ "${OS_NAME}" == "Amazon Linux AMI" && "${OS_VER}" -lt 2017 ]]; then + printf "You must be running Amazon Linux 2017.09 or higher to install EOSIO.\\n" + printf "exiting now.\\n" + exit 1 +fi - if [ "${COUNT}" -gt 1 ]; then - printf "\\n\\tThe following dependencies are required to install EOSIO.\\n" - printf "\\n\\t${DISPLAY}\\n\\n" - printf "\\tDo you wish to install these dependencies?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\n\\n\\tInstalling dependencies.\\n\\n" - if ! sudo "${YUM}" -y install ${DEP} - then - printf "\\n\\tYUM dependency installation failed.\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - else - printf "\\n\\tYUM dependencies installed successfully.\\n" - fi - break;; - [Nn]* ) printf "\\nUser aborting installation of required dependencies,\\n Exiting now.\\n"; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\n\\tNo required YUM dependencies to install.\\n" - fi +if [ "${DISK_AVAIL}" -lt "${DISK_MIN}" ]; then + printf "You must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" + printf "exiting now.\\n" + exit 1 +fi - if [ "${ENABLE_COVERAGE_TESTING}" = true ]; then - printf "\\n\\tChecking perl installation.\\n" - perl_bin=$( command -v perl 2>/dev/null ) - if [ -z "${perl_bin}" ]; then - printf "\\n\\tInstalling perl.\\n" - if ! sudo "${YUM}" -y install perl - then - printf "\\n\\tUnable to install perl at this time.\\n" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - else - printf "\\tPerl installation found at %s.\\n" "${perl_bin}" - fi - printf "\\n\\tChecking LCOV installation.\\n" - if [ ! -e "/usr/local/bin/lcov" ]; then - printf "\\n\\tLCOV installation not found.\\n" - printf "\\tInstalling LCOV.\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to enter %s. Exiting now.\\n" "${TEMP_DIR}" - exit 1; - fi - if ! git clone "https://github.com/linux-test-project/lcov.git" - then - printf "\\n\\tUnable to clone LCOV at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/lcov" - then - printf "\\n\\tUnable to enter %s/lcov. Exiting now.\\n" "${TEMP_DIR}" - exit 1; - fi - if ! sudo make install - then - printf "\\n\\tUnable to install LCOV at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - rm -rf "${TEMP_DIR}/lcov" - printf "\\n\\tSuccessfully installed LCOV.\\n\\n" - else - printf "\\n\\tLCOV installation found @ /usr/local/bin.\\n" - fi - fi +printf "\\nChecking Yum installation.\\n" +if ! YUM=$( command -v yum 2>/dev/null ) +then + printf "\\nYum must be installed to compile EOS.IO.\\n" + printf "\\nExiting now.\\n" + exit 1 +fi +printf "Yum installation found at ${YUM}.\\n" - printf "\\n\\tChecking CMAKE installation.\\n" - if [ ! -e "${CMAKE}" ]; then - printf "\\tInstalling CMAKE.\\n" - if ! mkdir -p "${HOME}/opt/" 2>/dev/null - then - printf "\\n\\tUnable to create directory %s/opt.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${HOME}/opt" - then - printf "\\n\\tUnable to enter directory %s/opt.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 "https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz" ) - if [ "${STATUS}" -ne 200 ]; then - printf "\\tUnable to clone CMAKE repo.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf "${HOME}/opt/cmake-3.10.2.tar.gz" - then - printf "\\tUnable to unarchive file %s/opt/cmake-3.10.2.tar.gz at this time.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" +if [ $1 == 0 ]; then read -p "Do you wish to update YUM repositories? (y/n) " answer; fi +case ${answer} in + 1 | [Yy]* ) + if ! sudo $YUM -y update; then + printf " - YUM update failed.\\n" exit 1; - fi - if ! rm -f "${HOME}/opt/cmake-3.10.2.tar.gz" - then - printf "\\tUnable to remove file %s/opt/cmake-3.10.2.tar.gz.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! ln -s "${HOME}/opt/cmake-3.10.2/" "${HOME}/opt/cmake" - then - printf "\\tUnable to symlink directory %s/opt/cmake-3.10.2/ to %s/opt/cmake at this time.\\n" "${HOME}" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${HOME}/opt/cmake/" - then - printf "\\n\\tUnable to change directory into %s/opt/cmake.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! ./bootstrap - then - printf "\\tRunning bootstrap for CMAKE exited with the above error.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make -j"${JOBS}" - then - printf "\\tError compiling CMAKE.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tCMAKE successfully installed @ %s.\\n" "${CMAKE}" + else + printf " - YUM update complete.\\n" + fi + ;; + [Nn]* ) echo " - Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no.";; +esac + +printf "Checking RPM for installed dependencies...\\n" +for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do + pkg=$( rpm -qi "${DEP_ARRAY[$i]}" 2>/dev/null | grep Name ) + if [[ -z $pkg ]]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" + printf " - Package %s ${bldred} NOT ${txtrst} found!\\n" "${DEP_ARRAY[$i]}" + (( COUNT++ )) else - printf "\\tCMAKE found @ %s.\\n" "${CMAKE}" + printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" + continue fi - - if [ -d "${HOME}/opt/boost_1_67_0" ]; then - if ! mv "${HOME}/opt/boost_1_67_0" "$BOOST_ROOT" - then - printf "\\n\\tUnable to move directory %s/opt/boost_1_67_0 to %s.\\n" "${HOME}" "${BOOST_ROOT}" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - fi - - printf "\\n\\tChecking boost library installation.\\n" - BVERSION=$( grep "BOOST_LIB_VERSION" "${BOOST_ROOT}/include/boost/version.hpp" 2>/dev/null \ - | tail -1 | tr -s ' ' | cut -d\ -f3 | sed 's/[^0-9\._]//gI' ) - if [ "${BVERSION}" != "1_67" ]; then - printf "\\tRemoving existing boost libraries in %s/opt/boost*.\\n" "${HOME}" - if ! rm -rf "${HOME}"/opt/boost* - then - printf "\\n\\tUnable to remove deprecated boost libraries at this time.\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - printf "\\tInstalling boost libraries.\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to cd into directory %s at this time.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 \ - "https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2" ) - if [ "${STATUS}" -ne 200 ]; then - printf "\\tUnable to download Boost libraries at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf "${TEMP_DIR}/boost_1_67_0.tar.bz2" - then - printf "\\tUnable to decompress Boost libraries @ %s/boost_1_67_0.tar.bz2 at this time.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/boost_1_67_0.tar.bz2" - then - printf "\\tUnable to remove Boost libraries @ %s/boost_1_67_0.tar.bz2 at this time.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/boost_1_67_0/" - then - printf "\\tUnable to change directory into %s/boost_1_67_0/ at this time.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! ./bootstrap.sh "--prefix=${BOOST_ROOT}" - then - printf "\\n\\tInstallation of boost libraries failed. 0\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - if ! "${TEMP_DIR}"/boost_1_67_0/b2 -j"${CPU_CORE}" install - then - printf "\\n\\tInstallation of boost libraries failed. 1\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - if ! rm -rf "${TEMP_DIR}/boost_1_67_0/" - then - printf "\\n\\tUnable to remove boost libraries directory @ %s/boost_1_67_0/.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; +done +if [ "${COUNT}" -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $1 == 0 ]; then read -p "Do you wish to install these dependencies? (y/n) " answer; fi + case ${answer} in + 1 | [Yy]* ) + if ! sudo $YUM -y install ${DEP}; then + printf " - YUM dependency installation failed!\\n" + exit 1; + else + printf " - YUM dependencies installed successfully.\\n" fi - fi - printf "\\tBoost successfully installed @ %s.\\n" "${BOOST_ROOT}" - else - printf "\\tBoost found at %s.\\n" "${BOOST_ROOT}" - fi - - printf "\\n\\tChecking MongoDB installation.\\n" - if [ ! -e "${MONGOD_CONF}" ]; then - printf "\\tInstalling MongoDB 3.6.3.\\n" - if ! cd "${HOME}/opt" - then - printf "\\n\\tUnable to cd into directory %s/opt.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 \ - "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.3.tgz" ) - if [ "${STATUS}" -ne 200 ]; then - printf "\\tUnable to download MongoDB at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf "${HOME}/opt/mongodb-linux-x86_64-amazon-3.6.3.tgz" - then - printf "\\tUnable to decompress file %s at this time.\\n" \ - "${HOME}/opt/mongodb-linux-x86_64-amazon-3.6.3.tgz" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${HOME}/opt/mongodb-linux-x86_64-amazon-3.6.3.tgz" - then - printf "\\tUnable to remove file %s/opt/mongodb-linux-x86_64-amazon-3.6.3.tgz at this time.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! ln -s "${HOME}/opt/mongodb-linux-x86_64-amazon-3.6.3/" "${HOME}/opt/mongodb" - then - printf "\\tUnable to symlink directory %s/opt/mongodb-linux-x86_64-amazon-3.6.3/ to directory %s/opt/mongodb at this time.\\n" \ - "${HOME}" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir "${HOME}/opt/mongodb/data" - then - printf "\\tUnable to create directory %s/opt/mongodb/data at this time.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir "${HOME}/opt/mongodb/log" - then - printf "\\tUnable to make directory %s/opt/mongodb/log at this time.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! touch "${HOME}/opt/mongodb/log/mongodb.log" - then - printf "\\tUnable to create log file @ %s/opt/mongodb/log/mongodb.log at this time.\\n" "${HOME}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - -if ! tee > "/dev/null" "${MONGOD_CONF}" </dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) +if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_ROOT \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j"${JOBS}" install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_LINK_LOCATION \ + && ln -s $BOOST_ROOT $BOOST_LINK_LOCATION \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +else + printf " - Boost library found with correct version @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking MongoDB installation...\\n" +if [ ! -d $MONGODB_ROOT ]; then + printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" + curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \ + && touch $MONGODB_LOG_LOCATION/mongod.log \ + && rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ + && mkdir -p $MONGODB_DATA_LOCATION \ + && rm -rf $MONGODB_LINK_LOCATION \ + && rm -rf $BIN_LOCATION/mongod \ + && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ + && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ + || exit 1 + printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" +else + printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C driver installation...\\n" +if [ ! -d $MONGO_C_DRIVER_ROOT ]; then + printf "Installing MongoDB C driver...\\n" + curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ + && mkdir -p cmake-build \ + && cd cmake-build \ + && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C++ driver installation...\\n" +if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then + printf "Installing MongoDB C++ driver...\\n" + curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ + && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ + && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ + && make -j"${JOBS}" VERBOSE=1 \ + && make install \ + && cd ../.. \ + && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking LLVM 4 support...\\n" +if [ ! -d $LLVM_ROOT ]; then + printf "Installing LLVM 4...\\n" + cd ../opt \ + && git clone --depth 1 --single-branch --branch $LLVM_VERSION https://github.com/llvm-mirror/llvm.git llvm && cd llvm \ + && mkdir build \ + && cd build \ + && $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${LLVM_ROOT}" -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_BUILD_TOOLS=false -DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE="Release" .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + || exit 1 + printf " - LLVM successfully installed @ ${LLVM_ROOT}\\n" +else + printf " - LLVM found @ ${LLVM_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi - if [ $MONGO_INSTALL == "true" ]; then - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz ) - if [ "${STATUS}" -ne 200 ]; then - if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz" - then - printf "\\tUnable to remove file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}" - fi - printf "\\tUnable to download MongoDB C driver at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf mongo-c-driver-1.10.2.tar.gz - then - printf "\\tUnable to unarchive file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz" - then - printf "\\tUnable to remove file mongo-c-driver-1.10.2.tar.gz.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}"/mongo-c-driver-1.10.2 - then - printf "\\tUnable to cd into directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir cmake-build - then - printf "\\tUnable to create directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd cmake-build - then - printf "\\tUnable to enter directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! "${CMAKE}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \ - -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=ON -DENABLE_STATIC=ON .. - then - printf "\\tConfiguring MongoDB C driver has encountered the errors above.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make -j"${CPU_CORE}" - then - printf "\\tError compiling MongoDB C driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install - then - printf "\\tError installing MongoDB C driver.\\nMake sure you have sudo privileges.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.10.2" - then - printf "\\tUnable to remove directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1 - then - printf "\\tUnable to clone MongoDB C++ driver at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/mongo-cxx-driver/build" - then - printf "\\tUnable to enter directory %s/mongo-cxx-driver/build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! "${CMAKE}" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. - then - printf "\\tCmake has encountered the above errors building the MongoDB C++ driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make -j"${CPU_CORE}" - then - printf "\\tError compiling MongoDB C++ driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install - then - printf "\\tError installing MongoDB C++ driver.\\nMake sure you have sudo privileges.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo rm -rf "${TEMP_DIR}/mongo-cxx-driver" - then - printf "\\tUnable to remove directory %s/mongo-cxx-driver.\\n" "${TEMP_DIR}" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tMongo C++ driver installed at /usr/local/lib64/libmongocxx-static.a.\\n" - else - printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n" - fi - printf "\\n\\tChecking LLVM with WASM support.\\n" - if [ ! -d "${HOME}/opt/wasm/bin" ]; then - printf "\\tInstalling LLVM & WASM.\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${TEMP_DIR}/llvm-compiler" 2>/dev/null - then - printf "\\n\\tUnable to make directory %s/llvm-compiler.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler" - then - printf "\\n\\tUnable to change directory into %s/llvm-compiler.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git - then - printf "\\tUnable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.\\n" - printf "\\tExiting now.\\n\\n" - exit; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm/tools" - then - printf "\\n\\tUnable to change directory into %s/llvm-compiler/llvm/tools.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git - then - printf "\\tUnable to clone clang repo @ https://github.com/llvm-mirror/clang.git.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm" - then - printf "\\n\\tUnable to change directory into %s/llvm-compiler/llvm.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${TEMP_DIR}/llvm-compiler/llvm/build" 2>/dev/null - then - printf "\\n\\tUnable to create directory %s/llvm-compiler/llvm/build.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm/build" - then - printf "\\n\\tUnable to change directory into %s/llvm-compiler/llvm/build.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! "$CMAKE" -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${HOME}/opt/wasm" \ - -DLLVM_ENABLE_RTTI=1 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly" \ - -DCMAKE_BUILD_TYPE="Release" .. - then - printf "\\tError compiling LLVM and clang with EXPERIMENTAL WASM support.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make -j"${JOBS}" - then - printf "\\tError compiling LLVM and clang with EXPERIMENTAL WASM support.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make install - then - printf "\\tError installing LLVM and clang with EXPERIMENTAL WASM support.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/llvm-compiler" 2>/dev/null - then - printf "\\tError removing directory %s/llvm-compiler.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tWASM successfully installed at %s/opt/wasm.\\n" "${HOME}" - else - printf "\\tWASM found at %s/opt/wasm.\\n" "${HOME}" - fi +cd .. +printf "\\n" - function print_instructions() - { - printf "\\n\\t%s -f %s &\\n" "$( command -v mongod )" "${MONGOD_CONF}" - printf '\texport PATH=${HOME}/opt/mongodb/bin:$PATH \n' - printf "\\tcd %s; make test\\n\\n" "${BUILD_DIR}" +function print_instructions() { return 0 - } +} \ No newline at end of file diff --git a/scripts/eosio_build_centos.sh b/scripts/eosio_build_centos.sh index fa5e3c61378..3465c6c2825 100644 --- a/scripts/eosio_build_centos.sh +++ b/scripts/eosio_build_centos.sh @@ -1,698 +1,305 @@ - OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' \ - | cut -d'.' -f1 ) - - MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 ) - CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) - CPU_CORE=$( lscpu -pCPU | grep -v "#" | wc -l ) - MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) - JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) - - DISK_INSTALL=$( df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 ) - DISK_TOTAL_KB=$( df . | tail -1 | awk '{print $2}' ) - DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' ) - DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) - DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) - - printf "\\n\\tOS name: %s\\n" "${OS_NAME}" - printf "\\tOS Version: %s\\n" "${OS_VER}" - printf "\\tCPU speed: %sMhz\\n" "${CPU_SPEED}" - printf "\\tCPU cores: %s\\n" "${CPU_CORE}" - printf "\\tPhysical Memory: %s Mgb\\n" "${MEM_MEG}" - printf "\\tDisk install: %s\\n" "${DISK_INSTALL}" - printf "\\tDisk space total: %sG\\n" "${DISK_TOTAL%.*}" - printf "\\tDisk space available: %sG\\n" "${DISK_AVAIL%.*}" - printf "\\tConcurrent Jobs (make -j): ${JOBS}\\n" - - if [ "${MEM_MEG}" -lt 7000 ]; then - printf "\\n\\tYour system must have 7 or more Gigabytes of physical memory installed.\\n" - printf "\\tExiting now.\\n\\n" +if [ $1 == 1 ]; then answer=1; fi # NONINTERACTIVE + +OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' \ +| cut -d'.' -f1 ) + +MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 ) +CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) +CPU_CORE=$( nproc ) +MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) +export JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) + +DISK_INSTALL=$( df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 ) +DISK_TOTAL_KB=$( df . | tail -1 | awk '{print $2}' ) +DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' ) +DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) +DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) + +printf "\\nOS name: ${OS_NAME}\\n" +printf "OS Version: ${OS_VER}\\n" +printf "CPU speed: ${CPU_SPEED}Mhz\\n" +printf "CPU cores: ${CPU_CORE}\\n" +printf "Physical Memory: ${MEM_MEG}Mgb\\n" +printf "Disk install: ${DISK_INSTALL}\\n" +printf "Disk space total: ${DISK_TOTAL%.*}G\\n" +printf "Disk space available: ${DISK_AVAIL%.*}G\\n" +printf "Concurrent Jobs (make -j): ${JOBS}\\n" + +if [ "${MEM_MEG}" -lt 7000 ]; then + printf "\\nYour system must have 7 or more Gigabytes of physical memory installed.\\n" + printf "Exiting now.\\n\\n" + exit 1; +fi + +if [ "${OS_VER}" -lt 7 ]; then + printf "\\nYou must be running Centos 7 or higher to install EOSIO.\\n" + printf "Exiting now.\\n\\n" + exit 1; +fi + +if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then + printf "\\nYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" + printf "Exiting now.\\n\\n" + exit 1; +fi + +printf "\\n" + +printf "Checking Yum installation...\\n" +if ! YUM=$( command -v yum 2>/dev/null ); then + printf "!! Yum must be installed to compile EOS.IO !!\\n" + printf "Exiting now.\\n" exit 1; - fi - - if [ "${OS_VER}" -lt 7 ]; then - printf "\\n\\tYou must be running Centos 7 or higher to install EOSIO.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - - if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then - printf "\\n\\tYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - - printf "\\n" - - printf "\\tChecking Yum installation...\\n" - if ! YUM=$( command -v yum 2>/dev/null ); then - printf "\\t!! Yum must be installed to compile EOS.IO !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\t- Yum installation found at %s.\\n" "${YUM}" - - printf "\\tUpdating YUM repository...\\n" - if ! sudo "${YUM}" -y update > /dev/null 2>&1; then - printf "\\t!! YUM update failed !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\t - YUM repository successfully updated.\\n" - - printf "\\tChecking installation of Centos Software Collections Repository...\\n" - SCL=$( rpm -qa | grep -E 'centos-release-scl-[0-9].*' ) - if [ -z "${SCL}" ]; then - printf "\\t - Do you wish to install and enable this repository?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\tInstalling SCL...\\n" - if ! sudo "${YUM}" -y --enablerepo=extras install centos-release-scl 2>/dev/null; then - printf "\\t!! Centos Software Collections Repository installation failed !!\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - else - printf "\\tCentos Software Collections Repository installed successfully.\\n" - fi - break;; - [Nn]* ) echo "\\tUser aborting installation of required Centos Software Collections Repository, Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\t - ${SCL} found.\\n" - fi - - printf "\\tChecking installation of devtoolset-7...\\n" - DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-7-[0-9].*' ) - if [ -z "${DEVTOOLSET}" ]; then - printf "\\tDo you wish to install devtoolset-7?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\tInstalling devtoolset-7...\\n" - if ! sudo "${YUM}" install -y devtoolset-7 2>/dev/null; then - printf "\\t!! Centos devtoolset-7 installation failed !!\\n" - printf "\\tExiting now.\\n" - exit 1; - else - printf "\\tCentos devtoolset installed successfully.\\n" - fi - break;; - [Nn]* ) echo "User aborting installation of devtoolset-7. Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\t - ${DEVTOOLSET} found.\\n" - fi - printf "\\tEnabling Centos devtoolset-7...\\n" - if ! source "/opt/rh/devtoolset-7/enable" 2>/dev/null; then - printf "\\t!! Unable to enable Centos devtoolset-7 at this time !!\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tCentos devtoolset-7 successfully enabled.\\n" - - printf "\\tChecking installation of python33...\\n" - PYTHON33=$( rpm -qa | grep -E 'python33-[0-9].*' ) - if [ -z "${PYTHON33}" ]; then - printf "\\tDo you wish to install python33?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\tInstalling Python33...\\n" - if ! sudo "${YUM}" install -y python33.x86_64 2>/dev/null; then - printf "\\t!! Centos Python33 installation failed !!\\n" - printf "\\tExiting now.\\n" - exit 1; - else - printf "\\n\\tCentos Python33 installed successfully.\\n" - fi - - break;; - [Nn]* ) echo "User aborting installation of python33. Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\t - ${PYTHON33} found.\\n" - fi - - printf "\\n" - - DEP_ARRAY=( git autoconf automake bzip2 libtool ocaml.x86_64 doxygen graphviz-devel.x86_64 \ - libicu-devel.x86_64 bzip2.x86_64 bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 \ - python-devel.x86_64 gettext-devel.x86_64) - COUNT=1 - DISPLAY="" - DEP="" - - printf "\\tChecking YUM for installed dependencies.\\n" - - for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); - do - pkg=$( "${YUM}" info "${DEP_ARRAY[$i]}" 2>/dev/null | grep Repo | tr -s ' ' | cut -d: -f2 | sed 's/ //g' ) - if [ "$pkg" != "installed" ]; then - DEP=$DEP" ${DEP_ARRAY[$i]} " - DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n\\t" - printf "\\t!! Package %s ${bldred} NOT ${txtrst} found !!\\n" "${DEP_ARRAY[$i]}" - (( COUNT++ )) - else - printf "\\t - Package %s found.\\n" "${DEP_ARRAY[$i]}" - continue - fi - done - - printf "\\n" - - if [ "${COUNT}" -gt 1 ]; then - printf "\\tThe following dependencies are required to install EOSIO.\\n" - printf "\\t${DISPLAY}\\n\\n" - printf "\\tDo you wish to install these dependencies?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\tInstalling dependencies\\n\\n" - if ! sudo "${YUM}" -y install ${DEP}; then - printf "\\t!! YUM dependency installation failed !!\\n" - printf "\\tExiting now.\\n" - exit 1; - else - printf "\\tYUM dependencies installed successfully.\\n" - fi - break;; - [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\t - No required YUM dependencies to install.\\n" - fi - - printf "\\n" - - if [ "${ENABLE_COVERAGE_TESTING}" = true ]; then - printf "\\tChecking perl installation...\\n" - perl_bin=$( command -v perl 2>/dev/null ) - if [ -z "${perl_bin}" ]; then - printf "\\tInstalling perl...\\n" - if ! sudo "${YUM}" -y install perl; then - printf "\\t!! Unable to install perl at this time !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - else - printf "\\t - Perl installation found at %s.\\n" "${perl_bin}" - fi - - printf "\\n" - - printf "\\tChecking LCOV installation...\\n" - lcov=$( command -v lcov 2>/dev/null ) - if [ -z "${lcov}" ]; then - printf "\\tInstalling LCOV...\\n" - if ! cd "${TEMP_DIR}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - LCOVURL="https://github.com/linux-test-project/lcov.git" - if ! git clone "${LCOVURL}"; then - printf "\\t!! Unable to clone LCOV from ${LCOVURL} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/lcov"; then - printf "\\t!! Unable to enter directory %s/lcov !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! sudo make install; then - printf "\\t!! Unable to install LCOV at this time !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${CWD}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${CWD}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/lcov"; then - printf "\\t!! Unable to remove directory %s/lcov !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\tSuccessfully installed LCOV.\\n" - else - printf "\\t - LCOV installation found @ %s.\\n" "${lcov}" - fi - fi - - printf "\\n" - - printf "\\tChecking CMAKE installation...\\n" - if [ ! -e "${CMAKE}" ]; then - printf "\\tInstalling CMAKE...\\n" - if [ ! -d "${HOME}/opt" ]; then - if ! mkdir "${HOME}/opt"; then - printf "\\t!! Unable to create directory %s/opt !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - fi - if ! cd "${HOME}/opt"; then - printf "\\t!! Unable to enter directory %s/opt !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - CMAKETGZ="cmake-3.10.2.tar.gz" - CMAKEURL="https://cmake.org/files/v3.10/${CMAKETGZ}" - STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 "${CMAKEURL}") - if [ "${STATUS}" -ne 200 ]; then - printf "\\t!! Unable to download CMAKE from ${CMAKEURL} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! tar xf "${HOME}/opt/${CMAKETGZ}"; then - printf "\\t!! Unable to unarchive %s/opt/CMAKETGZ} !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! rm -f "${HOME}/opt/${CMAKETGZ}"; then - printf "\\t!! Unable to remove %s/opt/${CMAKETGZ} !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - CMAKEFOLDER=$(echo $CMAKETGZ | sed 's/.tar.gz//g') - if ! ln -s "${HOME}/opt/${CMAKEFOLDER}/" "${HOME}/opt/cmake"; then - printf "\\t!! Unable to symlink %s/opt/${CMAKEFOLDER} to %s/opt/${CMAKEFOLDER}/cmake !!\\n" "${HOME}" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${HOME}/opt/cmake"; then - printf "\\t!! Unable to enter directory %s/opt/cmake !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! ./bootstrap; then - printf "\\t!! Error running bootstrap for CMAKE from $(pwd) !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! make -j"${JOBS}"; then - printf "\\t!! Compiling CMAKE has exited with the above error !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\tCMAKE successfully installed @ %s.\\n\\n" "${CMAKE}" - else - printf "\\t - CMAKE found @ %s.\\n" "${CMAKE}" - fi - - BOOSTTGZ="boost_1_67_0.tar.bz2" - BOOSTFOLDER=$(echo "${BOOSTTGZ}" | sed 's/.tar.bz2//g') - if [ -d "${HOME}/opt/${BOOSTFOLDER}" ]; then - if ! mv "${HOME}/opt/${BOOSTFOLDER}" "${BOOST_ROOT}"; then - printf "\\t!! Unable to move directory %s/opt/${BOOSTFOLDER} to %s !!\\n" "${HOME}" "${BOOST_ROOT}" - printf "\\tExiting now.\\n" - exit 1 - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR"; then - printf "\\t!! Unable to remove directory %s: Please delete it and try again !! 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n" - exit 1; - fi - fi - fi +fi +printf " - Yum installation found at %s.\\n" "${YUM}" - printf "\\tChecking boost library installation...\\n" - BOOSTVERSION=$( grep "#define BOOST_VERSION" "${BOOST_ROOT}/include/boost/version.hpp" 2>/dev/null \ - | tail -1 | tr -s ' ' | cut -d\ -f3) - if [ "${BOOSTVERSION}" != "106700" ]; then - printf "\\tRemoving existing boost libraries in %s/opt/boost*...\\n" "${HOME}" - if ! rm -rf "${HOME}"/opt/boost*; then - printf "\\t!! Unable to remove deprecated boost libraries at %s/opt/boost* !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\tInstalling boost libraries...\\n" - if ! cd "${TEMP_DIR}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - BOOSTURL="https://dl.bintray.com/boostorg/release/1.67.0/source/${BOOSTTGZ}" - STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 "${BOOSTURL}") - if [ "${STATUS}" -ne 200 ]; then - printf "\\t!! Unable to download Boost libraries from ${BOOSTURL} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! tar xf "${TEMP_DIR}/${BOOSTTGZ}"; then - printf "\\t!! Unable to unarchive file %s/${BOOSTTGZ} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/${BOOSTTGZ}"; then - printf "\\t!! Unable to remove file %s/${BOOSTTGZ} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/${BOOSTFOLDER}/"; then - printf "\\t!! Unable to enter directory %s/${BOOSTFOLDER} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! ./bootstrap.sh --prefix=$BOOST_ROOT; then - printf "\\t!! Installation of boost libraries failed with the above error !! 0\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! $TEMP_DIR/$BOOSTFOLDER/b2 -j"${JOBS}" install; then - printf "\\t!! Installation of boost libraries in ${BOOST_ROOT} failed with the above error !! 1\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/${BOOSTFOLDER}/"; then - printf "\\t!! Unable to remove directory %s/boost_1_67_0 !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" +if [ $1 == 0 ]; then read -p "Do you wish to update YUM repositories? (y/n) " answer; fi +case ${answer} in + 1 | [Yy]* ) + if ! "${YUM}" -y update; then + printf " - YUM update failed.\\n" exit 1; - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR"; then - printf "\\t!!Unable to remove directory %s: Please manually remove and try again !! 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n" + else + printf " - YUM update complete.\\n" + fi + ;; + [Nn]* ) echo " - Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no.";; +esac + +printf "Checking installation of Centos Software Collections Repository...\\n" +SCL=$( rpm -qa | grep -E 'centos-release-scl-[0-9].*' ) +if [ -z "${SCL}" ]; then + if [ $1 == 0 ]; then read -p "Do you wish to install and enable this repository? (y/n)? " answer; fi + case ${answer} in + 1 | [Yy]* ) + printf "Installing SCL...\\n" + if ! "${YUM}" -y --enablerepo=extras install centos-release-scl 2>/dev/null; then + printf "!! Centos Software Collections Repository installation failed !!\\n" + printf "Exiting now.\\n\\n" exit 1; + else + printf "Centos Software Collections Repository installed successfully.\\n" fi - fi - printf "\\tBoost successfully installed @ %s.\\n" "${BOOST_ROOT}" - else - printf "\\t - Boost ${BOOSTVERSION} found at %s.\\n" "${BOOST_ROOT}" - fi - - printf "\\n" - - printf "\\tChecking MongoDB installation.\\n" - if [ ! -e "${MONGOD_CONF}" ]; then - printf "\\tInstalling MongoDB 3.6.3...\\n" - if [ ! -d "${HOME}/opt" ]; then - if ! mkdir "${HOME}/opt"; then - printf "\\t!! Unable to create directory %s/opt !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; + ;; + [Nn]* ) echo "User aborting installation of required Centos Software Collections Repository, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac +else + printf " - ${SCL} found.\\n" +fi + +printf "Checking installation of devtoolset-7...\\n" +DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-7-[0-9].*' ) +if [ -z "${DEVTOOLSET}" ]; then + if [ $1 == 0 ]; then read -p "Do you wish to install devtoolset-7? (y/n)? " answer; fi + case ${answer} in + 1 | [Yy]* ) + printf "Installing devtoolset-7...\\n" + if ! "${YUM}" install -y devtoolset-7; then + printf "!! Centos devtoolset-7 installation failed !!\\n" + printf "Exiting now.\\n" + exit 1; + else + printf " - Centos devtoolset installed successfully!\\n" fi - fi - if ! cd "${HOME}/opt"; then - printf "\\t!! Unable to enter directory %s/opt !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - MONGOTGZ="mongodb-linux-x86_64-3.6.3.tgz" - MONGOURL="https://fastdl.mongodb.org/linux/${MONGOTGZ}" - STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 "${MONGOURL}") - if [ "${STATUS}" -ne 200 ]; then - printf "\\t!! Unable to download MongoDB from ${MONGOURL} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! tar xf "${HOME}/opt/${MONGOTGZ}"; then - printf "\\t!! Unable to unarchive file %s/opt/${MONGOTGZ} !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! rm -f "${HOME}/opt/${MONGOTGZ}"; then - printf "\\t!! Unable to remove file %s/opt/${MONGOTGZ} !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - MONGOFOLDER=$(echo "${MONGOTGZ}" | sed 's/.tgz//g') - if ! ln -s "${HOME}/opt/${MONGOFOLDER}/" "${HOME}/opt/mongodb"; then - printf "\\t!! Unable to symlink file %s/opt/${MONGOFOLDER} to %s/opt/mongodb !!\\n" "${HOME}" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${HOME}/opt/mongodb/data"; then - printf "\\t!! Unable to create directory %s/opt/mongodb/data !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${HOME}/opt/mongodb/log"; then - printf "\\t!! Unable to create directory %s/opt/mongodb/log !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! touch "${HOME}/opt/mongodb/log/mongodb.log"; then - printf "\\t!! Unable to create file %s/opt/mongodb/log/mongodb.log !!\\n" "${HOME}" - printf "\\tExiting now.\\n" - exit 1; - fi - - printf "\\n" - - if ! tee > /dev/null "${MONGOD_CONF}" </dev/null | grep Name ) + if [[ -z $pkg ]]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" + printf " - Package %s ${bldred} NOT ${txtrst} found!\\n" "${DEP_ARRAY[$i]}" + (( COUNT++ )) else - printf "\\t - MongoDB config found at %s.\\n" "${MONGOD_CONF}" + printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" + continue fi - - printf "\\tChecking MongoDB C++ driver installation...\\n" - MONGO_INSTALL=true - if [ -e "/usr/local/lib64/libmongocxx-static.a" ]; then - MONGO_INSTALL=false - if [ ! -f /usr/local/lib64/pkgconfig/libmongocxx-static.pc ]; then - MONGO_INSTALL=true - else - if ! version=$( grep "Version:" /usr/local/lib64/pkgconfig/libmongocxx-static.pc | tr -s ' ' | awk '{print $2}' ); then - printf "\\t!! Unable to determine mongodb-cxx-driver version !!\\n" - printf "\\tExiting now.\\n" +done +if [ "${COUNT}" -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $1 == 0 ]; then read -p "Do you wish to install these dependencies? (y/n) " answer; fi + case ${answer} in + 1 | [Yy]* ) + if ! "${YUM}" -y install ${DEP}; then + printf " - YUM dependency installation failed!\\n" exit 1; + else + printf " - YUM dependencies installed successfully.\\n" fi - maj=$( echo "${version}" | cut -d'.' -f1 ) - min=$( echo "${version}" | cut -d'.' -f2 ) - if [ "${maj}" -gt 3 ]; then - MONGO_INSTALL=true - elif [ "${maj}" -eq 3 ] && [ "${min}" -lt 3 ]; then - MONGO_INSTALL=true - fi - fi - fi - - if [ $MONGO_INSTALL == "true" ]; then - if ! cd "${TEMP_DIR}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - MONGODRIVERTGZ="mongo-c-driver-1.10.2.tar.gz" - MONGODRIVERURL="https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/${MONGODRIVERTGZ}" - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 "${MONGODRIVERURL}" ) - if [ "${STATUS}" -ne 200 ]; then - if ! rm -f "${TEMP_DIR}/${MONGODRIVERTGZ}"; then - printf "\\t!! Unable to remove file %s/${MONGODRIVERTGZ} !!\\n" "${TEMP_DIR}" - fi - printf "\\t!! Unable to download MongoDB C driver at this time !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! tar xf "${MONGODRIVERTGZ}"; then - printf "\\t!! Unable to unarchive file %s/${MONGODRIVERTGZ} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/${MONGODRIVERTGZ}"; then - printf "\\t!! Unable to remove file ${MONGODRIVERTGZ} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - MONGODRIVERFOLDER=$(echo $MONGODRIVERTGZ | sed 's/.tar.gz//g') - if ! cd "${TEMP_DIR}/${MONGODRIVERFOLDER}"; then - printf "\\t!! Unable to cd into directory %s/${MONGODRIVERFOLDER} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! mkdir cmake-build; then - printf "\\t!! Unable to create directory %s/${MONGODRIVERFOLDER}/cmake-build !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd cmake-build; then - printf "\\t!! Unable to enter directory %s/${MONGODRIVERFOLDER}/cmake-build !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! "${CMAKE}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \ - -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON ..;then - printf "\\t!! Configuring MongoDB C driver has encountered the errors above !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! make -j"${JOBS}"; then - printf "\\t!! Error compiling MongoDB C driver !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! sudo make install; then - printf "\\t!! Error installing MongoDB C driver: Make sure you have sudo privileges !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/${MONGODRIVERFOLDER}"; then - printf "\\t!! Unable to remove directory %s/${MONGODRIVERFOLDER} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1; then - printf "\\t!! Unable to clone MongoDB C++ driver at this time. !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/mongo-cxx-driver/build"; then - printf "\\t!! Unable to enter directory %s/mongo-cxx-driver/build !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! "${CMAKE}" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..;then - printf "\\t!! Cmake has encountered the above errors building the MongoDB C++ driver !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! sudo make -j"${JOBS}"; then - printf "\\t!! Error compiling MongoDB C++ driver !!\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install; then - printf "\\t!! Error installing MongoDB C++ driver.\\nMake sure you have sudo privileges !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! sudo rm -rf "${TEMP_DIR}/mongo-cxx-driver"; then - printf "\\t!! Unable to remove directory %s/mongo-cxx-driver !!\\n" "${TEMP_DIR}" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\tMongo C++ driver installed at /usr/local/lib64/libmongocxx-static.a.\\n" - else - printf "\\t - Mongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n" - fi - - printf "\\n" - - printf "\\tChecking LLVM with WASM support installation...\\n" - if [ ! -d "${HOME}/opt/wasm/bin" ]; then - printf "\\tInstalling LLVM with WASM...\\n" - if ! cd "${TEMP_DIR}"; then - printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${TEMP_DIR}/llvm-compiler" 2>/dev/null; then - printf "\\t!! Unable to create directory %s/llvm-compiler !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler"; then - printf "\\t!! Unable to enter directory %s/llvm-compiler !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - LLVMURL="https://github.com/llvm-mirror/llvm.git" - if ! git clone --depth 1 --single-branch --branch release_40 "${LLVMURL}"; then - printf "\\t!! Unable to clone llvm repo from ${LLVMURL} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - LLVMLOCATION="llvm-compiler/llvm/tools" - if ! cd "${TEMP_DIR}/${LLVMLOCATION}"; then - printf "\\t!! Unable to enter directory %s/${LLVMLOCATION} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - CLANGURL="https://github.com/llvm-mirror/clang.git" - if ! git clone --depth 1 --single-branch --branch release_40 "${CLANGURL}"; then - printf "\\t!! Unable to clone clang repo from ${CLANGURL} !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - LLVMMIDLOCATION=$(echo $LLVMLOCATION | sed 's/\/tools//g') - if ! cd "${TEMP_DIR}/${LLVMMIDLOCATION}"; then - printf "\\t!! Unable to enter directory %s/${LLVMMIDLOCATION} !!\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${TEMP_DIR}/${LLVMMIDLOCATION}/build" 2>/dev/null; then - printf "\\t!! Unable to create directory %s/${LLVMMIDLOCATION}/build !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/${LLVMMIDLOCATION}/build"; then - printf "\\t!! Unable to enter directory %s/${LLVMMIDLOCATION}/build !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! "${CMAKE}" -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${HOME}/opt/wasm" \ - -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly" \ - -DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE="Release" ..; then - printf "\\t!! CMake has exited with the above error !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! make -j"${JOBS}"; then - printf "\\t!! Compiling LLVM with EXPERIMENTAL WASM support has exited with the above errors !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - if ! make install; then - printf "\\t!! Installing LLVM with EXPERIMENTAL WASM support has exited with the above errors !!\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - LLVMFOLDER=$(echo $LLVMMIDLOCATION | | sed 's/\/llvm//g') - if ! rm -rf "${TEMP_DIR}/${LLVMFOLDER}" 2>/dev/null; then - printf "\\t!! Unable to remove directory %s/${LLVMFOLDER} !!\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n" - exit 1; - fi - printf "\\tWASM compiler successfully installed at %s/opt/wasm\\n" "${HOME}" - else - printf "\\t - WASM found at %s/opt/wasm\\n" "${HOME}" - fi - - printf "\\n" - - function print_instructions() - { - printf "\\t%s -f %s &\\n" "$( command -v mongod )" "${MONGOD_CONF}" - printf "\\tsource /opt/rh/python33/enable\\n" - printf '\texport PATH=${HOME}/opt/mongodb/bin:$PATH\n' - printf "\\tcd %s; make test\\n\\n" "${BUILD_DIR}" - return 0 - } + ;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac +else + printf " - No required YUM dependencies to install.\\n" +fi + +if [ -d /opt/rh/python33 ]; then + printf "Enabling python33...\\n" + source /opt/rh/python33/enable || exit 1 + printf " - Python33 successfully enabled!\\n" +fi + +printf "\\n" + +printf "Checking CMAKE installation...\\n" +if [ ! -e $CMAKE ]; then + printf "Installing CMAKE...\\n" + curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ + && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ + && cd cmake-$CMAKE_VERSION \ + && ./bootstrap --prefix=$HOME \ + && make -j"${JOBS}" \ + && make install \ + && cd .. \ + && rm -f cmake-$CMAKE_VERSION.tar.gz \ + || exit 1 + printf " - CMAKE successfully installed @ ${CMAKE} \\n" +else + printf " - CMAKE found @ ${CMAKE}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +export CPATH="$CPATH:/opt/rh/python33/root/usr/include/python3.3m" # m on the end causes problems with boost finding python3 +printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" +BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) +if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_ROOT \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j"${JOBS}" install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_LINK_LOCATION \ + && ln -s $BOOST_ROOT $BOOST_LINK_LOCATION \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +else + printf " - Boost library found with correct version @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking MongoDB installation...\\n" +if [ ! -d $MONGODB_ROOT ]; then + printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" + curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \ + && touch $MONGODB_LOG_LOCATION/mongod.log \ + && rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ + && mkdir -p $MONGODB_DATA_LOCATION \ + && rm -rf $MONGODB_LINK_LOCATION \ + && rm -rf $BIN_LOCATION/mongod \ + && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ + && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ + || exit 1 + printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" +else + printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C driver installation...\\n" +if [ ! -d $MONGO_C_DRIVER_ROOT ]; then + printf "Installing MongoDB C driver...\\n" + curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ + && mkdir -p cmake-build \ + && cd cmake-build \ + && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C++ driver installation...\\n" +if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then + printf "Installing MongoDB C++ driver...\\n" + curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ + && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ + && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ + && make -j"${JOBS}" VERBOSE=1 \ + && make install \ + && cd ../.. \ + && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking LLVM 4 support...\\n" +if [ ! -d $LLVM_ROOT ]; then + printf "Installing LLVM 4...\\n" + cd ../opt \ + && git clone --depth 1 --single-branch --branch $LLVM_VERSION https://github.com/llvm-mirror/llvm.git llvm && cd llvm \ + && mkdir build \ + && cd build \ + && $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${LLVM_ROOT}" -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_BUILD_TOOLS=false -DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE="Release" .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + || exit 1 + printf " - LLVM successfully installed @ ${LLVM_ROOT}\\n" +else + printf " - LLVM found @ ${LLVM_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +cd .. +printf "\\n" + +function print_instructions() { + printf "source /opt/rh/python33/enable\\n" + printf "source /opt/rh/devtoolset-7/enable\\n" + return 0 +} diff --git a/scripts/eosio_build_darwin.sh b/scripts/eosio_build_darwin.sh index d1f5894b60a..68cc70fc611 100644 --- a/scripts/eosio_build_darwin.sh +++ b/scripts/eosio_build_darwin.sh @@ -1,406 +1,269 @@ - OS_VER=$(sw_vers -productVersion) - OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1) - OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2) - OS_PATCH=$(echo "${OS_VER}" | cut -d'.' -f3) +if [ $1 == 1 ]; then answer=1; fi # NONINTERACTIVE - MEM_GIG=$(bc <<< "($(sysctl -in hw.memsize) / 1024000000)") +OS_VER=$(sw_vers -productVersion) +OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1) +OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2) +OS_PATCH=$(echo "${OS_VER}" | cut -d'.' -f3) +MEM_GIG=$(bc <<< "($(sysctl -in hw.memsize) / 1024000000)") +CPU_SPEED=$(bc <<< "scale=2; ($(sysctl -in hw.cpufrequency) / 10^8) / 10") +CPU_CORE=$( sysctl -in machdep.cpu.core_count ) +export JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) - CPU_SPEED=$(bc <<< "scale=2; ($(sysctl -in hw.cpufrequency) / 10^8) / 10") - CPU_CORE=$( sysctl -in machdep.cpu.core_count ) +DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1) +blksize=$(df . | head -1 | awk '{print $2}' | cut -d- -f1) +gbfactor=$(( 1073741824 / blksize )) +total_blks=$(df . | tail -1 | awk '{print $2}') +avail_blks=$(df . | tail -1 | awk '{print $4}') +DISK_TOTAL=$((total_blks / gbfactor )) +DISK_AVAIL=$((avail_blks / gbfactor )) - DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1) - blksize=$(df . | head -1 | awk '{print $2}' | cut -d- -f1) - gbfactor=$(( 1073741824 / blksize )) - total_blks=$(df . | tail -1 | awk '{print $2}') - avail_blks=$(df . | tail -1 | awk '{print $4}') - DISK_TOTAL=$((total_blks / gbfactor )) - DISK_AVAIL=$((avail_blks / gbfactor )) +export HOMEBREW_NO_AUTO_UPDATE=1 - printf "\\n\\tOS name: %s\\n" "${ARCH}" - printf "\\tOS Version: %s\\n" "${OS_VER}" - printf "\\tCPU speed: %sGhz\\n" "${CPU_SPEED}" - printf "\\tCPU cores: %s\\n" "${CPU_CORE}" - printf "\\tPhysical Memory: %s Gbytes\\n" "${MEM_GIG}" - printf "\\tDisk install: %s\\n" "${DISK_INSTALL}" - printf "\\tDisk space total: %sG\\n" "${DISK_TOTAL}" - printf "\\tDisk space available: %sG\\n\\n" "${DISK_AVAIL}" +COUNT=1 +DISPLAY="" +DEPS="" - if [ "${MEM_GIG}" -lt 7 ]; then - echo "Your system must have 7 or more Gigabytes of physical memory installed." - echo "Exiting now." - exit 1 - fi +printf "\\nOS name: ${OS_NAME}\\n" +printf "OS Version: ${OS_VER}\\n" +printf "CPU speed: ${CPU_SPEED}Mhz\\n" +printf "CPU cores: %s\\n" "${CPU_CORE}" +printf "Physical Memory: ${MEM_GIG} Gbytes\\n" +printf "Disk install: ${DISK_INSTALL}\\n" +printf "Disk space total: ${DISK_TOTAL}G\\n" +printf "Disk space available: ${DISK_AVAIL}G\\n" - if [ "${OS_MIN}" -lt 12 ]; then - echo "You must be running Mac OS 10.12.x or higher to install EOSIO." - echo "Exiting now." - exit 1 - fi +if [ "${MEM_GIG}" -lt 7 ]; then + echo "Your system must have 7 or more Gigabytes of physical memory installed." + echo "Exiting now." + exit 1 +fi - if [ "${DISK_AVAIL}" -lt "$DISK_MIN" ]; then - echo "You must have at least ${DISK_MIN}GB of available storage to install EOSIO." - echo "Exiting now." - exit 1 - fi +if [ "${OS_MIN}" -lt 12 ]; then + echo "You must be running Mac OS 10.12.x or higher to install EOSIO." + echo "Exiting now." + exit 1 +fi - printf "\\tChecking xcode-select installation\\n" - if ! XCODESELECT=$( command -v xcode-select) - then - printf "\\n\\tXCode must be installed in order to proceed.\\n\\n" - printf "\\tExiting now.\\n" - exit 1 - fi +if [ "${DISK_AVAIL}" -lt "$DISK_MIN" ]; then + echo "You must have at least ${DISK_MIN}GB of available storage to install EOSIO." + echo "Exiting now." + exit 1 +fi - printf "\\txcode-select installation found @ \\n" - printf "\\t%s \\n\\n" "${XCODESELECT}" +printf "\\n" - printf "\\tChecking Ruby installation.\\n" - if ! RUBY=$( command -v ruby) - then - printf "\\nRuby must be installed in order to proceed.\\n\\n" - printf "\\tExiting now.\\n" - exit 1 - fi +printf "Checking xcode-select installation...\\n" +if ! XCODESELECT=$( command -v xcode-select) +then + printf " - XCode must be installed in order to proceed!\\n\\n" + exit 1 +fi +printf " - XCode installation found @ ${XCODESELECT}\\n" - printf "\\tRuby installation found @ \\n" - printf "\\t%s \\n\\n" "${RUBY}" - - printf "\\tChecking Home Brew installation\\n" - if ! BREW=$( command -v brew ) - then - printf "\\tHomebrew must be installed to compile EOS.IO\\n\\n" - printf "\\tDo you wish to install Home Brew?\\n" - select yn in "Yes" "No"; do - case "${yn}" in - [Yy]* ) - "${XCODESELECT}" --install 2>/dev/null; - if ! "${RUBY}" -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - then - echo "Unable to install homebrew at this time. Exiting now." - exit 1; - else - BREW=$( command -v brew ) - fi - break;; - [Nn]* ) echo "User aborted homebrew installation. Exiting now."; - exit 1;; - * ) echo "Please enter 1 for yes or 2 for no.";; - esac - done - fi +printf "Checking Ruby installation...\\n" +if ! RUBY=$( command -v ruby) +then + printf " - Ruby must be installed in order to proceed!\\n" + exit 1 +fi +printf " - Ruby installation found @ ${RUBY}\\n" - printf "\\tHome Brew installation found @\\n" - printf "\\t%s\\n\\n" "${BREW}" +printf "Checking Home Brew installation...\\n" +if ! BREW=$( command -v brew ) +then + printf "Homebrew must be installed to compile EOS.IO!\\n" + if [ $1 == 0 ]; then read -p "Do you wish to install HomeBrew? (y/n)? " answer; fi + case ${answer} in + 1 | [Yy]* ) + "${XCODESELECT}" --install 2>/dev/null; + if ! "${RUBY}" -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; then + echo " - Unable to install homebrew at this time." + exit 1; + else + BREW=$( command -v brew ) + fi + ;; + [Nn]* ) echo "User aborted homebrew installation. Exiting now."; exit 1;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac - COUNT=1 - PERMISSION_GETTEXT=0 - DISPLAY="" - DEP="" +fi +printf " - Home Brew installation found @ ${BREW}\\n" - printf "\\tChecking dependencies.\\n" - var_ifs="${IFS}" - IFS="," - while read -r name tester testee brewname uri - do - printf "\\tChecking %s ... " "${name}" - if [ "${tester}" "${testee}" ]; then - printf "\\t\\t %s found\\n" "${name}" +printf "\\nChecking dependencies...\\n" +var_ifs="${IFS}" +IFS="," +while read -r name tester testee brewname uri; do + if [ "${tester}" "${testee}" ]; then + printf " - %s found\\n" "${name}" + continue + fi + # resolve conflict with homebrew glibtool and apple/gnu installs of libtool + if [ "${testee}" == "/usr/local/bin/glibtool" ]; then + if [ "${tester}" "/usr/local/bin/libtool" ]; then + printf " - %s found\\n" "${name}" continue fi - # resolve conflict with homebrew glibtool and apple/gnu installs of libtool - if [ "${testee}" == "/usr/local/bin/glibtool" ]; then - if [ "${tester}" "/usr/local/bin/libtool" ]; then - printf "\\t\\t %s found\\n" "${name}" - continue - fi - fi - if [ "${brewname}" = "gettext" ]; then - PERMISSION_GETTEXT=1 - fi - DEP=$DEP"${brewname} " - DISPLAY="${DISPLAY}${COUNT}. ${name}\\n\\t" - printf "\\t\\t %s ${bldred}NOT${txtrst} found.\\n" "${name}" - (( COUNT++ )) - done < "${SOURCE_DIR}/scripts/eosio_build_dep" - IFS="${var_ifs}" - - printf "\\tChecking Python3 ... " - if [ -z "$( python3 -c 'import sys; print(sys.version_info.major)' 2>/dev/null )" ]; then - DEP=$DEP"python@3 " - DISPLAY="${DISPLAY}${COUNT}. Python 3\\n\\t" - printf "\\t\\t python3 ${bldred}NOT${txtrst} found.\\n" - (( COUNT++ )) - else - printf "\\t\\t Python3 found\\n" fi + DEPS=$DEPS"${brewname}," + DISPLAY="${DISPLAY}${COUNT}. ${name}\\n" + printf " - %s ${bldred}NOT${txtrst} found.\\n" "${name}" + (( COUNT++ )) +done < "${REPO_ROOT}/scripts/eosio_build_darwin_deps" +IFS="${var_ifs}" - if [ $COUNT -gt 1 ]; then - printf "\\n\\tThe following dependencies are required to install EOSIO.\\n" - printf "\\n\\t${DISPLAY}\\n\\n" - echo "Do you wish to install these packages?" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - if [ $PERMISSION_GETTEXT -eq 1 ]; then - sudo chown -R "$(whoami)" /usr/local/share - fi - "${XCODESELECT}" --install 2>/dev/null; - printf "\\tUpdating Home Brew.\\n" - if ! brew update - then - printf "\\tUnable to update Home Brew at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tInstalling Dependencies.\\n" - if ! "${BREW}" install --force ${DEP} - then - printf "\\tHomebrew exited with the above errors.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if [[ "$DEP" == "llvm@4" ]]; then - "${BREW}" unlink ${DEP} - elif ! "${BREW}" unlink ${DEP} && "${BREW}" link --force ${DEP} - then - printf "\\tHomebrew exited with the above errors.\\n" - printf "\\tExiting now.\\n\\n" +if [ ! -d /usr/local/Frameworks ]; then + printf "\\n${bldred}/usr/local/Frameworks is necessary to brew install python@3. Run the following commands as sudo and try again:${txtrst}\\n" + printf "sudo mkdir /usr/local/Frameworks && sudo chown $(whoami):admin /usr/local/Frameworks\\n\\n" + exit 1; +fi + +if [ $COUNT -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $1 == 0 ]; then read -p "Do you wish to install these packages? (y/n) " answer; fi + case ${answer} in + 1 | [Yy]* ) + "${XCODESELECT}" --install 2>/dev/null; + if [ $1 == 0 ]; then read -p "Do you wish to update homebrew packages first? (y/n) " answer; fi + case ${answer} in + 1 | [Yy]* ) + if ! brew update; then + printf " - Brew update failed.\\n" exit 1; + else + printf " - Brew update complete.\\n" fi - break;; - [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; + ;; + [Nn]* ) echo "Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; esac - done - else - printf "\\n\\tNo required Home Brew dependencies to install.\\n" - fi + brew tap eosio/eosio # Required to install mongo-cxx-driver with static library + printf "\\nInstalling Dependencies...\\n" + # Ignore cmake so we don't install a newer version. + # Build from source to use local cmake; see homebrew-eosio repo for examples + # DON'T INSTALL llvm@4 WITH --force! + OIFS="$IFS" + IFS=$',' + for DEP in $DEPS; do + # Eval to support string/arguments with $DEP + if ! eval $BREW install $DEP; then + printf " - Homebrew exited with the above errors!\\n" + exit 1; + fi + done + IFS="$OIFS" + ;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac +else + printf "\\n - No required Home Brew dependencies to install.\\n" +fi - printf "\\n\\tChecking boost library installation.\\n" - BVERSION=$( grep "#define BOOST_VERSION" "/usr/local/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) - if [ "${BVERSION}" != "106700" ]; then - if [ ! -z "${BVERSION}" ]; then - printf "\\tFound Boost Version %s.\\n" "${BVERSION}" - printf "\\tEOS.IO requires Boost version 1.67.\\n" - printf "\\tWould you like to uninstall version %s and install Boost version 1.67.\\n" "${BVERSION}" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - if "${BREW}" list | grep "boost" - then - printf "\\tUninstalling Boost Version %s.\\n" "${BVERSION}" - if ! "${BREW}" uninstall --force boost - then - printf "\\tUnable to remove boost libraries at this time. 0\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - else - printf "\\tRemoving Boost Version %s.\\n" "${BVERSION}" - if ! sudo rm -rf "/usr/local/include/boost" - then - printf "\\tUnable to remove boost libraries at this time. 1\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo rm -rf /usr/local/lib/libboost* - then - printf "\\tUnable to remove boost libraries at this time. 2\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - break;; - [Nn]* ) echo "User cancelled installation of Boost libraries, Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - fi - printf "\\tInstalling boost libraries.\\n" - if ! "${BREW}" install https://raw.githubusercontent.com/Homebrew/homebrew-core/f946d12e295c8a27519b73cc810d06593270a07f/Formula/boost.rb - then - printf "\\tUnable to install boost 1.67 libraries at this time. 0\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - printf "\\tBoost 1.67.0 successfully installed @ /usr/local.\\n" - else - printf "\\tBoost 1.67.0 found at /usr/local.\\n" - fi +printf "\\n" - printf "\\n\\tChecking MongoDB C++ driver installation.\\n" - MONGO_INSTALL=true - if [ -e "/usr/local/lib/libmongocxx-static.a" ]; then - MONGO_INSTALL=false - if ! version=$( grep "Version:" /usr/local/lib/pkgconfig/libmongocxx-static.pc | tr -s ' ' | awk '{print $2}' ) - then - printf "\\tUnable to determine mongodb-cxx-driver version.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi +export CPATH="$(python-config --includes | awk '{print $1}' | cut -dI -f2):$CPATH" # Boost has trouble finding pyconfig.h +printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" +BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) +if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/$BOOST_VERSION_MAJOR.$BOOST_VERSION_MINOR.$BOOST_VERSION_PATCH/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_ROOT \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j$(sysctl -in machdep.cpu.core_count) install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_LINK_LOCATION \ + && ln -s $BOOST_ROOT $BOOST_LINK_LOCATION \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT}.\\n" +else + printf " - Boost library found with correct version @ ${BOOST_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi - maj=$( echo "${version}" | cut -d'.' -f1 ) - min=$( echo "${version}" | cut -d'.' -f2 ) - if [ "${maj}" -gt 3 ]; then - MONGO_INSTALL=true - elif [ "${maj}" -eq 3 ] && [ "${min}" -lt 3 ]; then - MONGO_INSTALL=true - fi - fi - if [ $MONGO_INSTALL == "true" ]; then - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! pkgconfig=$( "${BREW}" list | grep pkg-config ) - then - if ! "${BREW}" install --force pkg-config - then - printf "\\tHomebrew returned an error installing pkg-config.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! "${BREW}" unlink pkg-config && "${BREW}" link --force pkg-config - then - printf "\\tHomebrew returned an error linking pkgconfig.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz ) - if [ "${STATUS}" -ne 200 ]; then - if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz" - then - printf "\\tUnable to remove file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}" - fi - printf "\\tUnable to download MongoDB C driver at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf mongo-c-driver-1.10.2.tar.gz - then - printf "\\tUnable to unarchive file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz" - then - printf "\\tUnable to remove file mongo-c-driver-1.10.2.tar.gz.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}"/mongo-c-driver-1.10.2 - then - printf "\\tUnable to cd into directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir cmake-build - then - printf "\\tUnable to create directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd cmake-build - then - printf "\\tUnable to enter directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \ - -DENABLE_SSL=DARWIN -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. - then - printf "\\tConfiguring MongoDB C driver has encountered the errors above.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make -j"${CPU_CORE}" - then - printf "\\tError compiling MongoDB C driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install - then - printf "\\tError installing MongoDB C driver.\\nMake sure you have sudo privileges.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.10.2" - then - printf "\\tUnable to remove directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1 - then - printf "\\tUnable to clone MongoDB C++ driver at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/mongo-cxx-driver/build" - then - printf "\\tUnable to enter directory %s/mongo-cxx-driver/build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. - then - printf "\\tCmake has encountered the above errors building the MongoDB C++ driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make -j"${CPU_CORE}" - then - printf "\\tError compiling MongoDB C++ driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install - then - printf "\\tError installing MongoDB C++ driver.\\nMake sure you have sudo privileges.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/mongo-cxx-driver" - then - printf "\\tUnable to remove directory %s/mongo-cxx-driver.\\n" "${TEMP_DIR}" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tMongo C++ driver installed at /usr/local/lib/libmongocxx-static.a.\\n" - else - printf "\\tMongo C++ driver found at /usr/local/lib/libmongocxx-static.a.\\n" - fi +printf "\\n" + + +printf "Checking MongoDB installation...\\n" +if [ ! -d $MONGODB_ROOT ]; then + printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" + curl -OL https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-$MONGODB_VERSION.tgz \ + && tar -xzf mongodb-osx-ssl-x86_64-$MONGODB_VERSION.tgz \ + && mv $SRC_LOCATION/mongodb-osx-x86_64-$MONGODB_VERSION $MONGODB_ROOT \ + && touch $MONGODB_LOG_LOCATION/mongod.log \ + && rm -f mongodb-osx-ssl-x86_64-$MONGODB_VERSION.tgz \ + && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ + && mkdir -p $MONGODB_DATA_LOCATION \ + && rm -rf $MONGODB_LINK_LOCATION \ + && rm -rf $BIN_LOCATION/mongod \ + && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ + && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ + || exit 1 + printf " - MongoDB successfully installed @ ${MONGODB_ROOT}\\n" +else + printf " - MongoDB found with correct version @ ${MONGODB_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C driver installation...\\n" +if [ ! -d $MONGO_C_DRIVER_ROOT ]; then + printf "Installing MongoDB C driver...\\n" + curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ + && mkdir -p cmake-build \ + && cd cmake-build \ + && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=DARWIN -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C++ driver installation...\\n" +if [ "$(grep "Version:" $HOME/lib/pkgconfig/libmongocxx-static.pc 2>/dev/null | tr -s ' ' | awk '{print $2}')" != $MONGO_CXX_DRIVER_VERSION ]; then + printf "Installing MongoDB C++ driver...\\n" + curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ + && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ + && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ + && make -j"${JOBS}" VERBOSE=1 \ + && make install \ + && cd ../.. \ + && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + +printf "\\n" + + +# We install llvm into /usr/local/opt using brew install llvm@4 +printf "Checking LLVM 4 support...\\n" +if [ ! -d $LLVM_ROOT ]; then + ln -s /usr/local/opt/llvm@4 $LLVM_ROOT \ + || exit 1 + printf " - LLVM successfully linked from /usr/local/opt/llvm@4 to ${LLVM_ROOT}\\n" +else + printf " - LLVM found @ ${LLVM_ROOT}.\\n" +fi + + +cd .. +printf "\\n" - function print_instructions() - { - printf "\\n\\t%s -f %s &\\n" "$( command -v mongod )" "${MONGOD_CONF}" - printf "\\tcd %s; make test\\n\\n" "${BUILD_DIR}" +function print_instructions() { return 0 - } +} diff --git a/scripts/eosio_build_darwin_deps b/scripts/eosio_build_darwin_deps new file mode 100644 index 00000000000..27d0e0eea2a --- /dev/null +++ b/scripts/eosio_build_darwin_deps @@ -0,0 +1,10 @@ +automake,-x,/usr/local/bin/automake,automake,http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz +Libtool,-x,/usr/local/bin/glibtool,libtool,http://gnu.askapache.com/libtool/libtool-2.4.6.tar.gz +OpenSSL,-f,/usr/local/opt/openssl/lib/libssl.a,openssl,https://www.openssl.org/source/openssl-1.0.2n.tar.gz +wget,-x,/usr/local/bin/wget,wget,https://ftp.gnu.org/gnu/wget/wget-1.19.2.tar.gz +GMP,-f,/usr/local/opt/gmp/include/gmpxx.h,gmp,https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2 +llvm,-x,/usr/local/opt/llvm@4/bin/clang-4.0,llvm@4,http://releases.llvm.org/4.0.1/llvm-4.0.1.src.tar.xz +python,-d,/usr/local/Cellar/python/3.7.2_1,python,https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz +python@2,-d,/usr/local/Cellar/python@2/2.7.15_2,python@2,https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz +doxygen,-x,/usr/local/bin/doxygen,eosio/eosio/doxygen --with-graphviz --build-from-source,http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.14.src.tar.gz +cmake,-f,/usr/local/bin/cmake,cmake,https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz diff --git a/scripts/eosio_build_dep b/scripts/eosio_build_dep deleted file mode 100644 index 7123baf02f5..00000000000 --- a/scripts/eosio_build_dep +++ /dev/null @@ -1,12 +0,0 @@ -automake,-x,/usr/local/bin/automake,automake,http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz -Libtool,-x,/usr/local/bin/glibtool,libtool,http://gnu.askapache.com/libtool/libtool-2.4.6.tar.gz -OpenSSL,-f,/usr/local/opt/openssl/lib/libssl.a,openssl,https://www.openssl.org/source/openssl-1.0.2n.tar.gz -llvm,-x,/usr/local/opt/llvm@4/bin/clang-4.0,llvm@4,http://releases.llvm.org/5.0.1/llvm-5.0.1.src.tar.xz -wget,-x,/usr/local/bin/wget,wget,https://ftp.gnu.org/gnu/wget/wget-1.19.2.tar.gz -CMake,-x,/usr/local/bin/cmake,cmake,https://cmake.org/files/v3.10/cmake-3.10.1-Darwin-x86_64.tar.gz -GMP,-f,/usr/local/opt/gmp/include/gmpxx.h,gmp,https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2 -gettext,-x,/usr/local/opt/gettext/bin/gettext,gettext,https://ftp.gnu.org/pub/gnu/gettext/gettext-latest.tar.gz -MongoDB,-x,/usr/local/opt/mongodb/bin/mongod,mongodb,https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz -Doxygen,-x,/usr/local/bin/doxygen,doxygen,http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.14.src.tar.gz -Graphviz,-x,/usr/local/bin/dot,graphviz,https://graphviz.gitlab.io/pub/graphviz/stable/SOURCES/graphviz.tar.gz -LCOV,-f,/usr/local/bin/lcov,lcov,http://downloads.sourceforge.net/ltp/lcov-1.13.tar.gz diff --git a/scripts/eosio_build_fedora.sh b/scripts/eosio_build_fedora.sh index 661efea9fc0..16970e928c1 100644 --- a/scripts/eosio_build_fedora.sh +++ b/scripts/eosio_build_fedora.sh @@ -1,500 +1,236 @@ - OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' ) - - MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 ) - CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) - CPU_CORE=$( lscpu -pCPU | grep -v "#" | wc -l ) - MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) - JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) - - DISK_INSTALL=$( df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 ) - DISK_TOTAL_KB=$( df . | tail -1 | awk '{print $2}' ) - DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' ) - DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) - DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) - - printf "\\n\\tOS name: %s\\n" "${OS_NAME}" - printf "\\tOS Version: %s\\n" "${OS_VER}" - printf "\\tCPU speed: %sMhz\\n" "${CPU_SPEED}" - printf "\\tCPU cores: %s\\n" "${CPU_CORE}" - printf "\\tPhysical Memory: %s Mgb\\n" "${MEM_MEG}" - printf "\\tDisk install: %s\\n" "${DISK_INSTALL}" - printf "\\tDisk space total: %sG\\n" "${DISK_TOTAL%.*}" - printf "\\tDisk space available: %sG\\n" "${DISK_AVAIL%.*}" - - if [ "${MEM_MEG}" -lt 7000 ]; then - printf "\\tYour system must have 7 or more Gigabytes of physical memory installed.\\n" - printf "\\tExiting now.\\n" - exit 1; - fi - - if [ "${OS_VER}" -lt 25 ]; then - printf "\\tYou must be running Fedora 25 or higher to install EOSIO.\\n" - printf "\\tExiting now.\\n" +if [ $1 == 1 ]; then answer=1; fi # NONINTERACTIVE + +CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) +CPU_CORE=$( nproc ) + +OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' ) +if [ "${OS_VER}" -lt 25 ]; then + printf "You must be running Fedora 25 or higher to install EOSIO.\\n" + printf "Exiting now.\\n" + exit 1; +fi + +# procps-ng includes free command +if [[ -z "$( rpm -qi "procps-ng" 2>/dev/null | grep Name )" ]]; then yum install -y procps-ng; fi +MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 ) +if [ "${MEM_MEG}" -lt 7000 ]; then + printf "Your system must have 7 or more Gigabytes of physical memory installed.\\n" + printf "Exiting now.\\n" + exit 1; +fi +MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) +export JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) + +DISK_INSTALL=$( df -h . | tail -1 | tr -s ' ' | cut -d\\ -f1 ) +DISK_TOTAL_KB=$( df . | tail -1 | awk '{print $2}' ) +DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' ) +DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) +DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) +if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then + printf "You must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" + printf "Exiting now.\\n" + exit 1; +fi + +printf "\\nOS name: ${OS_NAME}\\n" +printf "OS Version: ${OS_VER}\\n" +printf "CPU speed: ${CPU_SPEED}Mhz\\n" +printf "CPU cores: ${CPU_CORE}\\n" +printf "Physical Memory: ${MEM_MEG} Mgb\\n" +printf "Disk space total: ${DISK_TOTAL%.*}G\\n" +printf "Disk space available: ${DISK_AVAIL%.*}G\\n" + +# llvm is symlinked from /usr/lib64/llvm4.0 into user's home +DEP_ARRAY=( + git sudo procps-ng which gcc gcc-c++ autoconf automake libtool make \ + bzip2-devel wget bzip2 compat-openssl10 graphviz doxygen \ + openssl-devel gmp-devel libstdc++-devel python2 python2-devel python3 python3-devel \ + libedit ncurses-devel swig llvm4.0 llvm4.0-devel llvm4.0-libs llvm4.0-static +) +COUNT=1 +DISPLAY="" +DEP="" + +printf "\\nChecking Yum installation...\\n" +if ! YUM=$( command -v yum 2>/dev/null ); then + printf "!! Yum must be installed to compile EOS.IO !!\\n" + printf "Exiting now.\\n" exit 1; - fi +fi +printf " - Yum installation found at %s.\\n" "${YUM}" - if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then - printf "\\tYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" - printf "\\tExiting now.\\n" - exit 1; - fi - - printf "\\n\\tChecking Yum installation\\n" - - YUM=$( command -v yum 2>/dev/null ) - if [ -z "${YUM}" ]; then - printf "\\n\\tYum must be installed to compile EOS.IO.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - - printf "\\tYum installation found at %s.\\n" "${YUM}" - printf "\\tUpdating YUM.\\n" - if ! sudo yum -y update - then - printf "\\n\\tYUM update failed with the above errors.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - - DEP_ARRAY=( git gcc.x86_64 gcc-c++.x86_64 autoconf automake libtool make cmake.x86_64 \ - bzip2.x86_64 bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 libstdc++-devel.x86_64 \ - python2-devel.x86_64 python3-devel.x86_64 mongodb.x86_64 mongodb-server.x86_64 libedit.x86_64 \ - graphviz.x86_64 doxygen.x86_64 ) - COUNT=1 - DISPLAY="" - DEP="" - - printf "\\n\\tChecking YUM for installed dependencies.\\n\\n" - - for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); - do - pkg=$( "${YUM}" info "${DEP_ARRAY[$i]}" 2>/dev/null | grep Repo | tr -s ' ' | cut -d: -f2 | sed 's/ //g' ) - - if [ "$pkg" != "@System" ]; then - DEP=$DEP" ${DEP_ARRAY[$i]} " - DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n\\t" - printf "\\tPackage %s ${bldred} NOT ${txtrst} found.\\n" "${DEP_ARRAY[$i]}" - (( COUNT++ )) - else - printf "\\tPackage %s found.\\n" "${DEP_ARRAY[$i]}" - continue - fi - done - - if [ ${COUNT} -gt 1 ]; then - printf "\\n\\tThe following dependencies are required to install EOSIO.\\n" - printf "\\n\\t${DISPLAY}\\n\\n" - printf "\\tDo you wish to install these dependencies?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\n\\n\\tInstalling dependencies\\n\\n" - if ! sudo yum -y install ${DEP} - then - printf "\\n\\tYUM dependency installation failed.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - else - printf "\\n\\tYUM dependencies installed successfully.\\n" - fi - break;; - [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\n\\tNo required YUM dependencies to install.\\n" - fi - - if [ "${ENABLE_COVERAGE_TESTING}" = true ]; then - printf "\\n\\tCode coverage build requested." - printf "\\n\\tChecking perl installation.\\n" - perl_bin=$( command -v perl 2>/dev/null ) - if [ -z "${perl_bin}" ]; then - printf "\\n\\tInstalling perl.\\n" - if ! sudo "${YUM}" -y install perl - then - printf "\\n\\tUnable to install perl at this time.\\n" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - else - printf "\\tPerl installation found at %s.\\n" "${perl_bin}" - fi - printf "\\n\\tChecking LCOV installation." - if [ ! -e "/usr/local/bin/lcov" ]; then - printf "\\n\\tLCOV installation not found.\\n" - printf "\\tInstalling LCOV.\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to enter %s. Exiting now.\\n" "${TEMP_DIR}" - exit 1; - fi - if ! git clone "https://github.com/linux-test-project/lcov.git" - then - printf "\\n\\tUnable to clone LCOV at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/lcov" - then - printf "\\n\\tUnable to enter %s/lcov. Exiting now.\\n" "${TEMP_DIR}" - exit 1; - fi - if ! sudo make install - then - printf "\\n\\tUnable to install LCOV at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - rm -rf "${TEMP_DIR}/lcov" - printf "\\n\\tSuccessfully installed LCOV.\\n\\n" - else - printf "\\n\\tLCOV installation found @ /usr/local/bin.\\n" - fi - fi - if [ -d "${HOME}/opt/boost_1_67_0" ]; then - if ! mv "${HOME}/opt/boost_1_67_0" "$BOOST_ROOT" - then - printf "\\n\\tUnable to move directory %s/opt/boost_1_67_0 to %s.\\n" "${HOME}" "${BOOST_ROOT}" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - fi - - printf "\\n\\tChecking boost library installation.\\n" - BVERSION=$( grep "BOOST_LIB_VERSION" "${BOOST_ROOT}/include/boost/version.hpp" 2>/dev/null \ - | tail -1 | tr -s ' ' | cut -d\ -f3 | sed 's/[^0-9\._]//gI' ) - if [ "${BVERSION}" != "1_67" ]; then - printf "\\tRemoving existing boost libraries in %s/opt/boost* .\\n" "${HOME}" - if ! rm -rf "${HOME}"/opt/boost* - then - printf "\\n\\tUnable to remove deprecated boost libraries at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tInstalling boost libraries.\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2 ) - if [ "${STATUS}" -ne 200 ]; then - printf "\\tUnable to download Boost libraries at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf "${TEMP_DIR}/boost_1_67_0.tar.bz2" - then - printf "\\n\\tUnable to unarchive file %s/boost_1_67_0.tar.bz2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/boost_1_67_0.tar.bz2" - then - printf "\\n\\tUnable to remove file %s/boost_1_67_0.tar.bz2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/boost_1_67_0/" - then - printf "\\n\\tUnable to enter directory %s/boost_1_67_0.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! "${TEMP_DIR}"/boost_1_67_0/bootstrap.sh "--prefix=${BOOST_ROOT}" - then - printf "\\n\\tInstallation of boost libraries failed. 0\\n" - printf "\\tExiting now.\\n\\n" +if [ $1 == 0 ]; then read -p "Do you wish to update YUM repositories? (y/n) " answer; fi +case ${answer} in + 1 | [Yy]* ) + if ! sudo $YUM -y update; then + printf " - YUM update failed.\\n" exit 1; - fi - if ! "${TEMP_DIR}"/boost_1_67_0/b2 -j"${CPU_CORE}" install - then - printf "\\n\\tInstallation of boost libraries failed. 1\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/boost_1_67_0" - then - printf "\\n\\tUnable to remove directory %s/boost_1_67_0. 1\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - printf "\\n\\tBoost 1.67.0 successfully installed at %s/opt/boost_1_67_0.\\n\\n" "${HOME}" + else + printf " - YUM update complete.\\n" + fi + ;; + [Nn]* ) echo " - Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no.";; +esac + +printf "Checking RPM for installed dependencies...\\n" +for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do + pkg=$( rpm -qi "${DEP_ARRAY[$i]}" 2>/dev/null | grep Name ) + if [[ -z $pkg ]]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" + printf " - Package %s ${bldred} NOT ${txtrst} found!\\n" "${DEP_ARRAY[$i]}" + (( COUNT++ )) else - printf "\\tBoost 1.67.0 found at %s/opt/boost_1_67_0.\\n" "${HOME}" + printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" + continue fi - - printf "\\n\\tChecking MongoDB C++ driver installation.\\n" - MONGO_INSTALL=true - if [ -e "/usr/local/lib64/libmongocxx-static.a" ]; then - MONGO_INSTALL=false - if [ ! -f /usr/local/lib64/pkgconfig/libmongocxx-static.pc ]; then - MONGO_INSTALL=true - else - if ! version=$( grep "Version:" /usr/local/lib64/pkgconfig/libmongocxx-static.pc | tr -s ' ' | awk '{print $2}' ) - then - printf "\\tUnable to determine mongodb-cxx-driver version.\\n" - printf "\\tExiting now.\\n\\n" +done +if [ "${COUNT}" -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $1 == 0 ]; then read -p "Do you wish to install these dependencies? (y/n) " answer; fi + case ${answer} in + 1 | [Yy]* ) + if ! sudo $YUM -y install ${DEP}; then + printf " - YUM dependency installation failed!\\n" exit 1; + else + printf " - YUM dependencies installed successfully.\\n" fi - maj=$( echo "${version}" | cut -d'.' -f1 ) - min=$( echo "${version}" | cut -d'.' -f2 ) - if [ "${maj}" -gt 3 ]; then - MONGO_INSTALL=true - elif [ "${maj}" -eq 3 ] && [ "${min}" -lt 3 ]; then - MONGO_INSTALL=true - fi - fi - fi - - if [ $MONGO_INSTALL == "true" ]; then - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - STATUS=$( curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz ) - if [ "${STATUS}" -ne 200 ]; then - if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz" - then - printf "\\tUnable to remove file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}" - fi - printf "\\tUnable to download MongoDB C driver at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf mongo-c-driver-1.10.2.tar.gz - then - printf "\\tUnable to unarchive file %s/mongo-c-driver-1.10.2.tar.gz.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.10.2.tar.gz" - then - printf "\\tUnable to remove file mongo-c-driver-1.10.2.tar.gz.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}"/mongo-c-driver-1.10.2 - then - printf "\\tUnable to cd into directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir cmake-build - then - printf "\\tUnable to create directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd cmake-build - then - printf "\\tUnable to enter directory %s/mongo-c-driver-1.10.2/cmake-build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \ - -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. - then - printf "\\tConfiguring MongoDB C driver has encountered the errors above.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! make -j"${CPU_CORE}" - then - printf "\\tError compiling MongoDB C driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install - then - printf "\\tError installing MongoDB C driver.\\nMake sure you have sudo privileges.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/mongo-c-driver-1.10.2" - then - printf "\\tUnable to remove directory %s/mongo-c-driver-1.10.2.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/v3.3 --depth 1 - then - printf "\\tUnable to clone MongoDB C++ driver at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/mongo-cxx-driver/build" - then - printf "\\tUnable to enter directory %s/mongo-cxx-driver/build.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. - then - printf "\\tCmake has encountered the above errors building the MongoDB C++ driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make -j"${CPU_CORE}" - then - printf "\\tError compiling MongoDB C++ driver.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo make install - then - printf "\\tError installing MongoDB C++ driver.\\nMake sure you have sudo privileges.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}" - then - printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! sudo rm -rf "${TEMP_DIR}/mongo-cxx-driver" - then - printf "\\tUnable to remove directory %s/mongo-cxx-driver.\\n" "${TEMP_DIR}" "${TEMP_DIR}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tMongo C++ driver installed at /usr/local/lib64/libmongocxx-static.a.\\n" - else - printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n" - fi - - printf "\\n\\tChecking LLVM with WASM support installation.\\n" - if [ ! -d "${HOME}/opt/wasm/bin" ]; then - printf "\\tInstalling LLVM & WASM\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${TEMP_DIR}/llvm-compiler" 2>/dev/null - then - printf "\\n\\tUnable to create directory %s/llvm-compiler.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler" - then - printf "\\n\\tUnable to enter directory %s/llvm-compiler.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git - then - printf "\\tUnable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm" - then - printf "\\n\\tUnable to enter directory %s/llvm-compiler/llvm.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! $(curl https://bugzilla.redhat.com/attachment.cgi?id=1389687 | git apply) - then - printf "\\n\\tUnable to apply patch https://bugzilla.redhat.com/attachment.cgi?id=1389687.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm/tools" - then - printf "\\n\\tUnable to enter directory %s/llvm-compiler/llvm/tools.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git - then - printf "\\tUnable to clone clang repo @ https://github.com/llvm-mirror/clang.git.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm" - then - printf "\\n\\tUnable to enter directory %s/llvm-compiler/llvm.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! mkdir "${TEMP_DIR}/llvm-compiler/llvm/build" - then - printf "\\n\\tUnable to create directory %s/llvm-compiler/llvm/build.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/llvm-compiler/llvm/build" - then - printf "\\n\\tUnable to enter directory %s/llvm-compiler/llvm/build.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${HOME}/opt/wasm" -DLLVM_ENABLE_RTTI=1 \ - -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ - then - printf "\\tCmake compiling LLVM/Clang with WASM support has exited with the above errors.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! make -j"${JOBS}" - then - printf "\\tMake compiling LLVM/Clang with WASM support has exited with the above errors.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! make install - then - printf "\\tMake installing LLVM/Clang with WASM support has exited with the above errors.\\n" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - if ! rm -rf "${TEMP_DIR}/llvm-compiler" 2>/dev/null - then - printf "\\n\\tUnable to remove directory %s/llvm-compiler.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n" - exit 1; - fi - printf "\\n\\tWASM successfully installed at %s/opt/wasm\\n\\n" "${HOME}" - else - printf "\\n\\tWASM found @ %s/opt/wasm\\n\\n" "${HOME}" - fi - - function print_instructions() - { - printf "\\n\\t%s -f %s &\\n" "$( command -v mongod )" "${MONGOD_CONF}" - printf "\\tcd %s; make test\\n\\n" "${BUILD_DIR}" - return 0; - } + ;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac +else + printf " - No required YUM dependencies to install.\\n" +fi + +printf "\\n" + + +printf "Checking CMAKE installation...\\n" +if [ ! -e $CMAKE ]; then + printf "Installing CMAKE...\\n" + curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ + && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ + && cd cmake-$CMAKE_VERSION \ + && ./bootstrap --prefix=$HOME \ + && make -j"${JOBS}" \ + && make install \ + && cd .. \ + && rm -f cmake-$CMAKE_VERSION.tar.gz \ + || exit 1 + printf " - CMAKE successfully installed @ ${CMAKE} \\n" +else + printf " - CMAKE found @ ${CMAKE}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" +BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) +if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_ROOT \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j"${JOBS}" install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_LINK_LOCATION \ + && ln -s $BOOST_ROOT $BOOST_LINK_LOCATION \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +else + printf " - Boost library found with correct version @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking MongoDB installation...\\n" +if [ ! -d $MONGODB_ROOT ]; then + printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" + curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \ + && touch $MONGODB_LOG_LOCATION/mongod.log \ + && rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ + && mkdir -p $MONGODB_DATA_LOCATION \ + && rm -rf $MONGODB_LINK_LOCATION \ + && rm -rf $BIN_LOCATION/mongod \ + && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ + && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ + || exit 1 + printf " - MongoDB successfully installed @ ${MONGODB_ROOT}\\n" +else + printf " - MongoDB found with correct version @ ${MONGODB_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C driver installation...\\n" +if [ ! -d $MONGO_C_DRIVER_ROOT ]; then + printf "Installing MongoDB C driver...\\n" + curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ + && mkdir -p cmake-build \ + && cd cmake-build \ + && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi +printf "Checking MongoDB C++ driver installation...\\n" +if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then + printf "Installing MongoDB C++ driver...\\n" + curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ + && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ + && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ + && make -j"${JOBS}" VERBOSE=1 \ + && make install \ + && cd ../.. \ + && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +else + printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +printf "\\n" + + +printf "Checking LLVM 4 support...\\n" +if [ ! -d $LLVM_ROOT ]; then + ln -s /usr/lib64/llvm4.0 $LLVM_ROOT \ + || exit 1 + printf " - LLVM successfully linked from /usr/lib64/llvm4.0 to ${LLVM_ROOT}\\n" +else + printf " - LLVM found @ ${LLVM_ROOT}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi + + +cd .. +printf "\\n" + +function print_instructions() { + return 0 +} \ No newline at end of file diff --git a/scripts/eosio_build_ubuntu.sh b/scripts/eosio_build_ubuntu.sh index 84b28a2701b..02bdec57b2e 100644 --- a/scripts/eosio_build_ubuntu.sh +++ b/scripts/eosio_build_ubuntu.sh @@ -1,430 +1,259 @@ - OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' ) - OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1) - OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2) +if [ $1 == 1 ]; then answer=1; fi # NONINTERACTIVE - MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 || cut -d' ' -f2 ) - CPU_SPEED=$( lscpu | grep -m1 "MHz" | tr -s ' ' | cut -d\ -f3 || cut -d' ' -f3 | cut -d'.' -f1 ) - CPU_CORE=$( lscpu -pCPU | grep -v "#" | wc -l ) +OS_VER=$( grep VERSION_ID /etc/os-release | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' ) +OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1) +OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2) - MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) - JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) +MEM_MEG=$( free -m | sed -n 2p | tr -s ' ' | cut -d\ -f2 || cut -d' ' -f2 ) +CPU_SPEED=$( lscpu | grep -m1 "MHz" | tr -s ' ' | cut -d\ -f3 || cut -d' ' -f3 | cut -d'.' -f1 ) +CPU_CORE=$( nproc ) +MEM_GIG=$(( ((MEM_MEG / 1000) / 2) )) +export JOBS=$(( MEM_GIG > CPU_CORE ? CPU_CORE : MEM_GIG )) - DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1) - DISK_TOTAL_KB=$(df . | tail -1 | awk '{print $2}') - DISK_AVAIL_KB=$(df . | tail -1 | awk '{print $4}') - DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) - DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) +DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1) +DISK_TOTAL_KB=$(df . | tail -1 | awk '{print $2}') +DISK_AVAIL_KB=$(df . | tail -1 | awk '{print $4}') +DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 )) +DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 )) - printf "\\n\\tOS name: %s\\n" "${OS_NAME}" - printf "\\tOS Version: %s\\n" "${OS_VER}" - printf "\\tCPU speed: %sMhz\\n" "${CPU_SPEED}" - printf "\\tCPU cores: %s\\n" "${CPU_CORE}" - printf "\\tPhysical Memory: %s Mgb\\n" "${MEM_MEG}" - printf "\\tDisk install: %s\\n" "${DISK_INSTALL}" - printf "\\tDisk space total: %sG\\n" "${DISK_TOTAL%.*}" - printf "\\tDisk space available: %sG\\n" "${DISK_AVAIL%.*}" +printf "\\nOS name: ${OS_NAME}\\n" +printf "OS Version: ${OS_VER}\\n" +printf "CPU speed: ${CPU_SPEED}Mhz\\n" +printf "CPU cores: %s\\n" "${CPU_CORE}" +printf "Physical Memory: ${MEM_MEG} Mgb\\n" +printf "Disk install: ${DISK_INSTALL}\\n" +printf "Disk space total: ${DISK_TOTAL%.*}G\\n" +printf "Disk space available: ${DISK_AVAIL%.*}G\\n" - if [ "${MEM_MEG}" -lt 7000 ]; then - printf "\\tYour system must have 7 or more Gigabytes of physical memory installed.\\n" - printf "\\tExiting now.\\n" - exit 1 +if [ "${MEM_MEG}" -lt 7000 ]; then + printf "Your system must have 7 or more Gigabytes of physical memory installed.\\n" + printf "Exiting now.\\n" + exit 1 +fi + +case "${OS_NAME}" in + "Linux Mint") + if [ "${OS_MAJ}" -lt 18 ]; then + printf "You must be running Linux Mint 18.x or higher to install EOSIO.\\n" + printf "Exiting now.\\n" + exit 1 + fi + ;; + "Ubuntu") + if [ "${OS_MAJ}" -lt 16 ]; then + printf "You must be running Ubuntu 16.04.x or higher to install EOSIO.\\n" + printf "Exiting now.\\n" + exit 1 + fi + # UBUNTU 18 doesn't have MONGODB 3.6.3 + if [ $OS_MAJ -gt 16 ]; then + export MONGODB_VERSION=4.1.1 + fi + # We have to re-set this with the new version + export MONGODB_ROOT=${OPT_LOCATION}/mongodb-${MONGODB_VERSION} + ;; + "Debian") + if [ $OS_MAJ -lt 10 ]; then + printf "You must be running Debian 10 to install EOSIO, and resolve missing dependencies from unstable (sid).\n" + printf "Exiting now.\n" + exit 1 fi + ;; +esac - case "${OS_NAME}" in - "Linux Mint") - if [ "${OS_MAJ}" -lt 18 ]; then - printf "\\tYou must be running Linux Mint 18.x or higher to install EOSIO.\\n" - printf "\\tExiting now.\\n" - exit 1 - fi - ;; - "Ubuntu") - if [ "${OS_MAJ}" -lt 16 ]; then - printf "\\tYou must be running Ubuntu 16.04.x or higher to install EOSIO.\\n" - printf "\\tExiting now.\\n" +if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then + printf "You must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" + printf "Exiting now.\\n" + exit 1 +fi + +# llvm-4.0 is installed into /usr/lib/llvm-4.0 +# clang is necessary for building on ubuntu +DEP_ARRAY=( + git llvm-4.0 clang-4.0 libclang-4.0-dev make automake libbz2-dev libssl-dev doxygen graphviz \ + libgmp3-dev autotools-dev build-essential libicu-dev python2.7 python2.7-dev python3 python3-dev \ + autoconf libtool curl zlib1g-dev sudo ruby +) +COUNT=1 +DISPLAY="" +DEP="" + +if [[ "${ENABLE_CODE_COVERAGE}" == true ]]; then + DEP_ARRAY+=(lcov) +fi + +if [ $1 == 0 ]; then read -p "Do you wish to update repositories with apt-get update? (y/n) " answer; fi +case ${answer} in + 1 | [Yy]* ) + if ! sudo apt-get update; then + printf " - APT update failed.\\n" + exit 1; + else + printf " - APT update complete.\\n" + fi + ;; + [Nn]* ) echo "Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no.";; +esac + +printf "\\nChecking for installed dependencies...\\n" +for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do + pkg=$( dpkg -s "${DEP_ARRAY[$i]}" 2>/dev/null | grep Status | tr -s ' ' | cut -d\ -f4 ) + if [ -z "$pkg" ]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" + printf " - Package %s${bldred} NOT${txtrst} found!\\n" "${DEP_ARRAY[$i]}" + (( COUNT++ )) + else + printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" + continue + fi +done +if [ "${COUNT}" -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $1 == 0 ]; then read -p "Do you wish to install these packages? (y/n) " answer; fi + case ${answer} in + 1 | [Yy]* ) + if ! sudo apt-get -y install ${DEP}; then + printf " - APT dependency failed.\\n" exit 1 + else + printf " - APT dependencies installed successfully.\\n" fi ;; - "Debian") - if [ $OS_MAJ -lt 10 ]; then - printf "\tYou must be running Debian 10 to install EOSIO, and resolve missing dependencies from unstable (sid).\n" - printf "\tExiting now.\n" - exit 1 - fi - ;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no.";; esac +else + printf " - No required APT dependencies to install." +fi - if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then - printf "\\tYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" - printf "\\tExiting now.\\n" - exit 1 - fi - DEP_ARRAY=(clang-4.0 lldb-4.0 libclang-4.0-dev cmake make automake libbz2-dev libssl-dev \ - libgmp3-dev autotools-dev build-essential libicu-dev python2.7-dev python3-dev \ - autoconf libtool curl zlib1g-dev doxygen graphviz) - COUNT=1 - DISPLAY="" - DEP="" +printf "\\n" - if [[ "${ENABLE_CODE_COVERAGE}" == true ]]; then - DEP_ARRAY+=(lcov) - fi - printf "\\n\\tChecking for installed dependencies.\\n\\n" +printf "Checking CMAKE installation...\\n" +if [ ! -e $CMAKE ]; then + printf "Installing CMAKE...\\n" + curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ + && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ + && cd cmake-$CMAKE_VERSION \ + && ./bootstrap --prefix=$HOME \ + && make -j"${JOBS}" \ + && make install \ + && cd .. \ + && rm -f cmake-$CMAKE_VERSION.tar.gz \ + || exit 1 + printf " - CMAKE successfully installed @ ${CMAKE} \\n" +else + printf " - CMAKE found @ ${CMAKE}.\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi - for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); - do - pkg=$( dpkg -s "${DEP_ARRAY[$i]}" 2>/dev/null | grep Status | tr -s ' ' | cut -d\ -f4 ) - if [ -z "$pkg" ]; then - DEP=$DEP" ${DEP_ARRAY[$i]} " - DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n\\t" - printf "\\tPackage %s ${bldred} NOT ${txtrst} found.\\n" "${DEP_ARRAY[$i]}" - (( COUNT++ )) - else - printf "\\tPackage %s found.\\n" "${DEP_ARRAY[$i]}" - continue - fi - done - if [ "${COUNT}" -gt 1 ]; then - printf "\\n\\tThe following dependencies are required to install EOSIO.\\n" - printf "\\n\\t${DISPLAY}\\n\\n" - printf "\\tDo you wish to install these packages?\\n" - select yn in "Yes" "No"; do - case $yn in - [Yy]* ) - printf "\\n\\n\\tInstalling dependencies\\n\\n" - sudo apt-get update - if ! sudo apt-get -y install ${DEP} - then - printf "\\n\\tDPKG dependency failed.\\n" - printf "\\n\\tExiting now.\\n" - exit 1 - else - printf "\\n\\tDPKG dependencies installed successfully.\\n" - fi - break;; - [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; - * ) echo "Please type 1 for yes or 2 for no.";; - esac - done - else - printf "\\n\\tNo required dpkg dependencies to install.\\n" - fi +printf "\\n" - if [ -d "${HOME}/opt/boost_1_67_0" ]; then - if ! mv "${HOME}/opt/boost_1_67_0" "$BOOST_ROOT" - then - printf "\\n\\tUnable to move directory %s/opt/boost_1_67_0 to %s.\\n" "${HOME}" "${BOOST_ROOT}" - printf "\\n\\tExiting now.\\n" - exit 1 - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - fi - printf "\\n\\tChecking boost library installation.\\n" - BVERSION=$( grep BOOST_LIB_VERSION "${BOOST_ROOT}/include/boost/version.hpp" 2>/dev/null \ - | tail -1 | tr -s ' ' | cut -d\ -f3 | sed 's/[^0-9\._]//gI') - if [ "${BVERSION}" != "1_67" ]; then - printf "\\tRemoving existing boost libraries in %s/opt/boost* .\\n" "${HOME}" - if ! rm -rf "${HOME}"/opt/boost* - then - printf "\\n\\tUnable to remove deprecated boost libraries at this time.\\n" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - printf "\\tInstalling boost libraries.\\n" - if ! cd "${TEMP_DIR}" - then - printf "\\n\\tUnable to enter directory %s.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2) - if [ "${STATUS}" -ne 200 ]; then - printf "\\tUnable to download Boost libraries at this time.\\n" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf "${TEMP_DIR}/boost_1_67_0.tar.bz2" - then - printf "\\n\\tUnable to unarchive file %s/boost_1_67_0.tar.bz2.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${TEMP_DIR}/boost_1_67_0.tar.bz2" - then - printf "\\n\\tUnable to remove file %s/boost_1_67_0.tar.bz2.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! cd "${TEMP_DIR}/boost_1_67_0/" - then - printf "\\n\\tUnable to enter directory %s/boost_1_67_0.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! ./bootstrap.sh "--prefix=$BOOST_ROOT" - then - printf "\\n\\tInstallation of boost libraries failed. 0\\n" - printf "\\n\\tExiting now.\\n\\n" - exit 1 - fi - if ! ./b2 -j"${CPU_CORE}" install - then - printf "\\n\\tInstallation of boost libraries failed. 1\\n" - printf "\\n\\tExiting now.\\n\\n" - exit 1 - fi - if ! rm -rf "${TEMP_DIR}"/boost_1_67_0 - then - printf "\\n\\tUnable to remove %s/boost_1_67_0.\\n" "${TEMP_DIR}" - printf "\\n\\tExiting now.\\n\\n" - exit 1 - fi - if [ -d "$BUILD_DIR" ]; then - if ! rm -rf "$BUILD_DIR" - then - printf "\\tUnable to remove directory %s. Please remove this directory and run this script %s again. 0\\n" "$BUILD_DIR" "${BASH_SOURCE[0]}" - printf "\\tExiting now.\\n\\n" - exit 1; - fi - fi - printf "\\tBoost successfully installed @ %s.\\n" "${BOOST_ROOT}" - else - printf "\\tBoost found at %s.\\n" "${BOOST_ROOT}" - fi +printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" +BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) +if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_ROOT \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j"${JOBS}" install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_LINK_LOCATION \ + && ln -s $BOOST_ROOT $BOOST_LINK_LOCATION \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +else + printf " - Boost library found with correct version @ ${BOOST_ROOT} (Symlinked to ${BOOST_LINK_LOCATION}).\\n" +fi +if [ $? -ne 0 ]; then exit -1; fi - printf "\\n\\tChecking MongoDB installation.\\n" - if [ ! -e "${MONGOD_CONF}" ]; then - printf "\\n\\tInstalling MongoDB 3.6.3.\\n" - if ! cd "${HOME}/opt" - then - printf "\\n\\tUnable to enter directory %s/opt.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz) - if [ "${STATUS}" -ne 200 ]; then - printf "\\tUnable to download MongoDB at this time.\\n" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! tar xf "${HOME}/opt/mongodb-linux-x86_64-3.6.3.tgz" - then - printf "\\tUnable to unarchive file %s/opt/mongodb-linux-x86_64-3.6.3.tgz.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! rm -f "${HOME}/opt/mongodb-linux-x86_64-3.6.3.tgz" - then - printf "\\tUnable to remove file %s/opt/mongodb-linux-x86_64-3.6.3.tgz.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! ln -s "${HOME}/opt/mongodb-linux-x86_64-3.6.3/" "${HOME}/opt/mongodb" - then - printf "\\tUnable to symbolic link %s/opt/mongodb-linux-x86_64-3.6.3/ to %s/opt/mongodb.\\n" "${HOME}" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir "${HOME}/opt/mongodb/data" - then - printf "\\tUnable to create directory %s/opt/mongodb/data.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! mkdir "${HOME}/opt/mongodb/log" - then - printf "\\tUnable to create directory %s/opt/mongodb/log.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi - if ! touch "${HOME}/opt/mongodb/log/mongodb.log" - then - printf "\\tUnable to create file %s/opt/mongodb/log/mongodb.log.\\n" "${HOME}" - printf "\\n\\tExiting now.\\n\\n" - exit 1; - fi -if ! tee > /dev/null "${MONGOD_CONF}" < /dev/null;then + printf "Unable to enter build directory %s.\\n Exiting now.\\n" "${BUILD_DIR}" + exit 1; +fi + +if ! make install; then + printf "\\nMAKE installing EOSIO has exited with the above error.\\n\\n" + exit -1 +fi +popd &> /dev/null + +printf "\n${bldred} ___ ___ ___ ___\n" +printf " / /\\ / /\\ / /\\ ___ / /\\ \n" +printf " / /:/_ / /::\\ / /:/_ / /\\ / /::\\ \n" +printf " / /:/ /\\ / /:/\\:\\ / /:/ /\\ / /:/ / /:/\\:\\ \n" +printf " / /:/ /:/_ / /:/ \\:\\ / /:/ /::\\ /__/::\\ / /:/ \\:\\ \n" +printf " /__/:/ /:/ /\\ /__/:/ \\__\\:\\ /__/:/ /:/\\:\\ \\__\\/\\:\\__ /__/:/ \\__\\:\\ \n" +printf " \\ \\:\\/:/ /:/ \\ \\:\\ / /:/ \\ \\:\\/:/~/:/ \\ \\:\\/\\ \\ \\:\\ / /:/ \n" +printf " \\ \\::/ /:/ \\ \\:\\ /:/ \\ \\::/ /:/ \\__\\::/ \\ \\:\\ /:/ \n" +printf " \\ \\:\\/:/ \\ \\:\\/:/ \\__\\/ /:/ /__/:/ \\ \\:\\/:/ \n" +printf " \\ \\::/ \\ \\::/ /__/:/ \\__\\/ \\ \\::/ \n" +printf " \\__\\/ \\__\\/ \\__\\/ \\__\\/ \n\n${txtrst}" + +printf "==============================================================================================\\n" +printf "EOSIO has been installed into ${OPT_LOCATION}/eosio/bin!\\n" +printf "If you need to, you can fully uninstall using eosio_uninstall.sh && scripts/clean_old_install.sh.\\n" +printf "==============================================================================================\\n\\n" + +printf "EOSIO website: https://eos.io\\n" +printf "EOSIO resources: https://eos.io/resources/\\n" +printf "EOSIO Stack Exchange: https://eosio.stackexchange.com\\n" diff --git a/scripts/eosio_uninstall.sh b/scripts/eosio_uninstall.sh new file mode 100755 index 00000000000..facb5f935f4 --- /dev/null +++ b/scripts/eosio_uninstall.sh @@ -0,0 +1,87 @@ +#! /bin/bash + +OPT_LOCATION=$HOME/opt + +binaries=( + cleos + eosio-abigen + eosio-launcher + eosio-s2wasm + eosio-wast2wasm + eosiocpp + keosd + nodeos + eosio-applesdemo +) + +if [ -d $OPT_LOCATION/eosio ]; then + printf "Do you wish to remove this install? (requires sudo)\n" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + if [ "$(id -u)" -ne 0 ]; then + printf "\nThis requires sudo, please run ./eosio_uninstall.sh with sudo\n\n" + exit -1 + fi + + pushd $HOME &> /dev/null + pushd opt &> /dev/null + rm -rf eosio + # Handle cleanup of directories created from installation + if [ "$1" == "--full" ]; then + if [ -d ~/Library/Application\ Support/eosio ]; then rm -rf ~/Library/Application\ Support/eosio; fi # Mac OS + if [ -d ~/.local/share/eosio ]; then rm -rf ~/.local/share/eosio; fi # Linux + fi + popd &> /dev/null + pushd bin &> /dev/null + for binary in ${binaries[@]}; do + rm ${binary} + done + popd &> /dev/null + pushd lib/cmake &> /dev/null + rm -rf eosio + popd &> /dev/null + + break;; + [Nn]* ) + printf "Aborting uninstall\n\n" + exit -1;; + esac + done +fi + +if [ -d "/usr/local/eosio" ]; then + printf "Do you wish to remove this install? (requires sudo)\n" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + if [ "$(id -u)" -ne 0 ]; then + printf "\nThis requires sudo, please run ./eosio_uninstall.sh with sudo\n\n" + exit -1 + fi + + pushd /usr/local &> /dev/null + pushd opt &> /dev/null + rm -rf eosio + # Handle cleanup of directories created from installation + if [ "$1" == "--full" ]; then + if [ -d ~/Library/Application\ Support/eosio ]; then rm -rf ~/Library/Application\ Support/eosio; fi # Mac OS + if [ -d ~/.local/share/eosio ]; then rm -rf ~/.local/share/eosio; fi # Linux + fi + popd &> /dev/null + pushd bin &> /dev/null + for binary in ${binaries[@]}; do + rm ${binary} + done + popd &> /dev/null + pushd lib/cmake &> /dev/null + rm -rf eosio + popd &> /dev/null + + break;; + [Nn]* ) + printf "Aborting uninstall\n\n" + exit -1;; + esac + done +fi diff --git a/scripts/generate_bottle.sh b/scripts/generate_bottle.sh index e1133fb3ca2..7b9908c0ba4 100644 --- a/scripts/generate_bottle.sh +++ b/scripts/generate_bottle.sh @@ -14,7 +14,7 @@ else MAC_VERSION="high_sierra" fi -NAME="${PROJECT}-${VERSION}.${MAC_VERSION}.bottle.tar.gz" +NAME="${PROJECT}-${VERSION}.${MAC_VERSION}.bottle" mkdir -p ${PROJECT}/${VERSION}/opt/eosio/lib/cmake @@ -28,9 +28,9 @@ export SPREFIX export SUBPREFIX export SSUBPREFIX -bash generate_tarball.sh ${NAME} +. ./generate_tarball.sh ${NAME} -hash=`openssl dgst -sha256 ${NAME} | awk 'NF>1{print $NF}'` +hash=`openssl dgst -sha256 ${NAME}.tar.gz | awk 'NF>1{print $NF}'` echo "class Eosio < Formula @@ -57,4 +57,4 @@ echo "class Eosio < Formula end __END__" &> eosio.rb -rm -r ${PROJECT} +rm -r ${PROJECT} || exit 1 diff --git a/scripts/generate_deb.sh b/scripts/generate_deb.sh index 2c23bdb3a34..c29b97a775b 100755 --- a/scripts/generate_deb.sh +++ b/scripts/generate_deb.sh @@ -32,7 +32,7 @@ else fi mkdir -p ${PROJECT}/DEBIAN -chmod 0755 ${PROJECT}/DEBIAN +chmod 0755 ${PROJECT}/DEBIAN || exit 1 echo "Package: ${PROJECT} Version: ${VERSION_NO_SUFFIX}-${RELEASE} Section: devel @@ -42,18 +42,16 @@ Architecture: amd64 Homepage: ${URL} Maintainer: ${EMAIL} Description: ${DESC}" &> ${PROJECT}/DEBIAN/control +cat ${PROJECT}/DEBIAN/control export PREFIX export SUBPREFIX export SPREFIX export SSUBPREFIX -bash generate_tarball.sh ${NAME}.tar.gz - -tar -xvzf ${NAME}.tar.gz -C ${PROJECT} -dpkg-deb --build ${PROJECT} -BUILDSTATUS=$? -mv ${PROJECT}.deb ${NAME}.deb -rm -r ${PROJECT} - -exit $BUILDSTATUS +. ./generate_tarball.sh ${NAME} +echo "Unpacking tarball: ${NAME}.tar.gz..." +tar -xzvf ${NAME}.tar.gz -C ${PROJECT} || exit 1 +dpkg-deb --build ${PROJECT} || exit 1 +mv ${PROJECT}.deb ${NAME}.deb || exit 1 +rm -r ${PROJECT} || exit 1 \ No newline at end of file diff --git a/scripts/generate_package.sh.in b/scripts/generate_package.sh.in index 9c190ed7d87..4874a1b4246 100644 --- a/scripts/generate_package.sh.in +++ b/scripts/generate_package.sh.in @@ -5,7 +5,9 @@ VARIANT=$1 VERSION_NO_SUFFIX="@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" VERSION_SUFFIX="@VERSION_SUFFIX@" VERSION="@VERSION_FULL@" -BUILD_DIR="@CMAKE_BINARY_DIR@" + +# Using CMAKE_BINARY_DIR uses an absolute path and will break cross-vm building/download/make functionality +BUILD_DIR="../../build" VENDOR="@VENDOR@" PROJECT="@PROJECT_NAME@" @@ -23,21 +25,17 @@ export DESC export URL export EMAIL -mkdir tmp +mkdir -p tmp if [[ ${VARIANT} == "brew" ]]; then - bash generate_bottle.sh + . ./generate_bottle.sh elif [[ ${VARIANT} == "deb" ]]; then - bash generate_deb.sh + . ./generate_deb.sh elif [[ ${VARIANT} == "rpm" ]]; then - bash generate_rpm.sh + . ./generate_rpm.sh else echo "Error, unknown package type. Use either ['brew', 'deb', 'rpm']." exit -1 fi -BUILDSTATUS=$? - -rm -r tmp - -exit $BUILDSTATUS +rm -r tmp || exit 1 diff --git a/scripts/generate_rpm.sh b/scripts/generate_rpm.sh index 8d7ebf03caa..d7aef147fc1 100644 --- a/scripts/generate_rpm.sh +++ b/scripts/generate_rpm.sh @@ -18,10 +18,10 @@ export SUBPREFIX export SPREFIX export SSUBPREFIX -bash generate_tarball.sh ${NAME}.tar.gz +. ./generate_tarball.sh ${NAME} RPMBUILD=`realpath ~/rpmbuild/BUILDROOT/${NAME}.x86_64` -mkdir -p ${RPMBUILD} +mkdir -p ${RPMBUILD} FILES=$(tar -xvzf ${NAME}.tar.gz -C ${RPMBUILD}) PFILES="" for f in ${FILES[@]}; do @@ -31,7 +31,7 @@ for f in ${FILES[@]}; do done echo -e ${PFILES} &> ~/rpmbuild/BUILD/filenames.txt -mkdir -p ${PROJECT} +mkdir -p ${PROJECT} echo -e "Name: ${PROJECT} Version: ${VERSION_NO_SUFFIX} License: MIT @@ -45,10 +45,8 @@ Release: ${RELEASE} %description ${DESC} %files -f filenames.txt" &> ${PROJECT}.spec +cat ${PROJECT}.spec -rpmbuild -bb ${PROJECT}.spec -BUILDSTATUS=$? -mv ~/rpmbuild/RPMS/x86_64 ./ -rm -r ${PROJECT} ~/rpmbuild/BUILD/filenames.txt ${PROJECT}.spec - -exit $BUILDSTATUS +rpmbuild -bb ${PROJECT}.spec || exit 1 +mv ~/rpmbuild/RPMS/x86_64/*.rpm ./ || exit 1 +rm -r ${PROJECT} ~/rpmbuild/BUILD/filenames.txt ${PROJECT}.spec || exit 1 diff --git a/scripts/generate_tarball.sh b/scripts/generate_tarball.sh index 675f30b4af7..02f5e009ce5 100644 --- a/scripts/generate_tarball.sh +++ b/scripts/generate_tarball.sh @@ -4,7 +4,7 @@ NAME=$1 EOS_PREFIX=${PREFIX}/${SUBPREFIX} mkdir -p ${PREFIX}/bin/ #mkdir -p ${PREFIX}/lib/cmake/${PROJECT} -mkdir -p ${EOS_PREFIX}/bin +mkdir -p ${EOS_PREFIX}/bin mkdir -p ${EOS_PREFIX}/licenses/eosio #mkdir -p ${EOS_PREFIX}/include #mkdir -p ${EOS_PREFIX}/lib/cmake/${PROJECT} @@ -12,10 +12,10 @@ mkdir -p ${EOS_PREFIX}/licenses/eosio #mkdir -p ${EOS_PREFIX}/scripts # install binaries -cp -R ${BUILD_DIR}/bin/* ${EOS_PREFIX}/bin +cp -R ${BUILD_DIR}/bin/* ${EOS_PREFIX}/bin || exit 1 # install licenses -cp -R ${BUILD_DIR}/licenses/eosio/* ${EOS_PREFIX}/licenses +cp -R ${BUILD_DIR}/licenses/eosio/* ${EOS_PREFIX}/licenses || exit 1 # install libraries #cp -R ${BUILD_DIR}/lib/* ${EOS_PREFIX}/lib @@ -33,12 +33,10 @@ cp -R ${BUILD_DIR}/licenses/eosio/* ${EOS_PREFIX}/licenses #ln -sf ../../../${SUBPREFIX}/lib/cmake/${PROJECT}/EosioTester.cmake EosioTester.cmake #popd &> /dev/null -pushd ${PREFIX}/bin &> /dev/null -for f in `ls ${BUILD_DIR}/bin/`; do +for f in $(ls "${BUILD_DIR}/bin/"); do bn=$(basename $f) - ln -sf ../${SUBPREFIX}/bin/$bn $bn + ln -sf ../${SUBPREFIX}/bin/$bn ${PREFIX}/bin/$bn || exit 1 done -popd &> /dev/null - -tar -cvzf $NAME ./${PREFIX}/* -rm -r ${PREFIX} +echo "Generating Tarball $NAME.tar.gz..." +tar -cvzf $NAME.tar.gz ./${PREFIX}/* || exit 1 +rm -r ${PREFIX} || exit 1 diff --git a/scripts/mongod.conf b/scripts/mongod.conf new file mode 100644 index 00000000000..9599b86fe2f --- /dev/null +++ b/scripts/mongod.conf @@ -0,0 +1,3 @@ +systemLog: + logAppend: true + logRotate: reopen \ No newline at end of file diff --git a/tests/nodeos_run_test.py b/tests/nodeos_run_test.py index 1563450d81a..1db83f7f692 100755 --- a/tests/nodeos_run_test.py +++ b/tests/nodeos_run_test.py @@ -669,6 +669,7 @@ errorExit("mongo get block by id %s" % blockId) Print("Request invalid block numbered %d. This will generate an expected error message." % (currentBlockNum+1000)) + currentBlockNum=node.getHeadBlockNum() # If the tests take too long, we could be far beyond currentBlockNum+1000 and that'll cause a block to be found. block=node.getBlock(currentBlockNum+1000, silentErrors=True) if block is not None: errorExit("ERROR: Received block where not expected")