Gentoo Archives: gentoo-commits

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