1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 DISTUTILS_USE_SETUPTOOLS=no
9 python3_6 python3_7 python3_8
12 PYTHON_REQ_USE='bzip2(+),threads(+)'
14 inherit distutils-r1 linux-info systemd prefix
16 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
17 HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
20 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86"
22 IUSE="build doc epydoc gentoo-dev +ipc +native-extensions +rsync-verify selinux xattr"
24 DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
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 )
30 $(python_gen_cond_dep '
31 >=dev-python/epydoc-2.0[${PYTHON_USEDEP}]
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
45 dev-lang/python-exec:2
48 app-shells/bash:0[readline]
49 >=app-admin/eselect-1.2
50 $(python_gen_cond_dep 'dev-python/pyblake2[${PYTHON_USEDEP}]' \
53 >=app-portage/gemato-14[${PYTHON_USEDEP}]
54 >=app-crypt/openpgp-keys-gentoo-release-20180706
55 >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
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}]' \
70 !<app-admin/logrotate-3.8.0
71 !<app-portage/gentoolkit-0.4.6
72 !<app-portage/repoman-2.3.10"
75 >=net-misc/rsync-2.6.4
76 userland_GNU? ( >=sys-apps/coreutils-6.4 )
78 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
79 # NOTE: FEATURES=installsources requires debugedit and rsync
81 REQUIRED_USE="epydoc? ( $(python_gen_useflags 'python2*') )"
83 SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives"
85 prefix_src_archives() {
88 for y in ${SRC_ARCHIVES}; do
95 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
96 $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)"
99 local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
105 use epydoc && DISTUTILS_ALL_SUBPHASE_IMPLS=( python2.7 )
108 python_prepare_all() {
109 distutils-r1_python_prepare_all
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"
117 einfo "Enabling additional FEATURES for gentoo-dev..."
118 echo 'FEATURES="${FEATURES} strict-keepdir"' \
119 >> cnf/make.globals || die
122 if use native-extensions; then
123 printf "[build_ext]\nportage-ext-modules=true\n" >> \
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"
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"
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"
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
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" || \
158 done < <(find . -type f ! -name etc-update -print0)
160 einfo "Adjusting make.globals, repos.conf and etc-update ..."
161 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
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"
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"
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"
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."
187 python_compile_all() {
189 use doc && targets+=( docbook )
190 use epydoc && targets+=( epydoc )
192 if [[ ${targets[@]} ]]; then
193 esetup.py "${targets[@]}"
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" \
215 python_install_all() {
216 distutils-r1_python_install_all
219 use doc && targets+=(
221 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
223 use epydoc && targets+=(
225 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
229 if [[ ${targets[@]} ]]; then
230 esetup.py "${targets[@]}"
233 systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
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"
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!"
248 python_export PYTHON_SITEDIR
249 [[ -d ${D%/}${PYTHON_SITEDIR} ]] || die "${D%/}${PYTHON_SITEDIR}: No such directory"
251 -u PORTAGE_OVERRIDE_EPREFIX \
252 -u PORTAGE_REPOSITORIES \
255 PYTHONPATH="${D%/}${PYTHON_SITEDIR}${PYTHONPATH:+:${PYTHONPATH}}" \
256 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
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}
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."