#!/bin/sh
set -eux

RPMBUILD_DIR="rpmbuild"

RPMBUILD_DIR="$(cd ${HOME} && pwd)/${RPMBUILD_DIR}"

# Create rpmbuild directory
rm -rf ${RPMBUILD_DIR}
mkdir -p ${RPMBUILD_DIR}/BUILD
mkdir ${RPMBUILD_DIR}/RPMS
mkdir ${RPMBUILD_DIR}/SOURCES
mkdir ${RPMBUILD_DIR}/SPECS
mkdir ${RPMBUILD_DIR}/SRPMS

# Create tar ball in ${RPMBUILD_DIR}/SOURCES
git archive master --format=tgz --output=${RPMBUILD_DIR}/SOURCES/python-dciclient-0.1.tgz

# Add spec file into ${RPMBUILD_DIR}/SPECS
cp python-dciclient.spec ${RPMBUILD_DIR}/SPECS/

# Build RPM sources
SRPM=$(rpmbuild -bs ${RPMBUILD_DIR}/SPECS/python-dciclient.spec | cut -d' ' -f2)

# Build RPM
mock --rebuild --resultdir=./ ${SRPM}

#!/bin/bash
set -eux
PROJ_NAME=python-dciclient

# Create the proper filesystem hierarchy to proceed with srpm creatioon
#
rpmdev-setuptree
cp ${PROJ_NAME}.spec ${HOME}/rpmbuild/SPECS/
git archive master --format=tgz --output=${HOME}/rpmbuild/SOURCES/${PROJ_NAME}-0.1.tgz
rpmbuild -bs ${HOME}/rpmbuild/SPECS/${PROJ_NAME}.spec

# Build the RPMs in a clean chroot environment with mock to detect missing
# BuildRequires lines.
for arch in fedora-22-x86_64 fedora-23-x86_64 epel-7-x86_64; do

    if [[ "$arch" == "fedora-23-x86_64" ]]; then
        RPATH='fedora/23/x86_64'
    elif [[ "$arch" == "fedora-22-x86_64" ]]; then
        RPATH='fedora/22/x86_64'
    else
        RPATH='el/7/x86_64'
    fi

    mkdir -p development
    mock -r $arch rebuild --resultdir=development/${RPATH} ${HOME}/rpmbuild/SRPMS/${PROJ_NAME}*
done

Build packages for various platforms (Fedora, EL)
Build packages for various platforms (Fedora, EL)

Currently packages are built only for the platform this script is run
on. Meaning that if the node this script is run on is a Fedora-23 only
packages for Fedora-23 will be created, same apply for Fedora-22 or
CentOS-7.

This commit aims for this script to build the packages for a given set
of platform we want to handle. The platform set is :

  * fedora-22-x86_64
  * fedora-23-x86_64
  * epel-7-x86_64 (CentOS 7)

Change-Id: I6946362c1f6690b984361707ded69db65bfa3e74
