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 git-r3 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"
22 IUSE="apidoc build doc 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 )
31 dev-python/sphinx-epytext
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"
73 >=net-misc/rsync-2.6.4
74 userland_GNU? ( >=sys-apps/coreutils-6.4 )
76 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
77 # NOTE: FEATURES=installsources requires debugedit and rsync
79 SRC_ARCHIVES="https://dev.gentoo.org/~dolsen/releases/portage"
81 prefix_src_archives() {
84 for y in ${SRC_ARCHIVES}; do
90 EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/portage.git
91 https://github.com/gentoo/portage.git"
94 local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
99 python_prepare_all() {
100 distutils-r1_python_prepare_all
102 if use gentoo-dev; then
103 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
104 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
105 -i lib/_emerge/create_depgraph_params.py || \
106 die "failed to patch create_depgraph_params.py"
108 einfo "Enabling additional FEATURES for gentoo-dev..."
109 echo 'FEATURES="${FEATURES} ipc-sandbox network-sandbox strict-keepdir"' \
110 >> cnf/make.globals || die
113 if use native-extensions; then
114 printf "[build_ext]\nportage-ext-modules=true\n" >> \
119 einfo "Disabling ipc..."
120 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
121 -i lib/_emerge/AbstractEbuildProcess.py || \
122 die "failed to patch AbstractEbuildProcess.py"
125 if use xattr && use kernel_linux ; then
126 einfo "Adding FEATURES=xattr to make.globals ..."
127 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
128 || die "failed to append to make.globals"
131 if use build || ! use rsync-verify; then
132 sed -e '/^sync-rsync-verify-metamanifest/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 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 # they 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 python_export PYTHON_SITEDIR
239 [[ -d ${D%/}${PYTHON_SITEDIR} ]] || die "${D%/}${PYTHON_SITEDIR}: No such directory"
241 -u PORTAGE_OVERRIDE_EPREFIX \
242 -u PORTAGE_REPOSITORIES \
245 PYTHONPATH="${D%/}${PYTHON_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}