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 git-r3 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"
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
30 # Require sandbox-2.2 for bug #288863.
31 # For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
32 # quite slow, so it's not considered in the dependencies as an alternative to
33 # to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
34 # for now, don't pull in xattr deps for other kernels.
35 # For whirlpool hash, require python[ssl] (bug #425046).
36 # For compgen, require bash[readline] (bug #445576).
37 # app-portage/gemato goes without PYTHON_USEDEP since we're calling
41 dev-lang/python-exec:2
44 app-shells/bash:0[readline]
45 >=app-admin/eselect-1.2
47 >=app-portage/gemato-14[${PYTHON_USEDEP}]
48 >=app-crypt/openpgp-keys-gentoo-release-20180706
49 >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
52 elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
53 elibc_glibc? ( >=sys-apps/sandbox-2.2 )
54 elibc_musl? ( >=sys-apps/sandbox-2.2 )
55 elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
56 kernel_linux? ( sys-apps/util-linux )
57 >=app-misc/pax-utils-0.1.17
58 selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
59 xattr? ( kernel_linux? (
60 >=sys-apps/install-xattr-0.3
62 !<app-admin/logrotate-3.8.0"
65 >=net-misc/rsync-2.6.4
66 userland_GNU? ( >=sys-apps/coreutils-6.4 )
68 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
69 # NOTE: FEATURES=installsources requires debugedit and rsync
71 SRC_ARCHIVES="https://dev.gentoo.org/~dolsen/releases/portage"
73 prefix_src_archives() {
76 for y in ${SRC_ARCHIVES}; do
82 EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/portage.git
83 https://github.com/gentoo/portage.git"
86 local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
91 python_prepare_all() {
92 distutils-r1_python_prepare_all
94 if use gentoo-dev; then
95 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
96 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
97 -i lib/_emerge/create_depgraph_params.py || \
98 die "failed to patch create_depgraph_params.py"
100 einfo "Enabling additional FEATURES for gentoo-dev..."
101 echo 'FEATURES="${FEATURES} ipc-sandbox network-sandbox strict-keepdir"' \
102 >> cnf/make.globals || die
105 if use native-extensions; then
106 printf "[build_ext]\nportage-ext-modules=true\n" >> \
111 einfo "Disabling ipc..."
112 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
113 -i lib/_emerge/AbstractEbuildProcess.py || \
114 die "failed to patch AbstractEbuildProcess.py"
117 if use xattr && use kernel_linux ; then
118 einfo "Adding FEATURES=xattr to make.globals ..."
119 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
120 || die "failed to append to make.globals"
123 if use build || ! use rsync-verify; then
124 sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
125 -i cnf/repos.conf || die "sed failed"
128 if [[ -n ${EPREFIX} ]] ; then
129 einfo "Setting portage.const.EPREFIX ..."
130 hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
131 -w "/_BINARY/" lib/portage/const.py
133 einfo "Prefixing shebangs ..."
134 while read -r -d $'\0' ; do
135 local shebang=$(head -n1 "$REPLY")
136 if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
137 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
140 done < <(find . -type f ! -name etc-update -print0)
142 einfo "Adjusting make.globals, repos.conf and etc-update ..."
143 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
145 if prefix-guest ; then
146 sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
147 -e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
148 -e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
149 -i cnf/repos.conf || die "sed failed"
152 einfo "Adding FEATURES=force-prefix to make.globals ..."
153 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
154 || die "failed to append to make.globals"
158 if [ -f "make.conf.example.${ARCH}".diff ]; then
159 patch make.conf.example "make.conf.example.${ARCH}".diff || \
160 die "Failed to patch make.conf.example"
163 eerror "Portage does not have an arch-specific configuration for this arch."
164 eerror "Please notify the arch maintainer about this issue. Using generic."
169 python_compile_all() {
171 use doc && targets+=( docbook )
172 use apidoc && targets+=( apidoc )
174 if [[ ${targets[@]} ]]; then
175 esetup.py "${targets[@]}"
184 # Install sbin scripts to bindir for python-exec linking
185 # they will be relocated in pkg_preinst()
186 distutils-r1_python_install \
187 --system-prefix="${EPREFIX}/usr" \
188 --bindir="$(python_get_scriptdir)" \
189 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
190 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
191 --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
192 --sbindir="$(python_get_scriptdir)" \
193 --sysconfdir="${EPREFIX}/etc" \
197 python_install_all() {
198 distutils-r1_python_install_all
201 use doc && targets+=(
203 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
205 use apidoc && targets+=(
207 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
211 if [[ ${targets[@]} ]]; then
212 esetup.py "${targets[@]}"
215 systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
217 # Due to distutils/python-exec limitations
218 # they must be installed to /usr/bin.
219 local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
220 einfo "Moving admin scripts to the correct directory"
222 for target in ${sbin_relocations}; do
223 einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
224 mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
230 local sitedir=$(python_get_sitedir)
231 [[ -d ${D%/}${sitedir} ]] || die "${D%/}${sitedir}: No such directory"
233 -u PORTAGE_OVERRIDE_EPREFIX \
234 -u PORTAGE_REPOSITORIES \
237 PYTHONPATH="${D%/}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
238 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
240 # elog dir must exist to avoid logrotate error for bug #415911.
241 # This code runs in preinst in order to bypass the mapping of
242 # portage:portage to root:root which happens after src_install.
243 keepdir /var/log/portage/elog
244 # This is allowed to fail if the user/group are invalid for prefix users.
245 if chown portage:portage "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
246 chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}