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 whirlpool hash, require python[ssl] (bug #425046).
31 # For compgen, require bash[readline] (bug #445576).
32 # app-portage/gemato goes without PYTHON_USEDEP since we're calling
36 dev-lang/python-exec:2
39 app-shells/bash:0[readline]
40 >=app-admin/eselect-1.2
42 >=app-portage/gemato-14[${PYTHON_USEDEP}]
43 >=app-crypt/openpgp-keys-gentoo-release-20180706
44 >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
47 elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
48 elibc_glibc? ( >=sys-apps/sandbox-2.2 )
49 elibc_musl? ( >=sys-apps/sandbox-2.2 )
50 elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
51 kernel_linux? ( sys-apps/util-linux )
52 >=app-misc/pax-utils-0.1.17
53 selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
54 xattr? ( kernel_linux? (
55 >=sys-apps/install-xattr-0.3
57 !<app-admin/logrotate-3.8.0
58 !<app-portage/gentoolkit-0.4.6
59 !<app-portage/repoman-2.3.10"
62 >=net-misc/rsync-2.6.4
63 userland_GNU? ( >=sys-apps/coreutils-6.4 )
65 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
66 # NOTE: FEATURES=installsources requires debugedit and rsync
68 SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives"
70 prefix_src_archives() {
73 for y in ${SRC_ARCHIVES}; do
80 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
81 $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)"
84 local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
89 python_prepare_all() {
90 distutils-r1_python_prepare_all
93 sed -e '50s|"EMERGE_FROM", "EPREFIX",|"EMERGE_FROM", "ENV_UNSET", "EPREFIX",|' -i lib/portage/package/ebuild/_config/special_env_vars.py || die
95 sed -e "s:^VERSION = \"HEAD\"$:VERSION = \"${PV}\":" -i lib/portage/__init__.py || die
97 if use gentoo-dev; then
98 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
99 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
100 -i lib/_emerge/create_depgraph_params.py || \
101 die "failed to patch create_depgraph_params.py"
103 einfo "Enabling additional FEATURES for gentoo-dev..."
104 echo 'FEATURES="${FEATURES} strict-keepdir"' \
105 >> cnf/make.globals || die
108 if use native-extensions; then
109 printf "[build_ext]\nportage-ext-modules=true\n" >> \
114 einfo "Disabling ipc..."
115 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
116 -i lib/_emerge/AbstractEbuildProcess.py || \
117 die "failed to patch AbstractEbuildProcess.py"
120 if use xattr && use kernel_linux ; then
121 einfo "Adding FEATURES=xattr to make.globals ..."
122 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
123 || die "failed to append to make.globals"
126 if use build || ! use rsync-verify; then
127 sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
128 -e '/^sync-webrsync-verify-signature/s|yes|no|' \
129 -i cnf/repos.conf || die "sed failed"
132 if [[ -n ${EPREFIX} ]] ; then
133 einfo "Setting portage.const.EPREFIX ..."
134 hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
135 -w "/_BINARY/" lib/portage/const.py
137 einfo "Prefixing shebangs ..."
138 while read -r -d $'\0' ; do
139 local shebang=$(head -n1 "$REPLY")
140 if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
141 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
144 done < <(find . -type f ! -name etc-update -print0)
146 einfo "Adjusting make.globals, repos.conf and etc-update ..."
147 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
149 if use prefix-guest ; then
150 sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
151 -e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
152 -e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
153 -i cnf/repos.conf || die "sed failed"
156 einfo "Adding FEATURES=force-prefix to make.globals ..."
157 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
158 || die "failed to append to make.globals"
162 if [ -f "make.conf.example.${ARCH}".diff ]; then
163 patch make.conf.example "make.conf.example.${ARCH}".diff || \
164 die "Failed to patch make.conf.example"
167 eerror "Portage does not have an arch-specific configuration for this arch."
168 eerror "Please notify the arch maintainer about this issue. Using generic."
173 python_compile_all() {
175 use doc && targets+=( docbook )
176 use apidoc && targets+=( apidoc )
178 if [[ ${targets[@]} ]]; then
179 esetup.py "${targets[@]}"
188 # Install sbin scripts to bindir for python-exec linking
189 # they will be relocated in pkg_preinst()
190 distutils-r1_python_install \
191 --system-prefix="${EPREFIX}/usr" \
192 --bindir="$(python_get_scriptdir)" \
193 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
194 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
195 --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
196 --sbindir="$(python_get_scriptdir)" \
197 --sysconfdir="${EPREFIX}/etc" \
201 python_install_all() {
202 distutils-r1_python_install_all
205 use doc && targets+=(
207 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
209 use apidoc && targets+=(
211 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
215 if [[ ${targets[@]} ]]; then
216 esetup.py "${targets[@]}"
219 systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
221 # Due to distutils/python-exec limitations
222 # these must be installed to /usr/bin.
223 local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
224 einfo "Moving admin scripts to the correct directory"
226 for target in ${sbin_relocations}; do
227 einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
228 mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
234 local sitedir=$(python_get_sitedir)
235 [[ -d ${D%/}${sitedir} ]] || die "${D%/}${sitedir}: No such directory"
237 -u PORTAGE_OVERRIDE_EPREFIX \
238 -u PORTAGE_REPOSITORIES \
241 PYTHONPATH="${D%/}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
242 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
244 # elog dir must exist to avoid logrotate error for bug #415911.
245 # This code runs in preinst in order to bypass the mapping of
246 # portage:portage to root:root which happens after src_install.
247 keepdir /var/log/portage/elog
248 # This is allowed to fail if the user/group are invalid for prefix users.
249 if chown portage:portage "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
250 chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}
253 if has_version "<${CATEGORY}/${PN}-2.3.77"; then
254 elog "The emerge --autounmask option is now disabled by default, except for"
255 elog "portions of behavior which are controlled by the --autounmask-use and"
256 elog "--autounmask-license options. For backward compatibility, previous"
257 elog "behavior of --autounmask=y and --autounmask=n is entirely preserved."
258 elog "Users can get the old behavior simply by adding --autounmask to the"
259 elog "make.conf EMERGE_DEFAULT_OPTS variable. For the rationale for this"
260 elog "change, see https://bugs.gentoo.org/658648."