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