#!/bin/bash -e

echo "Making temp dir to store our work"
TMPDIR=$(mktemp -d)

cd ${TMPDIR}

echo "Fetching centos-git-common"
git clone  https://git.centos.org/centos-git-common.git

echo "Adding centos-git-common to \$PATH"
PATH="${TMPDIR}/centos-git-common:${PATH}"

echo "Fetching the CentOS 8 Sources for Samba"
git clone https://git.centos.org/rpms/samba.git --branch c8

cd samba

echo "Putting our work in a sample branch"
git checkout -b example-branch

echo "Making a trivial change"
echo "##### EXAMPLE ######" >> SPECS/samba.spec

echo "Fetching Sources"
get_sources.sh

echo "Building SRPM"
rpmbuild --nodeps --define "%_topdir `pwd`" -bs SPECS/samba.spec

echo "Building binary RPMs"
rpmbuild --define "%_topdir `pwd`" -bb SPECS/samba.spec


