Show More
@@ -1,74 +1,74 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | # |
|
3 | 3 | # Build a Mercurial RPM in place. |
|
4 | 4 | # |
|
5 | 5 | # Bryan O'Sullivan <bos@serpentine.com> |
|
6 | 6 | # |
|
7 | 7 | # Tested on |
|
8 | 8 | # - Fedora 10 |
|
9 | 9 | # - Fedora 11 |
|
10 | 10 | # - Centos 5.3 (with Fedora EPEL repo for asciidoc) |
|
11 | 11 | |
|
12 | 12 | if hg --version > /dev/null 2>&1; then : |
|
13 | 13 | else |
|
14 | 14 | echo 'hg command not available!' 1>&2 |
|
15 | 15 | exit 1 |
|
16 | 16 | fi |
|
17 | 17 | |
|
18 | 18 | root="`hg root 2>/dev/null`" |
|
19 | 19 | specfile=contrib/mercurial.spec |
|
20 | 20 | |
|
21 | 21 | if [ -z "$root" ]; then |
|
22 | 22 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
23 | 23 | exit 1 |
|
24 | 24 | fi |
|
25 | 25 | |
|
26 | 26 | rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling |
|
27 | 27 | |
|
28 | 28 | cd "$root" |
|
29 | 29 | rm -rf $rpmdir |
|
30 | 30 | mkdir -p $rpmdir/RPMS |
|
31 | 31 | hg clone "$root" $rpmdir/BUILD |
|
32 | 32 | |
|
33 | 33 | if [ ! -f $specfile ]; then |
|
34 | 34 | echo "Cannot find $specfile!" 1>&2 |
|
35 | 35 | exit 1 |
|
36 | 36 | fi |
|
37 | 37 | |
|
38 | 38 | tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling |
|
39 | 39 | # Use the most recent tag as the version. |
|
40 | version=`hg tags | perl -e 'while(<STDIN>){if(/^(\d\S+)/){print$1;exit}}'` | |
|
40 | version=`hg tags | python -c 'import sys; print [l for l in sys.stdin.readlines() if l[0].isdigit()][0].split()[0]'` | |
|
41 | 41 | # Compute the release number as the difference in revision numbers |
|
42 | 42 | # between the tip and the most recent tag. |
|
43 | release=`hg tags | perl -e 'while(<STDIN>){($tag,$id)=/^(\S+)\s+(\d+)/;if($tag eq "tip"){$tip = $id}elsif($tag=~/^\d/){print $tip-$id+1;exit}}'` | |
|
43 | release=`hg tags | python -c 'import sys; l = sys.stdin.readlines(); print int(l[0].split()[1].split(":")[0]) - int([x for x in l if x[0].isdigit()][0].split()[1].split(":")[0])'` | |
|
44 | 44 | tip=`hg -q tip` |
|
45 | 45 | |
|
46 | 46 | # Beat up the spec file |
|
47 | 47 | sed -e 's,^Source:.*,Source: /dev/null,' \ |
|
48 | 48 | -e "s,^Version:.*,Version: $version," \ |
|
49 | 49 | -e "s,^Release:.*,Release: $release," \ |
|
50 | 50 | -e "s,^%prep.*,Changeset: $tip\n\0," \ |
|
51 | 51 | -e 's,^%setup.*,,' \ |
|
52 | 52 | $specfile > $tmpspec |
|
53 | 53 | |
|
54 | 54 | cat <<EOF >> $tmpspec |
|
55 | 55 | %changelog |
|
56 | 56 | * `date +'%a %b %d %Y'` `hg showconfig ui.username` $version-$release |
|
57 | 57 | - Automatically built via $0 |
|
58 | 58 | |
|
59 | 59 | EOF |
|
60 | 60 | hg log \ |
|
61 | 61 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ |
|
62 | 62 | .hgtags \ |
|
63 | 63 | | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
|
64 | 64 | -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ |
|
65 | 65 | >> $tmpspec |
|
66 | 66 | |
|
67 | 67 | rpmbuild --define "_topdir $rpmdir" -bb $tmpspec |
|
68 | 68 | if [ $? = 0 ]; then |
|
69 | 69 | rm -rf $tmpspec $rpmdir/BUILD |
|
70 | 70 | mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS |
|
71 | 71 | echo |
|
72 | 72 | echo "Packages are in $rpmdir:" |
|
73 | 73 | ls -l $rpmdir/*.rpm |
|
74 | 74 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now