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