Revert "sys-cluster/slurm: improve netloc dep, disable-static"
[gentoo.git] / dev-vcs / mercurial / mercurial-9999.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python2_7 python3_{6..8} )
7 PYTHON_REQ_USE="threads(+)"
8
9 inherit bash-completion-r1 elisp-common eutils distutils-r1 mercurial flag-o-matic
10
11 DESCRIPTION="Scalable distributed SCM"
12 HOMEPAGE="https://www.mercurial-scm.org/"
13 EHG_REPO_URI="https://www.mercurial-scm.org/repo/hg"
14
15 LICENSE="GPL-2+"
16 SLOT="0"
17 KEYWORDS=""
18 IUSE="+chg emacs gpg test tk zsh-completion"
19
20 BROKEN_PYTHON="
21         !~dev-python/python-3.5.0
22         !~dev-python/python-3.5.1
23         !~dev-python/python-3.5.2
24         !~dev-python/python-3.6.0
25         !~dev-python/python-3.6.1"
26
27 BDEPEND="${BROKEN_PYTHON}
28         dev-python/docutils[${PYTHON_USEDEP}]"
29
30 RDEPEND="${BROKEN_PYTHON}
31         app-misc/ca-certificates
32         dev-python/zstandard[${PYTHON_USEDEP}]
33         gpg? ( app-crypt/gnupg )
34         tk? ( dev-lang/tk )
35         zsh-completion? ( app-shells/zsh )"
36
37 DEPEND="emacs? ( >=app-editors/emacs-23.1:* )
38         test? ( app-arch/unzip
39                 dev-python/pygments[${PYTHON_USEDEP}] )"
40
41 SITEFILE="70${PN}-gentoo.el"
42
43 # Too many tests fail #608720
44 RESTRICT="test"
45
46 python_prepare_all() {
47         # fix up logic that won't work in Gentoo Prefix (also won't outside in
48         # certain cases), bug #362891
49         sed -i -e 's:xcodebuild:nocodebuild:' setup.py || die
50         sed -i -e '/    hgenv =/a\' -e '    hgenv.pop("PYTHONPATH", None)' setup.py || die
51         # Use absolute import for zstd
52         sed -i -e 's/from \.* import zstd/import zstd/' \
53                 mercurial/utils/compression.py \
54                 mercurial/wireprotoframing.py || die
55
56         distutils-r1_python_prepare_all
57 }
58
59 python_compile() {
60         filter-flags -ftracer -ftree-vectorize
61         python_is_python3 || local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
62         distutils-r1_python_compile build_ext --no-zstd
63 }
64
65 python_compile_all() {
66         rm -r contrib/win32 || die
67         emake doc
68         if use chg; then
69                 emake -C contrib/chg
70         fi
71         if use emacs; then
72                 cd contrib || die
73                 elisp-compile mercurial.el || die "elisp-compile failed!"
74         fi
75 }
76
77 python_install() {
78         distutils-r1_python_install build_ext --no-zstd
79 }
80
81 python_install_all() {
82         distutils-r1_python_install_all
83
84         newbashcomp contrib/bash_completion hg
85
86         if use zsh-completion ; then
87                 insinto /usr/share/zsh/site-functions
88                 newins contrib/zsh_completion _hg
89         fi
90
91         dobin hgeditor
92         if use tk; then
93                 dobin contrib/hgk
94         fi
95         python_foreach_impl python_doscript contrib/hg-ssh
96
97         if use emacs; then
98                 elisp-install ${PN} contrib/mercurial.el* || die "elisp-install failed!"
99                 elisp-site-file-install "${FILESDIR}"/${SITEFILE}
100         fi
101
102         local RM_CONTRIB=( hgk hg-ssh bash_completion zsh_completion plan9 *.el )
103
104         if use chg; then
105                 dobin contrib/chg/chg
106                 doman contrib/chg/chg.1
107                 RM_CONTRIB+=( chg )
108         fi
109
110         for f in ${RM_CONTRIB[@]}; do
111                 rm -rf contrib/${f} || die
112         done
113
114         dodoc -r contrib
115         docompress -x /usr/share/doc/${PF}/contrib
116         doman doc/*.?
117         dodoc CONTRIBUTORS hgweb.cgi
118
119         insinto /etc/mercurial/hgrc.d
120         doins "${FILESDIR}/cacerts.rc"
121 }
122
123 src_test() {
124         pushd tests &>/dev/null || die
125         rm -rf *svn*                    # Subversion tests fail with 1.5
126         rm -f test-archive*             # Fails due to verbose tar output changes
127         rm -f test-convert-baz*         # GNU Arch baz
128         rm -f test-convert-cvs*         # CVS
129         rm -f test-convert-darcs*       # Darcs
130         rm -f test-convert-git*         # git
131         rm -f test-convert-mtn*         # monotone
132         rm -f test-convert-tla*         # GNU Arch tla
133         rm -f test-largefiles*          # tends to time out
134         if [[ ${EUID} -eq 0 ]]; then
135                 einfo "Removing tests which require user privileges to succeed"
136                 rm -f test-convert*
137                 rm -f test-lock-badness*
138                 rm -f test-permissions*
139                 rm -f test-pull-permission*
140                 rm -f test-journal-exists*
141                 rm -f test-repair-strip*
142         fi
143
144         popd &>/dev/null || die
145         distutils-r1_src_test
146 }
147
148 python_test() {
149         local TEST_DIR
150
151         rm -rf "${TMPDIR}"/test
152         distutils_install_for_testing
153         cd tests || die
154         "${PYTHON}" run-tests.py --verbose \
155                 --tmpdir="${TMPDIR}"/test \
156                 --with-hg="${TEST_DIR}"/scripts/hg \
157                 || die "Tests fail with ${EPYTHON}"
158 }
159
160 pkg_postinst() {
161         use emacs && elisp-site-regen
162
163         elog "If you want to convert repositories from other tools using convert"
164         elog "extension please install correct tool:"
165         elog "  dev-vcs/cvs"
166         elog "  dev-vcs/darcs"
167         elog "  dev-vcs/git"
168         elog "  dev-vcs/monotone"
169         elog "  dev-vcs/subversion"
170 }
171
172 pkg_postrm() {
173         use emacs && elisp-site-regen
174 }