From: Alfredo Deza Date: Mon, 30 Nov 2015 20:38:08 +0000 (-0500) Subject: create a ceph-deploy-build project X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=36bb41a2bfde9b9269c9707821fec3b31e43a463;p=ceph-build.git create a ceph-deploy-build project Signed-off-by: Alfredo Deza --- diff --git a/ceph-deploy-build/build/build b/ceph-deploy-build/build/build new file mode 100644 index 00000000..c8eb82dc --- /dev/null +++ b/ceph-deploy-build/build/build @@ -0,0 +1,128 @@ +#!/bin/bash + +# This is the script that runs inside Jenkins. +# http://jenkins.ceph.com/job/ceph-deploy/ + +set -x +set -e + +HOST=$(hostname --short) +echo "Building on ${HOST}" +echo " DIST=${DIST}" +echo " BPTAG=${BPTAG}" +echo " WS=$WORKSPACE" +echo " PWD=$(pwd)" +echo " BRANCH=$BRANCH" + +# FIXME A very naive way to just list the RPM $DIST that we currently support. +# We should be a bit more lenient to allow any rhel/centos/sles/suse +rpm_dists="rhel centos6 centos7 centos" +deb_dists="precise wheezy squeeze trusty jessie" + +VENV="$WORKSPACE/venv/bin" + +# A helper to match an item in a list of items, like python's `if item in list` +listcontains() { + for word in $2; do + [[ $word = $1 ]] && return 0 + done + return 1 +} + +if listcontains $DIST "$rpm_dists" +then + # Tag tree and update version number in change log and + # in setup.py before building. + + # this exists in scripts/build_utils.sh + get_rpm_dist + + REPO=rpm-repo + BUILDAREA=./rpmbuild + DIST=el6 + RPM_BUILD=$(lsb_release -s -c) + + [ "$TEST" = true ] && chacra_ref="test" || chacra_ref="$BRANCH" + chacra_endpoint="ceph-deploy/${chacra_ref}/${DISTRO}/${DISTRO_VERSION}" + + # this exists in scripts/build_utils.sh + check_binary_existence $chacra_endpoint/$ARCH + + if [ ! -e setup.py ] ; then + echo "Are we in the right directory" + exit 1 + fi + + # Create Tarball + python setup.py sdist --formats=bztar + + # Build RPM + mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} + BUILDAREA=`readlink -fn ${BUILDAREA}` ### rpm wants absolute path + cp ceph-deploy.spec ${BUILDAREA}/SPECS + cp dist/*.tar.bz2 ${BUILDAREA}/SOURCES + echo "buildarea is: ${BUILDAREA}" + rpmbuild -ba --define "_topdir ${BUILDAREA}" --define "_unpackaged_files_terminate_build 0" ${BUILDAREA}/SPECS/ceph-deploy.spec + + [ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" + + find ${BUILDAREA}/SRPMS | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/source + find ${BUILDAREA}/RPMS/* | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/${ARCH} + + exit 0 + +elif listcontains $DIST "$deb_dists" +then + + # Tag tree and update version number in change log and + # in setup.py before building. + + REPO=debian-repo + COMPONENT=main + DEB_DIST="sid wheezy squeeze jessie precise raring trusty" + DEB_BUILD=$(lsb_release -s -c) + #XXX only releases until we fix this + RELEASE=1 + DISTRO=`python -c "exec 'import platform; print platform.linux_distribution()[0].lower()'"` + + [ "$TEST" = true ] && chacra_ref="test" || chacra_ref="$BRANCH" + chacra_endpoint="ceph-deploy/${chacra_ref}/${DISTRO}/${DEB_BUILD}/${ARCH}" + + # this exists in scripts/build_utils.sh + check_binary_existence $chacra_endpoint + + if [ ! -d debian ] ; then + echo "Are we in the right directory" + exit 1 + fi + + # Apply backport tag if release build + if [ $RELEASE -eq 1 ] ; then + DEB_VERSION=$(dpkg-parsechangelog | sed -rne 's,^Version: (.*),\1, p') + BP_VERSION=${DEB_VERSION}${BPTAG} + dch -D $DIST --force-distribution -b -v "$BP_VERSION" "$comment" + dpkg-source -b . + fi + + # Build Package + echo "Building for dist: $DEB_BUILD" + # we no longer sign the .dsc or .changes files (done by default with + # the `-k$KEYID` flag), so explicitly tell the tool not to sign them + dpkg-buildpackage -uc -us + if [ $? -ne 0 ] ; then + echo "Build failed" + exit 2 + fi + + [ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" + + # push binaries to chacra + # the binaries are created in one directory up from $WORKSPACE + find ../ | egrep "*\.(changes|deb|dsc|gz)$" | egrep -v "(Packages|Sources|Contents)" | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint} + + echo "Done" + +else + echo "Can't determine build host type, I suck. Sorry." + exit 4 +fi diff --git a/ceph-deploy-build/build/setup b/ceph-deploy-build/build/setup new file mode 100644 index 00000000..87e1aa00 --- /dev/null +++ b/ceph-deploy-build/build/setup @@ -0,0 +1,24 @@ +#!/bin/bash + +# This is the script that runs inside Jenkins. +# http://jenkins.ceph.com/job/ceph-deploy/ + +set -x +set -e + +# ensure dependencies are installed for RPM hosts, because they are required and +# we are not building with a contained environment like we do on DEB builds + +# TODO: use Mock to build ceph-deploy rpm's and avoid this + +rpm_deps="python-devel python-virtualenv python-mock python-tox pytest" + +if test -f /etc/redhat-release ; then + sudo yum install -y $rpm_deps +fi + +pkgs=( "chacractl>=0.0.4" ) +install_python_packages "pkgs[@]" + +# create the .chacractl config file using global variables +make_chacractl_config diff --git a/ceph-deploy-build/config/definitions/ceph-deploy-build.yml b/ceph-deploy-build/config/definitions/ceph-deploy-build.yml new file mode 100644 index 00000000..bc385724 --- /dev/null +++ b/ceph-deploy-build/config/definitions/ceph-deploy-build.yml @@ -0,0 +1,49 @@ +- job: + name: ceph-deploy-build + node: small && trusty + project-type: matrix + defaults: global + display-name: 'ceph-deploy-build' + concurrent: true + quiet-period: 5 + block-downstream: false + block-upstream: false + retry-count: 3 + + scm: + - git: + url: https://github.com/ceph/ceph-deploy.git + branches: + - $BRANCH + browser: auto + skip-tag: true + timeout: 20 + wipe-workspace: true + + axes: + - axis: + type: label-expression + name: ARCH + values: + - x86_64 + - axis: + type: label-expression + name: DIST + values: + - wheezy + - precise + - trusty + - jessie + - centos6 + - centos7 + + - shell: + !include-raw: + - ../../../scripts/build_utils.sh + - ../../build/setup + - ../../build/build + + wrappers: + - inject-passwords: + global: true + mask-password-params: true