##// END OF EJS Templates
contrib/buildrpm: Support python 2.4 and 2.6
Mads Kiilerich -
r8867:ff817723 default
parent child Browse files
Show More
@@ -1,72 +1,74
1 #!/bin/sh
1 #!/bin/sh
2 #
2 #
3 # Build a Mercurial RPM in place.
3 # Build a Mercurial RPM in place.
4 # Known to work on:
5 # - Fedora 9
6 # - Fedora 10
7 #
4 #
8 # Bryan O'Sullivan <bos@serpentine.com>
5 # Bryan O'Sullivan <bos@serpentine.com>
6 #
7 # Tested on
8 # - Fedora 10
9 # - Fedora 11
10 # - Centos 5.3 (with Fedora EPEL repo for asciidoc)
9
11
10 if hg --version > /dev/null 2>&1; then :
12 if hg --version > /dev/null 2>&1; then :
11 else
13 else
12 echo 'hg command not available!' 1>&2
14 echo 'hg command not available!' 1>&2
13 exit 1
15 exit 1
14 fi
16 fi
15
17
16 root="`hg root 2>/dev/null`"
18 root="`hg root 2>/dev/null`"
17 specfile=contrib/mercurial.spec
19 specfile=contrib/mercurial.spec
18
20
19 if [ -z "$root" ]; then
21 if [ -z "$root" ]; then
20 echo 'You are not inside a Mercurial repository!' 1>&2
22 echo 'You are not inside a Mercurial repository!' 1>&2
21 exit 1
23 exit 1
22 fi
24 fi
23
25
24 rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling
26 rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling
25
27
26 cd "$root"
28 cd "$root"
27 rm -rf $rpmdir
29 rm -rf $rpmdir
28 mkdir -p $rpmdir/RPMS
30 mkdir -p $rpmdir/RPMS
29 hg clone "$root" $rpmdir/BUILD
31 hg clone "$root" $rpmdir/BUILD
30
32
31 if [ ! -f $specfile ]; then
33 if [ ! -f $specfile ]; then
32 echo "Cannot find $specfile!" 1>&2
34 echo "Cannot find $specfile!" 1>&2
33 exit 1
35 exit 1
34 fi
36 fi
35
37
36 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling
38 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling
37 # Use the most recent tag as the version.
39 # Use the most recent tag as the version.
38 version=`hg tags | perl -e 'while(<STDIN>){if(/^(\d\S+)/){print$1;exit}}'`
40 version=`hg tags | perl -e 'while(<STDIN>){if(/^(\d\S+)/){print$1;exit}}'`
39 # Compute the release number as the difference in revision numbers
41 # Compute the release number as the difference in revision numbers
40 # between the tip and the most recent tag.
42 # between the tip and the most recent tag.
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}}'`
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}}'`
42 tip=`hg -q tip`
44 tip=`hg -q tip`
43
45
44 # Beat up the spec file
46 # Beat up the spec file
45 sed -e 's,^Source:.*,Source: /dev/null,' \
47 sed -e 's,^Source:.*,Source: /dev/null,' \
46 -e "s,^Version:.*,Version: $version," \
48 -e "s,^Version:.*,Version: $version," \
47 -e "s,^Release:.*,Release: $release," \
49 -e "s,^Release:.*,Release: $release," \
48 -e "s,^%prep.*,Changeset: $tip\n\0," \
50 -e "s,^%prep.*,Changeset: $tip\n\0," \
49 -e 's,^%setup.*,,' \
51 -e 's,^%setup.*,,' \
50 $specfile > $tmpspec
52 $specfile > $tmpspec
51
53
52 cat <<EOF >> $tmpspec
54 cat <<EOF >> $tmpspec
53 %changelog
55 %changelog
54 * `date +'%a %b %d %Y'` `hg showconfig ui.username` $version-$release
56 * `date +'%a %b %d %Y'` `hg showconfig ui.username` $version-$release
55 - Automatically built via $0
57 - Automatically built via $0
56
58
57 EOF
59 EOF
58 hg log \
60 hg log \
59 --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \
61 --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \
60 .hgtags \
62 .hgtags \
61 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \
63 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \
62 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \
64 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \
63 >> $tmpspec
65 >> $tmpspec
64
66
65 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec
67 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec
66 if [ $? = 0 ]; then
68 if [ $? = 0 ]; then
67 rm -rf $tmpspec $rpmdir/BUILD
69 rm -rf $tmpspec $rpmdir/BUILD
68 mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS
70 mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS
69 echo
71 echo
70 echo "Packages are in $rpmdir:"
72 echo "Packages are in $rpmdir:"
71 ls -l $rpmdir/*.rpm
73 ls -l $rpmdir/*.rpm
72 fi
74 fi
@@ -1,76 +1,78
1 Summary: Mercurial -- a distributed SCM
1 Summary: Mercurial -- a distributed SCM
2 Name: mercurial
2 Name: mercurial
3 Version: snapshot
3 Version: snapshot
4 Release: 0
4 Release: 0
5 License: GPL
5 License: GPL
6 Group: Development/Tools
6 Group: Development/Tools
7 Source: http://www.selenic.com/mercurial/release/%{name}-%{version}.tar.gz
7 Source: http://www.selenic.com/mercurial/release/%{name}-%{version}.tar.gz
8 URL: http://www.selenic.com/mercurial
8 URL: http://www.selenic.com/mercurial
9 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
9 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
10
10
11 # From the README:
11 # From the README:
12 #
12 #
13 # Note: some distributions fails to include bits of distutils by
13 # Note: some distributions fails to include bits of distutils by
14 # default, you'll need python-dev to install. You'll also need a C
14 # default, you'll need python-dev to install. You'll also need a C
15 # compiler and a 3-way merge tool like merge, tkdiff, or kdiff3.
15 # compiler and a 3-way merge tool like merge, tkdiff, or kdiff3.
16 #
16 #
17 # python-devel provides an adequate python-dev. The merge tool is a
17 # python-devel provides an adequate python-dev. The merge tool is a
18 # run-time dependency.
18 # run-time dependency.
19 #
19 #
20 BuildRequires: python >= 2.3, python-devel, make, gcc, asciidoc, xmlto
20 BuildRequires: python >= 2.3, python-devel, make, gcc, asciidoc, xmlto
21
21
22 %define pythonver %(python -c 'import sys;print ".".join(map(str, sys.version_info[:2]))')
22 %define pythonver %(python -c 'import sys;print ".".join(map(str, sys.version_info[:2]))')
23 %define pythonlib %{_libdir}/python%{pythonver}/site-packages/%{name}
23 %define pythonlib %{_libdir}/python%{pythonver}/site-packages/%{name}
24 %define hgext %{_libdir}/python%{pythonver}/site-packages/hgext
24 %define hgext %{_libdir}/python%{pythonver}/site-packages/hgext
25
25
26 %description
26 %description
27 Mercurial is a fast, lightweight source control management system designed
27 Mercurial is a fast, lightweight source control management system designed
28 for efficient handling of very large distributed projects.
28 for efficient handling of very large distributed projects.
29
29
30 %prep
30 %prep
31 %setup -q
31 %setup -q
32
32
33 %build
33 %build
34 make all
34 make all
35
35
36 %install
36 %install
37 rm -rf $RPM_BUILD_ROOT
37 rm -rf $RPM_BUILD_ROOT
38 python setup.py install --root $RPM_BUILD_ROOT --prefix %{_prefix}
38 python setup.py install --root $RPM_BUILD_ROOT --prefix %{_prefix}
39 make install-doc DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir}
39 make install-doc DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir}
40
40
41 install contrib/hgk $RPM_BUILD_ROOT%{_bindir}
41 install contrib/hgk $RPM_BUILD_ROOT%{_bindir}
42 install contrib/convert-repo $RPM_BUILD_ROOT%{_bindir}/mercurial-convert-repo
42 install contrib/convert-repo $RPM_BUILD_ROOT%{_bindir}/mercurial-convert-repo
43 install contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}
43 install contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}
44 install contrib/git-viz/{hg-viz,git-rev-tree} $RPM_BUILD_ROOT%{_bindir}
44 install contrib/git-viz/{hg-viz,git-rev-tree} $RPM_BUILD_ROOT%{_bindir}
45
45
46 bash_completion_dir=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
46 bash_completion_dir=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
47 mkdir -p $bash_completion_dir
47 mkdir -p $bash_completion_dir
48 install contrib/bash_completion $bash_completion_dir/mercurial.sh
48 install contrib/bash_completion $bash_completion_dir/mercurial.sh
49
49
50 zsh_completion_dir=$RPM_BUILD_ROOT%{_datadir}/zsh/site-functions
50 zsh_completion_dir=$RPM_BUILD_ROOT%{_datadir}/zsh/site-functions
51 mkdir -p $zsh_completion_dir
51 mkdir -p $zsh_completion_dir
52 install contrib/zsh_completion $zsh_completion_dir/_mercurial
52 install contrib/zsh_completion $zsh_completion_dir/_mercurial
53
53
54 lisp_dir=$RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp
54 lisp_dir=$RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp
55 mkdir -p $lisp_dir
55 mkdir -p $lisp_dir
56 install contrib/mercurial.el $lisp_dir
56 install contrib/mercurial.el $lisp_dir
57
57
58 %clean
58 %clean
59 rm -rf $RPM_BUILD_ROOT
59 rm -rf $RPM_BUILD_ROOT
60
60
61 %files
61 %files
62 %defattr(-,root,root,-)
62 %defattr(-,root,root,-)
63 %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html doc/ja *.cgi
63 %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html doc/ja *.cgi
64 %{_mandir}/man?/hg*.gz
64 %{_mandir}/man?/hg*.gz
65 %{_sysconfdir}/bash_completion.d/mercurial.sh
65 %{_sysconfdir}/bash_completion.d/mercurial.sh
66 %{_datadir}/zsh/site-functions/_mercurial
66 %{_datadir}/zsh/site-functions/_mercurial
67 %{_datadir}/emacs/site-lisp/mercurial.el
67 %{_datadir}/emacs/site-lisp/mercurial.el
68 %{_bindir}/hg
68 %{_bindir}/hg
69 %{_bindir}/hgk
69 %{_bindir}/hgk
70 %{_bindir}/hg-ssh
70 %{_bindir}/hg-ssh
71 %{_bindir}/hg-viz
71 %{_bindir}/hg-viz
72 %{_bindir}/git-rev-tree
72 %{_bindir}/git-rev-tree
73 %{_bindir}/mercurial-convert-repo
73 %{_bindir}/mercurial-convert-repo
74 %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py2.5.egg-info
74 %if "%{?pythonver}" != "2.4"
75 %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py%{pythonver}.egg-info
76 %endif
75 %{pythonlib}
77 %{pythonlib}
76 %{hgext}
78 %{hgext}
General Comments 0
You need to be logged in to leave comments. Login now