From efb5157027078b45dc6b3af9b236090f8486bdb7 Mon Sep 17 00:00:00 2001 From: Job Evers Date: Sat, 7 May 2016 14:15:42 -0500 Subject: [PATCH 1/2] Enabling builds on travis-ci - adds a travis.yml config file - modifies the ubuntu build script to work on travis - adds start of osx builds - waiting for certs to be added --- .gitmodules | 3 + .travis.yml | 32 +++++ packaging/osx/add-key.sh | 25 ++++ packaging/osx/lbry-osx-app | 1 + packaging/ubuntu/ubuntu_package_setup.sh | 150 ++++++++++++++++++----- 5 files changed, 182 insertions(+), 29 deletions(-) create mode 100644 .gitmodules create mode 100644 .travis.yml create mode 100755 packaging/osx/add-key.sh create mode 160000 packaging/osx/lbry-osx-app diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..a8c2e8de6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "packaging/osx/lbry-osx-app"] + path = packaging/osx/lbry-osx-app + url = https://github.com/jobevers/lbry-osx-app.git diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..d21cb628d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ + +matrix: + include: + - os: linux + sudo: required + dist: trust + # dh-virtualenv requires that we use the same python interpreter + # that comes with the system, so we don't want to use anything that + # travis would try to set-up for us in python + language: generic + +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install python; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip install --upgrade pip virtualenv; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then virtualenv $HOME/venv; source $HOME/venv/bin/activate; fi + +install: true + +before_script: +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in packaging/osx/certs/dist.cer.enc -d -a -out packaging/osx/certs/dist.cer; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in packaging/osx/certs/dist.p12.enc -d -a -out packaging/osx/certs/dist.p12; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./packaging/osx/add-key.sh; fi + +script: +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash packaging/ubuntu/ubuntu_package_setup.sh; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade gmp; fi +# the default py2app (v0.9) has a bug that is fixed in the head of /metachris/py2app +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip install git+https://github.com/metachris/py2app; fi +# py2app fails to find jsonrpc unless json-rpc is installed. why? I don't know. +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip install json-rpc; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd packaging/osx/lbry-osx-app; ./setup_app.sh; cd $TRAVIS_BUILD_DIR; fi + diff --git a/packaging/osx/add-key.sh b/packaging/osx/add-key.sh new file mode 100755 index 000000000..ac06aa373 --- /dev/null +++ b/packaging/osx/add-key.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# http://stackoverflow.com/a/246128 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# adapted from https://www.objc.io/issues/6-build-tools/travis-ci/#add-scripts + +KEYCHAIN_PASSWORD=travis + +# Create a custom keychain +security create-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain + +# Make the custom keychain default, so xcodebuild will use it for signing +security default-keychain -s osx-build.keychain + +# Unlock the keychain +security unlock-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain + +# Set keychain timeout to 1 hour for long builds +# see http://www.egeek.me/2013/02/23/jenkins-and-xcode-user-interaction-is-not-allowed/ +security set-keychain-settings -t 3600 -l ~/Library/Keychains/osx-build.keychain + +# Add certificates to keychain and allow codesign to access them +security import ${DIR}/certs/dist.cer -k ~/Library/Keychains/osx-build.keychain -T /usr/bin/codesign +security import ${DIR}/certs/dist.p12 -k ~/Library/Keychains/osx-build.keychain -P $KEY_PASSWORD -T /usr/bin/codesign + diff --git a/packaging/osx/lbry-osx-app b/packaging/osx/lbry-osx-app new file mode 160000 index 000000000..e5b465205 --- /dev/null +++ b/packaging/osx/lbry-osx-app @@ -0,0 +1 @@ +Subproject commit e5b465205469e8f14999b56138b3bea6666e006d diff --git a/packaging/ubuntu/ubuntu_package_setup.sh b/packaging/ubuntu/ubuntu_package_setup.sh index 95c0d4694..5e1437e18 100755 --- a/packaging/ubuntu/ubuntu_package_setup.sh +++ b/packaging/ubuntu/ubuntu_package_setup.sh @@ -1,38 +1,124 @@ #!/bin/bash -# Tested on fresh Ubuntu 14.04 install. - -# wget https://raw.githubusercontent.com/lbryio/lbry/master/packaging/ubuntu/ubuntu_package_setup.sh -# bash ubuntu_package_setup.sh [BRANCH] [WEB-UI-BRANCH] - set -euo pipefail -BRANCH=${1:-master} -WEB_UI_BRANCH=${2:-master} +function HELP { + echo "Build a debian package for lbry" + echo "-----" + echo "When run without any arguments, this script expects the current directory" + echo "to be the main lbry repo and it builds what is in that directory" + echo + echo "Optional arguments:" + echo + echo "-c: clone a fresh copy of the repo" + echo "-b : use the specified branch of the lbry repo" + echo "-w : set the webui branch" + echo "-d : specifiy the build directory" + echo "-h: show help" + echo "-t: turn trace on" + exit 1 +} -BUILD_DIR="lbry-build-$(date +%Y%m%d-%H%M%S)" -mkdir "$BUILD_DIR" +CLONE=false +BUILD_DIR="" +BRANCH="" +WEB_UI_BRANCH="master" + +while getopts :hctb:w:d: FLAG; do + case $FLAG in + c) + CLONE=true + ;; + b) + BRANCH=${OPTARG} + ;; + w) + WEB_UI_BRANCH=${OPTARG} + ;; + d) + BUILD_DIR=${OPTARG} + ;; + t) + set -o xtrace + ;; + h) + HELP + ;; + \?) #unrecognized option - show help + echo "Option -$OPTARG not allowed." + HELP + ;; + :) + echo "Option -$OPTARG requires an argument." + HELP + ;; + esac +done + +shift $((OPTIND-1)) + + +SUDO='' +if (( $EUID != 0 )); then + SUDO='sudo' +fi + +if [ "$CLONE" = false ]; then + if [ `basename $PWD` != "lbry" ]; then + echo "Not currently in the lbry directory. Cowardly refusing to go forward" + exit 1 + fi + SOURCE_DIR=$PWD +fi + +if [ -z "${BUILD_DIR}" ]; then + if [ "$CLONE" = true ]; then + # build in the current directory + BUILD_DIR="lbry-build-$(date +%Y%m%d-%H%M%S)" + else + BUILD_DIR="../lbry-build-$(date +%Y%m%d-%H%M%S)" + fi +fi + +mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" +if [ -z ${TRAVIS+x} ]; then + # if not on travis, its nice to see progress + QUIET="" +else + QUIET="-qq" +fi + # get the required OS packages -sudo add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv -sudo apt-get update -sudo apt-get install -y build-essential git python-dev libffi-dev libssl-dev libgmp3-dev dh-virtualenv debhelper +$SUDO apt-get ${QUIET} update +$SUDO apt-get ${QUIET} install -y --no-install-recommends software-properties-common +$SUDO add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv +$SUDO apt-get ${QUIET} update +$SUDO apt-get ${QUIET} install -y --no-install-recommends \ + build-essential git python-dev libffi-dev libssl-dev \ + libgmp3-dev dh-virtualenv debhelper wget python-pip # need a modern version of pip (more modern than ubuntu default) -wget https://bootstrap.pypa.io/get-pip.py -sudo python get-pip.py -rm get-pip.py -sudo pip install make-deb - -# check out LBRY -git clone https://github.com/lbryio/lbry.git --branch "$BRANCH" +$SUDO pip install --upgrade pip +$SUDO pip install make-deb # build packages +# +# dpkg-buildpackage outputs its results into '..' so +# we need to move/clone lbry into the build directory +if [ "$CLONE" == true]; then + cp -a $SOURCE_DIR lbry +else + git clone https://github.com/lbryio/lbry.git +fi ( - cd lbry - make-deb - dpkg-buildpackage -us -uc + cd lbry + if [ -n "${BRANCH}" ]; then + git checkout "${BRANCH}" + fi + make-deb + dpkg-buildpackage -us -uc ) @@ -42,8 +128,15 @@ git clone https://github.com/lbryio/lbry.git --branch "$BRANCH" PACKAGE="$(ls | grep '.deb')" ar vx "$PACKAGE" mkdir control data -tar -xvzf control.tar.gz --directory control -tar -xvJf data.tar.xz --directory data +tar -xzf control.tar.gz --directory control + +# The output of the travis build is a +# tar.gz and the output locally is tar.xz. +# Instead of having tar detect the compression used, we +# could update the config to output the same in either spot. +# Unfortunately, doing so requires editting some auto-generated +# files: http://linux.spiney.org/forcing_gzip_compression_when_building_debian_packages +tar -xf data.tar.?z --directory data PACKAGING_DIR='lbry/packaging/ubuntu' @@ -60,13 +153,12 @@ function addfile() { } addfile "$PACKAGING_DIR/lbry" usr/share/python/lbrynet/bin/lbry addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop -#addfile lbry/packaging/ubuntu/lbry-init.conf etc/init/lbry.conf # repackage .deb -sudo chown -R root:root control data -tar -cvzf control.tar.gz -C control . -tar -cvJf data.tar.xz -C data . -sudo chown root:root debian-binary control.tar.gz data.tar.xz +$SUDO chown -R root:root control data +tar -czf control.tar.gz -C control . +tar -cJf data.tar.xz -C data . +$SUDO chown root:root debian-binary control.tar.gz data.tar.xz ar r "$PACKAGE" debian-binary control.tar.gz data.tar.xz # TODO: we can append to data.tar instead of extracting it all and recompressing From 44aba93d37d333f6138144f90aa8cfe1b551759d Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Sun, 22 May 2016 22:36:56 -0400 Subject: [PATCH 2/2] need fakeroot too --- packaging/ubuntu/ubuntu_package_setup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/ubuntu/ubuntu_package_setup.sh b/packaging/ubuntu/ubuntu_package_setup.sh index 5e1437e18..7255f2fd0 100755 --- a/packaging/ubuntu/ubuntu_package_setup.sh +++ b/packaging/ubuntu/ubuntu_package_setup.sh @@ -26,13 +26,13 @@ WEB_UI_BRANCH="master" while getopts :hctb:w:d: FLAG; do case $FLAG in - c) + c) CLONE=true ;; - b) + b) BRANCH=${OPTARG} ;; - w) + w) WEB_UI_BRANCH=${OPTARG} ;; d) @@ -41,7 +41,7 @@ while getopts :hctb:w:d: FLAG; do t) set -o xtrace ;; - h) + h) HELP ;; \?) #unrecognized option - show help @@ -97,7 +97,7 @@ $SUDO add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv $SUDO apt-get ${QUIET} update $SUDO apt-get ${QUIET} install -y --no-install-recommends \ build-essential git python-dev libffi-dev libssl-dev \ - libgmp3-dev dh-virtualenv debhelper wget python-pip + libgmp3-dev dh-virtualenv debhelper wget python-pip fakeroot # need a modern version of pip (more modern than ubuntu default) $SUDO pip install --upgrade pip