Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-apps/portage: portage-2.2.0_alpha191.ebuild ChangeLog
Date: Tue, 30 Jul 2013 07:03:37
Message-Id: 20130730070332.136CF2171C@flycatcher.gentoo.org
1 zmedico 13/07/30 07:03:31
2
3 Modified: ChangeLog
4 Added: portage-2.2.0_alpha191.ebuild
5 Log:
6 2.2.0_alpha191 version bump. This includes all of the fixes in 2.1.13.2.
7 Bug #210077 tracks all bugs fixed since portage-2.1.x.
8
9 (Portage version: 2.2.0_alpha191/cvs/Linux i686, signed Manifest commit with key 0xFDE8EF85AE5719A3)
10
11 Revision Changes Path
12 1.1326 sys-apps/portage/ChangeLog
13
14 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?rev=1.1326&view=markup
15 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?rev=1.1326&content-type=text/plain
16 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?r1=1.1325&r2=1.1326
17
18 Index: ChangeLog
19 ===================================================================
20 RCS file: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v
21 retrieving revision 1.1325
22 retrieving revision 1.1326
23 diff -u -r1.1325 -r1.1326
24 --- ChangeLog 30 Jul 2013 07:01:10 -0000 1.1325
25 +++ ChangeLog 30 Jul 2013 07:03:31 -0000 1.1326
26 @@ -1,6 +1,12 @@
27 # ChangeLog for sys-apps/portage
28 # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
29 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v 1.1325 2013/07/30 07:01:10 zmedico Exp $
30 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v 1.1326 2013/07/30 07:03:31 zmedico Exp $
31 +
32 +*portage-2.2.0_alpha191 (30 Jul 2013)
33 +
34 + 30 Jul 2013; Zac Medico <zmedico@g.o> +portage-2.2.0_alpha191.ebuild:
35 + 2.2.0_alpha191 version bump. This includes all of the fixes in 2.1.13.2. Bug
36 + #210077 tracks all bugs fixed since portage-2.1.x.
37
38 30 Jul 2013; Zac Medico <zmedico@g.o> portage-2.1.13.2.ebuild:
39 Tweak repos.conf logic for bug #478726.
40
41
42
43 1.1 sys-apps/portage/portage-2.2.0_alpha191.ebuild
44
45 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.2.0_alpha191.ebuild?rev=1.1&view=markup
46 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.2.0_alpha191.ebuild?rev=1.1&content-type=text/plain
47
48 Index: portage-2.2.0_alpha191.ebuild
49 ===================================================================
50 # Copyright 1999-2013 Gentoo Foundation
51 # Distributed under the terms of the GNU General Public License v2
52 # $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-2.2.0_alpha191.ebuild,v 1.1 2013/07/30 07:03:31 zmedico Exp $
53
54 # Require EAPI 2 since we now require at least python-2.6 (for python 3
55 # syntax support) which also requires EAPI 2.
56 EAPI=3
57 PYTHON_COMPAT=(
58 pypy1_9 pypy2_0
59 python3_1 python3_2 python3_3 python3_4
60 python2_6 python2_7
61 )
62 inherit eutils multilib
63
64 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
65 HOMEPAGE="http://www.gentoo.org/proj/en/portage/index.xml"
66 LICENSE="GPL-2"
67 KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
68 SLOT="0"
69 IUSE="build doc epydoc +ipc linguas_ru pypy2_0 python2 python3 selinux xattr"
70
71 for _pyimpl in ${PYTHON_COMPAT[@]} ; do
72 IUSE+=" python_targets_${_pyimpl}"
73 done
74 unset _pyimpl
75
76 # Import of the io module in python-2.6 raises ImportError for the
77 # thread module if threading is disabled.
78 python_dep_ssl="python3? ( =dev-lang/python-3*[ssl] )
79 !pypy2_0? ( !python2? ( !python3? (
80 || ( >=dev-lang/python-2.7[ssl] dev-lang/python:2.6[threads,ssl] )
81 ) ) )
82 pypy2_0? ( !python2? ( !python3? ( virtual/pypy:2.0[bzip2] ) ) )
83 python2? ( !python3? ( || ( dev-lang/python:2.7[ssl] dev-lang/python:2.6[ssl,threads] ) ) )"
84 python_dep="${python_dep_ssl//\[ssl\]}"
85 python_dep="${python_dep//,ssl}"
86 python_dep="${python_dep//ssl,}"
87
88 python_dep="${python_dep}
89 python_targets_pypy1_9? ( virtual/pypy:1.9 )
90 python_targets_pypy2_0? ( virtual/pypy:2.0 )
91 python_targets_python2_6? ( dev-lang/python:2.6 )
92 python_targets_python2_7? ( dev-lang/python:2.7 )
93 python_targets_python3_1? ( dev-lang/python:3.1 )
94 python_targets_python3_2? ( dev-lang/python:3.2 )
95 python_targets_python3_3? ( dev-lang/python:3.3 )
96 python_targets_python3_4? ( dev-lang/python:3.4 )
97 "
98
99 # The pysqlite blocker is for bug #282760.
100 # make-3.82 is for bug #455858
101 DEPEND="${python_dep}
102 >=sys-devel/make-3.82
103 >=sys-apps/sed-4.0.5 sys-devel/patch
104 doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
105 epydoc? ( >=dev-python/epydoc-2.0 !<=dev-python/pysqlite-2.4.1 )"
106 # Require sandbox-2.2 for bug #288863.
107 # For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
108 # quite slow, so it's not considered in the dependencies as an alternative to
109 # to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
110 # for now, don't pull in xattr deps for other kernels.
111 # For whirlpool hash, require python[ssl] or python-mhash (bug #425046).
112 # For compgen, require bash[readline] (bug #445576).
113 RDEPEND="${python_dep}
114 !build? ( >=sys-apps/sed-4.0.5
115 || ( >=app-shells/bash-4.2_p37[readline] ( <app-shells/bash-4.2_p37 >=app-shells/bash-3.2_p17 ) )
116 >=app-admin/eselect-1.2
117 || ( ${python_dep_ssl} dev-python/python-mhash )
118 )
119 elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
120 elibc_glibc? ( >=sys-apps/sandbox-2.2 )
121 elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
122 >=app-misc/pax-utils-0.1.17
123 xattr? ( kernel_linux? ( || ( >=dev-lang/python-3.3_pre20110902 dev-python/pyxattr ) ) )
124 selinux? ( || ( >=sys-libs/libselinux-2.0.94[python] <sys-libs/libselinux-2.0.94 ) )
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/~zmedico/portage/archives"
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=2.2.0_alpha190
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}${site_dir} ]] || \
200 ewarn "site-packages dir missing for ${impl}: ${EROOT}${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://rsync.prefix.freens.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}/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}"/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" -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}"var/log/portage{,/elog} 2>/dev/null ; then
463 chmod g+s,ug+rwx "${ED}"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}"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 portageq >/dev/null 2>&1 && \
483 REPOS_CONF_SYNC=$(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}/usr/share/portage/config/repos.conf")
530 REPOS_CONF_SYNC=${REPOS_CONF_SYNC##* }
531 fi
532 cat <<-EOF > "${T}/repos.conf"
533 [DEFAULT]
534 main-repo = ${repo_name:-gentoo}
535
536 [${repo_name:-gentoo}]
537 location = ${PORTDIR:-${EPREFIX}/usr/portage}
538 sync-type = rsync
539 sync-uri = ${REPOS_CONF_SYNC}
540 EOF
541 local dest=${EROOT}/etc/portage/repos.conf
542 if [[ ! -f ${dest} ]] && mkdir -p "${dest}" 2>/dev/null ; then
543 dest=${EROOT}/etc/portage/repos.conf/${repo_name:-gentoo}.conf
544 fi
545 # Don't install the config update if the desired repos.conf directory
546 # and config file exist, since users may accept it blindly and break
547 # their config (bug #478726).
548 [[ -e ${EROOT}/etc/portage/repos.conf/${repo_name:-gentoo}.conf ]] || \
549 mv "${T}/repos.conf" "$(new_config_protect "${dest}")"
550 fi
551
552 if ${NEEDED_REBUILD_UPGRADE} ; then
553 einfo "rebuilding NEEDED.ELF.2 files"
554 local cpv filename line newline
555 for cpv in "${EROOT}/var/db/pkg"/*/*; do
556 [[ -f "${cpv}/NEEDED" && ! -f "${cpv}/NEEDED.ELF.2" ]] || continue
557 while read -r line; do
558 filename=${line% *}
559 newline=$(scanelf -BF "%a;%F;%S;%r;%n" "${ROOT%/}${filename}")
560 newline=${newline// - }
561 [[ ${#ROOT} -gt 1 ]] && newline=${newline/${ROOT%/}}
562 echo "${newline:3}" >> "${cpv}/NEEDED.ELF.2"
563 done < "${cpv}/NEEDED"
564 done
565 fi
566
567 local distdir=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}
568
569 if ${USERSYNC_UPGRADE} && \
570 [[ -d ${PORTDIR} && -w ${PORTDIR} ]] ; then
571 local ownership=$(get_ownership "${PORTDIR}")
572 if [[ -n ${ownership} ]] ; then
573 einfo "Adjusting PORTDIR permissions for usersync"
574 find "${PORTDIR}" -path "${distdir%/}" -prune -o \
575 ! \( -user "${ownership%:*}" -a -group "${ownership#*:}" \) \
576 -exec chown "${ownership}" {} +
577 fi
578 fi
579
580 # Do this last, since it could take a long time if there
581 # are lots of live sources, and the user may be tempted
582 # to kill emerge while it is running.
583 if ${USERPRIV_UPGRADE} && \
584 [[ -d ${distdir} && -w ${distdir} ]] ; then
585 local ownership=$(get_ownership "${distdir}")
586 if [[ ${ownership#*:} == portage ]] ; then
587 einfo "Adjusting DISTDIR permissions for userpriv"
588 find "${distdir}" -maxdepth 1 -type d -uid 0 \
589 -exec chown -R portage:portage {} +
590 fi
591 fi
592 }