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

WIP: Add gitian-build.sh script for Gitian builds #837

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions contrib/gitian-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# This script is to be used to generate Gitian builds for Elements releases.
# Requirements:
# - One needs the OSX SDK file in the following location:
# bec9d089ebf2e2dd59b1a811a38ec78ebd5da18cbbcd6ab39d1e59f64ac5033f $HOME/blockstream/gitian/MacOSX10.11.sdk.tar.gz
# The file can be downloaded here:
# https://bitcoincore.org/depends-sources/sdks/MacOSX10.11.sdk.tar.gz
#
# - On an Arch machine, I had to install and start apt-cacher-ng.
# Any non-Debian environment probably should do the same.
# $ sudo systemctl start apt-cacher-ng
#
# - You'll need a bunch of basic packages from your distro. Non-exhaustive:
# git, docker
#
# - User must have access to /tmp. /tmp/gitian and /tmp/elements are used in the process.
#
#
#
# Using the script:
# Just invoke the script and pass the tag you want to build as an argument:
# ./gitian-build.sh elements-0.18.1.6



: ${1?Need commit hash or tag}

rm -fr /tmp/gitian /tmp/elements
export USE_DOCKER=1
export NUM_JOB=$(cat /proc/cpuinfo | grep ^processor | wc -l)

export CI_PROJECT_DIR=/tmp/elements
export CI_COMMIT_TAG=$1
git clone https://github.com/devrandom/gitian-builder.git /tmp/gitian

RESULT_DIR=$HOME/blockstream/gitian/out/$CI_COMMIT_TAG
mkdir -p "$RESULT_DIR"

git clone https://github.com/ElementsProject/elements.git ${CI_PROJECT_DIR}
cd ${CI_PROJECT_DIR}
mkdir /tmp/gitian/inputs
cp $HOME/blockstream/gitian/MacOSX10.11.sdk.tar.gz /tmp/gitian/inputs/MacOSX10.11.sdk.tar.gz

cd /tmp/gitian

bin/make-base-vm --docker --suite bionic --arch amd64

bin/gbuild --num-make ${NUM_JOB} --memory 10000 --url elements=${CI_PROJECT_DIR} --commit elements=${CI_COMMIT_TAG} ${CI_PROJECT_DIR}/contrib/gitian-descriptors/gitian-linux.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be wrapped in a for loop

for platform_config in gitian-linux.yml gitian-win.yml gitian-osx.yml
do
...
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure I like that better. Like this it's very easy to comment parts out if something goes wrong and it's also very easy to do the steps manually by copy pasting them one by one. Which is probably what one should do using this for the first time.


cp result/* $RESULT_DIR
cp -r build/out/* $RESULT_DIR

bin/gbuild --num-make ${NUM_JOB} --memory 10000 --url elements=${CI_PROJECT_DIR} --commit elements=${CI_COMMIT_TAG} ${CI_PROJECT_DIR}/contrib/gitian-descriptors/gitian-win.yml

cp result/* $RESULT_DIR
cp -r build/out/* $RESULT_DIR

bin/gbuild --num-make ${NUM_JOB} --memory 10000 --url elements=${CI_PROJECT_DIR} --commit elements=${CI_COMMIT_TAG} ${CI_PROJECT_DIR}/contrib/gitian-descriptors/gitian-osx.yml

cp result/* $RESULT_DIR
cp -r build/out/* $RESULT_DIR

# Afterwards, move all but the following files into another folder (I call it `unused`):
# - elements-<version>-aarch64-linux-gnu.tar.gz
# - elements-<version>-arm-linux-gnueabihf.tar.gz
# - elements-<version>-i686-pc-linux-gnu.tar.gz
# - elements-<version>-osx64.tar.gz
# - elements-<version>-osx-unsigned.dmg
# - elements-<version>-osx-unsigned.tar.gz
# - elements-<version>-riscv64-linux-gnu.tar.gz
# - elements-<version>-win32-setup-unsigned.exe
# - elements-<version>-win32.zip
# - elements-<version>-win64-setup-unsigned.exe
# - elements-<version>-win64.zip
# - elements-<version>-win-unsigned.tar.gz
# - elements-<version>-x86_64-linux-gnu.tar.gz

# Then create SHA256SUMS.asc as follows:
#sha256sum <all files except unused; you get this by typing * then tab> | gpg2 --armor --clearsign > SHA256SUMS.asc