sgallagh / centos / centpkg

Forked from centos/centpkg 3 years ago
Clone
Blob Blame History Raw
#! /bin/sh -e

if [ "x$1" = "x" ]; then
  echo "Building this way needs a devrel."
  exit 1
fi

c=centpkg
p=$(pwd)

echo "%define devrel $1" > c.spec
echo "%define devsnap $(date +'%Y%m%d')git.$(git show -q --format='%h')" >> c.spec
cat centpkg.spec >> c.spec

ver=$(rpmspec -q \
       --qf '%{name} %{version}\n' \
       c.spec | \
      fgrep "centpkg " | awk '{ print $2 }')

cd ..
mkdir $c-$ver
cp -a \
  $p/COPYING \
  $p/README.md \
  $p/requirements.txt \
  $p/setup.py \
  $p/src \
  $c-$ver
tar --exclude='*~' -cvf $c-$ver.tar $c-$ver
rm -rf $c-$ver
cd $p
mv ../$c-$ver.tar .
gzip -9 $c-$ver.tar

rpmbuild \
         --define="_sourcedir $(pwd)" \
         --define="_srcrpmdir $(pwd)" \
         -bs c.spec

rm $c-$ver.tar.gz c.spec