|
| 1 | +#! /usr/bin/bash |
| 2 | +set -ex |
| 3 | + |
| 4 | +# Only do actual work when we are an RPM distro |
| 5 | +if test "$DISTRO" != "fedora" -a "$DISTRO" != "centos" -a "$DISTRO" != "rhel"; then |
| 6 | + exit 0 |
| 7 | +fi |
| 8 | + |
| 9 | + |
| 10 | +## Install any setup-time deps (to make dist package) |
| 11 | +# TODO -- upload install-deps.sh script that installs the setup time deps |
| 12 | +# to upstream repo or update this section to install these packages |
| 13 | + |
| 14 | +# We need this to get the major version from lsb_release |
| 15 | +yum install -y redhat-lsb-core mock |
| 16 | + |
| 17 | +# Run the install-deps.sh upstream script if it exists |
| 18 | +if [ -x install-deps.sh ]; then |
| 19 | + echo "Ensuring dependencies are installed" |
| 20 | + sudo ./install-deps.sh |
| 21 | +fi |
| 22 | + |
| 23 | + |
| 24 | +## Get some basic information about the system and the repository |
| 25 | +# TODO -- update this to get the proper VERSION/REVISION |
| 26 | +RELEASE="$(lsb_release --short -r | cut -d '.' -f 1)" # sytem release |
| 27 | +VERSION="$(./get-version.sh)" |
| 28 | +REVISION="$(./get-revision.sh)" |
| 29 | +RPM_RELEASE=$(echo $REVISION | tr '-' '_') # the '-' has a special meaning |
| 30 | + |
| 31 | + |
| 32 | +## Build the source tarball |
| 33 | +# TODO -- upload make-dist script that stores the tarball in dist/ to upstream repo or update this section |
| 34 | +echo "Building source distribution" |
| 35 | +if [ -x make-dist ]; then |
| 36 | + echo "Ensuring dependencies are installed" |
| 37 | + ./make-dist |
| 38 | +fi |
| 39 | + |
| 40 | + |
| 41 | +## Prepare the spec file for build |
| 42 | +# TODO -- Make sure the spec(.in) file is tracked upstream |
| 43 | +sed -e "s/@VERSION@/${VERSION}/g" -e "s/@RELEASE@/${RPM_RELEASE}/g" < PROJECT.spec.in > dist/PROJECT.spec |
| 44 | + |
| 45 | + |
| 46 | +## Create the source rpm |
| 47 | +# TODO -- update the paths to match the location of source package (dist/ by |
| 48 | +# default) and the spec file (PWD by default) |
| 49 | +echo "Building SRPM" |
| 50 | +rpmbuild \ |
| 51 | + --define "_sourcedir ./dist" \ |
| 52 | + --define "_specdir ." \ |
| 53 | + --define "_builddir ." \ |
| 54 | + --define "_srcrpmdir ." \ |
| 55 | + --define "_rpmdir ." \ |
| 56 | + --define "dist .any" \ |
| 57 | + --define "fedora 21" \ |
| 58 | + --define "rhel 7" \ |
| 59 | + --nodeps -bs dist/PROJECT.spec |
| 60 | +SRPM=$(readlink -f *.src.rpm) |
| 61 | + |
| 62 | + |
| 63 | +## Build the binaries with mock |
| 64 | +echo "Building RPMs" |
| 65 | +sudo mock -r ${MOCK_TARGET}-${RELEASE}-${ARCH} --resultdir=./dist/rpm/ ${SRPM} |
| 66 | + |
| 67 | + |
| 68 | +## Upload the created RPMs to chacra |
| 69 | +chacra_endpoint="PROJECT/${BRANCH}/${GIT_COMMIT}/${DISTRO}/${RELEASE}" |
| 70 | + |
| 71 | +[ "$FORCE" = true ] && chacra_flags="--force" || chacra_flags="" |
| 72 | + |
| 73 | +# push binaries to chacra |
| 74 | +find ./dist/rpm/ | egrep '\.rpm$' | $VENV/chacractl binary ${chacra_flags} create ${chacra_endpoint}/$ARCH/ |
| 75 | + |
| 76 | +# start repo creation |
| 77 | +$VENV/chacractl repo update ${chacra_endpoint} |
| 78 | + |
| 79 | +echo Check the status of the repo at: https://shaman.ceph.com/api/repos/${chacra_endpoint} |
0 commit comments