1 |
commit: b568948e423c3c0f843901853c0e1457bbd7b762 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 2 07:44:44 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 2 08:47:37 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b568948e |
7 |
|
8 |
dev-lang/python: Backport sec fixes to 3.9.5_p2 |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
dev-lang/python/Manifest | 1 + |
13 |
dev-lang/python/python-3.9.5_p2.ebuild | 345 +++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 346 insertions(+) |
15 |
|
16 |
diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest |
17 |
index 8cf3faa3b37..89349d888da 100644 |
18 |
--- a/dev-lang/python/Manifest |
19 |
+++ b/dev-lang/python/Manifest |
20 |
@@ -30,3 +30,4 @@ DIST python-gentoo-patches-3.8.9_p2.tar.xz 16600 BLAKE2B 895eebdfabfe9cc4a30d872 |
21 |
DIST python-gentoo-patches-3.9.4_p1.tar.xz 14472 BLAKE2B c8bd49c2eb77eb00377e6c6e63a2f6b1108a2c8d4eb45cc943ad2d0a2b4457e00002f90d2597032716af5268f33d24902d4634cf8e98778c1d15bf8dda5d7215 SHA512 9a12c1935be31b1663e4ab6c1f7aca51ba62ef4033600885678ce436ecab688e2df82742125b4885b1cb8da9c68140c5ca4ee1684360ac87d82c6491bce5d0a0 |
22 |
DIST python-gentoo-patches-3.9.5.tar.xz 8820 BLAKE2B 177234776f00c3efa6b76fefc1ef0001225ded1dd8ba916e3dc8498a7e845467bf387ba8a4f82da713a51bff627420a084f6627218863f70e1273cce58ca7252 SHA512 37b7e25a1703184556f12202da9cba1a8e2fb1c059d75195ef2997f55948229f164642a580e33c59f5877fe36d4c62f1735f95df318b36d92c528eb98f42e55f |
23 |
DIST python-gentoo-patches-3.9.5_p1.tar.xz 9124 BLAKE2B ab2f51c2d10c679022b563efa8b2494499d8d69b7617ec5229c3af546b1a9589e8aa064e9c025e19f658a316fba4134086ac8f357de97042288ee7b8f34ba9c7 SHA512 16da4a4736acd0ceb263766d14781a034a374372c7ab603a966fa364350b28e8c168f2e38c276d8e03cbdc2f3f9dde691fe959ca3db20533b036cc664a3cefe1 |
24 |
+DIST python-gentoo-patches-3.9.5_p2.tar.xz 14728 BLAKE2B b6b0a0c316d99e8282bdbb5e62a90f84880ff89b0b1e236a5bce37fbdd3c3b187f7964873882dbcbc8c9765af107377240e8aac544987452830f0069aff471c0 SHA512 42e4dd48f4b93bd45a70093b447b4862ab286c1b5adc32d22a3e3d08e67db13bfa829bdbcf989fac9b7c8634a4735cfb4a7b16bfc40bdff0c11bc5a768bbeaf8 |
25 |
|
26 |
diff --git a/dev-lang/python/python-3.9.5_p2.ebuild b/dev-lang/python/python-3.9.5_p2.ebuild |
27 |
new file mode 100644 |
28 |
index 00000000000..444f9d6d14b |
29 |
--- /dev/null |
30 |
+++ b/dev-lang/python/python-3.9.5_p2.ebuild |
31 |
@@ -0,0 +1,345 @@ |
32 |
+# Copyright 1999-2021 Gentoo Authors |
33 |
+# Distributed under the terms of the GNU General Public License v2 |
34 |
+ |
35 |
+EAPI="7" |
36 |
+WANT_LIBTOOL="none" |
37 |
+ |
38 |
+inherit autotools check-reqs flag-o-matic multiprocessing pax-utils \ |
39 |
+ python-utils-r1 toolchain-funcs verify-sig |
40 |
+ |
41 |
+MY_PV=${PV/_rc/rc} |
42 |
+MY_P="Python-${MY_PV%_p*}" |
43 |
+PYVER=$(ver_cut 1-2) |
44 |
+PATCHSET="python-gentoo-patches-${MY_PV}" |
45 |
+ |
46 |
+DESCRIPTION="An interpreted, interactive, object-oriented programming language" |
47 |
+HOMEPAGE="https://www.python.org/" |
48 |
+SRC_URI="https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz |
49 |
+ https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz |
50 |
+ verify-sig? ( |
51 |
+ https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc |
52 |
+ )" |
53 |
+S="${WORKDIR}/${MY_P}" |
54 |
+ |
55 |
+LICENSE="PSF-2" |
56 |
+SLOT="${PYVER}" |
57 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" |
58 |
+IUSE="bluetooth build examples gdbm hardened ipv6 +ncurses +readline +sqlite +ssl test tk wininst +xml" |
59 |
+RESTRICT="!test? ( test )" |
60 |
+ |
61 |
+# Do not add a dependency on dev-lang/python to this ebuild. |
62 |
+# If you need to apply a patch which requires python for bootstrapping, please |
63 |
+# run the bootstrap code on your dev box and include the results in the |
64 |
+# patchset. See bug 447752. |
65 |
+ |
66 |
+RDEPEND="app-arch/bzip2:= |
67 |
+ app-arch/xz-utils:= |
68 |
+ dev-libs/libffi:= |
69 |
+ sys-apps/util-linux:= |
70 |
+ >=sys-libs/zlib-1.1.3:= |
71 |
+ virtual/libcrypt:= |
72 |
+ virtual/libintl |
73 |
+ gdbm? ( sys-libs/gdbm:=[berkdb] ) |
74 |
+ ncurses? ( >=sys-libs/ncurses-5.2:= ) |
75 |
+ readline? ( >=sys-libs/readline-4.1:= ) |
76 |
+ sqlite? ( >=dev-db/sqlite-3.3.8:3= ) |
77 |
+ ssl? ( dev-libs/openssl:= ) |
78 |
+ tk? ( |
79 |
+ >=dev-lang/tcl-8.0:= |
80 |
+ >=dev-lang/tk-8.0:= |
81 |
+ dev-tcltk/blt:= |
82 |
+ dev-tcltk/tix |
83 |
+ ) |
84 |
+ xml? ( >=dev-libs/expat-2.1:= )" |
85 |
+# bluetooth requires headers from bluez |
86 |
+DEPEND="${RDEPEND} |
87 |
+ bluetooth? ( net-wireless/bluez ) |
88 |
+ test? ( app-arch/xz-utils[extra-filters(+)] )" |
89 |
+BDEPEND=" |
90 |
+ virtual/pkgconfig |
91 |
+ sys-devel/autoconf-archive |
92 |
+ verify-sig? ( app-crypt/openpgp-keys-python ) |
93 |
+ !sys-devel/gcc[libffi(-)]" |
94 |
+RDEPEND+=" !build? ( app-misc/mime-types )" |
95 |
+PDEPEND="app-eselect/eselect-python" |
96 |
+ |
97 |
+VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/python.org.asc |
98 |
+ |
99 |
+# large file tests involve a 2.5G file being copied (duplicated) |
100 |
+CHECKREQS_DISK_BUILD=5500M |
101 |
+ |
102 |
+pkg_pretend() { |
103 |
+ use test && check-reqs_pkg_pretend |
104 |
+} |
105 |
+ |
106 |
+pkg_setup() { |
107 |
+ use test && check-reqs_pkg_setup |
108 |
+} |
109 |
+ |
110 |
+src_unpack() { |
111 |
+ if use verify-sig; then |
112 |
+ verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc} |
113 |
+ fi |
114 |
+ default |
115 |
+} |
116 |
+ |
117 |
+src_prepare() { |
118 |
+ # Ensure that internal copies of expat, libffi and zlib are not used. |
119 |
+ rm -fr Modules/expat || die |
120 |
+ rm -fr Modules/_ctypes/libffi* || die |
121 |
+ rm -fr Modules/zlib || die |
122 |
+ |
123 |
+ local PATCHES=( |
124 |
+ "${WORKDIR}/${PATCHSET}" |
125 |
+ ) |
126 |
+ |
127 |
+ default |
128 |
+ |
129 |
+ sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \ |
130 |
+ setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@" |
131 |
+ |
132 |
+ # force correct number of jobs |
133 |
+ # https://bugs.gentoo.org/737660 |
134 |
+ local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)") |
135 |
+ sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die |
136 |
+ sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die |
137 |
+ |
138 |
+ eautoreconf |
139 |
+} |
140 |
+ |
141 |
+src_configure() { |
142 |
+ local disable |
143 |
+ # disable automagic bluetooth headers detection |
144 |
+ use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no |
145 |
+ use gdbm || disable+=" gdbm" |
146 |
+ use ncurses || disable+=" _curses _curses_panel" |
147 |
+ use readline || disable+=" readline" |
148 |
+ use sqlite || disable+=" _sqlite3" |
149 |
+ use ssl || export PYTHON_DISABLE_SSL="1" |
150 |
+ use tk || disable+=" _tkinter" |
151 |
+ use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat. |
152 |
+ export PYTHON_DISABLE_MODULES="${disable}" |
153 |
+ |
154 |
+ if ! use xml; then |
155 |
+ ewarn "You have configured Python without XML support." |
156 |
+ ewarn "This is NOT a recommended configuration as you" |
157 |
+ ewarn "may face problems parsing any XML documents." |
158 |
+ fi |
159 |
+ |
160 |
+ if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then |
161 |
+ einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}" |
162 |
+ fi |
163 |
+ |
164 |
+ if [[ "$(gcc-major-version)" -ge 4 ]]; then |
165 |
+ append-flags -fwrapv |
166 |
+ fi |
167 |
+ |
168 |
+ filter-flags -malign-double |
169 |
+ |
170 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=50309 |
171 |
+ if is-flagq -O3; then |
172 |
+ is-flagq -fstack-protector-all && replace-flags -O3 -O2 |
173 |
+ use hardened && replace-flags -O3 -O2 |
174 |
+ fi |
175 |
+ |
176 |
+ # https://bugs.gentoo.org/700012 |
177 |
+ if is-flagq -flto || is-flagq '-flto=*'; then |
178 |
+ append-cflags $(test-flags-CC -ffat-lto-objects) |
179 |
+ fi |
180 |
+ |
181 |
+ # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile. |
182 |
+ tc-export CXX |
183 |
+ |
184 |
+ # Fix implicit declarations on cross and prefix builds. Bug #674070. |
185 |
+ use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw |
186 |
+ |
187 |
+ local dbmliborder |
188 |
+ if use gdbm; then |
189 |
+ dbmliborder+="${dbmliborder:+:}gdbm" |
190 |
+ fi |
191 |
+ |
192 |
+ local myeconfargs=( |
193 |
+ # glibc-2.30 removes it; since we can't cleanly force-rebuild |
194 |
+ # Python on glibc upgrade, remove it proactively to give |
195 |
+ # a chance for users rebuilding python before glibc |
196 |
+ ac_cv_header_stropts_h=no |
197 |
+ |
198 |
+ --enable-shared |
199 |
+ $(use_enable ipv6) |
200 |
+ --infodir='${prefix}/share/info' |
201 |
+ --mandir='${prefix}/share/man' |
202 |
+ --with-computed-gotos |
203 |
+ --with-dbmliborder="${dbmliborder}" |
204 |
+ --with-libc= |
205 |
+ --enable-loadable-sqlite-extensions |
206 |
+ --without-ensurepip |
207 |
+ --with-system-expat |
208 |
+ --with-system-ffi |
209 |
+ ) |
210 |
+ |
211 |
+ OPT="" econf "${myeconfargs[@]}" |
212 |
+ |
213 |
+ if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then |
214 |
+ eerror "configure has detected that the sem_open function is broken." |
215 |
+ eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777." |
216 |
+ die "Broken sem_open function (bug 496328)" |
217 |
+ fi |
218 |
+} |
219 |
+ |
220 |
+src_compile() { |
221 |
+ # Ensure sed works as expected |
222 |
+ # https://bugs.gentoo.org/594768 |
223 |
+ local -x LC_ALL=C |
224 |
+ |
225 |
+ emake CPPFLAGS= CFLAGS= LDFLAGS= |
226 |
+ |
227 |
+ # Work around bug 329499. See also bug 413751 and 457194. |
228 |
+ if has_version dev-libs/libffi[pax_kernel]; then |
229 |
+ pax-mark E python |
230 |
+ else |
231 |
+ pax-mark m python |
232 |
+ fi |
233 |
+} |
234 |
+ |
235 |
+src_test() { |
236 |
+ # Tests will not work when cross compiling. |
237 |
+ if tc-is-cross-compiler; then |
238 |
+ elog "Disabling tests due to crosscompiling." |
239 |
+ return |
240 |
+ fi |
241 |
+ |
242 |
+ # Skip failing tests. |
243 |
+ local skipped_tests="gdb" |
244 |
+ |
245 |
+ for test in ${skipped_tests}; do |
246 |
+ mv "${S}"/Lib/test/test_${test}.py "${T}" |
247 |
+ done |
248 |
+ |
249 |
+ # bug 660358 |
250 |
+ local -x COLUMNS=80 |
251 |
+ local -x PYTHONDONTWRITEBYTECODE= |
252 |
+ |
253 |
+ local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)") |
254 |
+ |
255 |
+ emake test EXTRATESTOPTS="-u-network -j${jobs}" \ |
256 |
+ CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty |
257 |
+ local result=$? |
258 |
+ |
259 |
+ for test in ${skipped_tests}; do |
260 |
+ mv "${T}/test_${test}.py" "${S}"/Lib/test |
261 |
+ done |
262 |
+ |
263 |
+ elog "The following tests have been skipped:" |
264 |
+ for test in ${skipped_tests}; do |
265 |
+ elog "test_${test}.py" |
266 |
+ done |
267 |
+ |
268 |
+ elog "If you would like to run them, you may:" |
269 |
+ elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'" |
270 |
+ elog "and run the tests separately." |
271 |
+ |
272 |
+ if [[ ${result} -ne 0 ]]; then |
273 |
+ die "emake test failed" |
274 |
+ fi |
275 |
+} |
276 |
+ |
277 |
+src_install() { |
278 |
+ local libdir=${ED}/usr/lib/python${PYVER} |
279 |
+ |
280 |
+ emake DESTDIR="${D}" altinstall |
281 |
+ |
282 |
+ # Remove static library |
283 |
+ rm "${ED}"/usr/$(get_libdir)/libpython*.a || die |
284 |
+ |
285 |
+ sed \ |
286 |
+ -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \ |
287 |
+ -e "s/\(PY_LDFLAGS=\).*/\1/" \ |
288 |
+ -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed" |
289 |
+ |
290 |
+ # Fix collisions between different slots of Python. |
291 |
+ rm "${ED}/usr/$(get_libdir)/libpython3.so" || die |
292 |
+ |
293 |
+ # Cheap hack to get version with ABIFLAGS |
294 |
+ local abiver=$(cd "${ED}/usr/include"; echo python*) |
295 |
+ if [[ ${abiver} != python${PYVER} ]]; then |
296 |
+ # Replace python3.X with a symlink to python3.Xm |
297 |
+ rm "${ED}/usr/bin/python${PYVER}" || die |
298 |
+ dosym "${abiver}" "/usr/bin/python${PYVER}" |
299 |
+ # Create python3.X-config symlink |
300 |
+ dosym "${abiver}-config" "/usr/bin/python${PYVER}-config" |
301 |
+ # Create python-3.5m.pc symlink |
302 |
+ dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc" |
303 |
+ fi |
304 |
+ |
305 |
+ # python seems to get rebuilt in src_install (bug 569908) |
306 |
+ # Work around it for now. |
307 |
+ if has_version dev-libs/libffi[pax_kernel]; then |
308 |
+ pax-mark E "${ED}/usr/bin/${abiver}" |
309 |
+ else |
310 |
+ pax-mark m "${ED}/usr/bin/${abiver}" |
311 |
+ fi |
312 |
+ |
313 |
+ use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die |
314 |
+ use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die |
315 |
+ |
316 |
+ dodoc Misc/{ACKS,HISTORY,NEWS} |
317 |
+ |
318 |
+ if use examples; then |
319 |
+ docinto examples |
320 |
+ find Tools -name __pycache__ -exec rm -fr {} + || die |
321 |
+ dodoc -r Tools |
322 |
+ fi |
323 |
+ insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 |
324 |
+ local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ |
325 |
+ emake --no-print-directory -s -f - 2>/dev/null) |
326 |
+ newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py |
327 |
+ |
328 |
+ newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER} |
329 |
+ newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER} |
330 |
+ sed \ |
331 |
+ -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \ |
332 |
+ -e "s:@PYDOC@:pydoc${PYVER}:" \ |
333 |
+ -i "${ED}/etc/conf.d/pydoc-${PYVER}" \ |
334 |
+ "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed" |
335 |
+ |
336 |
+ local -x EPYTHON=python${PYVER} |
337 |
+ # if not using a cross-compiler, use the fresh binary |
338 |
+ if ! tc-is-cross-compiler; then |
339 |
+ local -x PYTHON=./python |
340 |
+ local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD} |
341 |
+ else |
342 |
+ local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON} |
343 |
+ fi |
344 |
+ |
345 |
+ echo "EPYTHON='${EPYTHON}'" > epython.py || die |
346 |
+ python_domodule epython.py |
347 |
+ |
348 |
+ # python-exec wrapping support |
349 |
+ local pymajor=${PYVER%.*} |
350 |
+ local scriptdir=${D}$(python_get_scriptdir) |
351 |
+ mkdir -p "${scriptdir}" || die |
352 |
+ # python and pythonX |
353 |
+ ln -s "../../../bin/${abiver}" \ |
354 |
+ "${scriptdir}/python${pymajor}" || die |
355 |
+ ln -s "python${pymajor}" "${scriptdir}/python" || die |
356 |
+ # python-config and pythonX-config |
357 |
+ # note: we need to create a wrapper rather than symlinking it due |
358 |
+ # to some random dirname(argv[0]) magic performed by python-config |
359 |
+ cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die |
360 |
+ #!/bin/sh |
361 |
+ exec "${abiver}-config" "\${@}" |
362 |
+ EOF |
363 |
+ chmod +x "${scriptdir}/python${pymajor}-config" || die |
364 |
+ ln -s "python${pymajor}-config" \ |
365 |
+ "${scriptdir}/python-config" || die |
366 |
+ # 2to3, pydoc |
367 |
+ ln -s "../../../bin/2to3-${PYVER}" \ |
368 |
+ "${scriptdir}/2to3" || die |
369 |
+ ln -s "../../../bin/pydoc${PYVER}" \ |
370 |
+ "${scriptdir}/pydoc" || die |
371 |
+ # idle |
372 |
+ if use tk; then |
373 |
+ ln -s "../../../bin/idle${PYVER}" \ |
374 |
+ "${scriptdir}/idle" || die |
375 |
+ fi |
376 |
+} |