Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build basenode with Vagrant - notes #1407

Closed
leet4tari opened this issue Mar 4, 2020 · 4 comments
Closed

Build basenode with Vagrant - notes #1407

leet4tari opened this issue Mar 4, 2020 · 4 comments
Labels
A-base_node Area - The Tari base node executable and libraries C-documentation Category - exclusively or dominantly adding to documentation

Comments

@leet4tari
Copy link
Contributor

Using vagrant to build and run a basenode, as cleanly as possible.

@leet4tari
Copy link
Contributor Author

leet4tari commented Mar 4, 2020

First problem ran into, is that doing a cargo build on a vagrant synced folder, breaks mostly at the randomx compile.

error: failed to run custom build command for `randomx-rs v0.1.2`

Caused by:
  process didn't exit successfully: `/vagrant/tari/target/release/build/randomx-rs-16788db1e04085a7/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Failed to clone RandomX: failed to mmap. Could not write data: Invalid argument; class=Os (2)', /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/randomx-rs-0.1.2/build.rs:159:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

Just build on the VM file system and not on a synced folder, until we find a fix.

@leet4tari
Copy link
Contributor Author

Used https://github.com/Dentosal/rust_os/blob/master/Vagrantfile as a base to bootstrap a VM to do the basenode build for Ubuntu 18.04

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "generic/ubuntu1804"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  config.vm.define "ubuntu-build"
  config.vm.hostname = "ubuntu-build"

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "8192"
    vb.cpus = "8" # makes the initial setup much faster
    vb.name = "ubuntu-build"
  end

  config.vm.synced_folder "shared", "/vagrant", disabled: false

  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.auto_detect = true  # If you are using VirtualBox, you might want to enable NFS for shared folders

    #config.cache.scope = :box

    #config.cache.enable_nfs  = true

  end

  # Install rust osdev toolkit and some standard utilities
  # these run as user vagrant instead of root
  config.vm.provision "shell", privileged: false, inline: <<-SHELL

    export DEBIAN_FRONTEND=noninteractive
    sudo apt-get update

    # Fix grub update issue
    sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" install grub-pc

    sudo apt-get upgrade -y
    sudo apt-get --purge autoremove -y
    sudo apt-get install python3.7 python3.7-dev python3-pip -y
    sudo apt-get install vim git nasm -y
    #sudo apt-get install xorriso -y
    sudo apt-get install texinfo flex bison python-dev ncurses-dev -y
    sudo apt-get install cmake libssl-dev -y

    mkdir -p ~/.cache/pip/http

    sudo python3.7 -m pip install --upgrade pip
    sudo python3.7 -m pip install requests toml natsort

    #curl -sf https://raw.githubusercontent.com/phil-opp/binutils-gdb/rust-os/build-rust-os-gdb.sh | sh

    if hash rustup; then
    rustup update
    else
    curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
    fi
    rustup component add rustfmt

    export PATH="$HOME/.cargo/bin:$HOME/.bin:$PATH"
    rustup component add rust-src
    cargo install --force cargo-xbuild

    git clone https://github.com/Dentosal/factory.git /tmp/factory || true
    cd /tmp/factory
    git pull
    PYTHON_SYS_EXECUTABLE=python3.7 cargo install --path . --force
    cd -

    git clone https://github.com/Dentosal/constcodegen.git /tmp/constcodegen || true
    cd /tmp/constcodegen
    git pull
    PYTHON_SYS_EXECUTABLE=python3.7 cargo install --path . --force
    cd -

    echo "export PATH="$HOME/.cargo/bin:$PATH"; cd /vagrant" >> $HOME/.bashrc

    # tari build requires
    sudo apt-get -y install pkg-config libssl-dev libsqlite3-dev clang cmake libc++-dev libc++abi-dev

  SHELL
end

@CjS77 CjS77 added A-base_node Area - The Tari base node executable and libraries C-documentation Category - exclusively or dominantly adding to documentation Tooling labels Mar 4, 2020
@crypt0ginge
Copy link

Create Ansible role to apply a security baseline.

@leet4tari
Copy link
Contributor Author

Quick and easier ways to build. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-base_node Area - The Tari base node executable and libraries C-documentation Category - exclusively or dominantly adding to documentation
Projects
None yet
Development

No branches or pull requests

3 participants