--- /dev/null
+#! /usr/bin/bash
+set -ex
+
+# Only do actual work when we are a DEB distro
+if test "$DISTRO" != "debian" -a "$DISTRO" != "ubuntu"; then
+ exit 0
+fi
+
+REPO_URL="https://shaman.ceph.com/api/repos/ceph/$CEPH_BRANCH/$CEPH_SHA1/$DISTRO/$DIST/repo"
+TIME_LIMIT=1200
+INTERVAL=30
+REPO_FOUND=0
+
+# poll shaman for up to 10 minutes
+while [ "$SECONDS" -le "$TIME_LIMIT" ]
+do
+ SHAMAN_MIRROR=`curl --fail -L ${REPO_URL} || true`
+ if [[ ${SHAMAN_MIRROR} ]]; then
+ echo "Ceph debian lib repo exists in shaman"
+ REPO_FOUND=1
+ break
+ else
+ sleep $INTERVAL
+ fi
+done
+
+if [[ "$REPO_FOUND" -eq 0 ]]; then
+ echo "Ceph debian lib repo does NOT exist in shaman"
+ exit 1
+fi
+
+# We need this for system and to run the cmake
+sudo apt-get update
+
+# Normalize variables across rpm/deb builds
+NORMAL_DISTRO=$DISTRO
+NORMAL_DISTRO_VERSION=$DIST
+NORMAL_ARCH=$ARCH
+
+# create build status in shaman
+create_build_status "started" "nfs-ganesha" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
+
+## Setup the pbuilder
+setup_pbuilder
+
+cd $WORKSPACE/nfs-ganesha
+git submodule update --init || git submodule sync
+
+PACKAGE_MANAGER_VERSION="`git describe --long | sed 's/V//1'`-1${DIST}"
+
+# Version is in format X.XdevX-X-SHA1
+VERSION=`git describe --long | sed -e 's/V//1'`
+
+rm -rf .git
+
+cd $WORKSPACE
+
+## Build the source tarball
+NFS_GANESHA_ORIG_TAR_GZ="nfs-ganesha_${VERSION}.orig.tar.gz"
+tar czf ${NFS_GANESHA_ORIG_TAR_GZ} nfs-ganesha/src
+
+# remove old version
+rm -rf $WORKSPACE/nfs-ganesha
+
+# unpack just the src
+tar xzf ${NFS_GANESHA_ORIG_TAR_GZ}
+
+cd $WORKSPACE/nfs-ganesha
+
+# add debian directory next to src
+mv $WORKSPACE/nfs-ganesha-debian/debian $WORKSPACE/nfs-ganesha/
+
+## Get some basic information about the system and the repository
+DEB_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
+
+## Prepare the debian files
+# Bump the changelog
+dch -v "$VERSION-1${DIST}" "$VERSION for Shaman"
+
+# Create .dsc and source tarball, we don't care about signing changes or source package
+sudo dpkg-buildpackage -S -us -uc -d
+
+## Build with pbuilder
+echo "Building debs"
+
+PBUILDDIR="/srv/debian-base"
+
+sudo pbuilder --clean
+
+mkdir -p $WORKSPACE/dist/deb
+
+# add missing packages and components to pbuilder
+sudo pbuilder update \
+ --basetgz $PBUILDDIR/$DIST.tgz \
+ --distribution $DIST \
+ --extrapackages "apt-transport-https apt-utils ca-certificates" \
+ --components "main restricted universe multiverse"
+
+# add other mirror to pbuilder
+sudo pbuilder update \
+ --basetgz $PBUILDDIR/$DIST.tgz \
+ --distribution $DIST \
+ --othermirror "${SHAMAN_MIRROR}" \
+ --override-config
+
+# use libcephfs and librgw from shaman
+sudo pbuilder update \
+ --basetgz $PBUILDDIR/$DIST.tgz \
+ --distribution $DIST \
+ --extrapackages "librados-dev libcephfs-dev librgw-dev"
+
+echo "Building debs for $DIST"
+sudo pbuilder build \
+ --distribution $DIST \
+ --basetgz $PBUILDDIR/$DIST.tgz \
+ --buildresult $WORKSPACE/dist/deb/ \
+ --debbuildopts "-j`grep -c processor /proc/cpuinfo`" \
+ $WORKSPACE/nfs-ganesha_${VERSION}-1${DIST}.dsc
+
+
+## Upload the created debs to chacra
+chacra_endpoint="nfs-ganesha/${NFS_GANESHA_BRANCH}/${GIT_COMMIT}/${DISTRO}/${DIST}"
+chacra_repo_endpoint="${chacra_endpoint}/flavors/${FLAVOR}"
+
+[ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags=""
+
+# push binaries to chacra
+
+if [ "$THROWAWAY" = false ] ; then
+ # push binaries to chacra
+ find $WORKSPACE/dist/deb | egrep "*\.(changes|deb|dsc|gz)$" | egrep -v "(Packages|Sources|Contents)" | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/${ARCH}/flavors/${FLAVOR}
+ # write json file with build info
+ # version and package_manager version are needed for teuthology
+ cat > $WORKSPACE/repo-extra.json << EOF
+{
+ "version":"$VERSION",
+ "package_manager_version":"$PACKAGE_MANAGER_VERSION",
+ "build_url":"$BUILD_URL",
+ "root_build_cause":"$ROOT_BUILD_CAUSE",
+ "node_name":"$NODE_NAME",
+ "job_name":"$JOB_NAME"
+}
+EOF
+ # post the json to repo-extra json to chacra
+ curl -X POST -H "Content-Type:application/json" --data "@$WORKSPACE/repo-extra.json" -u $CHACRACTL_USER:$CHACRACTL_KEY ${chacra_url}repos/${chacra_repo_endpoint}/extra/
+ # start repo creation
+ $VENV/chacractl repo update ${chacra_repo_endpoint}
+fi
+
+echo "Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_repo_endpoint}"
+
+# update shaman with the completed build status
+SHA1=${GIT_COMMIT}
+update_build_status "completed" "nfs-ganesha" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
+
+sudo rm -rf $WORKSPACE/dist
--- /dev/null
+#! /usr/bin/bash
+set -ex
+
+# Only do actual work when we are an RPM distro
+if test "$DISTRO" != "fedora" -a "$DISTRO" != "centos" -a "$DISTRO" != "rhel"; then
+ exit 0
+fi
+
+## Get some basic information about the system and the repository
+RELEASE="$(lsb_release --short -r | cut -d '.' -f 1)" # sytem release
+
+# Get .repo file from appropriate shaman build
+REPO_URL="https://shaman.ceph.com/api/repos/ceph/$CEPH_BRANCH/$CEPH_SHA1/$DISTRO/$RELEASE/flavors/default/repo"
+TIME_LIMIT=1200
+INTERVAL=30
+REPO_FOUND=0
+
+# poll shaman for up to 10 minutes
+while [ "$SECONDS" -le "$TIME_LIMIT" ]
+do
+ if `curl --fail -L $REPO_URL > $WORKSPACE/shaman.repo`; then
+ echo "Ceph repo file has been added from shaman"
+ REPO_FOUND=1
+ break
+ else
+ sleep $INTERVAL
+ fi
+done
+
+if [[ "$REPO_FOUND" -eq 0 ]]; then
+ echo "Ceph lib repo does NOT exist in shaman"
+ exit 1
+fi
+
+# add shaman repos to /etc/yum.repos.d/ to install ceph libraries so enable
+#FSAL_CEPH (enabled by default) and FSAL_RGW in the .spec file when cmake command runs
+sudo cp $WORKSPACE/shaman.repo /etc/yum.repos.d/
+# for debugging
+cat /etc/yum.repos.d/shaman.repo
+xargs sudo yum install -y <<< "
+dbus-devel
+libacl-devel
+libblkid-devel
+libcap-devel
+libnfsidmap-devel
+libwbclient-devel
+krb5-devel
+librgw-devel
+libcephfs-devel
+"
+
+sudo yum install -y mock
+
+# Normalize variables across rpm/deb builds
+NORMAL_DISTRO=$DISTRO
+NORMAL_DISTRO_VERSION=$RELEASE
+NORMAL_ARCH=$ARCH
+
+# create build status in shaman
+create_build_status "started" "nfs-ganesha" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
+
+cd $WORKSPACE/nfs-ganesha
+
+git submodule update --init || git submodule sync
+
+mkdir build
+cd build
+
+# generate .spec file, edit .spec file for correct versions of libs and make source tarball
+cmake -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=ON -DUSE_FSAL_RGW=ON $WORKSPACE/nfs-ganesha/src && make dist || exit 1
+
+sed -i 's/libcephfs1-devel/libcephfs-devel/' $WORKSPACE/nfs-ganesha/src/nfs-ganesha.spec
+sed -i 's/librgw2-devel/librgw-devel/' $WORKSPACE/nfs-ganesha/src/nfs-ganesha.spec
+
+## Create the source rpm
+echo "Building SRPM"
+rpmbuild \
+ --define "_sourcedir ." \
+ --define "_specdir $WORKSPACE/dist" \
+ --define "_builddir $WORKSPACE/dist" \
+ --define "_srcrpmdir $WORKSPACE/dist/SRPMS" \
+ --define "_rpmdir $WORKSPACE/dist/RPMS" \
+ --nodeps -bs $WORKSPACE/nfs-ganesha/src/nfs-ganesha.spec
+SRPM=$(readlink -f $WORKSPACE/dist/SRPMS/*.src.rpm)
+
+# add repo file to mock config
+sudo head -n -1 /etc/mock/${MOCK_TARGET}-${RELEASE}-${ARCH}.cfg > temp.cfg
+echo >> temp
+sudo cat temp.cfg $WORKSPACE/shaman.repo > nfs-ganesha.cfg
+echo "\"\"\"" >> nfs-ganesha.cfg
+# for debugging
+cat nfs-ganesha.cfg
+
+## Build the binaries with mock
+echo "Building RPMs"
+sudo mock --verbose -r nfs-ganesha.cfg --scrub=all
+sudo mock --verbose -r nfs-ganesha.cfg --define "dist .el7" --resultdir=$WORKSPACE/dist/RPMS/ ${SRPM} || ( tail -n +1 $WORKSPACE/dist/RPMS/{root,build}.log && exit 1 )
+
+VERSION=`grep -R "#define GANESHA_VERSION \"" $WORKSPACE/nfs-ganesha/build/include/config.h | sed -e 's/#define GANESHA_VERSION "//1; s/"//1;'`
+chacra_endpoint="nfs-ganesha/${NFS_GANESHA_BRANCH}/${GIT_COMMIT}/${DISTRO}/${RELEASE}"
+chacra_repo_endpoint="${chacra_endpoint}/flavors/${FLAVOR}"
+RPM_RELEASE=`grep Release $WORKSPACE/nfs-ganesha/src/nfs-ganesha.spec | sed 's/Release:[ \t]*//g' | cut -d '%' -f 1`
+RPM_VERSION=`grep Version $WORKSPACE/nfs-ganesha/src/nfs-ganesha.spec | sed 's/Version:[ \t]*//g'`
+PACKAGE_MANAGER_VERSION="$RPM_VERSION-$RPM_RELEASE"
+
+[ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags=""
+
+if [ "$THROWAWAY" = false ] ; then
+ # push binaries to chacra
+ find $WORKSPACE/dist/SRPMS | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/source/flavors/${FLAVOR}
+ find $WORKSPACE/dist/RPMS/ | grep rpm | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/${ARCH}/flavors/${FLAVOR}
+ # write json file with build info
+ # version and package_manager version are needed for teuthology
+ cat > $WORKSPACE/repo-extra.json << EOF
+{
+ "version":"$VERSION",
+ "package_manager_version":"$PACKAGE_MANAGER_VERSION",
+ "build_url":"$BUILD_URL",
+ "root_build_cause":"$ROOT_BUILD_CAUSE",
+ "node_name":"$NODE_NAME",
+ "job_name":"$JOB_NAME"
+}
+EOF
+ # post the json to repo-extra json to chacra
+ curl -X POST -H "Content-Type:application/json" --data "@$WORKSPACE/repo-extra.json" -u $CHACRACTL_USER:$CHACRACTL_KEY ${chacra_url}repos/${chacra_repo_endpoint}/extra/
+ # start repo creation
+ $VENV/chacractl repo update ${chacra_repo_endpoint}
+fi
+
+echo "Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_repo_endpoint}"
+
+# update shaman with the completed build status
+SHA1=${GIT_COMMIT}
+update_build_status "completed" "nfs-ganesha" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
+
+sudo rm -rf $WORKSPACE/dist
--- /dev/null
+#!/bin/bash -ex
+
+# note: the failed_build_status call relies on normalized variable names that
+# are infered by the builds themselves. If the build fails before these are
+# set, they will be posted with empty values
+NFS_GANESHA_BRANCH=`branch_slash_filter $NFS_GANESHA_BRANCH`
+
+# update shaman with the failed build status
+failed_build_status "nfs-ganesha" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
--- /dev/null
+#! /usr/bin/bash
+#
+# Ceph distributed storage system
+#
+# Copyright (C) 2016 Red Hat <contact@redhat.com>
+#
+# Author: Boris Ranto <branto@redhat.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+
+set -ex
+
+# Make sure we execute at the top level directory before we do anything
+cd $WORKSPACE
+
+# This will set the DISTRO and MOCK_TARGET variables
+get_distro_and_target
+
+# Perform a clean-up
+cd $WORKSPACE/nfs-ganesha
+git clean -fxd
+
+cd $WORKSPACE/nfs-ganesha-debian
+git clean -fxd
+
+# Make sure the dist directory is clean
+cd $WORKSPACE
+rm -rf dist
+mkdir -p dist
+
+# Print some basic system info
+HOST=$(hostname --short)
+echo "Building on $(hostname) with the following env"
+echo "*****"
+env
+echo "*****"
+
+export LC_ALL=C # the following is vulnerable to i18n
+
+pkgs=( "chacractl>=0.0.4" )
+install_python_packages "pkgs[@]"
+
+NFS_GANESHA_BRANCH=`branch_slash_filter $NFS_GANESHA_BRANCH`
+CEPH_BRANCH=`branch_slash_filter $CEPH_BRANCH`
+BRANCH=${NFS_GANESHA_BRANCH}
+# set flavor as ceph branch libs are coming from
+FLAVOR="ceph_${CEPH_BRANCH}"
+
+# ask shaman which chacra instance to use
+chacra_url="https://chacra.ceph.com/"
+# create the .chacractl config file using global variables
+make_chacractl_config $chacra_url
--- /dev/null
+#!/bin/bash
+set -ex
+
+# Only do actual work when we are a DEB distro
+if test -f /etc/redhat-release ; then
+ exit 0
+fi
--- /dev/null
+#!/bin/bash
+set -ex
+
+# only do work if we are a RPM distro
+if [[ ! -f /etc/redhat-release && ! -f /usr/bin/zypper ]] ; then
+ exit 0
+fi
--- /dev/null
+- scm:
+ name: nfs-ganesha
+ scm:
+ - git:
+ url: https://github.com/nfs-ganesha/nfs-ganesha.git
+ branches:
+ - $NFS_GANESHA_BRANCH
+ skip-tag: true
+ wipe-workspace: true
+ basedir: "nfs-ganesha"
+
+- scm:
+ name: nfs-ganesha-debian
+ scm:
+ - git:
+ url: https://github.com/nfs-ganesha/nfs-ganesha-debian.git
+ branches:
+ - xenial-nfs-ganesha-ceph-fsals
+ skip-tag: true
+ wipe-workspace: true
+ basedir: "nfs-ganesha-debian"
+- job:
+ name: nfs-ganesha
+ project-type: matrix
+ defaults: global
+ display-name: 'nfs-ganesha'
+ block-downstream: false
+ block-upstream: false
+ properties:
+ - github:
+ url: https://github.com/nfs-ganesha/nfs-ganesha
+ concurrent: true
+ parameters:
+ - string:
+ name: NFS_GANESHA_BRANCH
+ description: "The git branch (or tag) to build"
+ default: "V2.5-stable"
+
+ - string:
+ name: CEPH_SHA1
+ description: "The SHA1 of the ceph branch"
+ default: "f2337d1b42fa49dbb0a93e4048a42762e3dffbbf"
+
+ - string:
+ name: CEPH_BRANCH
+ description: "The branch of Ceph to get the repo file of for libcephfs"
+ default: "luminous"
+
+ - string:
+ name: DISTROS
+ description: "A list of distros to build for. Available options are: xenial, centos7"
+ default: "centos7 xenial"
+
+ - string:
+ name: ARCHS
+ description: "A list of architectures to build for. Available options are: x86_64, and arm64"
+ default: "x86_64"
+
+ - bool:
+ name: THROWAWAY
+ description: "
+Default: False. When True it will not POST binaries to chacra. Artifacts will not be around for long. Useful to test builds."
+ default: false
+
+ - bool:
+ name: FORCE
+ description: "
+If this is unchecked, then nothing is built or pushed if they already exist in chacra. This is the default.
+
+If this is checked, then the binaries will be built and pushed to chacra even if they already exist in chacra."
+
+ - string:
+ name: BUILD_VIRTUALENV
+ description: "Base parent path for virtualenv locations, set to avoid issues with extremely long paths that are incompatible with tools like pip. Defaults to '/tmp/' (note the trailing slash, which is required)."
+ default: "/tmp/"
+
+ execution-strategy:
+ combination-filter: DIST==AVAILABLE_DIST && ARCH==AVAILABLE_ARCH && (ARCH=="x86_64" || (ARCH == "arm64" && (DIST == "xenial" || DIST == "centos7")))
+ axes:
+ - axis:
+ type: label-expression
+ name: MACHINE_SIZE
+ values:
+ - huge
+ - axis:
+ type: label-expression
+ name: AVAILABLE_ARCH
+ values:
+ - x86_64
+ - arm64
+ - axis:
+ type: label-expression
+ name: AVAILABLE_DIST
+ values:
+ - centos7
+ - xenial
+ - axis:
+ type: dynamic
+ name: DIST
+ values:
+ - DISTROS
+ - axis:
+ type: dynamic
+ name: ARCH
+ values:
+ - ARCHS
+ triggers:
+ - github
+
+ scm:
+ - nfs-ganesha
+ - nfs-ganesha-debian
+
+ builders:
+ - shell: |
+ echo "Cleaning up top-level workarea (shared among workspaces)"
+ rm -rf dist
+ rm -rf venv
+ rm -rf release
+ # debian build scripts
+ - shell:
+ !include-raw:
+ - ../../build/validate_deb
+ - ../../../scripts/build_utils.sh
+ - ../../build/setup
+ - ../../build/build_deb
+ # rpm build scripts
+ - shell:
+ !include-raw:
+ - ../../build/validate_rpm
+ - ../../../scripts/build_utils.sh
+ - ../../build/setup
+ - ../../build/build_rpm
+
+ publishers:
+ - postbuildscript:
+ script-only-if-failed: True
+ script-only-if-succeeded: False
+ builders:
+ - inject:
+ properties-file: ${WORKSPACE}/build_info
+ - shell:
+ !include-raw:
+ - ../../../scripts/build_utils.sh
+ - ../../build/failure
+
+ wrappers:
+ - inject-passwords:
+ global: true
+ mask-password-params: true