-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmakesrpm.sh
executable file
·30 lines (29 loc) · 1.01 KB
/
makesrpm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
if [ "$1" = "" ]
then
tree=HEAD
else
tree=$1
fi
eval $(git describe --tags --match='v*' |awk '
BEGIN { FS = "-" }
{
if (NF == 1)
printf("Version=%s\nRelease=1\n", substr($1, 2, length($1) - 1));
else if (NF == 2)
printf("Version=%s\nRelease=%s\n", substr($1, 2, length($1) - 1), $2);
else if (NF == 3)
printf("Version=%s\nRelease=%s.%s%s\n", substr($1, 2, length($1) - 1), $2 + 1, strftime("%Y%m%d"), $3);
else if (NF == 4)
printf("Version=%s\nRelease=%s.%sx%s%s\n", substr($1, 2, length($1) - 1), $2, strftime("%Y%m%d"), $3 + 1, $4);
}')
if [ -z "${Version}" -o -z "${Release}" ]
then
echo "No version tag found\n"
exit 1
fi
rm -rf rpmbuild.tmp
mkdir rpmbuild.tmp
git archive --prefix snebu-${Version}/ ${tree} |gzip >rpmbuild.tmp/snebu-${Version}.tar.gz
git cat-file -p ${tree}:snebu.spec |sed "s/_VERSION_/${Version}/g;s/_RELEASE_/${Release}/g" >rpmbuild.tmp/snebu.spec
rpmbuild --define "_sourcedir ./rpmbuild.tmp" --define "_srcrpmdir ./rpmbuild.tmp" -bs rpmbuild.tmp/snebu.spec