3 |
3 |
|
4 |
4 |
EAPI=7
|
5 |
5 |
|
6 |
|
DISTUTILS_EXT=1
|
7 |
6 |
PYTHON_COMPAT=( pypy3 python3_{10..12} )
|
8 |
7 |
PYTHON_REQ_USE='bzip2(+),threads(+)'
|
9 |
|
SETUPTOOLS_USE_DISTUTILS=local
|
10 |
8 |
TMPFILES_OPTIONAL=1
|
11 |
9 |
|
12 |
|
inherit distutils-r1 linux-info toolchain-funcs tmpfiles prefix
|
|
10 |
inherit meson linux-info multiprocessing python-r1 tmpfiles
|
13 |
11 |
|
14 |
12 |
DESCRIPTION="The package management and distribution system for Gentoo"
|
15 |
13 |
HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
|
... | ... | |
22 |
20 |
inherit git-r3
|
23 |
21 |
else
|
24 |
22 |
SRC_URI="https://gitweb.gentoo.org/proj/portage.git/snapshot/${P}.tar.bz2"
|
25 |
|
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
|
|
23 |
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
|
26 |
24 |
fi
|
27 |
25 |
|
28 |
26 |
LICENSE="GPL-2"
|
29 |
27 |
SLOT="0"
|
30 |
28 |
IUSE="apidoc build doc gentoo-dev +ipc +native-extensions +rsync-verify selinux test xattr"
|
|
29 |
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
|
31 |
30 |
RESTRICT="!test? ( test )"
|
32 |
31 |
|
|
32 |
# setuptools is still needed as a workaround for Python 3.12+ for now.
|
|
33 |
# https://github.com/mesonbuild/meson/issues/7702
|
33 |
34 |
BDEPEND="
|
34 |
|
dev-python/setuptools[${PYTHON_USEDEP}]
|
35 |
|
test? ( dev-vcs/git )
|
|
35 |
${PYTHON_DEPS}
|
|
36 |
$(python_gen_cond_dep '
|
|
37 |
dev-python/setuptools[${PYTHON_USEDEP}]
|
|
38 |
' python3_12)
|
|
39 |
test? (
|
|
40 |
dev-python/pytest-xdist[${PYTHON_USEDEP}]
|
|
41 |
dev-vcs/git
|
|
42 |
)
|
36 |
43 |
"
|
37 |
44 |
DEPEND="
|
|
45 |
${PYTHON_DEPS}
|
38 |
46 |
>=app-arch/tar-1.27
|
39 |
47 |
dev-lang/python-exec:2
|
40 |
|
>=sys-apps/sed-4.0.5 sys-devel/patch
|
|
48 |
>=sys-apps/sed-4.0.5
|
|
49 |
sys-devel/patch
|
41 |
50 |
!build? ( $(python_gen_impl_dep 'ssl(+)') )
|
42 |
51 |
apidoc? (
|
43 |
52 |
dev-python/sphinx[${PYTHON_USEDEP}]
|
44 |
53 |
dev-python/sphinx-epytext[${PYTHON_USEDEP}]
|
45 |
54 |
)
|
46 |
55 |
doc? (
|
47 |
|
app-text/xmlto
|
48 |
56 |
~app-text/docbook-xml-dtd-4.4
|
|
57 |
app-text/xmlto
|
49 |
58 |
)
|
50 |
59 |
"
|
51 |
60 |
# Require sandbox-2.2 for bug #288863.
|
52 |
61 |
# For whirlpool hash, require python[ssl] (bug #425046).
|
53 |
|
# For compgen, require bash[readline] (bug #445576).
|
54 |
|
# app-portage/gemato goes without PYTHON_USEDEP since we're calling
|
55 |
|
# the executable.
|
56 |
62 |
RDEPEND="
|
|
63 |
${PYTHON_DEPS}
|
57 |
64 |
acct-user/portage
|
58 |
|
app-arch/zstd
|
59 |
65 |
>=app-arch/tar-1.27
|
|
66 |
app-arch/zstd
|
|
67 |
>=app-misc/pax-utils-0.1.17
|
60 |
68 |
dev-lang/python-exec:2
|
61 |
69 |
>=sys-apps/baselayout-2.9
|
62 |
70 |
>=sys-apps/findutils-4.4
|
63 |
71 |
!build? (
|
64 |
72 |
>=app-admin/eselect-1.2
|
65 |
|
>=app-shells/bash-5.0:0[readline]
|
66 |
|
>=sys-apps/sed-4.0.5
|
|
73 |
>=app-shells/bash-5.0:0
|
67 |
74 |
>=sec-keys/openpgp-keys-gentoo-release-20230329
|
|
75 |
>=sys-apps/sed-4.0.5
|
68 |
76 |
rsync-verify? (
|
69 |
|
>=app-portage/gemato-14.5[${PYTHON_USEDEP}]
|
70 |
77 |
>=app-crypt/gnupg-2.2.4-r2[ssl(-)]
|
|
78 |
>=app-portage/gemato-14.5[${PYTHON_USEDEP}]
|
71 |
79 |
)
|
72 |
80 |
)
|
73 |
81 |
elibc_glibc? ( >=sys-apps/sandbox-2.2 )
|
74 |
82 |
elibc_musl? ( >=sys-apps/sandbox-2.2 )
|
75 |
83 |
kernel_linux? ( sys-apps/util-linux )
|
76 |
|
>=app-misc/pax-utils-0.1.17
|
77 |
84 |
selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
|
78 |
85 |
xattr? ( kernel_linux? (
|
79 |
86 |
>=sys-apps/install-xattr-0.3
|
... | ... | |
93 |
100 |
)
|
94 |
101 |
"
|
95 |
102 |
|
96 |
|
PATCHES=(
|
97 |
|
# message patch used in 3.0.48.1 and 3.0.49 (bug 909853)
|
98 |
|
"${FILESDIR}/depgraph.py-fix-no-ebuilds-binpkgs-message.patch"
|
99 |
|
# backport from master to help Prefix bootstraps (bug #640658)
|
100 |
|
"${FILESDIR}/portage-3.0.49-prefixify-init-script-shebangs.patch"
|
101 |
|
)
|
102 |
|
|
103 |
|
distutils_enable_tests pytest
|
104 |
|
|
105 |
103 |
pkg_pretend() {
|
106 |
104 |
local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS ~UTS_NS"
|
107 |
105 |
|
108 |
|
if use native-extensions && tc-is-cross-compiler; then
|
109 |
|
einfo "Disabling USE=native-extensions for cross-compilation (bug #612158)"
|
110 |
|
fi
|
111 |
|
|
112 |
106 |
check_extra_config
|
113 |
107 |
}
|
114 |
108 |
|
115 |
|
python_prepare_all() {
|
116 |
|
distutils-r1_python_prepare_all
|
|
109 |
src_prepare() {
|
|
110 |
default
|
117 |
111 |
|
118 |
|
if [[ ${PV} != 9999 ]] ; then
|
119 |
|
sed -e "s:^VERSION = \"HEAD\"$:VERSION = \"${PV}\":" -i lib/portage/__init__.py || die
|
120 |
|
fi
|
121 |
|
|
122 |
|
if use gentoo-dev; then
|
123 |
|
einfo "Disabling --dynamic-deps by default for gentoo-dev..."
|
124 |
|
sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
|
125 |
|
-i lib/_emerge/create_depgraph_params.py || \
|
126 |
|
die "failed to patch create_depgraph_params.py"
|
127 |
|
|
128 |
|
einfo "Enabling additional FEATURES for gentoo-dev..."
|
129 |
|
echo 'FEATURES="${FEATURES} ipc-sandbox network-sandbox strict-keepdir warn-on-large-env"' \
|
130 |
|
>> cnf/make.globals || die
|
|
112 |
if use prefix-guest; then
|
|
113 |
sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
|
|
114 |
-e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
|
|
115 |
-e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
|
|
116 |
-i cnf/repos.conf || die "sed failed"
|
131 |
117 |
fi
|
|
118 |
}
|
132 |
119 |
|
133 |
|
if use native-extensions && ! tc-is-cross-compiler; then
|
134 |
|
printf "[build_ext]\nportage_ext_modules=true\n" >> \
|
135 |
|
setup.cfg || die
|
136 |
|
fi
|
|
120 |
src_configure() {
|
|
121 |
local code_only=false
|
|
122 |
python_foreach_impl my_src_configure
|
|
123 |
}
|
137 |
124 |
|
138 |
|
if ! use ipc ; then
|
139 |
|
einfo "Disabling ipc..."
|
140 |
|
sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
|
141 |
|
-i lib/_emerge/AbstractEbuildProcess.py || \
|
142 |
|
die "failed to patch AbstractEbuildProcess.py"
|
143 |
|
fi
|
|
125 |
my_src_configure() {
|
|
126 |
local emesonargs=(
|
|
127 |
-Dcode-only=${code_only}
|
|
128 |
-Deprefix="${EPREFIX}"
|
|
129 |
-Dportage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}"
|
|
130 |
-Ddocdir="${EPREFIX}/usr/share/doc/${PF}"
|
|
131 |
$(meson_use doc)
|
|
132 |
$(meson_use apidoc)
|
|
133 |
$(meson_use gentoo-dev)
|
|
134 |
$(meson_use ipc)
|
|
135 |
$(meson_use xattr)
|
|
136 |
)
|
144 |
137 |
|
145 |
|
if use xattr && use kernel_linux ; then
|
146 |
|
einfo "Adding FEATURES=xattr to make.globals ..."
|
147 |
|
echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
|
148 |
|
|| die "failed to append to make.globals"
|
|
138 |
if use native-extensions && [[ "${EPYTHON}" != "pypy3" ]] ; then
|
|
139 |
emesonargs+=( -Dnative-extensions=true )
|
|
140 |
else
|
|
141 |
emesonargs+=( -Dnative-extensions=false )
|
149 |
142 |
fi
|
150 |
143 |
|
151 |
|
if use build || ! use rsync-verify; then
|
152 |
|
sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
|
153 |
|
-e '/^sync-webrsync-verify-signature/s|yes|no|' \
|
154 |
|
-i cnf/repos.conf || die "sed failed"
|
|
144 |
if use build; then
|
|
145 |
emesonargs+=( -Drsync-verify=false )
|
|
146 |
else
|
|
147 |
emesonargs+=( $(meson_use rsync-verify) )
|
155 |
148 |
fi
|
156 |
149 |
|
157 |
|
if [[ -n ${EPREFIX} ]] ; then
|
158 |
|
einfo "Setting portage.const.EPREFIX ..."
|
159 |
|
hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
|
160 |
|
-w "/_BINARY/" lib/portage/const.py
|
161 |
|
|
162 |
|
einfo "Prefixing shebangs ..."
|
163 |
|
> "${T}/shebangs" || die
|
164 |
|
while read -r -d $'\0' ; do
|
165 |
|
local shebang=$(head -n1 "$REPLY")
|
166 |
|
if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
|
167 |
|
echo "${REPLY}" >> "${T}/shebangs" || die
|
168 |
|
fi
|
169 |
|
done < <(find . -type f -executable ! -name etc-update -print0)
|
170 |
|
|
171 |
|
if [[ -s ${T}/shebangs ]]; then
|
172 |
|
xargs sed -i -e "1s:^#!:#!${EPREFIX}:" < "${T}/shebangs" || die "sed failed"
|
173 |
|
fi
|
174 |
|
|
175 |
|
einfo "Adjusting make.globals, repos.conf and etc-update ..."
|
176 |
|
hprefixify cnf/{make.globals,repos.conf} bin/etc-update
|
177 |
|
|
178 |
|
if use prefix-guest ; then
|
179 |
|
sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
|
180 |
|
-e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
|
181 |
|
-e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
|
182 |
|
-i cnf/repos.conf || die "sed failed"
|
183 |
|
fi
|
184 |
|
fi
|
|
150 |
meson_src_configure
|
|
151 |
code_only=true
|
|
152 |
}
|
185 |
153 |
|
186 |
|
cd "${S}/cnf" || die
|
187 |
|
if [[ -f "make.conf.example.${ARCH}".diff ]] ; then
|
188 |
|
patch make.conf.example "make.conf.example.${ARCH}".diff || \
|
189 |
|
die "Failed to patch make.conf.example"
|
190 |
|
else
|
191 |
|
eerror ""
|
192 |
|
eerror "Portage does not have an arch-specific configuration for this arch."
|
193 |
|
eerror "Please notify the arch maintainer about this issue. Using generic."
|
194 |
|
eerror ""
|
195 |
|
fi
|
|
154 |
src_compile() {
|
|
155 |
python_foreach_impl meson_src_compile
|
196 |
156 |
}
|
197 |
157 |
|
198 |
|
python_compile_all() {
|
199 |
|
local targets=()
|
200 |
|
use doc && targets+=( docbook )
|
201 |
|
use apidoc && targets+=( apidoc )
|
|
158 |
src_test() {
|
|
159 |
local -x PYTEST_ADDOPTS="-vv -ra -l -o console_output_style=count -n $(makeopts_jobs) --dist=worksteal"
|
202 |
160 |
|
203 |
|
if [[ ${targets[@]} ]]; then
|
204 |
|
esetup.py "${targets[@]}"
|
205 |
|
fi
|
|
161 |
python_foreach_impl meson_src_test --no-rebuild --verbose
|
206 |
162 |
}
|
207 |
163 |
|
208 |
|
python_install() {
|
209 |
|
# Install sbin scripts to bindir for python-exec linking
|
210 |
|
# they will be relocated in pkg_preinst()
|
211 |
|
distutils-r1_python_install \
|
212 |
|
--system-prefix="${EPREFIX}/usr" \
|
213 |
|
--bindir="$(python_get_scriptdir)" \
|
214 |
|
--docdir="${EPREFIX}/usr/share/doc/${PF}" \
|
215 |
|
--htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
|
216 |
|
--portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
|
217 |
|
--sbindir="$(python_get_scriptdir)" \
|
218 |
|
--sysconfdir="${EPREFIX}/etc" \
|
219 |
|
"${@}"
|
220 |
|
}
|
221 |
|
|
222 |
|
python_install_all() {
|
223 |
|
distutils-r1_python_install_all
|
224 |
|
|
225 |
|
local targets=()
|
226 |
|
use doc && targets+=(
|
227 |
|
install_docbook
|
228 |
|
--htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
|
229 |
|
)
|
230 |
|
use apidoc && targets+=(
|
231 |
|
install_apidoc
|
232 |
|
--htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
|
233 |
|
)
|
234 |
|
|
235 |
|
# install docs
|
236 |
|
if [[ ${targets[@]} ]]; then
|
237 |
|
esetup.py "${targets[@]}"
|
238 |
|
fi
|
239 |
|
|
|
164 |
src_install() {
|
|
165 |
python_foreach_impl my_src_install
|
240 |
166 |
dotmpfiles "${FILESDIR}"/portage-{ccache,tmpdir}.conf
|
241 |
167 |
|
242 |
|
# Due to distutils/python-exec limitations
|
243 |
|
# these must be installed to /usr/bin.
|
244 |
|
local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
|
245 |
|
einfo "Moving admin scripts to the correct directory"
|
246 |
|
dodir /usr/sbin
|
247 |
|
for target in ${sbin_relocations}; do
|
248 |
|
einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
|
249 |
|
mv "${ED}/usr/bin/${target}" "${ED}/usr/sbin/${target}" || die "sbin scripts move failed!"
|
250 |
|
done
|
|
168 |
local scripts
|
|
169 |
mapfile -t scripts < <(awk '/^#!.*python/ {print FILENAME} {nextfile}' "${ED}"/usr/{bin,sbin}/* || die)
|
|
170 |
python_replicate_script "${scripts[@]}"
|
|
171 |
}
|
|
172 |
|
|
173 |
my_src_install() {
|
|
174 |
local pydirs=(
|
|
175 |
"${D}$(python_get_sitedir)"
|
|
176 |
"${ED}/usr/lib/portage/${EPYTHON}"
|
|
177 |
)
|
|
178 |
|
|
179 |
meson_src_install
|
|
180 |
python_optimize "${pydirs[@]}"
|
|
181 |
python_fix_shebang "${pydirs[@]}"
|
251 |
182 |
}
|
252 |
183 |
|
253 |
184 |
pkg_preinst() {
|
254 |
|
if ! use build; then
|
|
185 |
if ! use build && [[ -z ${ROOT} ]]; then
|
255 |
186 |
python_setup
|
256 |
187 |
local sitedir=$(python_get_sitedir)
|
257 |
188 |
[[ -d ${D}${sitedir} ]] || die "${D}${sitedir}: No such directory"
|