From 35b5e917aa2eaa0bf85ed2fdeaf3a6a6103a7413 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 11 Nov 2019 09:13:47 +0000 Subject: [PATCH] gitian: add FreeBSD --- contrib/gitian/gitian-build.py | 29 +++---- contrib/gitian/gitian-freebsd.yml | 133 ++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 17 deletions(-) create mode 100644 contrib/gitian/gitian-freebsd.yml diff --git a/contrib/gitian/gitian-build.py b/contrib/gitian/gitian-build.py index f934ffa17..64eb218bb 100755 --- a/contrib/gitian/gitian-build.py +++ b/contrib/gitian/gitian-build.py @@ -8,6 +8,12 @@ import sys gsigs = 'https://github.com/monero-project/gitian.sigs.git' gbrepo = 'https://github.com/devrandom/gitian-builder.git' +platforms = {'l': ['Linux', 'linux', 'tar.bz2'], + 'a': ['Android', 'android', 'tar.bz2'], + 'f': ['FreeBSD', 'freebsd', 'tar.bz2'], + 'w': ['Windows', 'win', 'zip'], + 'm': ['MacOS', 'osx', 'tar.bz2'] } + def setup(): global args, workdir programs = ['apt-cacher-ng', 'ruby', 'git', 'make', 'wget'] @@ -48,10 +54,6 @@ def rebuild(): print('\nBuilding Dependencies\n') os.makedirs('../out/' + args.version, exist_ok=True) - platforms = {'l': ['Linux', 'linux', 'tar.bz2'], - 'a': ['Android', 'android', 'tar.bz2'], - 'w': ['Windows', 'win', 'zip'], - 'm': ['MacOS', 'osx', 'tar.bz2'] } for i in args.os: if i is 'm' and args.nomac: @@ -76,10 +78,8 @@ def rebuild(): if args.commit_files: 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]) + for i, v in platforms: + subprocess.check_call(['git', 'add', args.version+'-'+v[1]+'/'+args.signer]) subprocess.check_call(['git', 'commit', '-m', 'Add '+args.version+' unsigned sigs for '+args.signer]) os.chdir(workdir) @@ -104,14 +104,9 @@ 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') - subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-osx', 'inputs/monero/contrib/gitian/gitian-osx.yml']) + for i, v in platforms: + print('\nVerifying v'+args.version+' '+v[0]+'\n') + subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-'+v[1], 'inputs/monero/contrib/gitian/gitian-'+v[1]+'.yml']) os.chdir(workdir) def main(): @@ -124,7 +119,7 @@ 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='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('-o', '--os', dest='os', default='lafwm', help='Specify which Operating Systems the build is for. Default is %(default)s. l for Linux, a for Android, f for FreeBSD, 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') diff --git a/contrib/gitian/gitian-freebsd.yml b/contrib/gitian/gitian-freebsd.yml new file mode 100644 index 000000000..3402a2b6c --- /dev/null +++ b/contrib/gitian/gitian-freebsd.yml @@ -0,0 +1,133 @@ +--- +name: "monero-freebsd-0.15" +enable_cache: true +suites: +- "bionic" +architectures: +- "amd64" +packages: +- "curl" +- "clang-8" +- "llvm-8" +- "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" +remotes: +- "url": "https://github.com/monero-project/monero.git" + "dir": "monero" +files: [] +script: | + + WRAP_DIR=$HOME/wrapped + HOSTS="x86_64-unknown-freebsd" + FAKETIME_HOST_PROGS="" + FAKETIME_PROGS="clang-8 clang++-8 llvm-ar-8 llvm-ranlib-8 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 + for prog in ${FAKETIME_HOST_PROGS}; do + WRAPPER=${WRAP_DIR}/${i}-${prog} + echo '#!/usr/bin/env bash' > ${WRAPPER} + echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${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}" + + ORIGPATH="$PATH" + # Build in a new dir for each host + for i in ${HOSTS}; do + export PATH=${WRAP_DIR}:${BASEPREFIX}/${i}/native/bin:${ORIGPATH} + mkdir build && cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE=${BASEPREFIX}/${i}/share/toolchain.cmake -DCMAKE_BUILD_TYPE=Release + make ${MAKEOPTS} + chmod 755 bin/* + cp ../LICENSE bin + chmod 644 bin/LICENSE + DISTNAME=monero-${i}-${version} + mv bin ${DISTNAME} + find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2 + cd .. + rm -rf build + done +