• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3echo Building ninja RPMs..
4GITROOT=$(git rev-parse --show-toplevel)
5cd $GITROOT
6
7VER=1.0
8REL=$(git rev-parse --short HEAD)git
9RPMTOPDIR=$GITROOT/rpm-build
10echo "Ver: $VER, Release: $REL"
11
12# Create tarball
13mkdir -p $RPMTOPDIR/{SOURCES,SPECS}
14git archive --format=tar --prefix=ninja-${VER}-${REL}/ HEAD | gzip -c > $RPMTOPDIR/SOURCES/ninja-${VER}-${REL}.tar.gz
15
16# Convert git log to RPM's ChangeLog format (shown with rpm -qp --changelog <rpm file>)
17sed -e "s/%{ver}/$VER/" -e "s/%{rel}/$REL/" misc/packaging/ninja.spec > $RPMTOPDIR/SPECS/ninja.spec
18git log --format="* %cd %aN%n- (%h) %s%d%n" --date=local | sed -r 's/[0-9]+:[0-9]+:[0-9]+ //' >> $RPMTOPDIR/SPECS/ninja.spec
19
20# Build SRC and binary RPMs
21rpmbuild    --quiet                       \
22            --define "_topdir $RPMTOPDIR" \
23            --define "_rpmdir $PWD"       \
24            --define "_srcrpmdir $PWD"    \
25            --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \
26            -ba $RPMTOPDIR/SPECS/ninja.spec &&
27
28rm -rf $RPMTOPDIR &&
29echo Done
30