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