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-9999.ebuild portage-2.2.0_alpha123-r2.ebuild portage-2.1.11.12-r2.ebuild ChangeLog portage-2.1.11.12-r1.ebuild portage-2.2.0_alpha123-r1.ebuild
Date: Sun, 02 Sep 2012 17:32:09
Message-Id: 20120902173159.49DDB21009@flycatcher.gentoo.org
1 zmedico 12/09/02 17:31:58
2
3 Modified: portage-9999.ebuild ChangeLog
4 Added: portage-2.2.0_alpha123-r2.ebuild
5 portage-2.1.11.12-r2.ebuild
6 Removed: portage-2.1.11.12-r1.ebuild
7 portage-2.2.0_alpha123-r1.ebuild
8 Log:
9 Add /usr/lib/portage/pym to PYTHONPATH via /etc/env.d/05portage, for portage API consumers. This way we don't have to rely on patched python having the correct path, since it has been known to incorrectly add /usr/libx32/portage/pym to sys.path. Also, remove obsolete ebuild-helpers/sed code from portage-9999.ebuild.
10
11 (Portage version: 2.2.0_alpha123_p29/cvs/Linux i686)
12
13 Revision Changes Path
14 1.57 sys-apps/portage/portage-9999.ebuild
15
16 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-9999.ebuild?rev=1.57&view=markup
17 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-9999.ebuild?rev=1.57&content-type=text/plain
18 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-9999.ebuild?r1=1.56&r2=1.57
19
20 Index: portage-9999.ebuild
21 ===================================================================
22 RCS file: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-9999.ebuild,v
23 retrieving revision 1.56
24 retrieving revision 1.57
25 diff -u -r1.56 -r1.57
26 --- portage-9999.ebuild 1 Sep 2012 20:15:23 -0000 1.56
27 +++ portage-9999.ebuild 2 Sep 2012 17:31:58 -0000 1.57
28 @@ -1,6 +1,6 @@
29 # Copyright 1999-2012 Gentoo Foundation
30 # Distributed under the terms of the GNU General Public License v2
31 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-9999.ebuild,v 1.56 2012/09/01 20:15:23 zmedico Exp $
32 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-9999.ebuild,v 1.57 2012/09/02 17:31:58 zmedico Exp $
33
34 EAPI=3
35 inherit git-2 eutils python
36 @@ -208,12 +208,6 @@
37 eerror "Please notify the arch maintainer about this issue. Using generic."
38 eerror ""
39 fi
40 -
41 - # BSD and OSX need a sed wrapper so that find/xargs work properly
42 - if use userland_GNU; then
43 - rm -f "${S}"/bin/ebuild-helpers/sed || \
44 - die "Failed to remove sed wrapper"
45 - fi
46 }
47
48 src_compile() {
49 @@ -239,6 +233,13 @@
50
51 # Use dodoc for compression, since the Makefile doesn't do that.
52 dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES} || die
53 +
54 + # Set PYTHONPATH for portage API consumers. This way we don't have
55 + # to rely on patched python having the correct path, since it has
56 + # been known to incorrectly add /usr/libx32/portage/pym to sys.path.
57 + echo "PYTHONPATH=${EPREFIX}/usr/lib/portage/pym" > \
58 + "${T}/05portage" || die
59 + doenvd "${T}/05portage"
60 }
61
62 pkg_preinst() {
63
64
65
66 1.1084 sys-apps/portage/ChangeLog
67
68 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?rev=1.1084&view=markup
69 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?rev=1.1084&content-type=text/plain
70 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/ChangeLog?r1=1.1083&r2=1.1084
71
72 Index: ChangeLog
73 ===================================================================
74 RCS file: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v
75 retrieving revision 1.1083
76 retrieving revision 1.1084
77 diff -u -r1.1083 -r1.1084
78 --- ChangeLog 1 Sep 2012 21:10:02 -0000 1.1083
79 +++ ChangeLog 2 Sep 2012 17:31:58 -0000 1.1084
80 @@ -1,6 +1,18 @@
81 # ChangeLog for sys-apps/portage
82 # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
83 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v 1.1083 2012/09/01 21:10:02 zmedico Exp $
84 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/ChangeLog,v 1.1084 2012/09/02 17:31:58 zmedico Exp $
85 +
86 +*portage-2.1.11.12-r2 (02 Sep 2012)
87 +*portage-2.2.0_alpha123-r2 (02 Sep 2012)
88 +
89 + 02 Sep 2012; Zac Medico <zmedico@g.o> +portage-2.1.11.12-r2.ebuild,
90 + +portage-2.2.0_alpha123-r2.ebuild, -portage-2.1.11.12-r1.ebuild,
91 + -portage-2.2.0_alpha123-r1.ebuild, portage-9999.ebuild:
92 + Add /usr/lib/portage/pym to PYTHONPATH via /etc/env.d/05portage, for portage
93 + API consumers. This way we don't have to rely on patched python having the
94 + correct path, since it has been known to incorrectly add
95 + /usr/libx32/portage/pym to sys.path. Also, remove obsolete ebuild-helpers/sed
96 + code from portage-9999.ebuild.
97
98 *portage-2.1.11.12-r1 (01 Sep 2012)
99 *portage-2.2.0_alpha123-r1 (01 Sep 2012)
100
101
102
103 1.1 sys-apps/portage/portage-2.2.0_alpha123-r2.ebuild
104
105 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.2.0_alpha123-r2.ebuild?rev=1.1&view=markup
106 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.2.0_alpha123-r2.ebuild?rev=1.1&content-type=text/plain
107
108 Index: portage-2.2.0_alpha123-r2.ebuild
109 ===================================================================
110 # Copyright 1999-2012 Gentoo Foundation
111 # Distributed under the terms of the GNU General Public License v2
112 # $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-2.2.0_alpha123-r2.ebuild,v 1.1 2012/09/02 17:31:58 zmedico Exp $
113
114 # Require EAPI 2 since we now require at least python-2.6 (for python 3
115 # syntax support) which also requires EAPI 2.
116 EAPI=3
117 inherit eutils python
118
119 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
120 HOMEPAGE="http://www.gentoo.org/proj/en/portage/index.xml"
121 LICENSE="GPL-2"
122 KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
123 SLOT="0"
124 IUSE="build doc epydoc +ipc linguas_pl pypy1_9 python2 python3 selinux xattr"
125
126 # Import of the io module in python-2.6 raises ImportError for the
127 # thread module if threading is disabled.
128 python_dep_ssl="python3? ( =dev-lang/python-3*[ssl] )
129 !pypy1_9? ( !python2? ( !python3? (
130 || ( >=dev-lang/python-2.7[ssl] dev-lang/python:2.6[threads,ssl] )
131 ) ) )
132 pypy1_9? ( !python2? ( !python3? ( dev-python/pypy:1.9[bzip2,ssl] ) ) )
133 python2? ( !python3? ( || ( dev-lang/python:2.7[ssl] dev-lang/python:2.6[ssl,threads] ) ) )"
134 python_dep="${python_dep_ssl//\[ssl\]}"
135 python_dep="${python_dep//,ssl}"
136 python_dep="${python_dep//ssl,}"
137
138 # The pysqlite blocker is for bug #282760.
139 DEPEND="${python_dep}
140 >=sys-apps/sed-4.0.5 sys-devel/patch
141 doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
142 epydoc? ( >=dev-python/epydoc-2.0 !<=dev-python/pysqlite-2.4.1 )"
143 # Require sandbox-2.2 for bug #288863.
144 # For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
145 # quite slow, so it's not considered in the dependencies as an alternative to
146 # to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
147 # for now, don't pull in xattr deps for other kernels.
148 # For whirlpool hash, require python[ssl] or python-mhash (bug #425046).
149 RDEPEND="${python_dep}
150 !build? ( >=sys-apps/sed-4.0.5
151 >=app-shells/bash-3.2_p17
152 >=app-admin/eselect-1.2
153 || ( ${python_dep_ssl} dev-python/python-mhash )
154 )
155 elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
156 elibc_glibc? ( >=sys-apps/sandbox-2.2 )
157 elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
158 >=app-misc/pax-utils-0.1.17
159 xattr? ( kernel_linux? ( || ( >=dev-lang/python-3.3_pre20110902 dev-python/pyxattr ) ) )
160 selinux? ( || ( >=sys-libs/libselinux-2.0.94[python] <sys-libs/libselinux-2.0.94 ) )
161 !<app-shells/bash-3.2_p17
162 !<app-admin/logrotate-3.8.0"
163 PDEPEND="
164 !build? (
165 >=net-misc/rsync-2.6.4
166 userland_GNU? ( >=sys-apps/coreutils-6.4 )
167 )"
168 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
169 # NOTE: FEATURES=install-sources requires debugedit and rsync
170
171 SRC_ARCHIVES="http://dev.gentoo.org/~zmedico/portage/archives"
172
173 prefix_src_archives() {
174 local x y
175 for x in ${@}; do
176 for y in ${SRC_ARCHIVES}; do
177 echo ${y}/${x}
178 done
179 done
180 }
181
182 PV_PL="2.1.2"
183 PATCHVER_PL=""
184 TARBALL_PV=2.2.0_alpha123
185 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
186 $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)
187 linguas_pl? ( mirror://gentoo/${PN}-man-pl-${PV_PL}.tar.bz2
188 $(prefix_src_archives ${PN}-man-pl-${PV_PL}.tar.bz2) )"
189
190 PATCHVER=
191 [[ $TARBALL_PV = $PV ]] || PATCHVER=$PV
192 if [ -n "${PATCHVER}" ]; then
193 SRC_URI="${SRC_URI} mirror://gentoo/${PN}-${PATCHVER}.patch.bz2
194 $(prefix_src_archives ${PN}-${PATCHVER}.patch.bz2)"
195 fi
196
197 S="${WORKDIR}"/${PN}-${TARBALL_PV}
198 S_PL="${WORKDIR}"/${PN}-${PV_PL}
199
200 compatible_python_is_selected() {
201 [[ $("${EPREFIX}/usr/bin/python" -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x2060000 and "good" or "bad")') = good ]]
202 }
203
204 current_python_has_xattr() {
205 [[ $("${EPREFIX}/usr/bin/python" -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x3030000 and "yes" or "no")') = yes ]] || \
206 "${EPREFIX}/usr/bin/python" -c 'import xattr' 2>/dev/null
207 }
208
209 pkg_setup() {
210 if use python2 && use python3 ; then
211 ewarn "Both python2 and python3 USE flags are enabled, but only one"
212 ewarn "can be in the shebangs. Using python3."
213 fi
214 if use pypy1_9 && use python3 ; then
215 ewarn "Both pypy1_9 and python3 USE flags are enabled, but only one"
216 ewarn "can be in the shebangs. Using python3."
217 fi
218 if use pypy1_9 && use python2 ; then
219 ewarn "Both pypy1_9 and python2 USE flags are enabled, but only one"
220 ewarn "can be in the shebangs. Using python2"
221 fi
222 if ! use pypy1_9 && ! use python2 && ! use python3 && \
223 ! compatible_python_is_selected ; then
224 ewarn "Attempting to select a compatible default python interpreter"
225 local x success=0
226 for x in /usr/bin/python2.* ; do
227 x=${x#/usr/bin/python2.}
228 if [[ $x -ge 6 ]] 2>/dev/null ; then
229 eselect python set python2.$x
230 if compatible_python_is_selected ; then
231 elog "Default python interpreter is now set to python-2.$x"
232 success=1
233 break
234 fi
235 fi
236 done
237 if [ $success != 1 ] ; then
238 eerror "Unable to select a compatible default python interpreter!"
239 die "This version of portage requires at least python-2.6 to be selected as the default python interpreter (see \`eselect python --help\`)."
240 fi
241 fi
242
243 if use python3; then
244 python_set_active_version 3
245 elif use python2; then
246 python_set_active_version 2
247 elif use pypy1_9; then
248 python_set_active_version 2.7-pypy-1.9
249 fi
250 }
251
252 src_prepare() {
253 if [ -n "${PATCHVER}" ] ; then
254 if [[ -L $S/bin/ebuild-helpers/portageq ]] ; then
255 rm "$S/bin/ebuild-helpers/portageq" \
256 || die "failed to remove portageq helper symlink"
257 fi
258 epatch "${WORKDIR}/${PN}-${PATCHVER}.patch"
259 fi
260 einfo "Setting portage.VERSION to ${PVR} ..."
261 sed -e "s/^VERSION=.*/VERSION=\"${PVR}\"/" -i pym/portage/__init__.py || \
262 die "Failed to patch portage.VERSION"
263 sed -e "1s/VERSION/${PVR}/" -i doc/fragment/version || \
264 die "Failed to patch VERSION in doc/fragment/version"
265 sed -e "1s/VERSION/${PVR}/" -i man/* || \
266 die "Failed to patch VERSION in man page headers"
267
268 if ! use ipc ; then
269 einfo "Disabling ipc..."
270 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
271 -i pym/_emerge/AbstractEbuildProcess.py || \
272 die "failed to patch AbstractEbuildProcess.py"
273 fi
274
275 if use xattr && use kernel_linux ; then
276 einfo "Adding FEATURES=xattr to make.globals ..."
277 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
278 || die "failed to append to make.globals"
279 fi
280
281 if use python3; then
282 einfo "Converting shebangs for python3..."
283 python_convert_shebangs -r 3 .
284 elif use python2; then
285 einfo "Converting shebangs for python2..."
286 python_convert_shebangs -r 2 .
287 elif use pypy1_9; then
288 einfo "Converting shebangs for pypy-c1.9..."
289 python_convert_shebangs -r 2.7-pypy-1.9 .
290 fi
291
292 if [[ -n ${EPREFIX} ]] ; then
293 einfo "Setting portage.const.EPREFIX ..."
294 sed -e "s|^\(SANDBOX_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/bin/sandbox\"\)|\\1${EPREFIX}\\2|" \
295 -e "s|^\(FAKEROOT_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/bin/fakeroot\"\)|\\1${EPREFIX}\\2|" \
296 -e "s|^\(BASH_BINARY[[:space:]]*=[[:space:]]*\"\)\(/bin/bash\"\)|\\1${EPREFIX}\\2|" \
297 -e "s|^\(MOVE_BINARY[[:space:]]*=[[:space:]]*\"\)\(/bin/mv\"\)|\\1${EPREFIX}\\2|" \
298 -e "s|^\(PRELINK_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/sbin/prelink\"\)|\\1${EPREFIX}\\2|" \
299 -e "s|^\(EPREFIX[[:space:]]*=[[:space:]]*\"\).*|\\1${EPREFIX}\"|" \
300 -i pym/portage/const.py || \
301 die "Failed to patch portage.const.EPREFIX"
302
303 einfo "Prefixing shebangs ..."
304 find . -type f -print0 | \
305 while read -r -d $'\0' ; do
306 local shebang=$(head -n1 "$REPLY")
307 if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
308 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
309 die "sed failed"
310 fi
311 done
312
313 einfo "Adjusting make.globals ..."
314 sed -e 's|^SYNC=.*|SYNC="rsync://rsync.prefix.freens.org/gentoo-portage-prefix"|' \
315 -e "s|^\(PORTDIR=\)\(/usr/portage\)|\\1\"${EPREFIX}\\2\"|" \
316 -e "s|^\(PORTAGE_TMPDIR=\)\(/var/tmp\)|\\1\"${EPREFIX}\\2\"|" \
317 -i cnf/make.globals || die "sed failed"
318
319 einfo "Adding FEATURES=force-prefix to make.globals ..."
320 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
321 || die "failed to append to make.globals"
322 fi
323
324 cd "${S}/cnf" || die
325 if [ -f "make.conf.${ARCH}".diff ]; then
326 patch make.conf "make.conf.${ARCH}".diff || \
327 die "Failed to patch make.conf.example"
328 else
329 eerror ""
330 eerror "Portage does not have an arch-specific configuration for this arch."
331 eerror "Please notify the arch maintainer about this issue. Using generic."
332 eerror ""
333 fi
334
335 # BSD and OSX need a sed wrapper so that find/xargs work properly
336 if use userland_GNU; then
337 rm -f "${S}"/bin/ebuild-helpers/sed || \
338 die "Failed to remove sed wrapper"
339 fi
340 }
341
342 src_compile() {
343 if use doc; then
344 emake docbook || die
345 fi
346
347 if use epydoc; then
348 einfo "Generating api docs"
349 emake epydoc || die
350 fi
351 }
352
353 src_test() {
354 # make files executable, in case they were created by patch
355 find bin -type f | xargs chmod +x
356 emake test || die
357 }
358
359 src_install() {
360 emake DESTDIR="${D}" \
361 sysconfdir="${EPREFIX}/etc" \
362 prefix="${EPREFIX}/usr" \
363 install || die
364
365 # Use dodoc for compression, since the Makefile doesn't do that.
366 dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES} || die
367
368 if use linguas_pl; then
369 doman -i18n=pl "${S_PL}"/man/pl/*.[0-9] || die
370 doman -i18n=pl_PL.UTF-8 "${S_PL}"/man/pl_PL.UTF-8/*.[0-9] || die
371 fi
372
373 # Set PYTHONPATH for portage API consumers. This way we don't have
374 # to rely on patched python having the correct path, since it has
375 # been known to incorrectly add /usr/libx32/portage/pym to sys.path.
376 echo "PYTHONPATH=${EPREFIX}/usr/lib/portage/pym" > \
377 "${T}/05portage" || die
378 doenvd "${T}/05portage" || die
379 }
380
381 pkg_preinst() {
382 if [[ $ROOT == / ]] ; then
383 # Run some minimal tests as a sanity check.
384 local test_runner=$(find "$ED" -name runTests)
385 if [[ -n $test_runner && -x $test_runner ]] ; then
386 einfo "Running preinst sanity tests..."
387 "$test_runner" || die "preinst sanity tests failed"
388 fi
389 fi
390
391 if use xattr && ! current_python_has_xattr ; then
392 ewarn "For optimal performance in xattr handling, install"
393 ewarn "dev-python/pyxattr, or install >=dev-lang/python-3.3 and"
394 ewarn "enable USE=python3 for $CATEGORY/$PN."
395 fi
396
397 if ! use build && ! has_version dev-python/pycrypto && \
398 ! has_version '>=dev-lang/python-2.6[ssl]' ; then
399 ewarn "If you are an ebuild developer and you plan to commit ebuilds"
400 ewarn "with this system then please install dev-python/pycrypto or"
401 ewarn "enable the ssl USE flag for >=dev-lang/python-2.6 in order"
402 ewarn "to enable RMD160 hash support."
403 ewarn "See bug #198398 for more information."
404 fi
405
406 has_version "<=${CATEGORY}/${PN}-2.2_pre5" \
407 && WORLD_MIGRATION_UPGRADE=true || WORLD_MIGRATION_UPGRADE=false
408
409 # If portage-2.1.6 is installed and the preserved_libs_registry exists,
410 # assume that the NEEDED.ELF.2 files have already been generated.
411 has_version "<=${CATEGORY}/${PN}-2.2_pre7" && \
412 ! ( [ -e "${EROOT}"var/lib/portage/preserved_libs_registry ] && \
413 has_version ">=${CATEGORY}/${PN}-2.1.6_rc" ) \
414 && NEEDED_REBUILD_UPGRADE=true || NEEDED_REBUILD_UPGRADE=false
415 }
416
417 pkg_postinst() {
418 # Compile all source files recursively. Any orphans
419 # will be identified and removed in postrm.
420 python_mod_optimize /usr/lib/portage/pym
421
422 if $WORLD_MIGRATION_UPGRADE && \
423 grep -q "^@" "${EROOT}/var/lib/portage/world"; then
424 einfo "moving set references from the worldfile into world_sets"
425 cd "${EROOT}/var/lib/portage/"
426 grep "^@" world >> world_sets
427 sed -i -e '/^@/d' world
428 fi
429
430 if $NEEDED_REBUILD_UPGRADE ; then
431 einfo "rebuilding NEEDED.ELF.2 files"
432 for cpv in "${EROOT}/var/db/pkg"/*/*; do
433 if [ -f "${cpv}/NEEDED" ]; then
434 rm -f "${cpv}/NEEDED.ELF.2"
435 while read line; do
436 filename=${line% *}
437 needed=${line#* }
438 needed=${needed//+/++}
439 needed=${needed//#/##}
440 needed=${needed//%/%%}
441 newline=$(scanelf -BF "%a;%F;%S;%r;${needed}" $filename)
442 newline=${newline// - }
443 echo "${newline:3}" >> "${cpv}/NEEDED.ELF.2"
444 done < "${cpv}/NEEDED"
445 fi
446 done
447 fi
448 }
449
450 pkg_postrm() {
451 python_mod_cleanup /usr/lib/portage/pym
452 }
453
454
455
456 1.1 sys-apps/portage/portage-2.1.11.12-r2.ebuild
457
458 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.1.11.12-r2.ebuild?rev=1.1&view=markup
459 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/portage/portage-2.1.11.12-r2.ebuild?rev=1.1&content-type=text/plain
460
461 Index: portage-2.1.11.12-r2.ebuild
462 ===================================================================
463 # Copyright 1999-2012 Gentoo Foundation
464 # Distributed under the terms of the GNU General Public License v2
465 # $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-2.1.11.12-r2.ebuild,v 1.1 2012/09/02 17:31:58 zmedico Exp $
466
467 # Require EAPI 2 since we now require at least python-2.6 (for python 3
468 # syntax support) which also requires EAPI 2.
469 EAPI=2
470 inherit eutils python
471
472 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
473 HOMEPAGE="http://www.gentoo.org/proj/en/portage/index.xml"
474 LICENSE="GPL-2"
475 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
476 SLOT="0"
477 IUSE="build doc epydoc +ipc linguas_pl pypy1_9 python2 python3 selinux xattr"
478
479 # Import of the io module in python-2.6 raises ImportError for the
480 # thread module if threading is disabled.
481 python_dep_ssl="python3? ( =dev-lang/python-3*[ssl] )
482 !pypy1_9? ( !python2? ( !python3? (
483 || ( >=dev-lang/python-2.7[ssl] dev-lang/python:2.6[threads,ssl] )
484 ) ) )
485 pypy1_9? ( !python2? ( !python3? ( dev-python/pypy:1.9[bzip2,ssl] ) ) )
486 python2? ( !python3? ( || ( dev-lang/python:2.7[ssl] dev-lang/python:2.6[ssl,threads] ) ) )"
487 python_dep="${python_dep_ssl//\[ssl\]}"
488 python_dep="${python_dep//,ssl}"
489 python_dep="${python_dep//ssl,}"
490
491 # The pysqlite blocker is for bug #282760.
492 DEPEND="${python_dep}
493 >=sys-apps/sed-4.0.5 sys-devel/patch
494 doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
495 epydoc? ( >=dev-python/epydoc-2.0 !<=dev-python/pysqlite-2.4.1 )"
496 # Require sandbox-2.2 for bug #288863.
497 # For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
498 # quite slow, so it's not considered in the dependencies as an alternative to
499 # to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
500 # for now, don't pull in xattr deps for other kernels.
501 # For whirlpool hash, require python[ssl] or python-mhash (bug #425046).
502 RDEPEND="${python_dep}
503 !build? ( >=sys-apps/sed-4.0.5
504 >=app-shells/bash-3.2_p17
505 >=app-admin/eselect-1.2
506 || ( ${python_dep_ssl} dev-python/python-mhash )
507 )
508 elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
509 elibc_glibc? ( >=sys-apps/sandbox-2.2 )
510 elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
511 >=app-misc/pax-utils-0.1.17
512 xattr? ( kernel_linux? ( || ( >=dev-lang/python-3.3_pre20110902 dev-python/pyxattr ) ) )
513 selinux? ( || ( >=sys-libs/libselinux-2.0.94[python] <sys-libs/libselinux-2.0.94 ) )
514 !<app-shells/bash-3.2_p17
515 !<app-admin/logrotate-3.8.0"
516 PDEPEND="
517 !build? (
518 >=net-misc/rsync-2.6.4
519 userland_GNU? ( >=sys-apps/coreutils-6.4 )
520 )"
521 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
522 # NOTE: FEATURES=install-sources requires debugedit and rsync
523
524 SRC_ARCHIVES="http://dev.gentoo.org/~zmedico/portage/archives"
525
526 prefix_src_archives() {
527 local x y
528 for x in ${@}; do
529 for y in ${SRC_ARCHIVES}; do
530 echo ${y}/${x}
531 done
532 done
533 }
534
535 PV_PL="2.1.2"
536 PATCHVER_PL=""
537 TARBALL_PV=$PV
538 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
539 $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)
540 linguas_pl? ( mirror://gentoo/${PN}-man-pl-${PV_PL}.tar.bz2
541 $(prefix_src_archives ${PN}-man-pl-${PV_PL}.tar.bz2) )"
542
543 PATCHVER=
544 [[ $TARBALL_PV = $PV ]] || PATCHVER=$PV
545 if [ -n "${PATCHVER}" ]; then
546 SRC_URI="${SRC_URI} mirror://gentoo/${PN}-${PATCHVER}.patch.bz2
547 $(prefix_src_archives ${PN}-${PATCHVER}.patch.bz2)"
548 fi
549
550 S="${WORKDIR}"/${PN}-${TARBALL_PV}
551 S_PL="${WORKDIR}"/${PN}-${PV_PL}
552
553 compatible_python_is_selected() {
554 [[ $(/usr/bin/python -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x2060000 and "good" or "bad")') = good ]]
555 }
556
557 current_python_has_xattr() {
558 [[ $(/usr/bin/python -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x3030000 and "yes" or "no")') = yes ]] || \
559 /usr/bin/python -c 'import xattr' 2>/dev/null
560 }
561
562 pkg_setup() {
563 if use python2 && use python3 ; then
564 ewarn "Both python2 and python3 USE flags are enabled, but only one"
565 ewarn "can be in the shebangs. Using python3."
566 fi
567 if use pypy1_9 && use python3 ; then
568 ewarn "Both pypy1_9 and python3 USE flags are enabled, but only one"
569 ewarn "can be in the shebangs. Using python3."
570 fi
571 if use pypy1_9 && use python2 ; then
572 ewarn "Both pypy1_9 and python2 USE flags are enabled, but only one"
573 ewarn "can be in the shebangs. Using python2"
574 fi
575 if ! use pypy1_9 && ! use python2 && ! use python3 && \
576 ! compatible_python_is_selected ; then
577 ewarn "Attempting to select a compatible default python interpreter"
578 local x success=0
579 for x in /usr/bin/python2.* ; do
580 x=${x#/usr/bin/python2.}
581 if [[ $x -ge 6 ]] 2>/dev/null ; then
582 eselect python set python2.$x
583 if compatible_python_is_selected ; then
584 elog "Default python interpreter is now set to python-2.$x"
585 success=1
586 break
587 fi
588 fi
589 done
590 if [ $success != 1 ] ; then
591 eerror "Unable to select a compatible default python interpreter!"
592 die "This version of portage requires at least python-2.6 to be selected as the default python interpreter (see \`eselect python --help\`)."
593 fi
594 fi
595
596 if use python3; then
597 python_set_active_version 3
598 elif use python2; then
599 python_set_active_version 2
600 elif use pypy1_9; then
601 python_set_active_version 2.7-pypy-1.9
602 fi
603 }
604
605 src_prepare() {
606 if [ -n "${PATCHVER}" ] ; then
607 if [[ -L $S/bin/ebuild-helpers/portageq ]] ; then
608 rm "$S/bin/ebuild-helpers/portageq" \
609 || die "failed to remove portageq helper symlink"
610 fi
611 epatch "${WORKDIR}/${PN}-${PATCHVER}.patch"
612 fi
613 einfo "Setting portage.VERSION to ${PVR} ..."
614 sed -e "s/^VERSION=.*/VERSION=\"${PVR}\"/" -i pym/portage/__init__.py || \
615 die "Failed to patch portage.VERSION"
616 sed -e "1s/VERSION/${PVR}/" -i doc/fragment/version || \
617 die "Failed to patch VERSION in doc/fragment/version"
618 sed -e "1s/VERSION/${PVR}/" -i man/* || \
619 die "Failed to patch VERSION in man page headers"
620
621 if ! use ipc ; then
622 einfo "Disabling ipc..."
623 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
624 -i pym/_emerge/AbstractEbuildProcess.py || \
625 die "failed to patch AbstractEbuildProcess.py"
626 fi
627
628 if use xattr && use kernel_linux ; then
629 einfo "Adding FEATURES=xattr to make.globals ..."
630 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
631 || die "failed to append to make.globals"
632 fi
633
634 if use python3; then
635 einfo "Converting shebangs for python3..."
636 python_convert_shebangs -r 3 .
637 elif use python2; then
638 einfo "Converting shebangs for python2..."
639 python_convert_shebangs -r 2 .
640 elif use pypy1_9; then
641 einfo "Converting shebangs for pypy-c1.9..."
642 python_convert_shebangs -r 2.7-pypy-1.9 .
643 fi
644
645 cd "${S}/cnf" || die
646 if [ -f "make.conf.${ARCH}".diff ]; then
647 patch make.conf "make.conf.${ARCH}".diff || \
648 die "Failed to patch make.conf.example"
649 else
650 eerror ""
651 eerror "Portage does not have an arch-specific configuration for this arch."
652 eerror "Please notify the arch maintainer about this issue. Using generic."
653 eerror ""
654 fi
655
656 # BSD and OSX need a sed wrapper so that find/xargs work properly
657 if use userland_GNU; then
658 rm -f "${S}"/bin/ebuild-helpers/sed || \
659 die "Failed to remove sed wrapper"
660 fi
661 }
662
663 src_compile() {
664 if use doc; then
665 emake docbook || die
666 fi
667
668 if use epydoc; then
669 einfo "Generating api docs"
670 emake epydoc || die
671 fi
672 }
673
674 src_test() {
675 emake test || die
676 }
677
678 src_install() {
679 emake DESTDIR="${D}" \
680 sysconfdir="/etc" \
681 prefix="/usr" \
682 install || die
683
684 # Use dodoc for compression, since the Makefile doesn't do that.
685 dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES} || die
686
687 if use linguas_pl; then
688 doman -i18n=pl "${S_PL}"/man/pl/*.[0-9] || die
689 doman -i18n=pl_PL.UTF-8 "${S_PL}"/man/pl_PL.UTF-8/*.[0-9] || die
690 fi
691
692 # Set PYTHONPATH for portage API consumers. This way we don't have
693 # to rely on patched python having the correct path, since it has
694 # been known to incorrectly add /usr/libx32/portage/pym to sys.path.
695 echo "PYTHONPATH=/usr/lib/portage/pym" > \
696 "${T}/05portage" || die
697 doenvd "${T}/05portage" || die
698 }
699
700 pkg_preinst() {
701 if [[ $ROOT == / ]] ; then
702 # Run some minimal tests as a sanity check.
703 local test_runner=$(find "$D" -name runTests)
704 if [[ -n $test_runner && -x $test_runner ]] ; then
705 einfo "Running preinst sanity tests..."
706 "$test_runner" || die "preinst sanity tests failed"
707 fi
708 fi
709
710 if use xattr && ! current_python_has_xattr ; then
711 ewarn "For optimal performance in xattr handling, install"
712 ewarn "dev-python/pyxattr, or install >=dev-lang/python-3.3 and"
713 ewarn "enable USE=python3 for $CATEGORY/$PN."
714 fi
715
716 if ! use build && ! has_version dev-python/pycrypto && \
717 ! has_version '>=dev-lang/python-2.6[ssl]' ; then
718 ewarn "If you are an ebuild developer and you plan to commit ebuilds"
719 ewarn "with this system then please install dev-python/pycrypto or"
720 ewarn "enable the ssl USE flag for >=dev-lang/python-2.6 in order"
721 ewarn "to enable RMD160 hash support."
722 ewarn "See bug #198398 for more information."
723 fi
724
725 if [[ -d ${ROOT}var/log/portage && \
726 $(ls -ld "${ROOT}var/log/portage") != *" portage portage "* ]] && \
727 has_version '<sys-apps/portage-2.1.10.11' ; then
728 # Initialize permissions for bug #378451 and bug #377177, since older
729 # portage does not create /var/log/portage with the desired default
730 # permissions.
731 einfo "Applying portage group permission to ${ROOT}var/log/portage for bug #378451"
732 chown portage:portage "${ROOT}var/log/portage"
733 chmod g+ws "${ROOT}var/log/portage"
734 fi
735
736 if has_version '<sys-apps/portage-2.1.10.61' ; then
737 ewarn "FEATURES=config-protect-if-modified is now enabled by default."
738 ewarn "This causes the CONFIG_PROTECT behavior to be skipped for"
739 ewarn "files that have not been modified since they were installed."
740 fi
741 }
742
743 pkg_postinst() {
744 # Compile all source files recursively. Any orphans
745 # will be identified and removed in postrm.
746 python_mod_optimize /usr/lib/portage/pym
747 }
748
749 pkg_postrm() {
750 python_mod_cleanup /usr/lib/portage/pym
751 }