1 |
hasufell 14/08/31 21:27:58 |
2 |
|
3 |
Modified: ChangeLog |
4 |
Added: portage-2.2.12-r1.ebuild |
5 |
Log: |
6 |
revbump to EAPI=5 to fix broken dep calculation wrt #506158, as discussed with mgorny and bernalex |
7 |
|
8 |
(Portage version: 2.2.12-r1/cvs/Linux x86_64, signed Manifest commit with key BDEED020) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1404 sys-apps/portage/ChangeLog |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?rev=1.1404&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?rev=1.1404&content-type=text/plain |
15 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?r1=1.1403&r2=1.1404 |
16 |
|
17 |
Index: ChangeLog |
18 |
=================================================================== |
19 |
RCS file: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v |
20 |
retrieving revision 1.1403 |
21 |
retrieving revision 1.1404 |
22 |
diff -u -r1.1403 -r1.1404 |
23 |
--- ChangeLog 12 Aug 2014 19:54:39 -0000 1.1403 |
24 |
+++ ChangeLog 31 Aug 2014 21:27:58 -0000 1.1404 |
25 |
@@ -1,6 +1,12 @@ |
26 |
# ChangeLog for sys-apps/portage |
27 |
# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 |
28 |
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v 1.1403 2014/08/12 19:54:39 dolsen Exp $ |
29 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v 1.1404 2014/08/31 21:27:58 hasufell Exp $ |
30 |
+ |
31 |
+*portage-2.2.12-r1 (31 Aug 2014) |
32 |
+ |
33 |
+ 31 Aug 2014; Julian Ospald <hasufell@g.o> +portage-2.2.12-r1.ebuild: |
34 |
+ revbump to EAPI=5 to fix broken dep calculation wrt #506158, as discussed |
35 |
+ with mgorny and bernalex |
36 |
|
37 |
*portage-2.2.12 (12 Aug 2014) |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
1.1 sys-apps/portage/portage-2.2.12-r1.ebuild |
43 |
|
44 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.2.12-r1.ebuild?rev=1.1&view=markup |
45 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.2.12-r1.ebuild?rev=1.1&content-type=text/plain |
46 |
|
47 |
Index: portage-2.2.12-r1.ebuild |
48 |
=================================================================== |
49 |
# Copyright 1999-2014 Gentoo Foundation |
50 |
# Distributed under the terms of the GNU General Public License v2 |
51 |
# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-2.2.12-r1.ebuild,v 1.1 2014/08/31 21:27:58 hasufell Exp $ |
52 |
|
53 |
# Require EAPI 2 since we now require at least python-2.6 (for python 3 |
54 |
# syntax support) which also requires EAPI 2. |
55 |
EAPI=5 |
56 |
PYTHON_COMPAT=( |
57 |
pypy |
58 |
python3_2 python3_3 python3_4 |
59 |
python2_7 |
60 |
) |
61 |
inherit eutils multilib |
62 |
|
63 |
DESCRIPTION="Portage is the package management and distribution system for Gentoo" |
64 |
HOMEPAGE="http://www.gentoo.org/proj/en/portage/index.xml" |
65 |
LICENSE="GPL-2" |
66 |
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" |
67 |
SLOT="0" |
68 |
IUSE="build doc epydoc +ipc linguas_ru pypy python2 python3 selinux xattr" |
69 |
|
70 |
for _pyimpl in ${PYTHON_COMPAT[@]} ; do |
71 |
IUSE+=" python_targets_${_pyimpl}" |
72 |
done |
73 |
unset _pyimpl |
74 |
|
75 |
python_dep_ssl="python3? ( =dev-lang/python-3*[ssl] ) |
76 |
!pypy? ( !python2? ( !python3? ( |
77 |
>=dev-lang/python-2.7[ssl] |
78 |
) ) ) |
79 |
pypy? ( !python2? ( !python3? ( virtual/pypy:0[bzip2] ) ) ) |
80 |
python2? ( !python3? ( dev-lang/python:2.7[ssl] ) )" |
81 |
python_dep="${python_dep_ssl//\[ssl\]}" |
82 |
python_dep="${python_dep//,ssl}" |
83 |
python_dep="${python_dep//ssl,}" |
84 |
|
85 |
python_dep="${python_dep} |
86 |
python_targets_pypy? ( virtual/pypy:0 ) |
87 |
python_targets_python2_7? ( dev-lang/python:2.7 ) |
88 |
python_targets_python3_2? ( dev-lang/python:3.2 ) |
89 |
python_targets_python3_3? ( dev-lang/python:3.3 ) |
90 |
python_targets_python3_4? ( dev-lang/python:3.4 ) |
91 |
" |
92 |
|
93 |
# The pysqlite blocker is for bug #282760. |
94 |
# make-3.82 is for bug #455858 |
95 |
DEPEND="${python_dep} |
96 |
>=sys-devel/make-3.82 |
97 |
>=sys-apps/sed-4.0.5 sys-devel/patch |
98 |
doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 ) |
99 |
epydoc? ( >=dev-python/epydoc-2.0 !<=dev-python/pysqlite-2.4.1 )" |
100 |
# Require sandbox-2.2 for bug #288863. |
101 |
# For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's |
102 |
# quite slow, so it's not considered in the dependencies as an alternative to |
103 |
# to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so |
104 |
# for now, don't pull in xattr deps for other kernels. |
105 |
# For whirlpool hash, require python[ssl] or python-mhash (bug #425046). |
106 |
# For compgen, require bash[readline] (bug #445576). |
107 |
RDEPEND="${python_dep} |
108 |
!build? ( >=sys-apps/sed-4.0.5 |
109 |
|| ( >=app-shells/bash-4.2_p37[readline] ( <app-shells/bash-4.2_p37 >=app-shells/bash-3.2_p17 ) ) |
110 |
>=app-admin/eselect-1.2 |
111 |
|| ( ${python_dep_ssl} dev-python/python-mhash ) |
112 |
) |
113 |
elibc_FreeBSD? ( sys-freebsd/freebsd-bin ) |
114 |
elibc_glibc? ( >=sys-apps/sandbox-2.2 ) |
115 |
elibc_uclibc? ( >=sys-apps/sandbox-2.2 ) |
116 |
>=app-misc/pax-utils-0.1.17 |
117 |
selinux? ( >=sys-libs/libselinux-2.0.94[python] ) |
118 |
xattr? ( kernel_linux? ( |
119 |
>=sys-apps/install-xattr-0.3 |
120 |
$(for python_impl in python{2_7,3_2} pypy; do |
121 |
echo "python_targets_${python_impl}? ( dev-python/pyxattr[python_targets_${python_impl}] )" |
122 |
done) ) ) |
123 |
!<app-shells/bash-3.2_p17 |
124 |
!<app-admin/logrotate-3.8.0" |
125 |
PDEPEND=" |
126 |
!build? ( |
127 |
>=net-misc/rsync-2.6.4 |
128 |
userland_GNU? ( >=sys-apps/coreutils-6.4 ) |
129 |
)" |
130 |
# coreutils-6.4 rdep is for date format in emerge-webrsync #164532 |
131 |
# NOTE: FEATURES=installsources requires debugedit and rsync |
132 |
|
133 |
SRC_ARCHIVES="http://dev.gentoo.org/~dolsen/releases/portage" |
134 |
|
135 |
prefix_src_archives() { |
136 |
local x y |
137 |
for x in ${@}; do |
138 |
for y in ${SRC_ARCHIVES}; do |
139 |
echo ${y}/${x} |
140 |
done |
141 |
done |
142 |
} |
143 |
|
144 |
PV_PL="2.1.2" |
145 |
PATCHVER_PL="" |
146 |
TARBALL_PV=${PV} |
147 |
SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2 |
148 |
$(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)" |
149 |
|
150 |
PATCHVER= |
151 |
[[ $TARBALL_PV = $PV ]] || PATCHVER=$PV |
152 |
if [ -n "${PATCHVER}" ]; then |
153 |
SRC_URI="${SRC_URI} mirror://gentoo/${PN}-${PATCHVER}.patch.bz2 |
154 |
$(prefix_src_archives ${PN}-${PATCHVER}.patch.bz2)" |
155 |
fi |
156 |
|
157 |
S="${WORKDIR}"/${PN}-${TARBALL_PV} |
158 |
S_PL="${WORKDIR}"/${PN}-${PV_PL} |
159 |
|
160 |
compatible_python_is_selected() { |
161 |
[[ $("${EPREFIX}/usr/bin/python" -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x2060000 and "good" or "bad")') = good ]] |
162 |
} |
163 |
|
164 |
current_python_has_xattr() { |
165 |
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' |
166 |
local PYTHON=${EPREFIX}/usr/bin/${EPYTHON} |
167 |
[[ $("${PYTHON}" -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x3030000 and "yes" or "no")') = yes ]] || \ |
168 |
"${PYTHON}" -c 'import xattr' 2>/dev/null |
169 |
} |
170 |
|
171 |
call_with_python_impl() { |
172 |
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' |
173 |
env EPYTHON=${EPYTHON} "$@" |
174 |
} |
175 |
|
176 |
get_python_interpreter() { |
177 |
[ $# -eq 1 ] || die "expected 1 argument, got $#: $*" |
178 |
local impl=$1 python |
179 |
case "${impl}" in |
180 |
python*) |
181 |
python=${impl/_/.} |
182 |
;; |
183 |
pypy) |
184 |
python=${impl} |
185 |
;; |
186 |
*) |
187 |
die "Unrecognized python target: ${impl}" |
188 |
esac |
189 |
echo ${python} |
190 |
} |
191 |
|
192 |
get_python_sitedir() { |
193 |
[ $# -eq 1 ] || die "expected 1 argument, got $#: $*" |
194 |
local impl=$1 |
195 |
local site_dir=usr/$(get_libdir)/${impl/_/.}/site-packages |
196 |
[[ -d ${EROOT:-${ROOT}}${site_dir} ]] || \ |
197 |
ewarn "site-packages dir missing for ${impl}: ${EROOT:-${ROOT}}${site_dir}" |
198 |
echo "/${site_dir}" |
199 |
} |
200 |
|
201 |
python_compileall() { |
202 |
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' |
203 |
local d=${EPREFIX}$1 PYTHON=${EPREFIX}/usr/bin/${EPYTHON} |
204 |
local d_image=${D}${d#/} |
205 |
[[ -d ${d_image} ]] || die "directory does not exist: ${d_image}" |
206 |
case "${EPYTHON}" in |
207 |
python*) |
208 |
"${PYTHON}" -m compileall -q -f -d "${d}" "${d_image}" || die |
209 |
# Note: Using -OO breaks emaint, since it requires __doc__, |
210 |
# and __doc__ is None when -OO is used. |
211 |
"${PYTHON}" -O -m compileall -q -f -d "${d}" "${d_image}" || die |
212 |
;; |
213 |
pypy) |
214 |
"${PYTHON}" -m compileall -q -f -d "${d}" "${d_image}" || die |
215 |
;; |
216 |
*) |
217 |
die "Unrecognized EPYTHON value: ${EPYTHON}" |
218 |
esac |
219 |
} |
220 |
|
221 |
pkg_setup() { |
222 |
if use python2 && use python3 ; then |
223 |
ewarn "Both python2 and python3 USE flags are enabled, but only one" |
224 |
ewarn "can be in the shebangs. Using python3." |
225 |
fi |
226 |
if use pypy && use python3 ; then |
227 |
ewarn "Both pypy and python3 USE flags are enabled, but only one" |
228 |
ewarn "can be in the shebangs. Using python3." |
229 |
fi |
230 |
if use pypy && use python2 ; then |
231 |
ewarn "Both pypy and python2 USE flags are enabled, but only one" |
232 |
ewarn "can be in the shebangs. Using python2" |
233 |
fi |
234 |
if ! use pypy && ! use python2 && ! use python3 && \ |
235 |
! compatible_python_is_selected ; then |
236 |
ewarn "Attempting to select a compatible default python interpreter" |
237 |
local x success=0 |
238 |
for x in "${EPREFIX}"/usr/bin/python2.* ; do |
239 |
x=${x#${EPREFIX}/usr/bin/python2.} |
240 |
if [[ $x -ge 6 ]] 2>/dev/null ; then |
241 |
eselect python set python2.$x |
242 |
if compatible_python_is_selected ; then |
243 |
elog "Default python interpreter is now set to python-2.$x" |
244 |
success=1 |
245 |
break |
246 |
fi |
247 |
fi |
248 |
done |
249 |
if [ $success != 1 ] ; then |
250 |
eerror "Unable to select a compatible default python interpreter!" |
251 |
die "This version of portage requires at least python-2.6 to be selected as the default python interpreter (see \`eselect python --help\`)." |
252 |
fi |
253 |
fi |
254 |
|
255 |
# We use EPYTHON to designate the active python interpreter, |
256 |
# but we only export when needed, via call_with_python_impl. |
257 |
EPYTHON=python |
258 |
export -n EPYTHON |
259 |
if use python3; then |
260 |
EPYTHON=python3 |
261 |
elif use python2; then |
262 |
EPYTHON=python2 |
263 |
elif use pypy; then |
264 |
EPYTHON=pypy |
265 |
fi |
266 |
} |
267 |
|
268 |
src_prepare() { |
269 |
if [ -n "${PATCHVER}" ] ; then |
270 |
if [[ -L $S/bin/ebuild-helpers/portageq ]] ; then |
271 |
rm "$S/bin/ebuild-helpers/portageq" \ |
272 |
|| die "failed to remove portageq helper symlink" |
273 |
fi |
274 |
epatch "${WORKDIR}/${PN}-${PATCHVER}.patch" |
275 |
fi |
276 |
einfo "Setting portage.VERSION to ${PVR} ..." |
277 |
sed -e "s/^VERSION = .*/VERSION = \"${PVR}\"/" -i pym/portage/__init__.py || \ |
278 |
die "Failed to patch portage.VERSION" |
279 |
sed -e "1s/VERSION/${PVR}/" -i doc/fragment/version || \ |
280 |
die "Failed to patch VERSION in doc/fragment/version" |
281 |
sed -e "1s/VERSION/${PVR}/" -i $(find man -type f) || \ |
282 |
die "Failed to patch VERSION in man page headers" |
283 |
|
284 |
if ! use ipc ; then |
285 |
einfo "Disabling ipc..." |
286 |
sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \ |
287 |
-i pym/_emerge/AbstractEbuildProcess.py || \ |
288 |
die "failed to patch AbstractEbuildProcess.py" |
289 |
fi |
290 |
|
291 |
if use xattr && use kernel_linux ; then |
292 |
einfo "Adding FEATURES=xattr to make.globals ..." |
293 |
echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \ |
294 |
|| die "failed to append to make.globals" |
295 |
fi |
296 |
|
297 |
local set_shebang= |
298 |
if use python3; then |
299 |
set_shebang=python3 |
300 |
elif use python2; then |
301 |
set_shebang=python2 |
302 |
elif use pypy; then |
303 |
set_shebang=pypy |
304 |
fi |
305 |
if [[ -n ${set_shebang} ]] ; then |
306 |
einfo "Converting shebangs for ${set_shebang}..." |
307 |
while read -r -d $'\0' ; do |
308 |
local shebang=$(head -n1 "$REPLY") |
309 |
if [[ ${shebang} == "#!/usr/bin/python"* ]] ; then |
310 |
sed -i -e "1s:python:${set_shebang}:" "$REPLY" || \ |
311 |
die "sed failed" |
312 |
fi |
313 |
done < <(find . -type f -print0) |
314 |
fi |
315 |
|
316 |
if [[ -n ${EPREFIX} ]] ; then |
317 |
einfo "Setting portage.const.EPREFIX ..." |
318 |
sed -e "s|^\(SANDBOX_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/bin/sandbox\"\)|\\1${EPREFIX}\\2|" \ |
319 |
-e "s|^\(FAKEROOT_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/bin/fakeroot\"\)|\\1${EPREFIX}\\2|" \ |
320 |
-e "s|^\(BASH_BINARY[[:space:]]*=[[:space:]]*\"\)\(/bin/bash\"\)|\\1${EPREFIX}\\2|" \ |
321 |
-e "s|^\(MOVE_BINARY[[:space:]]*=[[:space:]]*\"\)\(/bin/mv\"\)|\\1${EPREFIX}\\2|" \ |
322 |
-e "s|^\(PRELINK_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/sbin/prelink\"\)|\\1${EPREFIX}\\2|" \ |
323 |
-e "s|^\(EPREFIX[[:space:]]*=[[:space:]]*\"\).*|\\1${EPREFIX}\"|" \ |
324 |
-i pym/portage/const.py || \ |
325 |
die "Failed to patch portage.const.EPREFIX" |
326 |
|
327 |
einfo "Prefixing shebangs ..." |
328 |
while read -r -d $'\0' ; do |
329 |
local shebang=$(head -n1 "$REPLY") |
330 |
if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then |
331 |
sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \ |
332 |
die "sed failed" |
333 |
fi |
334 |
done < <(find . -type f -print0) |
335 |
|
336 |
einfo "Adjusting make.globals ..." |
337 |
sed -e "s|\(/usr/portage\)|${EPREFIX}\\1|" \ |
338 |
-e "s|^\(PORTAGE_TMPDIR=\"\)\(/var/tmp\"\)|\\1${EPREFIX}\\2|" \ |
339 |
-i cnf/make.globals || die "sed failed" |
340 |
|
341 |
einfo "Adjusting repos.conf ..." |
342 |
sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \ |
343 |
-e "s|^\\[gentoo\\]|[gentoo_prefix]|" \ |
344 |
-e "s|^\(location = \)\(/usr/portage\)|\\1${EPREFIX}\\2|" \ |
345 |
-e "s|^\(sync-uri = \).*|\\1rsync://prefix.gentooexperimental.org/gentoo-portage-prefix|" \ |
346 |
-i cnf/repos.conf || die "sed failed" |
347 |
|
348 |
einfo "Adding FEATURES=force-prefix to make.globals ..." |
349 |
echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \ |
350 |
|| die "failed to append to make.globals" |
351 |
fi |
352 |
|
353 |
cd "${S}/cnf" || die |
354 |
if [ -f "make.conf.example.${ARCH}".diff ]; then |
355 |
patch make.conf.example "make.conf.example.${ARCH}".diff || \ |
356 |
die "Failed to patch make.conf.example" |
357 |
else |
358 |
eerror "" |
359 |
eerror "Portage does not have an arch-specific configuration for this arch." |
360 |
eerror "Please notify the arch maintainer about this issue. Using generic." |
361 |
eerror "" |
362 |
fi |
363 |
} |
364 |
|
365 |
src_compile() { |
366 |
if use doc; then |
367 |
call_with_python_impl \ |
368 |
emake docbook || die |
369 |
fi |
370 |
|
371 |
if use epydoc; then |
372 |
einfo "Generating api docs" |
373 |
call_with_python_impl \ |
374 |
emake epydoc || die |
375 |
fi |
376 |
} |
377 |
|
378 |
src_test() { |
379 |
# make files executable, in case they were created by patch |
380 |
find bin -type f | xargs chmod +x |
381 |
call_with_python_impl \ |
382 |
emake test || die |
383 |
} |
384 |
|
385 |
src_install() { |
386 |
call_with_python_impl \ |
387 |
emake DESTDIR="${D}" \ |
388 |
sysconfdir="${EPREFIX}/etc" \ |
389 |
prefix="${EPREFIX}/usr" \ |
390 |
install || die |
391 |
|
392 |
# Use dodoc for compression, since the Makefile doesn't do that. |
393 |
dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES} || die |
394 |
|
395 |
# Allow external portage API consumers to import portage python modules |
396 |
# (this used to be done with PYTHONPATH setting in /etc/env.d). |
397 |
# For each of PYTHON_TARGETS, install a tree of *.py symlinks in |
398 |
# site-packages, and compile with the corresponding interpreter. |
399 |
local impl files mod_dir dest_mod_dir python relative_path x |
400 |
for impl in "${PYTHON_COMPAT[@]}" ; do |
401 |
use "python_targets_${impl}" || continue |
402 |
if use build && [[ ${ROOT} == / && |
403 |
! -x ${EPREFIX}/usr/bin/$(get_python_interpreter ${impl}) ]] ; then |
404 |
# Tolerate --nodeps at beginning of stage1 for catalyst |
405 |
ewarn "skipping python_targets_${impl}, interpreter not found" |
406 |
continue |
407 |
fi |
408 |
while read -r mod_dir ; do |
409 |
cd "${ED:-${D}}usr/lib/portage/pym/${mod_dir}" || die |
410 |
files=$(echo *.py) |
411 |
if [ -z "${files}" ] || [ "${files}" = "*.py" ]; then |
412 |
# __pycache__ directories contain no py files |
413 |
continue |
414 |
fi |
415 |
dest_mod_dir=$(get_python_sitedir ${impl})/${mod_dir} |
416 |
dodir "${dest_mod_dir}" || die |
417 |
relative_path=../../../lib/portage/pym/${mod_dir} |
418 |
x=/${mod_dir} |
419 |
while [ -n "${x}" ] ; do |
420 |
relative_path=../${relative_path} |
421 |
x=${x%/*} |
422 |
done |
423 |
for x in ${files} ; do |
424 |
dosym "${relative_path}/${x}" \ |
425 |
"${dest_mod_dir}/${x}" || die |
426 |
done |
427 |
done < <(cd "${ED:-${D}}"usr/lib/portage/pym || die ; find * -type d ! -path "portage/tests*") |
428 |
cd "${S}" || die |
429 |
EPYTHON=$(get_python_interpreter ${impl}) \ |
430 |
python_compileall "$(get_python_sitedir ${impl})" |
431 |
done |
432 |
|
433 |
# Compile /usr/lib/portage/pym with the active interpreter, since portage |
434 |
# internal commands force this directory to the beginning of sys.path. |
435 |
python_compileall /usr/lib/portage/pym |
436 |
} |
437 |
|
438 |
pkg_preinst() { |
439 |
if [[ $ROOT == / ]] ; then |
440 |
# Run some minimal tests as a sanity check. |
441 |
local test_runner=$(find "${ED:-${D}}" -name runTests) |
442 |
if [[ -n $test_runner && -x $test_runner ]] ; then |
443 |
einfo "Running preinst sanity tests..." |
444 |
"$test_runner" || die "preinst sanity tests failed" |
445 |
fi |
446 |
fi |
447 |
|
448 |
if use xattr && ! current_python_has_xattr ; then |
449 |
ewarn "For optimal performance in xattr handling, install" |
450 |
ewarn "dev-python/pyxattr, or install >=dev-lang/python-3.3 and" |
451 |
ewarn "enable USE=python3 for $CATEGORY/$PN." |
452 |
fi |
453 |
|
454 |
# elog dir must exist to avoid logrotate error for bug #415911. |
455 |
# This code runs in preinst in order to bypass the mapping of |
456 |
# portage:portage to root:root which happens after src_install. |
457 |
keepdir /var/log/portage/elog |
458 |
# This is allowed to fail if the user/group are invalid for prefix users. |
459 |
if chown portage:portage "${ED:-${D}}"var/log/portage{,/elog} 2>/dev/null ; then |
460 |
chmod g+s,ug+rwx "${ED:-${D}}"var/log/portage{,/elog} |
461 |
fi |
462 |
|
463 |
# If portage-2.1.6 is installed and the preserved_libs_registry exists, |
464 |
# assume that the NEEDED.ELF.2 files have already been generated. |
465 |
has_version "<=${CATEGORY}/${PN}-2.2_pre7" && \ |
466 |
! { [ -e "${EROOT:-${ROOT}}"var/lib/portage/preserved_libs_registry ] && \ |
467 |
has_version ">=${CATEGORY}/${PN}-2.1.6_rc" ; } \ |
468 |
&& NEEDED_REBUILD_UPGRADE=true || NEEDED_REBUILD_UPGRADE=false |
469 |
|
470 |
if has_version "<${CATEGORY}/${PN}-2.1.13" || \ |
471 |
{ |
472 |
has_version ">=${CATEGORY}/${PN}-2.2_rc0" && \ |
473 |
has_version "<${CATEGORY}/${PN}-2.2.0_alpha189" |
474 |
} ; then |
475 |
USERPRIV_UPGRADE=true |
476 |
USERSYNC_UPGRADE=true |
477 |
REPOS_CONF_UPGRADE=true |
478 |
REPOS_CONF_SYNC= |
479 |
type -P portageq >/dev/null 2>&1 && \ |
480 |
REPOS_CONF_SYNC=$("$(type -P portageq)" envvar SYNC) |
481 |
else |
482 |
USERPRIV_UPGRADE=false |
483 |
USERSYNC_UPGRADE=false |
484 |
REPOS_CONF_UPGRADE=false |
485 |
fi |
486 |
} |
487 |
|
488 |
get_ownership() { |
489 |
case ${USERLAND} in |
490 |
BSD) |
491 |
stat -f '%Su:%Sg' "${1}" |
492 |
;; |
493 |
*) |
494 |
stat -c '%U:%G' "${1}" |
495 |
;; |
496 |
esac |
497 |
} |
498 |
|
499 |
new_config_protect() { |
500 |
# Generate a ._cfg file even if the target file |
501 |
# does not exist, ensuring that the user will |
502 |
# notice the config change. |
503 |
local basename=${1##*/} |
504 |
local dirname=${1%/*} |
505 |
local i=0 |
506 |
while true ; do |
507 |
local filename=$( |
508 |
echo -n "${dirname}/._cfg" |
509 |
printf "%04d" ${i} |
510 |
echo -n "_${basename}" |
511 |
) |
512 |
[[ -e ${filename} ]] || break |
513 |
(( i++ )) |
514 |
done |
515 |
echo "${filename}" |
516 |
} |
517 |
|
518 |
pkg_postinst() { |
519 |
|
520 |
if ${REPOS_CONF_UPGRADE} ; then |
521 |
einfo "Generating repos.conf" |
522 |
local repo_name= |
523 |
[[ -f ${PORTDIR}/profiles/repo_name ]] && \ |
524 |
repo_name=$(< "${PORTDIR}/profiles/repo_name") |
525 |
if [[ -z ${REPOS_CONF_SYNC} ]] ; then |
526 |
REPOS_CONF_SYNC=$(grep "^sync-uri =" "${EROOT:-${ROOT}}usr/share/portage/config/repos.conf") |
527 |
REPOS_CONF_SYNC=${REPOS_CONF_SYNC##* } |
528 |
fi |
529 |
local sync_type= |
530 |
[[ ${REPOS_CONF_SYNC} == git://* ]] && sync_type=git |
531 |
|
532 |
if [[ ${REPOS_CONF_SYNC} == cvs://* ]]; then |
533 |
sync_type=cvs |
534 |
REPOS_CONF_SYNC=${REPOS_CONF_SYNC#cvs://} |
535 |
fi |
536 |
|
537 |
cat <<-EOF > "${T}/repos.conf" |
538 |
[DEFAULT] |
539 |
main-repo = ${repo_name:-gentoo} |
540 |
|
541 |
[${repo_name:-gentoo}] |
542 |
location = ${PORTDIR:-${EPREFIX}/usr/portage} |
543 |
sync-type = ${sync_type:-rsync} |
544 |
sync-uri = ${REPOS_CONF_SYNC} |
545 |
EOF |
546 |
|
547 |
[[ ${sync_type} == cvs ]] && echo "sync-cvs-repo = $(<"${PORTDIR}/CVS/Repository")" >> "${T}/repos.conf" |
548 |
|
549 |
local dest=${EROOT:-${ROOT}}etc/portage/repos.conf |
550 |
if [[ ! -f ${dest} ]] && mkdir -p "${dest}" 2>/dev/null ; then |
551 |
dest=${EROOT:-${ROOT}}etc/portage/repos.conf/${repo_name:-gentoo}.conf |
552 |
fi |
553 |
# Don't install the config update if the desired repos.conf directory |
554 |
# and config file exist, since users may accept it blindly and break |
555 |
# their config (bug #478726). |
556 |
[[ -e ${EROOT:-${ROOT}}etc/portage/repos.conf/${repo_name:-gentoo}.conf ]] || \ |
557 |
mv "${T}/repos.conf" "$(new_config_protect "${dest}")" |
558 |
|
559 |
if [[ ${PORTDIR} == ${EPREFIX}/usr/portage ]] ; then |
560 |
einfo "Generating make.conf PORTDIR setting for backward compatibility" |
561 |
for dest in "${EROOT:-${ROOT}}etc/make.conf" "${EROOT:-${ROOT}}etc/portage/make.conf" ; do |
562 |
[[ -e ${dest} ]] && break |
563 |
done |
564 |
[[ -d ${dest} ]] && dest=${dest}/portdir.conf |
565 |
rm -rf "${T}/make.conf" |
566 |
[[ -f ${dest} ]] && cat "${dest}" > "${T}/make.conf" |
567 |
cat <<-EOF >> "${T}/make.conf" |
568 |
|
569 |
# Set PORTDIR for backward compatibility with various tools: |
570 |
# gentoo-bashcomp - bug #478444 |
571 |
# euse - bug #474574 |
572 |
# euses and ufed - bug #478318 |
573 |
PORTDIR="${EPREFIX}/usr/portage" |
574 |
EOF |
575 |
mkdir -p "${dest%/*}" |
576 |
mv "${T}/make.conf" "$(new_config_protect "${dest}")" |
577 |
fi |
578 |
fi |
579 |
|
580 |
if ${NEEDED_REBUILD_UPGRADE} ; then |
581 |
einfo "rebuilding NEEDED.ELF.2 files" |
582 |
local cpv filename line newline |
583 |
for cpv in "${EROOT:-${ROOT}}var/db/pkg"/*/*; do |
584 |
[[ -f "${cpv}/NEEDED" && ! -f "${cpv}/NEEDED.ELF.2" ]] || continue |
585 |
while read -r line; do |
586 |
filename=${line% *} |
587 |
newline=$(scanelf -BF "%a;%F;%S;%r;%n" "${ROOT%/}${filename}") |
588 |
newline=${newline// - } |
589 |
[[ ${#ROOT} -gt 1 ]] && newline=${newline/${ROOT%/}} |
590 |
echo "${newline:3}" >> "${cpv}/NEEDED.ELF.2" |
591 |
done < "${cpv}/NEEDED" |
592 |
done |
593 |
fi |
594 |
|
595 |
local distdir=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}} |
596 |
|
597 |
if ${USERSYNC_UPGRADE} && \ |
598 |
[[ -d ${PORTDIR} && -w ${PORTDIR} ]] ; then |
599 |
local ownership=$(get_ownership "${PORTDIR}") |
600 |
if [[ -n ${ownership} ]] ; then |
601 |
einfo "Adjusting PORTDIR permissions for usersync" |
602 |
find "${PORTDIR}" -path "${distdir%/}" -prune -o \ |
603 |
! \( -user "${ownership%:*}" -a -group "${ownership#*:}" \) \ |
604 |
-exec chown "${ownership}" {} + |
605 |
fi |
606 |
fi |
607 |
|
608 |
# Do this last, since it could take a long time if there |
609 |
# are lots of live sources, and the user may be tempted |
610 |
# to kill emerge while it is running. |
611 |
if ${USERPRIV_UPGRADE} && \ |
612 |
[[ -d ${distdir} && -w ${distdir} ]] ; then |
613 |
local ownership=$(get_ownership "${distdir}") |
614 |
if [[ ${ownership#*:} == portage ]] ; then |
615 |
einfo "Adjusting DISTDIR permissions for userpriv" |
616 |
find "${distdir}" -mindepth 1 -maxdepth 1 -type d -uid 0 \ |
617 |
-exec chown -R portage:portage {} + |
618 |
fi |
619 |
fi |
620 |
} |