sys-apps/portage: replace epydoc with sphinx-apidoc
[gentoo.git] / sys-apps / portage / portage-2.3.86.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 DISTUTILS_USE_SETUPTOOLS=no
7 PYTHON_COMPAT=(
8         pypy3
9         python3_6 python3_7 python3_8
10         python2_7
11 )
12 PYTHON_REQ_USE='bzip2(+),threads(+)'
13
14 inherit distutils-r1 linux-info systemd prefix
15
16 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
17 HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
18
19 LICENSE="GPL-2"
20 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86"
21 SLOT="0"
22 IUSE="build doc epydoc gentoo-dev +ipc +native-extensions +rsync-verify selinux xattr"
23
24 DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
25         >=app-arch/tar-1.27
26         dev-lang/python-exec:2
27         >=sys-apps/sed-4.0.5 sys-devel/patch
28         doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
29         epydoc? (
30                 $(python_gen_cond_dep '
31                         >=dev-python/epydoc-2.0[${PYTHON_USEDEP}]
32                 ' 'python2*')
33         )"
34 # Require sandbox-2.2 for bug #288863.
35 # For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
36 # quite slow, so it's not considered in the dependencies as an alternative to
37 # to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
38 # for now, don't pull in xattr deps for other kernels.
39 # For whirlpool hash, require python[ssl] (bug #425046).
40 # For compgen, require bash[readline] (bug #445576).
41 # app-portage/gemato goes without PYTHON_USEDEP since we're calling
42 # the executable.
43 RDEPEND="
44         >=app-arch/tar-1.27
45         dev-lang/python-exec:2
46         !build? (
47                 >=sys-apps/sed-4.0.5
48                 app-shells/bash:0[readline]
49                 >=app-admin/eselect-1.2
50                 $(python_gen_cond_dep 'dev-python/pyblake2[${PYTHON_USEDEP}]' \
51                         python{2_7,3_5} pypy)
52                 rsync-verify? (
53                         >=app-portage/gemato-14[${PYTHON_USEDEP}]
54                         >=app-crypt/openpgp-keys-gentoo-release-20180706
55                         >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
56                 )
57         )
58         elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
59         elibc_glibc? ( >=sys-apps/sandbox-2.2 )
60         elibc_musl? ( >=sys-apps/sandbox-2.2 )
61         elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
62         kernel_linux? ( sys-apps/util-linux )
63         >=app-misc/pax-utils-0.1.17
64         selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
65         xattr? ( kernel_linux? (
66                 >=sys-apps/install-xattr-0.3
67                 $(python_gen_cond_dep 'dev-python/pyxattr[${PYTHON_USEDEP}]' \
68                         python2_7 pypy)
69         ) )
70         !<app-admin/logrotate-3.8.0
71         !<app-portage/gentoolkit-0.4.6
72         !<app-portage/repoman-2.3.10"
73 PDEPEND="
74         !build? (
75                 >=net-misc/rsync-2.6.4
76                 userland_GNU? ( >=sys-apps/coreutils-6.4 )
77         )"
78 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
79 # NOTE: FEATURES=installsources requires debugedit and rsync
80
81 REQUIRED_USE="epydoc? ( $(python_gen_useflags 'python2*') )"
82
83 SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives"
84
85 prefix_src_archives() {
86         local x y
87         for x in ${@}; do
88                 for y in ${SRC_ARCHIVES}; do
89                         echo ${y}/${x}
90                 done
91         done
92 }
93
94 TARBALL_PV=${PV}
95 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
96         $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)"
97
98 pkg_pretend() {
99         local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
100
101         check_extra_config
102 }
103
104 pkg_setup() {
105         use epydoc && DISTUTILS_ALL_SUBPHASE_IMPLS=( python2.7 )
106 }
107
108 python_prepare_all() {
109         distutils-r1_python_prepare_all
110
111         if use gentoo-dev; then
112                 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
113                 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
114                         -i lib/_emerge/create_depgraph_params.py || \
115                         die "failed to patch create_depgraph_params.py"
116
117                 einfo "Enabling additional FEATURES for gentoo-dev..."
118                 echo 'FEATURES="${FEATURES} strict-keepdir"' \
119                         >> cnf/make.globals || die
120         fi
121
122         if use native-extensions; then
123                 printf "[build_ext]\nportage-ext-modules=true\n" >> \
124                         setup.cfg || die
125         fi
126
127         if ! use ipc ; then
128                 einfo "Disabling ipc..."
129                 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
130                         -i lib/_emerge/AbstractEbuildProcess.py || \
131                         die "failed to patch AbstractEbuildProcess.py"
132         fi
133
134         if use xattr && use kernel_linux ; then
135                 einfo "Adding FEATURES=xattr to make.globals ..."
136                 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
137                         || die "failed to append to make.globals"
138         fi
139
140         if use build || ! use rsync-verify; then
141                 sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
142                         -e '/^sync-webrsync-verify-signature/s|yes|no|' \
143                         -i cnf/repos.conf || die "sed failed"
144         fi
145
146         if [[ -n ${EPREFIX} ]] ; then
147                 einfo "Setting portage.const.EPREFIX ..."
148                 hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
149                         -w "/_BINARY/" lib/portage/const.py
150
151                 einfo "Prefixing shebangs ..."
152                 while read -r -d $'\0' ; do
153                         local shebang=$(head -n1 "$REPLY")
154                         if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
155                                 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
156                                         die "sed failed"
157                         fi
158                 done < <(find . -type f ! -name etc-update -print0)
159
160                 einfo "Adjusting make.globals, repos.conf and etc-update ..."
161                 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
162
163                 if use prefix-guest ; then
164                         sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
165                                 -e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
166                                 -e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
167                                 -i cnf/repos.conf || die "sed failed"
168                 fi
169
170                 einfo "Adding FEATURES=force-prefix to make.globals ..."
171                 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
172                         || die "failed to append to make.globals"
173         fi
174
175         cd "${S}/cnf" || die
176         if [ -f "make.conf.example.${ARCH}".diff ]; then
177                 patch make.conf.example "make.conf.example.${ARCH}".diff || \
178                         die "Failed to patch make.conf.example"
179         else
180                 eerror ""
181                 eerror "Portage does not have an arch-specific configuration for this arch."
182                 eerror "Please notify the arch maintainer about this issue. Using generic."
183                 eerror ""
184         fi
185 }
186
187 python_compile_all() {
188         local targets=()
189         use doc && targets+=( docbook )
190         use epydoc && targets+=( epydoc )
191
192         if [[ ${targets[@]} ]]; then
193                 esetup.py "${targets[@]}"
194         fi
195 }
196
197 python_test() {
198         esetup.py test
199 }
200
201 python_install() {
202         # Install sbin scripts to bindir for python-exec linking
203         # they will be relocated in pkg_preinst()
204         distutils-r1_python_install \
205                 --system-prefix="${EPREFIX}/usr" \
206                 --bindir="$(python_get_scriptdir)" \
207                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
208                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
209                 --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
210                 --sbindir="$(python_get_scriptdir)" \
211                 --sysconfdir="${EPREFIX}/etc" \
212                 "${@}"
213 }
214
215 python_install_all() {
216         distutils-r1_python_install_all
217
218         local targets=()
219         use doc && targets+=(
220                 install_docbook
221                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
222         )
223         use epydoc && targets+=(
224                 install_epydoc
225                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
226         )
227
228         # install docs
229         if [[ ${targets[@]} ]]; then
230                 esetup.py "${targets[@]}"
231         fi
232
233         systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
234
235         # Due to distutils/python-exec limitations
236         # these must be installed to /usr/bin.
237         local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
238         einfo "Moving admin scripts to the correct directory"
239         dodir /usr/sbin
240         for target in ${sbin_relocations}; do
241                 einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
242                 mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
243         done
244 }
245
246 pkg_preinst() {
247         python_setup
248         python_export PYTHON_SITEDIR
249         [[ -d ${D%/}${PYTHON_SITEDIR} ]] || die "${D%/}${PYTHON_SITEDIR}: No such directory"
250         env -u DISTDIR \
251                 -u PORTAGE_OVERRIDE_EPREFIX \
252                 -u PORTAGE_REPOSITORIES \
253                 -u PORTDIR \
254                 -u PORTDIR_OVERLAY \
255                 PYTHONPATH="${D%/}${PYTHON_SITEDIR}${PYTHONPATH:+:${PYTHONPATH}}" \
256                 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
257
258         # elog dir must exist to avoid logrotate error for bug #415911.
259         # This code runs in preinst in order to bypass the mapping of
260         # portage:portage to root:root which happens after src_install.
261         keepdir /var/log/portage/elog
262         # This is allowed to fail if the user/group are invalid for prefix users.
263         if chown portage:portage "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
264                 chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}
265         fi
266
267         if has_version "<${CATEGORY}/${PN}-2.3.77"; then
268                 elog "The emerge --autounmask option is now disabled by default, except for"
269                 elog "portions of behavior which are controlled by the --autounmask-use and"
270                 elog "--autounmask-license options. For backward compatibility, previous"
271                 elog "behavior of --autounmask=y and --autounmask=n is entirely preserved."
272                 elog "Users can get the old behavior simply by adding --autounmask to the"
273                 elog "make.conf EMERGE_DEFAULT_OPTS variable. For the rationale for this"
274                 elog "change, see https://bugs.gentoo.org/658648."
275         fi
276 }