1 |
commit: 4d3ba41818e0b69d765978ec1059700d86a681fe |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Aug 30 21:48:40 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 30 22:23:48 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d3ba418 |
7 |
|
8 |
dev-lang/python: Backport secfixes to 3.9.6_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.6_p2.ebuild | 344 +++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 345 insertions(+) |
15 |
|
16 |
diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest |
17 |
index ea475748752..bc7c8b10002 100644 |
18 |
--- a/dev-lang/python/Manifest |
19 |
+++ b/dev-lang/python/Manifest |
20 |
@@ -17,3 +17,4 @@ DIST python-gentoo-patches-3.6.14.tar.xz 14744 BLAKE2B b9482f9d2b7ada60eff9a5672 |
21 |
DIST python-gentoo-patches-3.7.11.tar.xz 16708 BLAKE2B 4f74b38f400c20b4112f080447021e7140704b282d6369a1479886740d12a17e7818b52a382a4b115238847bb08df0260b092b6ead491623b869c3d3a56f4cc2 SHA512 b96d7af8c9f7fb4b246a8b66e6440336a7d123678d990dd259d7ffb87d79ce74295ff350e220fee38d1b12f1ca94533899c2d2ce700391b3eac907722a79bba6 |
22 |
DIST python-gentoo-patches-3.8.11.tar.xz 16932 BLAKE2B aaa1df33997f4077916fb7cca2ec3a2b2ac1c0ead3db7c638a5152a82cfaaf5fc2768a10ac7235c417e25b2b735c53628ec096878f08eef0d211b03f4747103c SHA512 d2639b95c5a32f7145f92e52a94aec7c63f3ed4a66036ff73f052ff6836742d1e1dd7180f8634b65b4a44a10bf336092695bcc2230a7fd8be35bae870ed64b08 |
23 |
DIST python-gentoo-patches-3.9.6_p1.tar.xz 12764 BLAKE2B 927718f1aadb5d5ef67e647a639a10bffdd48474bf01e50bd37ef1242bce57606b7b54c4823c1da3585ee76e737028163e38e9b4e19037585cc53f925e1c5fa7 SHA512 f06fb55786bd942e72e3225ee9ce218724aeee29f301279743588749007e991851a8f29db5b5dfd85435e3d763c00942947909a6fc60581bd0f3e8a6e913bff8 |
24 |
+DIST python-gentoo-patches-3.9.6_p2.tar.xz 14720 BLAKE2B e14634229b65a29f5294694949c138bfa6146810349d1207a07d84eeca529571eb9c760b58ddbe6e8d96d50d1a3e0d1dfe42328c53c977a9eeb22ecd553317dc SHA512 5d84b8bb4e5584e3ef8e6298af000e772240ad93ed0aaadf1d785db947f1e79aecae7313b8dbeb65849212c9930e683be6e18e42ef6c41a3c27d60f75df08a01 |
25 |
|
26 |
diff --git a/dev-lang/python/python-3.9.6_p2.ebuild b/dev-lang/python/python-3.9.6_p2.ebuild |
27 |
new file mode 100644 |
28 |
index 00000000000..682541d3448 |
29 |
--- /dev/null |
30 |
+++ b/dev-lang/python/python-3.9.6_p2.ebuild |
31 |
@@ -0,0 +1,344 @@ |
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-1.1.1:= ) |
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 |
+ |
96 |
+VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc |
97 |
+ |
98 |
+# large file tests involve a 2.5G file being copied (duplicated) |
99 |
+CHECKREQS_DISK_BUILD=5500M |
100 |
+ |
101 |
+pkg_pretend() { |
102 |
+ use test && check-reqs_pkg_pretend |
103 |
+} |
104 |
+ |
105 |
+pkg_setup() { |
106 |
+ use test && check-reqs_pkg_setup |
107 |
+} |
108 |
+ |
109 |
+src_unpack() { |
110 |
+ if use verify-sig; then |
111 |
+ verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc} |
112 |
+ fi |
113 |
+ default |
114 |
+} |
115 |
+ |
116 |
+src_prepare() { |
117 |
+ # Ensure that internal copies of expat, libffi and zlib are not used. |
118 |
+ rm -fr Modules/expat || die |
119 |
+ rm -fr Modules/_ctypes/libffi* || die |
120 |
+ rm -fr Modules/zlib || die |
121 |
+ |
122 |
+ local PATCHES=( |
123 |
+ "${WORKDIR}/${PATCHSET}" |
124 |
+ ) |
125 |
+ |
126 |
+ default |
127 |
+ |
128 |
+ sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \ |
129 |
+ setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@" |
130 |
+ |
131 |
+ # force correct number of jobs |
132 |
+ # https://bugs.gentoo.org/737660 |
133 |
+ local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)") |
134 |
+ sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die |
135 |
+ sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die |
136 |
+ |
137 |
+ eautoreconf |
138 |
+} |
139 |
+ |
140 |
+src_configure() { |
141 |
+ local disable |
142 |
+ # disable automagic bluetooth headers detection |
143 |
+ use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no |
144 |
+ use gdbm || disable+=" gdbm" |
145 |
+ use ncurses || disable+=" _curses _curses_panel" |
146 |
+ use readline || disable+=" readline" |
147 |
+ use sqlite || disable+=" _sqlite3" |
148 |
+ use ssl || export PYTHON_DISABLE_SSL="1" |
149 |
+ use tk || disable+=" _tkinter" |
150 |
+ use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat. |
151 |
+ export PYTHON_DISABLE_MODULES="${disable}" |
152 |
+ |
153 |
+ if ! use xml; then |
154 |
+ ewarn "You have configured Python without XML support." |
155 |
+ ewarn "This is NOT a recommended configuration as you" |
156 |
+ ewarn "may face problems parsing any XML documents." |
157 |
+ fi |
158 |
+ |
159 |
+ if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then |
160 |
+ einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}" |
161 |
+ fi |
162 |
+ |
163 |
+ if [[ "$(gcc-major-version)" -ge 4 ]]; then |
164 |
+ append-flags -fwrapv |
165 |
+ fi |
166 |
+ |
167 |
+ filter-flags -malign-double |
168 |
+ |
169 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=50309 |
170 |
+ if is-flagq -O3; then |
171 |
+ is-flagq -fstack-protector-all && replace-flags -O3 -O2 |
172 |
+ use hardened && replace-flags -O3 -O2 |
173 |
+ fi |
174 |
+ |
175 |
+ # https://bugs.gentoo.org/700012 |
176 |
+ if is-flagq -flto || is-flagq '-flto=*'; then |
177 |
+ append-cflags $(test-flags-CC -ffat-lto-objects) |
178 |
+ fi |
179 |
+ |
180 |
+ # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile. |
181 |
+ tc-export CXX |
182 |
+ |
183 |
+ # Fix implicit declarations on cross and prefix builds. Bug #674070. |
184 |
+ use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw |
185 |
+ |
186 |
+ local dbmliborder |
187 |
+ if use gdbm; then |
188 |
+ dbmliborder+="${dbmliborder:+:}gdbm" |
189 |
+ fi |
190 |
+ |
191 |
+ local myeconfargs=( |
192 |
+ # glibc-2.30 removes it; since we can't cleanly force-rebuild |
193 |
+ # Python on glibc upgrade, remove it proactively to give |
194 |
+ # a chance for users rebuilding python before glibc |
195 |
+ ac_cv_header_stropts_h=no |
196 |
+ |
197 |
+ --enable-shared |
198 |
+ $(use_enable ipv6) |
199 |
+ --infodir='${prefix}/share/info' |
200 |
+ --mandir='${prefix}/share/man' |
201 |
+ --with-computed-gotos |
202 |
+ --with-dbmliborder="${dbmliborder}" |
203 |
+ --with-libc= |
204 |
+ --enable-loadable-sqlite-extensions |
205 |
+ --without-ensurepip |
206 |
+ --with-system-expat |
207 |
+ --with-system-ffi |
208 |
+ ) |
209 |
+ |
210 |
+ OPT="" econf "${myeconfargs[@]}" |
211 |
+ |
212 |
+ if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then |
213 |
+ eerror "configure has detected that the sem_open function is broken." |
214 |
+ eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777." |
215 |
+ die "Broken sem_open function (bug 496328)" |
216 |
+ fi |
217 |
+} |
218 |
+ |
219 |
+src_compile() { |
220 |
+ # Ensure sed works as expected |
221 |
+ # https://bugs.gentoo.org/594768 |
222 |
+ local -x LC_ALL=C |
223 |
+ |
224 |
+ emake CPPFLAGS= CFLAGS= LDFLAGS= |
225 |
+ |
226 |
+ # Work around bug 329499. See also bug 413751 and 457194. |
227 |
+ if has_version dev-libs/libffi[pax-kernel]; then |
228 |
+ pax-mark E python |
229 |
+ else |
230 |
+ pax-mark m python |
231 |
+ fi |
232 |
+} |
233 |
+ |
234 |
+src_test() { |
235 |
+ # Tests will not work when cross compiling. |
236 |
+ if tc-is-cross-compiler; then |
237 |
+ elog "Disabling tests due to crosscompiling." |
238 |
+ return |
239 |
+ fi |
240 |
+ |
241 |
+ # Skip failing tests. |
242 |
+ local skipped_tests="gdb" |
243 |
+ |
244 |
+ for test in ${skipped_tests}; do |
245 |
+ mv "${S}"/Lib/test/test_${test}.py "${T}" |
246 |
+ done |
247 |
+ |
248 |
+ # bug 660358 |
249 |
+ local -x COLUMNS=80 |
250 |
+ local -x PYTHONDONTWRITEBYTECODE= |
251 |
+ |
252 |
+ local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)") |
253 |
+ |
254 |
+ emake test EXTRATESTOPTS="-u-network -j${jobs}" \ |
255 |
+ CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty |
256 |
+ local result=$? |
257 |
+ |
258 |
+ for test in ${skipped_tests}; do |
259 |
+ mv "${T}/test_${test}.py" "${S}"/Lib/test |
260 |
+ done |
261 |
+ |
262 |
+ elog "The following tests have been skipped:" |
263 |
+ for test in ${skipped_tests}; do |
264 |
+ elog "test_${test}.py" |
265 |
+ done |
266 |
+ |
267 |
+ elog "If you would like to run them, you may:" |
268 |
+ elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'" |
269 |
+ elog "and run the tests separately." |
270 |
+ |
271 |
+ if [[ ${result} -ne 0 ]]; then |
272 |
+ die "emake test failed" |
273 |
+ fi |
274 |
+} |
275 |
+ |
276 |
+src_install() { |
277 |
+ local libdir=${ED}/usr/lib/python${PYVER} |
278 |
+ |
279 |
+ emake DESTDIR="${D}" altinstall |
280 |
+ |
281 |
+ # Remove static library |
282 |
+ rm "${ED}"/usr/$(get_libdir)/libpython*.a || die |
283 |
+ |
284 |
+ sed \ |
285 |
+ -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \ |
286 |
+ -e "s/\(PY_LDFLAGS=\).*/\1/" \ |
287 |
+ -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed" |
288 |
+ |
289 |
+ # Fix collisions between different slots of Python. |
290 |
+ rm "${ED}/usr/$(get_libdir)/libpython3.so" || die |
291 |
+ |
292 |
+ # Cheap hack to get version with ABIFLAGS |
293 |
+ local abiver=$(cd "${ED}/usr/include"; echo python*) |
294 |
+ if [[ ${abiver} != python${PYVER} ]]; then |
295 |
+ # Replace python3.X with a symlink to python3.Xm |
296 |
+ rm "${ED}/usr/bin/python${PYVER}" || die |
297 |
+ dosym "${abiver}" "/usr/bin/python${PYVER}" |
298 |
+ # Create python3.X-config symlink |
299 |
+ dosym "${abiver}-config" "/usr/bin/python${PYVER}-config" |
300 |
+ # Create python-3.5m.pc symlink |
301 |
+ dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc" |
302 |
+ fi |
303 |
+ |
304 |
+ # python seems to get rebuilt in src_install (bug 569908) |
305 |
+ # Work around it for now. |
306 |
+ if has_version dev-libs/libffi[pax-kernel]; then |
307 |
+ pax-mark E "${ED}/usr/bin/${abiver}" |
308 |
+ else |
309 |
+ pax-mark m "${ED}/usr/bin/${abiver}" |
310 |
+ fi |
311 |
+ |
312 |
+ use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die |
313 |
+ use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die |
314 |
+ |
315 |
+ dodoc Misc/{ACKS,HISTORY,NEWS} |
316 |
+ |
317 |
+ if use examples; then |
318 |
+ docinto examples |
319 |
+ find Tools -name __pycache__ -exec rm -fr {} + || die |
320 |
+ dodoc -r Tools |
321 |
+ fi |
322 |
+ insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 |
323 |
+ local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ |
324 |
+ emake --no-print-directory -s -f - 2>/dev/null) |
325 |
+ newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py |
326 |
+ |
327 |
+ newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER} |
328 |
+ newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER} |
329 |
+ sed \ |
330 |
+ -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \ |
331 |
+ -e "s:@PYDOC@:pydoc${PYVER}:" \ |
332 |
+ -i "${ED}/etc/conf.d/pydoc-${PYVER}" \ |
333 |
+ "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed" |
334 |
+ |
335 |
+ local -x EPYTHON=python${PYVER} |
336 |
+ # if not using a cross-compiler, use the fresh binary |
337 |
+ if ! tc-is-cross-compiler; then |
338 |
+ local -x PYTHON=./python |
339 |
+ local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD} |
340 |
+ else |
341 |
+ local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON} |
342 |
+ fi |
343 |
+ |
344 |
+ echo "EPYTHON='${EPYTHON}'" > epython.py || die |
345 |
+ python_domodule epython.py |
346 |
+ |
347 |
+ # python-exec wrapping support |
348 |
+ local pymajor=${PYVER%.*} |
349 |
+ local scriptdir=${D}$(python_get_scriptdir) |
350 |
+ mkdir -p "${scriptdir}" || die |
351 |
+ # python and pythonX |
352 |
+ ln -s "../../../bin/${abiver}" \ |
353 |
+ "${scriptdir}/python${pymajor}" || die |
354 |
+ ln -s "python${pymajor}" "${scriptdir}/python" || die |
355 |
+ # python-config and pythonX-config |
356 |
+ # note: we need to create a wrapper rather than symlinking it due |
357 |
+ # to some random dirname(argv[0]) magic performed by python-config |
358 |
+ cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die |
359 |
+ #!/bin/sh |
360 |
+ exec "${abiver}-config" "\${@}" |
361 |
+ EOF |
362 |
+ chmod +x "${scriptdir}/python${pymajor}-config" || die |
363 |
+ ln -s "python${pymajor}-config" \ |
364 |
+ "${scriptdir}/python-config" || die |
365 |
+ # 2to3, pydoc |
366 |
+ ln -s "../../../bin/2to3-${PYVER}" \ |
367 |
+ "${scriptdir}/2to3" || die |
368 |
+ ln -s "../../../bin/pydoc${PYVER}" \ |
369 |
+ "${scriptdir}/pydoc" || die |
370 |
+ # idle |
371 |
+ if use tk; then |
372 |
+ ln -s "../../../bin/idle${PYVER}" \ |
373 |
+ "${scriptdir}/idle" || die |
374 |
+ fi |
375 |
+} |