Gentoo Archives: gentoo-commits

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