1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 DISTUTILS_USE_SETUPTOOLS=no
7 PYTHON_COMPAT=( pypy3 python3_6 python3_7 python3_8 )
8 PYTHON_REQ_USE='bzip2(+),threads(+)'
10 inherit distutils-r1 linux-info systemd prefix
12 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
13 HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
18 IUSE="apidoc build doc gentoo-dev +ipc +native-extensions +rsync-verify selinux xattr"
20 DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
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 )
27 dev-python/sphinx-epytext
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
40 dev-lang/python-exec:2
43 app-shells/bash:0[readline]
44 >=app-admin/eselect-1.2
46 >=app-portage/gemato-14[${PYTHON_USEDEP}]
47 >=app-crypt/openpgp-keys-gentoo-release-20180706
48 >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
51 elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
52 elibc_glibc? ( >=sys-apps/sandbox-2.2 )
53 elibc_musl? ( >=sys-apps/sandbox-2.2 )
54 elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
55 kernel_linux? ( sys-apps/util-linux )
56 >=app-misc/pax-utils-0.1.17
57 selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
58 xattr? ( kernel_linux? (
59 >=sys-apps/install-xattr-0.3
61 !<app-admin/logrotate-3.8.0
62 !<app-portage/gentoolkit-0.4.6
63 !<app-portage/repoman-2.3.10"
66 >=net-misc/rsync-2.6.4
67 userland_GNU? ( >=sys-apps/coreutils-6.4 )
69 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
70 # NOTE: FEATURES=installsources requires debugedit and rsync
72 SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives"
74 prefix_src_archives() {
77 for y in ${SRC_ARCHIVES}; do
84 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
85 $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)"
88 local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
93 python_prepare_all() {
94 distutils-r1_python_prepare_all
97 sed -e '1638s|^\t\t\tself\._schedule()|\t\t\tif self._main_exit is not None and not self._main_exit.done():\n\t\t\t\tself._schedule()|' -i lib/_emerge/Scheduler.py || die
99 sed -e "s:^VERSION = \"HEAD\"$:VERSION = \"${PV}\":" -i lib/portage/__init__.py || die
101 if use gentoo-dev; then
102 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
103 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
104 -i lib/_emerge/create_depgraph_params.py || \
105 die "failed to patch create_depgraph_params.py"
107 einfo "Enabling additional FEATURES for gentoo-dev..."
108 echo 'FEATURES="${FEATURES} strict-keepdir"' \
109 >> cnf/make.globals || die
112 if use native-extensions; then
113 printf "[build_ext]\nportage-ext-modules=true\n" >> \
118 einfo "Disabling ipc..."
119 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
120 -i lib/_emerge/AbstractEbuildProcess.py || \
121 die "failed to patch AbstractEbuildProcess.py"
124 if use xattr && use kernel_linux ; then
125 einfo "Adding FEATURES=xattr to make.globals ..."
126 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
127 || die "failed to append to make.globals"
130 if use build || ! use rsync-verify; then
131 sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
132 -e '/^sync-webrsync-verify-signature/s|yes|no|' \
133 -i cnf/repos.conf || die "sed failed"
136 if [[ -n ${EPREFIX} ]] ; then
137 einfo "Setting portage.const.EPREFIX ..."
138 hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
139 -w "/_BINARY/" lib/portage/const.py
141 einfo "Prefixing shebangs ..."
142 while read -r -d $'\0' ; do
143 local shebang=$(head -n1 "$REPLY")
144 if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
145 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
148 done < <(find . -type f ! -name etc-update -print0)
150 einfo "Adjusting make.globals, repos.conf and etc-update ..."
151 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
153 if use prefix-guest ; then
154 sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
155 -e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
156 -e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
157 -i cnf/repos.conf || die "sed failed"
160 einfo "Adding FEATURES=force-prefix to make.globals ..."
161 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
162 || die "failed to append to make.globals"
166 if [ -f "make.conf.example.${ARCH}".diff ]; then
167 patch make.conf.example "make.conf.example.${ARCH}".diff || \
168 die "Failed to patch make.conf.example"
171 eerror "Portage does not have an arch-specific configuration for this arch."
172 eerror "Please notify the arch maintainer about this issue. Using generic."
177 python_compile_all() {
179 use doc && targets+=( docbook )
180 use apidoc && targets+=( apidoc )
182 if [[ ${targets[@]} ]]; then
183 esetup.py "${targets[@]}"
192 # Install sbin scripts to bindir for python-exec linking
193 # they will be relocated in pkg_preinst()
194 distutils-r1_python_install \
195 --system-prefix="${EPREFIX}/usr" \
196 --bindir="$(python_get_scriptdir)" \
197 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
198 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
199 --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
200 --sbindir="$(python_get_scriptdir)" \
201 --sysconfdir="${EPREFIX}/etc" \
205 python_install_all() {
206 distutils-r1_python_install_all
209 use doc && targets+=(
211 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
213 use apidoc && targets+=(
215 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
219 if [[ ${targets[@]} ]]; then
220 esetup.py "${targets[@]}"
223 systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
225 # Due to distutils/python-exec limitations
226 # these must be installed to /usr/bin.
227 local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
228 einfo "Moving admin scripts to the correct directory"
230 for target in ${sbin_relocations}; do
231 einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
232 mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
238 local sitedir=$(python_get_sitedir)
239 [[ -d ${D%/}${sitedir} ]] || die "${D%/}${sitedir}: No such directory"
241 -u PORTAGE_OVERRIDE_EPREFIX \
242 -u PORTAGE_REPOSITORIES \
245 PYTHONPATH="${D%/}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
246 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
248 # elog dir must exist to avoid logrotate error for bug #415911.
249 # This code runs in preinst in order to bypass the mapping of
250 # portage:portage to root:root which happens after src_install.
251 keepdir /var/log/portage/elog
252 # This is allowed to fail if the user/group are invalid for prefix users.
253 if chown portage:portage "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
254 chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}
257 if has_version "<${CATEGORY}/${PN}-2.3.77"; then
258 elog "The emerge --autounmask option is now disabled by default, except for"
259 elog "portions of behavior which are controlled by the --autounmask-use and"
260 elog "--autounmask-license options. For backward compatibility, previous"
261 elog "behavior of --autounmask=y and --autounmask=n is entirely preserved."
262 elog "Users can get the old behavior simply by adding --autounmask to the"
263 elog "make.conf EMERGE_DEFAULT_OPTS variable. For the rationale for this"
264 elog "change, see https://bugs.gentoo.org/658648."