Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:musl commit in: dev-lang/python/
Date: Fri, 28 Mar 2014 18:06:32
Message-Id: 1396030007.3dbaff3e369cdb371abab22e6450545c7cb0aff5.blueness@gentoo
1 commit: 3dbaff3e369cdb371abab22e6450545c7cb0aff5
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 27 16:52:01 2014 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 28 18:06:47 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=3dbaff3e
7
8 dev-lan/python: bump to 2.7.6
9
10 Package-Manager: portage-2.2.9-r1
11
12 ---
13 dev-lang/python/python-2.7.6-r99.ebuild | 361 ++++++++++++++++++++++++++++++++
14 1 file changed, 361 insertions(+)
15
16 diff --git a/dev-lang/python/python-2.7.6-r99.ebuild b/dev-lang/python/python-2.7.6-r99.ebuild
17 new file mode 100644
18 index 0000000..f64a033
19 --- /dev/null
20 +++ b/dev-lang/python/python-2.7.6-r99.ebuild
21 @@ -0,0 +1,361 @@
22 +# Copyright 1999-2014 Gentoo Foundation
23 +# Distributed under the terms of the GNU General Public License v2
24 +# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.6.ebuild,v 1.8 2014/03/20 14:13:55 jer Exp $
25 +
26 +EAPI="4"
27 +WANT_AUTOMAKE="none"
28 +WANT_LIBTOOL="none"
29 +
30 +inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs multiprocessing
31 +
32 +MY_P="Python-${PV}"
33 +PATCHSET_REVISION="1"
34 +
35 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
36 +HOMEPAGE="http://www.python.org/"
37 +SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz
38 + mirror://gentoo/python-gentoo-patches-${PV}-${PATCHSET_REVISION}.tar.xz
39 + http://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PV}-${PATCHSET_REVISION}.tar.xz"
40 +
41 +LICENSE="PSF-2"
42 +SLOT="2.7"
43 +KEYWORDS="~amd64 ~arm ~mips ~x86"
44 +IUSE="-berkdb build doc elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
45 +
46 +# Do not add a dependency on dev-lang/python to this ebuild.
47 +# If you need to apply a patch which requires python for bootstrapping, please
48 +# run the bootstrap code on your dev box and include the results in the
49 +# patchset. See bug 447752.
50 +
51 +RDEPEND="app-arch/bzip2
52 + >=sys-libs/zlib-1.1.3
53 + virtual/libffi
54 + virtual/libintl
55 + !build? (
56 + berkdb? ( || (
57 + sys-libs/db:5.3
58 + sys-libs/db:5.2
59 + sys-libs/db:5.1
60 + sys-libs/db:5.0
61 + sys-libs/db:4.8
62 + sys-libs/db:4.7
63 + sys-libs/db:4.6
64 + sys-libs/db:4.5
65 + sys-libs/db:4.4
66 + sys-libs/db:4.3
67 + sys-libs/db:4.2
68 + ) )
69 + gdbm? ( sys-libs/gdbm[berkdb] )
70 + ncurses? (
71 + >=sys-libs/ncurses-5.2
72 + readline? ( >=sys-libs/readline-4.1 )
73 + )
74 + sqlite? ( >=dev-db/sqlite-3.3.8:3 )
75 + ssl? ( dev-libs/openssl )
76 + tk? (
77 + >=dev-lang/tk-8.0
78 + dev-tcltk/blt
79 + )
80 + xml? ( >=dev-libs/expat-2.1 )
81 + )
82 + !!<sys-apps/portage-2.1.9"
83 +DEPEND="${RDEPEND}
84 + virtual/pkgconfig
85 + >=sys-devel/autoconf-2.65
86 + !sys-devel/gcc[libffi]"
87 +RDEPEND+=" !build? ( app-misc/mime-types )
88 + doc? ( dev-python/python-docs:${SLOT} )"
89 +PDEPEND="app-admin/eselect-python
90 + app-admin/python-updater"
91 +
92 +S="${WORKDIR}/${MY_P}"
93 +
94 +pkg_setup() {
95 + if use berkdb; then
96 + ewarn "'bsddb' module is out-of-date and no longer maintained inside"
97 + ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
98 + ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
99 + ewarn "is provided by dev-python/bsddb3."
100 + else
101 + if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
102 + ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
103 + ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
104 + ewarn "You might need to migrate your databases."
105 + fi
106 + fi
107 +}
108 +
109 +src_prepare() {
110 + # Ensure that internal copies of expat, libffi and zlib are not used.
111 + rm -r Modules/expat || die
112 + rm -r Modules/_ctypes/libffi* || die
113 + rm -r Modules/zlib || die
114 +
115 + if tc-is-cross-compiler; then
116 + local EPATCH_EXCLUDE="*_regenerate_platform-specific_modules.patch"
117 + fi
118 +
119 + EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
120 +
121 + # Fix for cross-compiling.
122 + epatch "${FILESDIR}/python-2.7.5-nonfatal-compileall.patch"
123 +
124 + # Fix for class with posix_close on musl
125 + epatch "${FILESDIR}/python-fix-posix-close-clash.patch"
126 +
127 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
128 + Lib/distutils/command/install.py \
129 + Lib/distutils/sysconfig.py \
130 + Lib/site.py \
131 + Lib/sysconfig.py \
132 + Lib/test/test_site.py \
133 + Makefile.pre.in \
134 + Modules/Setup.dist \
135 + Modules/getpath.c \
136 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
137 +
138 + epatch_user
139 + epatch "${FILESDIR}/Python-2.7.5-remove-ptmx-ptc-checks.patch"
140 +
141 + eautoconf
142 + eautoheader
143 +}
144 +
145 +src_configure() {
146 + if use build; then
147 + # Disable extraneous modules with extra dependencies.
148 + export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
149 + export PYTHON_DISABLE_SSL="1"
150 + else
151 + # dbm module can be linked against berkdb or gdbm.
152 + # Defaults to gdbm when both are enabled, #204343.
153 + local disable
154 + use berkdb || use gdbm || disable+=" dbm"
155 + use berkdb || disable+=" _bsddb"
156 + use gdbm || disable+=" gdbm"
157 + use ncurses || disable+=" _curses _curses_panel"
158 + use readline || disable+=" readline"
159 + use sqlite || disable+=" _sqlite3"
160 + use ssl || export PYTHON_DISABLE_SSL="1"
161 + use tk || disable+=" _tkinter"
162 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
163 + export PYTHON_DISABLE_MODULES="${disable}"
164 +
165 + if ! use xml; then
166 + ewarn "You have configured Python without XML support."
167 + ewarn "This is NOT a recommended configuration as you"
168 + ewarn "may face problems parsing any XML documents."
169 + fi
170 + fi
171 +
172 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
173 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
174 + fi
175 +
176 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
177 + append-flags -fwrapv
178 + fi
179 +
180 + filter-flags -malign-double
181 +
182 + [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
183 +
184 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
185 + if is-flagq -O3; then
186 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
187 + use hardened && replace-flags -O3 -O2
188 + fi
189 +
190 + if tc-is-cross-compiler; then
191 + # Force some tests that try to poke fs paths.
192 + export ac_cv_file__dev_ptc=no
193 + export ac_cv_file__dev_ptmx=yes
194 + fi
195 +
196 + # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
197 + tc-export CXX
198 + # The configure script fails to use pkg-config correctly.
199 + # http://bugs.python.org/issue15506
200 + export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
201 +
202 + # Set LDFLAGS so we link modules with -lpython2.7 correctly.
203 + # Needed on FreeBSD unless Python 2.7 is already installed.
204 + # Please query BSD team before removing this!
205 + append-ldflags "-L."
206 +
207 + local dbmliborder
208 + if use gdbm; then
209 + dbmliborder+="${dbmliborder:+:}gdbm"
210 + fi
211 + if use berkdb; then
212 + dbmliborder+="${dbmliborder:+:}bdb"
213 + fi
214 +
215 + BUILD_DIR="${WORKDIR}/${CHOST}"
216 + mkdir -p "${BUILD_DIR}" || die
217 + cd "${BUILD_DIR}" || die
218 +
219 + ECONF_SOURCE="${S}" OPT="" \
220 + econf \
221 + --with-fpectl \
222 + --enable-shared \
223 + $(use_enable ipv6) \
224 + $(use_with threads) \
225 + $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
226 + --infodir='${prefix}/share/info' \
227 + --mandir='${prefix}/share/man' \
228 + --with-dbmliborder="${dbmliborder}" \
229 + --with-libc="" \
230 + --enable-loadable-sqlite-extensions \
231 + --with-system-expat \
232 + --with-system-ffi
233 +
234 + if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
235 + eerror "configure has detected that the sem_open function is broken."
236 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
237 + die "Broken sem_open function (bug 496328)"
238 + fi
239 +}
240 +
241 +src_compile() {
242 + # Avoid invoking pgen for cross-compiles.
243 + touch Include/graminit.h Python/graminit.c
244 +
245 + cd "${BUILD_DIR}" || die
246 + emake
247 +
248 + # Work around bug 329499. See also bug 413751 and 457194.
249 + if has_version dev-libs/libffi[pax_kernel]; then
250 + pax-mark E python
251 + else
252 + pax-mark m python
253 + fi
254 +}
255 +
256 +src_test() {
257 + # Tests will not work when cross compiling.
258 + if tc-is-cross-compiler; then
259 + elog "Disabling tests due to crosscompiling."
260 + return
261 + fi
262 +
263 + cd "${BUILD_DIR}" || die
264 +
265 + # Skip failing tests.
266 + local skipped_tests="distutils gdb"
267 +
268 + for test in ${skipped_tests}; do
269 + mv "${S}"/Lib/test/test_${test}.py "${T}"
270 + done
271 +
272 + # Rerun failed tests in verbose mode (regrtest -w).
273 + emake test EXTRATESTOPTS="-w" < /dev/tty
274 + local result="$?"
275 +
276 + for test in ${skipped_tests}; do
277 + mv "${T}/test_${test}.py" "${S}"/Lib/test
278 + done
279 +
280 + elog "The following tests have been skipped:"
281 + for test in ${skipped_tests}; do
282 + elog "test_${test}.py"
283 + done
284 +
285 + elog "If you would like to run them, you may:"
286 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'"
287 + elog "and run the tests separately."
288 +
289 + if [[ "${result}" -ne 0 ]]; then
290 + die "emake test failed"
291 + fi
292 +}
293 +
294 +src_install() {
295 + local libdir=${ED}/usr/$(get_libdir)/python${SLOT}
296 +
297 + cd "${BUILD_DIR}" || die
298 + emake DESTDIR="${D}" altinstall
299 +
300 + sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die "sed failed"
301 +
302 + # Backwards compat with Gentoo divergence.
303 + dosym python${SLOT}-config /usr/bin/python-config-${SLOT}
304 +
305 + # Fix collisions between different slots of Python.
306 + mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
307 + mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
308 + mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
309 + rm -f "${ED}usr/bin/smtpd.py"
310 +
311 + if use build; then
312 + rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
313 + else
314 + use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*} || die
315 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
316 + use tk || rm -r "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk} || die
317 + use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
318 + fi
319 +
320 + use threads || rm -r "${libdir}/multiprocessing" || die
321 + use wininst || rm -r "${libdir}/distutils/command/"wininst-*.exe || die
322 +
323 + dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS}
324 +
325 + if use examples; then
326 + insinto /usr/share/doc/${PF}/examples
327 + doins -r "${S}"/Tools
328 + fi
329 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
330 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
331 + emake --no-print-directory -s -f - 2>/dev/null)
332 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
333 +
334 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT}
335 + newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT}
336 + sed \
337 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
338 + -e "s:@PYDOC@:pydoc${SLOT}:" \
339 + -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
340 +
341 + # for python-exec
342 + python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR
343 +
344 + # if not using a cross-compiler, use the fresh binary
345 + if ! tc-is-cross-compiler; then
346 + local PYTHON=./python
347 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}.
348 + fi
349 +
350 + echo "EPYTHON='${EPYTHON}'" > epython.py
351 + python_domodule epython.py
352 +}
353 +
354 +pkg_preinst() {
355 + if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
356 + python_updater_warning="1"
357 + fi
358 +}
359 +
360 +eselect_python_update() {
361 + if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
362 + eselect python update
363 + fi
364 +
365 + if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
366 + eselect python update --python${PV%%.*}
367 + fi
368 +}
369 +
370 +pkg_postinst() {
371 + eselect_python_update
372 +
373 + if [[ "${python_updater_warning}" == "1" ]]; then
374 + ewarn "You have just upgraded from an older version of Python."
375 + ewarn "You should switch active version of Python ${PV%%.*} and run"
376 + ewarn "'python-updater [options]' to rebuild Python modules."
377 + fi
378 +}
379 +
380 +pkg_postrm() {
381 + eselect_python_update
382 +}