sys-apps/portage: Bump to version 2.3.70
[gentoo.git] / sys-apps / portage / portage-2.3.69.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 PYTHON_COMPAT=(
7         pypy
8         python3_5 python3_6 python3_7
9         python2_7
10 )
11 PYTHON_REQ_USE='bzip2(+),threads(+)'
12
13 inherit distutils-r1 linux-info systemd prefix
14
15 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
16 HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
17
18 LICENSE="GPL-2"
19 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sh sparc x86 ~amd64-fbsd"
20 SLOT="0"
21 IUSE="build doc epydoc gentoo-dev +ipc +native-extensions +rsync-verify selinux xattr"
22
23 DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
24         >=app-arch/tar-1.27
25         dev-lang/python-exec:2
26         >=sys-apps/sed-4.0.5 sys-devel/patch
27         doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
28         epydoc? ( >=dev-python/epydoc-2.0[$(python_gen_usedep 'python2*')] )"
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/repoman-2.3.10"
67 PDEPEND="
68         !build? (
69                 >=net-misc/rsync-2.6.4
70                 userland_GNU? ( >=sys-apps/coreutils-6.4 )
71         )"
72 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
73 # NOTE: FEATURES=installsources requires debugedit and rsync
74
75 REQUIRED_USE="epydoc? ( $(python_gen_useflags 'python2*') )"
76
77 SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives"
78
79 prefix_src_archives() {
80         local x y
81         for x in ${@}; do
82                 for y in ${SRC_ARCHIVES}; do
83                         echo ${y}/${x}
84                 done
85         done
86 }
87
88 TARBALL_PV=${PV}
89 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
90         $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)"
91
92 pkg_pretend() {
93         local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
94
95         check_extra_config
96 }
97
98 pkg_setup() {
99         use epydoc && DISTUTILS_ALL_SUBPHASE_IMPLS=( python2.7 )
100 }
101
102 python_prepare_all() {
103         distutils-r1_python_prepare_all
104
105         if use gentoo-dev; then
106                 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
107                 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
108                         -i lib/_emerge/create_depgraph_params.py || \
109                         die "failed to patch create_depgraph_params.py"
110
111                 einfo "Enabling additional FEATURES for gentoo-dev..."
112                 echo 'FEATURES="${FEATURES} ipc-sandbox network-sandbox strict-keepdir"' \
113                         >> cnf/make.globals || die
114         fi
115
116         if use native-extensions; then
117                 printf "[build_ext]\nportage-ext-modules=true\n" >> \
118                         setup.cfg || die
119         fi
120
121         if ! use ipc ; then
122                 einfo "Disabling ipc..."
123                 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
124                         -i lib/_emerge/AbstractEbuildProcess.py || \
125                         die "failed to patch AbstractEbuildProcess.py"
126         fi
127
128         if use xattr && use kernel_linux ; then
129                 einfo "Adding FEATURES=xattr to make.globals ..."
130                 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
131                         || die "failed to append to make.globals"
132         fi
133
134         if use build || ! use rsync-verify; then
135                 sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
136                         -e '/^sync-webrsync-verify-signature/s|yes|no|' \
137                         -i cnf/repos.conf || die "sed failed"
138         fi
139
140         if [[ -n ${EPREFIX} ]] ; then
141                 einfo "Setting portage.const.EPREFIX ..."
142                 hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
143                         -w "/_BINARY/" lib/portage/const.py
144
145                 einfo "Prefixing shebangs ..."
146                 while read -r -d $'\0' ; do
147                         local shebang=$(head -n1 "$REPLY")
148                         if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
149                                 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
150                                         die "sed failed"
151                         fi
152                 done < <(find . -type f ! -name etc-update -print0)
153
154                 einfo "Adjusting make.globals, repos.conf and etc-update ..."
155                 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
156
157                 if use prefix-guest ; then
158                         sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
159                                 -e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
160                                 -e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
161                                 -i cnf/repos.conf || die "sed failed"
162                 fi
163
164                 einfo "Adding FEATURES=force-prefix to make.globals ..."
165                 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
166                         || die "failed to append to make.globals"
167         fi
168
169         cd "${S}/cnf" || die
170         if [ -f "make.conf.example.${ARCH}".diff ]; then
171                 patch make.conf.example "make.conf.example.${ARCH}".diff || \
172                         die "Failed to patch make.conf.example"
173         else
174                 eerror ""
175                 eerror "Portage does not have an arch-specific configuration for this arch."
176                 eerror "Please notify the arch maintainer about this issue. Using generic."
177                 eerror ""
178         fi
179 }
180
181 python_compile_all() {
182         local targets=()
183         use doc && targets+=( docbook )
184         use epydoc && targets+=( epydoc )
185
186         if [[ ${targets[@]} ]]; then
187                 esetup.py "${targets[@]}"
188         fi
189 }
190
191 python_test() {
192         esetup.py test
193 }
194
195 python_install() {
196         # Install sbin scripts to bindir for python-exec linking
197         # they will be relocated in pkg_preinst()
198         distutils-r1_python_install \
199                 --system-prefix="${EPREFIX}/usr" \
200                 --bindir="$(python_get_scriptdir)" \
201                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
202                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
203                 --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
204                 --sbindir="$(python_get_scriptdir)" \
205                 --sysconfdir="${EPREFIX}/etc" \
206                 "${@}"
207 }
208
209 python_install_all() {
210         distutils-r1_python_install_all
211
212         local targets=()
213         use doc && targets+=(
214                 install_docbook
215                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
216         )
217         use epydoc && targets+=(
218                 install_epydoc
219                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
220         )
221
222         # install docs
223         if [[ ${targets[@]} ]]; then
224                 esetup.py "${targets[@]}"
225         fi
226
227         systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
228
229         # Due to distutils/python-exec limitations
230         # these must be installed to /usr/bin.
231         local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
232         einfo "Moving admin scripts to the correct directory"
233         dodir /usr/sbin
234         for target in ${sbin_relocations}; do
235                 einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
236                 mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
237         done
238 }
239
240 pkg_preinst() {
241         python_setup
242         python_export PYTHON_SITEDIR
243         [[ -d ${D%/}${PYTHON_SITEDIR} ]] || die "${D%/}${PYTHON_SITEDIR}: No such directory"
244         env -u DISTDIR \
245                 -u PORTAGE_OVERRIDE_EPREFIX \
246                 -u PORTAGE_REPOSITORIES \
247                 -u PORTDIR \
248                 -u PORTDIR_OVERLAY \
249                 PYTHONPATH="${D%/}${PYTHON_SITEDIR}${PYTHONPATH:+:${PYTHONPATH}}" \
250                 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
251
252         # elog dir must exist to avoid logrotate error for bug #415911.
253         # This code runs in preinst in order to bypass the mapping of
254         # portage:portage to root:root which happens after src_install.
255         keepdir /var/log/portage/elog
256         # This is allowed to fail if the user/group are invalid for prefix users.
257         if chown portage:portage "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
258                 chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}
259         fi
260 }