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