Mercurial > hg
annotate contrib/buildrpm @ 8664:f265106ccb53
commands: expand "arg" -> "argument" in showconfig help strings
It is easier to translate full sentences without abbreviations, or
said differently, I don't know a short Danish word for "argument".
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sun, 31 May 2009 14:48:17 +0200 |
parents | 3d827cc616b6 |
children | ff817723280a |
rev | line source |
---|---|
564 | 1 #!/bin/sh |
2 # | |
3 # Build a Mercurial RPM in place. | |
7277
3e000e2bf5f6
Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents:
4755
diff
changeset
|
4 # Known to work on: |
3e000e2bf5f6
Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents:
4755
diff
changeset
|
5 # - Fedora 9 |
7431
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
6 # - Fedora 10 |
564 | 7 # |
8 # Bryan O'Sullivan <bos@serpentine.com> | |
9 | |
7431
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
10 if hg --version > /dev/null 2>&1; then : |
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
11 else |
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
12 echo 'hg command not available!' 1>&2 |
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
13 exit 1 |
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
14 fi |
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
15 |
564 | 16 root="`hg root 2>/dev/null`" |
17 specfile=contrib/mercurial.spec | |
18 | |
19 if [ -z "$root" ]; then | |
20 echo 'You are not inside a Mercurial repository!' 1>&2 | |
21 exit 1 | |
22 fi | |
23 | |
7277
3e000e2bf5f6
Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents:
4755
diff
changeset
|
24 rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling |
564 | 25 |
26 cd "$root" | |
27 rm -rf $rpmdir | |
28 mkdir -p $rpmdir/RPMS | |
29 hg clone "$root" $rpmdir/BUILD | |
30 | |
31 if [ ! -f $specfile ]; then | |
32 echo "Cannot find $specfile!" 1>&2 | |
33 exit 1 | |
34 fi | |
35 | |
7277
3e000e2bf5f6
Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents:
4755
diff
changeset
|
36 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling |
564 | 37 # Use the most recent tag as the version. |
38 version=`hg tags | perl -e 'while(<STDIN>){if(/^(\d\S+)/){print$1;exit}}'` | |
39 # Compute the release number as the difference in revision numbers | |
40 # between the tip and the most recent tag. | |
4755
6def53be19fb
buildrpm: fix rpm release number calculation
Adam Spiers <hg@adamspiers.org>
parents:
4754
diff
changeset
|
41 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}}'` |
564 | 42 tip=`hg -q tip` |
43 | |
44 # Beat up the spec file | |
45 sed -e 's,^Source:.*,Source: /dev/null,' \ | |
46 -e "s,^Version:.*,Version: $version," \ | |
47 -e "s,^Release:.*,Release: $release," \ | |
48 -e "s,^%prep.*,Changeset: $tip\n\0," \ | |
49 -e 's,^%setup.*,,' \ | |
50 $specfile > $tmpspec | |
51 | |
4754
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
52 cat <<EOF >> $tmpspec |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
53 %changelog |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
54 * `date +'%a %b %d %Y'` `hg showconfig ui.username` $version-$release |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
55 - Automatically built via $0 |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
56 |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
57 EOF |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
58 hg log \ |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
59 --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
60 .hgtags \ |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
61 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
62 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
63 >> $tmpspec |
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
64 |
564 | 65 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec |
66 if [ $? = 0 ]; then | |
67 rm -rf $tmpspec $rpmdir/BUILD | |
68 mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS | |
69 echo | |
7277
3e000e2bf5f6
Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents:
4755
diff
changeset
|
70 echo "Packages are in $rpmdir:" |
3e000e2bf5f6
Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents:
4755
diff
changeset
|
71 ls -l $rpmdir/*.rpm |
564 | 72 fi |