From b9de302ba98d1f6a7f78a5b71685f0c23dd43118 Mon Sep 17 00:00:00 2001 From: Ali Maredia Date: Fri, 16 Dec 2016 17:30:07 -0500 Subject: [PATCH] nfs-ganesha: first run at a build script for rpms Signed-off-by: Ali Maredia --- nfs-ganesha/build/build_deb | 85 ++++++++++++ nfs-ganesha/build/build_rpm | 74 ++++++++++ nfs-ganesha/build/setup | 44 ++++++ .../config/definitions/nfs-ganesha.yml | 129 ++++++++++++++++++ 4 files changed, 332 insertions(+) create mode 100644 nfs-ganesha/build/build_deb create mode 100644 nfs-ganesha/build/build_rpm create mode 100644 nfs-ganesha/build/setup create mode 100644 nfs-ganesha/config/definitions/nfs-ganesha.yml diff --git a/nfs-ganesha/build/build_deb b/nfs-ganesha/build/build_deb new file mode 100644 index 00000000..046e0539 --- /dev/null +++ b/nfs-ganesha/build/build_deb @@ -0,0 +1,85 @@ +#! /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 + + +## Install any setup-time deps +# TODO -- upload install-deps.sh script that installs the setup time deps +# to upstream repo or update this section to install these packages + +# We need this for mk-build-deps +sudo apt-get install -y equivs cmake git + +## Setup the pbuilder +# TODO remove if you do not want to use pbuilders +setup_pbuilder + + +## Build the source tarball + +cd $WORKSPACE/nfs-ganesha + +git submodule update --init || git submodule sync + +mkdir build +cd build + +# make source tarball +cmake -DCMAKE_BUILDER_TYPE=Maintainer $WORKSPACE/nfs-ganesha/src && make dist || exit 0 + +## Get some basic information about the system and the repository +DEB_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH) +VERSION=`grep -om 1 "[0-9]\.[0-9]-dev-[0-9]" include/config.h` + +# terrible hack +cd $WORKSPACE/nfs-ganesha-debian +mv $WORKSPACE/nfs-ganesha/build/nfs-ganesha-*.tar.gz . +tar -xvf nfs-ganesha-*.tar.gz +rm *.tar.gz +mv nfs-ganesha* src + +## Prepare the debian files +# Bump the changelog +dch -v "$VERSION" "New release ($VERSION)" + +# Create .dsc and source tarball +sudo dpkg-buildpackage -S -us -uc + +## Build with pbuilder +echo "Building debs" + +PBUILDDIR="/srv/debian-base" + +sudo pbuilder --clean + +mkdir -p dist/deb + +REPO_URL="https://shaman.ceph.com/api/repos/ceph/$CEPH_BRANCH/$CEPH_SHA1/$DISTRO/$DIST/repo" +echo "EXTRAPACKAGES=\"libcephfs-dev\"" >> ~/.pbuilderrc +echo "OTHERMIRROR=deb ${REPO_URL}" >> ~/.pbuildrrc + +echo "Building debs for $DIST" +sudo pbuilder build \ + --distribution $DIST \ + --basetgz $PBUILDDIR/$DIST.tgz \ + --buildresult dist/deb/ \ + --debbuildopts "-j`grep -c processor /proc/cpuinfo`" \ + dist/nfs-ganesha_$VERSION.dsc + + +## Upload the created RPMs to chacra +chacra_endpoint="nfs-ganesha/${NFS_GANESHA_BRANCH}/${GIT_COMMIT}/${DISTRO}/${DIST}" + +[ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" + +# push binaries to chacra +find ../*.deb | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/${DEB_ARCH}/ + +# start repo creation +$VENV/chacractl repo update ${chacra_endpoint} + +echo Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_endpoint} diff --git a/nfs-ganesha/build/build_rpm b/nfs-ganesha/build/build_rpm new file mode 100644 index 00000000..690a1300 --- /dev/null +++ b/nfs-ganesha/build/build_rpm @@ -0,0 +1,74 @@ +#! /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" +if `curl --fail -L $REPO_URL > $WORKSPACE/libcephfs.repo`; then + echo "Ceph repo file has been added from shaman" +else + echo "Ceph repo file was NOT added from shaman" + exit 0 +fi + +## Install any setup-time deps (to make dist package) +# We need this to get the major version from lsb_release +# ALI TO DO: find out if all these packages are necessary +xargs sudo yum install -y <<< " +redhat-lsb-core +mock +cmake +git +" + +cd $WORKSPACE/nfs-ganesha + +git submodule update --init || git submodule sync + +mkdir build +cd build + +# generate .spec file and make source tarball +cmake -DCMAKE_BUILDER_TYPE=Maintainer $WORKSPACE/nfs-ganesha/src && make dist || exit 0 + +## Create the source rpm +echo "Building SRPM" +rpmbuild \ + --define "_sourcedir ./dist" \ + --define "_specdir ." \ + --define "_builddir ." \ + --define "_srcrpmdir ." \ + --define "_rpmdir ." \ + --nodeps -bs ../src/nfs-ganesha.spec +SRPM=$(readlink -f *.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/libcephfs.repo > nfs-ganesha.cfg +echo "\"\"\"" >> nfs-ganesha.cfg + +## Build the binaries with mock +echo "Building RPMs" +sudo mock -r nfs-ganesha.cfg --resultdir=./dist/rpm/ ${SRPM} + + +## Upload the created RPMs to chacra +chacra_endpoint="nfs-ganesha/${NFS_GANESHA_BRANCH}/${GIT_COMMIT}/${DISTRO}/${RELEASE}" + +[ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" + +# push binaries to chacra +find ./dist/rpm/ | egrep '\.rpm$' | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/$ARCH/ + +# start repo creation +$VENV/chacractl repo update ${chacra_endpoint} + +echo Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_endpoint} diff --git a/nfs-ganesha/build/setup b/nfs-ganesha/build/setup new file mode 100644 index 00000000..41939805 --- /dev/null +++ b/nfs-ganesha/build/setup @@ -0,0 +1,44 @@ +#! /usr/bin/bash +# +# Ceph distributed storage system +# +# Copyright (C) 2016 Red Hat +# +# Author: Boris Ranto +# +# 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 +git clean -fxd + +# Make sure the dist directory is clean +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[@]" + +# ask shaman which chacra instance to use +chacra_url=`curl -f -u $SHAMAN_API_USER:$SHAMAN_API_KEY https://shaman.ceph.com/api/nodes/next/` +# create the .chacractl config file using global variables +make_chacractl_config $chacra_url diff --git a/nfs-ganesha/config/definitions/nfs-ganesha.yml b/nfs-ganesha/config/definitions/nfs-ganesha.yml new file mode 100644 index 00000000..acec1daf --- /dev/null +++ b/nfs-ganesha/config/definitions/nfs-ganesha.yml @@ -0,0 +1,129 @@ +- job: + name: nfs-ganesha + project-type: matrix + defaults: global + display-name: 'nfs-ganesha' + block-downstream: false + block-upstream: false + concurrent: true + parameters: + - string: + name: NFS_GANESHA_BRANCH + description: "The git branch (or tag) to build" + default: "next" + + - string: + name: CEPH_SHA1 + description: "The SHA1 of the ceph branch" + default: "latest" + + - string: + name: CEPH_BRANCH + description: "The branch of Ceph to get the repo file of for libcephfs" + + - string: + name: DISTROS + description: "A list of distros to build for. Available options are: xenial, centos7, centos6, trusty, precise, wheezy, and jessie" + default: "centos7 precise xenial" + + - string: + name: ARCHS + description: "A list of architectures to build for. Available options are: x86_64, and arm64" + default: "x86_64" + + - 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: + - centos6 + - centos7 + - trusty + - xenial + - jessie + - precise + - wheezy + - axis: + type: dynamic + name: DIST + - axis: + type: dynamic + name: DIST + values: + - DISTROS + - axis: + type: dynamic + name: ARCH + values: + - ARCHS + + scm: + - git: + url: git@github.com/nfs-ganesha/nfs-ganesha.git + # Use the SSH key attached to the ceph-jenkins GitHub account. + credentials-id: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' + branches: + - $NFS_GANESHA_BRANCH + skip-tag: true + wipe-workspace: true + basedir: "nfs-ganesha" + + scm: + - git: + url: git@github.com/nfs-ganesha/nfs-ganesha-debian.git + # Use the SSH key attached to the ceph-jenkins GitHub account. + credentials-id: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' + branches: + - xenial-nfs-ganesha-ceph-fsals + skip-tag: true + wipe-workspace: true + basedir: "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: + - ../../../scripts/build_utils.sh + - ../../build/setup + - ../../build/build_deb + # rpm build scripts + - shell: + !include-raw: + - ../../../scripts/build_utils.sh + - ../../build/setup + - ../../build/build_rpm + + wrappers: + - inject-passwords: + global: true + mask-password-params: true -- 2.39.5