Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. # Using gitian to create multi-OS, multi-arch builds of bitcoin-like blockchains
  2.  
  3. ## Warning
  4. This steps in this guide will leave your machine highly insecure. Hence, the guide should be used on a temporary VPS not an actual machine/server.
  5.  
  6. ## Setting up Ubuntu for gitian building
  7.  
  8. In this section we will be setting up the Ubuntu installation for Gitian building.
  9.  
  10. First we need to log in as `root` to set up dependencies and make sure that our
  11. user can use the sudo command. Type/paste the following in the terminal:
  12.  
  13. ```bash
  14. apt-get install make git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils python-vm-builder
  15. adduser builder sudo
  16. ```
  17.  
  18. When you get a colorful screen with a question about the 'LXC directory', just
  19. go with the default (`/var/lib/lxc`).
  20.  
  21. Then set up LXC and the rest with the following, which is a complex jumble of settings and workarounds:
  22.  
  23. ```bash
  24. # lxc-start in Ubuntu needs to run as root, so make sure
  25. # that the build script can exectute it without providing a password
  26. echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/builder
  27.  
  28. # also add the following line if you want to run the gitian-build.py
  29. # script in the background using nohup.
  30. # Note: it will give 'builder' a __password-less sudo__ capability
  31. builder ALL=(ALL) NOPASSWD: ALL
  32.  
  33. # add cgroup for LXC
  34. echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
  35.  
  36. # make /etc/rc.local script that sets up bridge between guest and host
  37. echo '#!/bin/sh -e' > /etc/rc.local
  38. echo 'brctl addbr br0' >> /etc/rc.local
  39. echo 'ifconfig br0 10.0.3.2/24 up' >> /etc/rc.local
  40. echo 'exit 0' >> /etc/rc.local
  41.  
  42. # make sure that USE_LXC is always set when logging in as gitian,
  43. # and configure LXC IP addresses
  44. echo 'export USE_LXC=1' >> /home/gitian/.profile
  45. echo 'export GITIAN_HOST_IP=10.0.3.2' >> /home/gitian/.profile
  46. echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/gitian/.profile
  47. reboot
  48. ```
  49.  
  50. At the end the VM is rebooted to make sure that the changes take effect. The steps in this
  51. section need only to be performed once.
  52.  
  53. ## Running the gitian python script.
  54.  
  55. Re-login as the user `builder` that was created during installation. The rest of the steps in this guide will be performed as that user.
  56.  
  57. If you don't have one, create a GPG key. The script will stop if it doesn't find a key in your keychain.
  58. ```bash
  59. gpg --gen-key
  60. ```
  61. Copy the `gitian-build.py` script from your blockchain's `/contrib/' directory to `builder`'s home directory. Then, run
  62.  
  63. ```bash
  64. ./gitian-build.py --setup "GPG Key Name" "1.0.0"
  65. ```
  66.  
  67. If you don't pass `--commit` (completely unrelated to the option --no-commit), the script will assume the version to be a tag and automaticall prepend `v` to it.
  68.  
  69. Create the dir `inputs` inside `gitian-builder` and copy `MacOSX10.11.sdk.tar.gz` to it. (See `README_osx.md`)
  70.  
  71.  
  72. ```bash
  73. ./gitian-build.py --build --jobs $(nproc) --os lwm --no-commit "GPG Key Name" "1.0.0"
  74. ```
  75.  
  76. The building phase of the gitian job is going to take an extremely long time because, by default binaries for the following architectures are built: "i686-pc-linux-gnu x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu". AFAIK, the only way to change this is remove hosts(archs) directly from the .yml file.
  77.  
  78. You can use nohup if you enabled password-less sudo in the previous step.
  79.  
  80. ## Lastly
  81.  
  82. Once the build is over, you should find all the packaged binaries in $HOME/blockchain-binaries/1.0.0/ diretory. scp that directory over to your machine and **delete the VPS**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement