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