equal
deleted
inserted
replaced
1 #!/bin/sh |
1 #!/bin/sh |
2 # |
2 # |
3 # Build a Mercurial RPM in place. |
3 # Build a Mercurial RPM in place. |
4 # |
4 # |
5 # Bryan O'Sullivan <bos@serpentine.com> |
|
6 # |
|
7 # Tested on |
5 # Tested on |
8 # - Fedora 10 |
6 # - Fedora 8 (with docutils 0.5) |
9 # - Fedora 11 |
7 # - Fedora 11 |
10 # - Centos 5.3 (with Fedora EPEL repo for asciidoc) |
8 # - OpenSuse 11.2 |
11 |
9 |
12 cd "`dirname $0`/.." |
10 cd "`dirname $0`/.." |
13 HG="$PWD/hg" |
11 HG="$PWD/hg" |
14 PYTHONPATH="$PWD/mercurial/pure" |
12 PYTHONPATH="$PWD/mercurial/pure" |
15 export PYTHONPATH |
13 export PYTHONPATH |
16 |
14 |
17 root="`$HG root 2>/dev/null`" |
|
18 specfile=contrib/mercurial.spec |
15 specfile=contrib/mercurial.spec |
|
16 if [ ! -f $specfile ]; then |
|
17 echo "Cannot find $specfile!" 1>&2 |
|
18 exit 1 |
|
19 fi |
19 |
20 |
20 if [ -z "$root" ]; then |
21 if [ ! -d .hg ]; then |
21 echo 'You are not inside a Mercurial repository!' 1>&2 |
22 echo 'You are not inside a Mercurial repository!' 1>&2 |
22 exit 1 |
23 exit 1 |
23 fi |
24 fi |
24 |
25 |
25 if $HG id -i | grep '+$' > /dev/null 2>&1; then |
26 if $HG id -i | grep '+$' > /dev/null 2>&1; then |
28 if echo $answer | grep -iv '^y'; then |
29 if echo $answer | grep -iv '^y'; then |
29 exit |
30 exit |
30 fi |
31 fi |
31 fi |
32 fi |
32 |
33 |
33 rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling |
34 rpmdir="$PWD/rpmbuild" |
34 |
35 |
35 cd "$root" |
|
36 rm -rf $rpmdir |
36 rm -rf $rpmdir |
37 mkdir -p $rpmdir/RPMS |
37 mkdir -p $rpmdir/RPMS |
38 $HG clone -u . "$root" $rpmdir/BUILD |
38 $HG clone -u . . $rpmdir/BUILD |
39 |
|
40 if [ ! -f $specfile ]; then |
|
41 echo "Cannot find $specfile!" 1>&2 |
|
42 exit 1 |
|
43 fi |
|
44 |
39 |
45 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling |
40 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling |
46 # make setup.py build the version string |
41 # make setup.py build the version string |
47 python setup.py build_py -c -d . |
42 python setup.py build_py -c -d . |
48 hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` |
43 hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` |
54 else |
49 else |
55 # official tag, version is like 1.3.1 |
50 # official tag, version is like 1.3.1 |
56 version=`echo $hgversion | sed -e 's/+.*//'` |
51 version=`echo $hgversion | sed -e 's/+.*//'` |
57 release='0' |
52 release='0' |
58 fi |
53 fi |
59 tip=`$HG -q tip` |
|
60 |
54 |
61 # Beat up the spec file |
55 sed -e "s,^Version:.*,Version: $version," \ |
62 sed -e 's,^Source:.*,Source: /dev/null,' \ |
|
63 -e "s,^Version:.*,Version: $version," \ |
|
64 -e "s,^Release:.*,Release: $release," \ |
56 -e "s,^Release:.*,Release: $release," \ |
65 -e "s,^%prep.*,Changeset: $tip\n\0," \ |
57 -e "s,^%prep.*,\n\0," \ |
66 -e 's,^%setup.*,,' \ |
58 -e 's,^%setup.*,,' \ |
67 $specfile > $tmpspec |
59 $specfile > $tmpspec |
68 |
60 |
69 cat <<EOF >> $tmpspec |
61 cat <<EOF >> $tmpspec |
70 %changelog |
62 %changelog |
77 .hgtags \ |
69 .hgtags \ |
78 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
70 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
79 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ |
71 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ |
80 >> $tmpspec |
72 >> $tmpspec |
81 |
73 |
82 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec |
74 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec --clean |
83 if [ $? = 0 ]; then |
75 if [ $? = 0 ]; then |
84 rm -rf $tmpspec $rpmdir/BUILD |
|
85 mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS |
76 mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS |
86 echo |
77 echo |
87 echo "Packages are in $rpmdir:" |
78 echo "Packages are in $rpmdir:" |
88 ls -l $rpmdir/*.rpm |
79 ls -l $rpmdir/*.rpm |
89 fi |
80 fi |