proj/gentoo: Initial commit
[gentoo.git] / dev-vcs / mercurial / mercurial-9999.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python2_7 )
8 PYTHON_REQ_USE="threads"
9
10 inherit bash-completion-r1 elisp-common eutils distutils-r1 mercurial flag-o-matic
11
12 DESCRIPTION="Scalable distributed SCM"
13 HOMEPAGE="http://mercurial.selenic.com/"
14 EHG_REPO_URI="http://selenic.com/repo/hg"
15 EHG_REVISION="@"
16
17 LICENSE="GPL-2"
18 SLOT="0"
19 KEYWORDS=""
20 IUSE="bugzilla emacs gpg test tk zsh-completion"
21
22 RDEPEND="bugzilla? ( dev-python/mysql-python[${PYTHON_USEDEP}] )
23         gpg? ( app-crypt/gnupg )
24         tk? ( dev-lang/tk )
25         zsh-completion? ( app-shells/zsh )
26         app-misc/ca-certificates"
27 DEPEND="emacs? ( virtual/emacs )
28         test? ( app-arch/unzip
29                 dev-python/pygments[${PYTHON_USEDEP}] )
30         dev-python/docutils[${PYTHON_USEDEP}]"
31
32 SITEFILE="70${PN}-gentoo.el"
33
34 python_prepare_all() {
35         # fix up logic that won't work in Gentoo Prefix (also won't outside in
36         # certain cases), bug #362891
37         sed -i -e 's:xcodebuild:nocodebuild:' setup.py || die
38
39         distutils-r1_python_prepare_all
40 }
41
42 python_configure_all() {
43         strip-flags -ftracer -ftree-vectorize
44         # Note: make it impl-conditional if py3 is supported
45         append-flags -fno-strict-aliasing
46
47         "${PYTHON}" setup.py build_mo || die
48 }
49
50 python_compile_all() {
51         rm -r contrib/{win32,macosx} || die
52         emake doc
53         if use emacs; then
54                 cd contrib || die
55                 elisp-compile mercurial.el || die "elisp-compile failed!"
56         fi
57 }
58
59 python_install_all() {
60         distutils-r1_python_install_all
61
62         newbashcomp contrib/bash_completion hg
63
64         if use zsh-completion ; then
65                 insinto /usr/share/zsh/site-functions
66                 newins contrib/zsh_completion _hg
67         fi
68
69         rm -f doc/*.?.txt || die
70         dodoc CONTRIBUTORS doc/*.txt
71         cp hgweb*.cgi "${ED}"/usr/share/doc/${PF}/ || die
72
73         dobin hgeditor
74         dobin contrib/hgk
75         python_foreach_impl python_doscript contrib/hg-ssh
76
77         if use emacs; then
78                 elisp-install ${PN} contrib/mercurial.el* || die "elisp-install failed!"
79                 elisp-site-file-install "${FILESDIR}"/${SITEFILE}
80         fi
81
82         local RM_CONTRIB=(hgk hg-ssh bash_completion zsh_completion wix buildrpm plan9
83                           *.el mercurial.spec)
84         for f in ${RM_CONTRIB[@]}; do
85                 rm -rf contrib/$f || die
86         done
87
88         dodoc -r contrib
89         docompress -x /usr/share/doc/${PF}/contrib
90         doman doc/*.?
91
92         cat > "${T}/80mercurial" <<-EOF
93 HG="${EPREFIX}/usr/bin/hg"
94 EOF
95         doenvd "${T}/80mercurial"
96
97         insinto /etc/mercurial/hgrc.d
98         doins "${FILESDIR}/cacerts.rc"
99 }
100
101 src_test() {
102         cd tests || die
103         rm -rf *svn* || die                                     # Subversion tests fail with 1.5
104         rm -f test-archive* || die                      # Fails due to verbose tar output changes
105         rm -f test-convert-baz* || die          # GNU Arch baz
106         rm -f test-convert-cvs* || die          # CVS
107         rm -f test-convert-darcs* || die        # Darcs
108         rm -f test-convert-git* || die          # git
109         rm -f test-convert-mtn* || die          # monotone
110         rm -f test-convert-tla* || die          # GNU Arch tla
111         rm -f test-doctest* || die                      # doctest always fails with python 2.5.x
112         rm -f test-largefiles* || die           # tends to time out
113         if [[ ${EUID} -eq 0 ]]; then
114                 einfo "Removing tests which require user privileges to succeed"
115                 rm -f test-command-template* || die     # Test is broken when run as root
116                 rm -f test-convert* || die                      # Test is broken when run as root
117                 rm -f test-lock-badness* || die         # Test is broken when run as root
118                 rm -f test-permissions* || die          # Test is broken when run as root
119                 rm -f test-pull-permission* || die      # Test is broken when run as root
120                 rm -f test-clone-failure* || die
121                 rm -f test-journal-exists* || die
122                 rm -f test-repair-strip* || die
123         fi
124
125         cd .. || die
126         distutils-r1_src_test
127 }
128
129 python_test() {
130         local TEST_DIR
131
132         rm -rf "${TMPDIR}"/test
133         distutils_install_for_testing
134         cd tests || die
135         "${PYTHON}" run-tests.py --verbose \
136                 --tmpdir="${TMPDIR}"/test \
137                 --with-hg="${TEST_DIR}"/scripts/hg \
138                 || die "Tests fail with ${EPYTHON}"
139 }
140
141 pkg_postinst() {
142         use emacs && elisp-site-regen
143
144         elog "If you want to convert repositories from other tools using convert"
145         elog "extension please install correct tool:"
146         elog "  dev-vcs/cvs"
147         elog "  dev-vcs/darcs"
148         elog "  dev-vcs/git"
149         elog "  dev-vcs/monotone"
150         elog "  dev-vcs/subversion"
151 }
152
153 pkg_postrm() {
154         use emacs && elisp-site-regen
155 }