aboutsummaryrefslogtreecommitdiff
path: root/contrib/gitian
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gitian')
-rw-r--r--contrib/gitian/README.md16
-rw-r--r--contrib/gitian/gitian-android.yml135
-rwxr-xr-xcontrib/gitian/gitian-build.py56
3 files changed, 194 insertions, 13 deletions
diff --git a/contrib/gitian/README.md b/contrib/gitian/README.md
index 3c40d09e0..4fa393283 100644
--- a/contrib/gitian/README.md
+++ b/contrib/gitian/README.md
@@ -226,3 +226,19 @@ To get all build options run:
./gitian-build.py --help
```
+Doing Successive Builds
+-----------------------
+
+If you need to do multiple iterations (while developing/testing) you can use the
+`--rebuild` option instead of `--build` on subsequent iterations. This skips the
+initial check for the freshness of the depends tools. In particular, doing this
+check all the time prevents rebuilding when you have no network access.
+
+
+Local-Only Builds
+-----------------
+
+If you need to run builds while disconnected from the internet, make sure you have
+local up-to-date repos in advance. Then specify your local repo using the `--url`
+option when building. This will avoid attempts to git pull across a network.
+
diff --git a/contrib/gitian/gitian-android.yml b/contrib/gitian/gitian-android.yml
new file mode 100644
index 000000000..0de588409
--- /dev/null
+++ b/contrib/gitian/gitian-android.yml
@@ -0,0 +1,135 @@
+---
+name: "monero-android-0.15"
+enable_cache: true
+suites:
+- "bionic"
+architectures:
+- "amd64"
+packages:
+- "curl"
+- "gperf"
+- "gcc-7"
+- "g++-7"
+- "gcc"
+- "g++"
+- "binutils-gold"
+- "git"
+- "pkg-config"
+- "build-essential"
+- "autoconf"
+- "libtool"
+- "automake"
+- "faketime"
+- "bsdmainutils"
+- "ca-certificates"
+- "python"
+- "cmake"
+- "ccache"
+- "protobuf-compiler"
+- "libdbus-1-dev"
+- "libharfbuzz-dev"
+- "libprotobuf-dev"
+- "python3-zmq"
+- "unzip"
+remotes:
+- "url": "https://github.com/monero-project/monero.git"
+ "dir": "monero"
+files: []
+script: |
+
+ WRAP_DIR=$HOME/wrapped
+ HOSTS="arm-linux-android aarch64-linux-android"
+ FAKETIME_HOST_PROGS="clang clang++ ar ranlib nm"
+ FAKETIME_PROGS="date"
+ HOST_CFLAGS="-O2 -g"
+ HOST_CXXFLAGS="-O2 -g"
+ HOST_LDFLAGS=-static-libstdc++
+
+ export GZIP="-9n"
+ export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME""
+ export TZ="UTC"
+ export BUILD_DIR=`pwd`
+ mkdir -p ${WRAP_DIR}
+ if test -n "$GBUILD_CACHE_ENABLED"; then
+ export SOURCES_PATH=${GBUILD_COMMON_CACHE}
+ export BASE_CACHE=${GBUILD_PACKAGE_CACHE}
+ mkdir -p ${BASE_CACHE} ${SOURCES_PATH}
+ fi
+
+ export ZERO_AR_DATE=1
+
+ function create_global_faketime_wrappers {
+ for prog in ${FAKETIME_PROGS}; do
+ echo '#!/usr/bin/env bash' > ${WRAP_DIR}/${prog}
+ echo "REAL=\`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1\`" >> ${WRAP_DIR}/${prog}
+ echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${prog}
+ echo "export FAKETIME=\"$1\"" >> ${WRAP_DIR}/${prog}
+ echo "\$REAL \$@" >> $WRAP_DIR/${prog}
+ chmod +x ${WRAP_DIR}/${prog}
+ done
+ }
+
+ function create_per-host_faketime_wrappers {
+ for i in $HOSTS; do
+ ABI=$i
+ if expr $i : arm- > /dev/null
+ then
+ ABI=$i"eabi"
+ fi
+ NDKDIR="${BUILD_DIR}/monero/contrib/depends/$i/native/bin"
+ for prog in ${FAKETIME_HOST_PROGS}; do
+ WRAPPER=${WRAP_DIR}/${ABI}-${prog}
+ echo '#!/usr/bin/env bash' > ${WRAPPER}
+ echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1' >> ${WRAPPER}
+ echo "export FAKETIME=\"$1\"" >> ${WRAPPER}
+ echo "$NDKDIR/${ABI}-$prog \$@" >> ${WRAPPER}
+ chmod +x ${WRAPPER}
+ done
+ done
+ }
+
+ # Faketime for depends so intermediate results are comparable
+ DUMMYTIME="2000-01-01 12:00:00"
+ export PATH_orig=${PATH}
+ create_global_faketime_wrappers "$DUMMYTIME"
+ create_per-host_faketime_wrappers "$DUMMYTIME"
+ export PATH=${WRAP_DIR}:${PATH}
+
+ # gcc 7+ honors SOURCE_DATE_EPOCH, no faketime needed
+ export SOURCE_DATE_EPOCH=`date -d "$DUMMYTIME" +%s`
+
+ git config --global core.abbrev 9
+ cd monero
+ # Set the version string that gets added to the tar archive name
+ version="`git describe`"
+ if [[ $version == *"-"*"-"* ]]; then
+ version="`git rev-parse --short=9 HEAD`"
+ version="`echo $version | head -c 9`"
+ fi
+
+ BASEPREFIX=`pwd`/contrib/depends
+ # Build dependencies for each host
+ for i in $HOSTS; do
+ make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}"
+ done
+
+ # Faketime for binaries
+ export PATH=${PATH_orig}
+ create_global_faketime_wrappers "${REFERENCE_DATETIME}"
+ create_per-host_faketime_wrappers "${REFERENCE_DATETIME}"
+ export PATH=${WRAP_DIR}:${PATH}
+
+ ORIGPATH="$PATH"
+ # Build in a new dir for each host
+ for i in ${HOSTS}; do
+ export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
+ mkdir build && cd build
+ cmake .. -DCMAKE_TOOLCHAIN_FILE=${BASEPREFIX}/${i}/share/toolchain.cmake -DCMAKE_BUILD_TYPE=Release
+ make ${MAKEOPTS}
+ DISTNAME=monero-${i}-${version}
+ mv bin ${DISTNAME}
+ find ${DISTNAME}/ | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
+ cd ..
+ rm -rf build
+ done
+
diff --git a/contrib/gitian/gitian-build.py b/contrib/gitian/gitian-build.py
index a8d164c2c..a24c71b4f 100755
--- a/contrib/gitian/gitian-build.py
+++ b/contrib/gitian/gitian-build.py
@@ -46,19 +46,11 @@ def setup():
print('Reboot is required')
sys.exit(0)
-def build():
+def rebuild():
global args, workdir
- os.makedirs('out/' + args.version, exist_ok=True)
print('\nBuilding Dependencies\n')
- os.chdir('builder')
- os.makedirs('inputs', exist_ok=True)
-
- subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz'])
- subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'])
- subprocess.check_output(["echo 'a8c4e9cafba922f89de0df1f2152e7be286aba73f78505169bc351a7938dd911 inputs/osslsigncode-Backports-to-1.7.1.patch' | sha256sum -c"], shell=True)
- subprocess.check_output(["echo 'f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 inputs/osslsigncode-1.7.1.tar.gz' | sha256sum -c"], shell=True)
- subprocess.check_call(['make', '-C', 'inputs/monero/contrib/depends', 'download', 'SOURCES_PATH=' + os.getcwd() + '/cache/common'])
+ os.makedirs('out/' + args.version, exist_ok=True)
if args.linux:
print('\nCompiling ' + args.version + ' Linux')
@@ -66,6 +58,12 @@ def build():
subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-linux', '--destination', '../sigs/', 'inputs/monero/contrib/gitian/gitian-linux.yml'])
subprocess.check_call('mv build/out/monero-*.tar.bz2 ../out/'+args.version, shell=True)
+ if args.android:
+ print('\nCompiling ' + args.version + ' Android')
+ subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, 'inputs/monero/contrib/gitian/gitian-android.yml'])
+ subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-android', '--destination', '../sigs/', 'inputs/monero/contrib/gitian/gitian-android.yml'])
+ subprocess.check_call('mv build/out/monero-*.tar.bz2 ../out/'+args.version, shell=True)
+
if args.windows:
print('\nCompiling ' + args.version + ' Windows')
subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, 'inputs/monero/contrib/gitian/gitian-win.yml'])
@@ -84,17 +82,37 @@ def build():
print('\nCommitting '+args.version+' Unsigned Sigs\n')
os.chdir('sigs')
subprocess.check_call(['git', 'add', args.version+'-linux/'+args.signer])
+ subprocess.check_call(['git', 'add', args.version+'-android/'+args.signer])
subprocess.check_call(['git', 'add', args.version+'-win/'+args.signer])
subprocess.check_call(['git', 'add', args.version+'-osx/'+args.signer])
subprocess.check_call(['git', 'commit', '-m', 'Add '+args.version+' unsigned sigs for '+args.signer])
os.chdir(workdir)
+
+def build():
+ global args, workdir
+
+ print('\nChecking Depends Freshness\n')
+ os.chdir('builder')
+ os.makedirs('inputs', exist_ok=True)
+
+ subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz'])
+ subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'])
+ subprocess.check_output(["echo 'a8c4e9cafba922f89de0df1f2152e7be286aba73f78505169bc351a7938dd911 inputs/osslsigncode-Backports-to-1.7.1.patch' | sha256sum -c"], shell=True)
+ subprocess.check_output(["echo 'f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 inputs/osslsigncode-1.7.1.tar.gz' | sha256sum -c"], shell=True)
+ subprocess.check_call(['make', '-C', 'inputs/monero/contrib/depends', 'download', 'SOURCES_PATH=' + os.getcwd() + '/cache/common'])
+
+ rebuild()
+
+
def verify():
global args, workdir
os.chdir('builder')
print('\nVerifying v'+args.version+' Linux\n')
subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-linux', 'inputs/monero/contrib/gitian/gitian-linux.yml'])
+ print('\nVerifying v'+args.version+' Android\n')
+ subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-android', 'inputs/monero/contrib/gitian/gitian-android.yml'])
print('\nVerifying v'+args.version+' Windows\n')
subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-win', 'inputs/monero/contrib/gitian/gitian-win.yml'])
print('\nVerifying v'+args.version+' MacOS\n')
@@ -111,7 +129,9 @@ def main():
parser.add_argument('-v', '--verify', action='store_true', dest='verify', help='Verify the Gitian build')
parser.add_argument('-b', '--build', action='store_true', dest='build', help='Do a Gitian build')
parser.add_argument('-B', '--buildsign', action='store_true', dest='buildsign', help='Build both signed and unsigned binaries')
- parser.add_argument('-o', '--os', dest='os', default='lwm', help='Specify which Operating Systems the build is for. Default is %(default)s. l for Linux, w for Windows, m for MacOS')
+ parser.add_argument('-o', '--os', dest='os', default='lawm', help='Specify which Operating Systems the build is for. Default is %(default)s. l for Linux, a for Android, w for Windows, m for MacOS')
+ parser.add_argument('-r', '--rebuild', action='store_true', dest='rebuild', help='Redo a Gitian build')
+ parser.add_argument('-R', '--rebuildsign', action='store_true', dest='rebuildsign', help='Redo and sign a Gitian build')
parser.add_argument('-j', '--jobs', dest='jobs', default='2', help='Number of processes to use. Default %(default)s')
parser.add_argument('-m', '--memory', dest='memory', default='2000', help='Memory to allocate in MiB. Default %(default)s')
parser.add_argument('-k', '--kvm', action='store_true', dest='kvm', help='Use KVM instead of LXC')
@@ -127,6 +147,7 @@ def main():
workdir = os.getcwd()
args.linux = 'l' in args.os
+ args.android = 'a' in args.os
args.windows = 'w' in args.os
args.macos = 'm' in args.os
@@ -136,6 +157,10 @@ def main():
args.build = True
args.sign = True
+ if args.rebuildsign:
+ args.rebuild = True
+ args.sign = True
+
if args.kvm and args.docker:
raise Exception('Error: cannot have both kvm and docker')
@@ -152,9 +177,10 @@ def main():
os.environ['LXC_GUEST_IP'] = '10.0.3.5'
# Disable MacOS build if no SDK found
- if args.build and args.macos and not os.path.isfile('builder/inputs/MacOSX10.11.sdk.tar.gz'):
- print('Cannot build for MacOS, SDK does not exist. Will build for other OSes')
+ if args.macos and not os.path.isfile('builder/inputs/MacOSX10.11.sdk.tar.gz'):
args.macos = False
+ if args.build:
+ print('Cannot build for MacOS, SDK does not exist. Will build for other OSes')
script_name = os.path.basename(sys.argv[0])
# Signer and version shouldn't be empty
@@ -189,6 +215,10 @@ def main():
if args.build:
build()
+ if args.rebuild:
+ os.chdir('builder')
+ rebuild()
+
if args.verify:
verify()