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