add a line on the planetlab branch
[rvm-ruby.git] / rpm / create_rpm_from_here
1 #!/bin/bash
2
3 # This script will build a RPM from the files in the current directory, given that there is a rpm/file.spec
4 # Its primary purpose is to be used by Jenkins
5
6 set -e
7 set -x
8
9 specfile=`find rpm -name \*.spec |head -1`
10 test -z "$specfile" && exit -1
11
12 specfile=`basename $specfile`
13
14 name=`grep -P '^Name:\s+' rpm/$specfile |awk '{print $2}'`
15 commitdate=`git log -1 --format="%ct"`
16 version=`grep -P '^Version:\s+' rpm/$specfile |awk '{print $2}'`.$commitdate
17 #release=`grep -P '^Release:\s+' rpm/$specfile |awk '{print $2}'`
18
19 rm -rf rpmbuild
20 mkdir -p rpmbuild/{BUILD,RPMS,SOURCES/$name-$version,SPECS,SRPMS,tmp}
21 cp -a rpm/$specfile rpmbuild/SPECS
22 sed -i "s/^[\t ]*Version:.*\$/Version: ${version}/" rpmbuild/SPECS/$specfile
23 #tar --exclude-vcs --exclude='rpmbuild' --exclude='rpm' -cp * | (cd rpmbuild/SOURCES/$name-$version ; tar xp)
24
25 pushd rpmbuild/SOURCES
26 #tar cf $name-$version.tar $name-$version  # Best not to use cpu on our small ec2 instances
27 #sed -i "s/^[\t ]*Source0:.*/Source0: $name-$version.tar/g" rpmbuild/SPECS/*.spec
28 #sed -i "s/^[\t ]*%setup[\t ]\+-n[\t ]\+.*/%setup -n $name-$version/g" rpmbuild/SPECS/*.spec
29 popd
30
31 rpmbuild --define "_topdir %(pwd)/rpmbuild" -ba rpmbuild/SPECS/$specfile