Gentoo Archives: gentoo-commits

From: James Le Cuirot <chewi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/ncurses/
Date: Thu, 29 Dec 2022 16:17:20
Message-Id: 1672330594.11f4e009bbb74ea06be8c9e78127be4505217c51.chewi@gentoo
1 commit: 11f4e009bbb74ea06be8c9e78127be4505217c51
2 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 29 15:30:09 2022 +0000
4 Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 29 16:16:34 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=11f4e009
7
8 sys-libs/ncurses: Fix leaking of cross toolchain into native build
9
10 If you had overridden CXX or CPP for a cross build, to use Clang for example,
11 the native build would have erroneously used these. It didn't seem to break the
12 build, but it did at least emit some scary warnings.
13
14 Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
15
16 sys-libs/ncurses/ncurses-6.3_p20221203-r1.ebuild | 488 +++++++++++++++++++++++
17 1 file changed, 488 insertions(+)
18
19 diff --git a/sys-libs/ncurses/ncurses-6.3_p20221203-r1.ebuild b/sys-libs/ncurses/ncurses-6.3_p20221203-r1.ebuild
20 new file mode 100644
21 index 000000000000..a6358a7b4821
22 --- /dev/null
23 +++ b/sys-libs/ncurses/ncurses-6.3_p20221203-r1.ebuild
24 @@ -0,0 +1,488 @@
25 +# Copyright 1999-2022 Gentoo Authors
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI=7
29 +
30 +VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/thomasdickey.asc
31 +inherit flag-o-matic toolchain-funcs multilib-minimal preserve-libs usr-ldscript verify-sig
32 +
33 +MY_PV="${PV:0:3}"
34 +MY_P="${PN}-${MY_PV}"
35 +DESCRIPTION="Console display library"
36 +HOMEPAGE="https://www.gnu.org/software/ncurses/ https://invisible-island.net/ncurses/"
37 +# Keep invisible-mirror.net here as some users reported 403 forbidden with invisible-island.net
38 +SRC_URI="
39 + mirror://gnu/ncurses/${MY_P}.tar.gz
40 + https://invisible-island.net/archives/${PN}/${MY_P}.tar.gz
41 + https://invisible-mirror.net/archives/${PN}/${MY_P}.tar.gz
42 + verify-sig? ( mirror://gnu/ncurses/${MY_P}.tar.gz.sig )
43 +"
44 +
45 +GENTOO_PATCH_DEV=sam
46 +GENTOO_PATCH_PV=6.3_p20221203
47 +GENTOO_PATCH_NAME=${PN}-${GENTOO_PATCH_PV}-patches
48 +
49 +# Populated below in a loop. Do not add patches manually here.
50 +UPSTREAM_PATCHES=()
51 +
52 +if [[ ${PV} == *_p* ]] ; then
53 + # Sometimes, after releases, there's no megapatch available yet.
54 + #
55 + # From upstream README at e.g. https://invisible-island.net/archives/ncurses/6.3/:
56 + #
57 + # "At times (generally to mark a relatively stable point), I create a rollup
58 + # patch, which consists of all changes from the release through the current date."
59 + #
60 + # Also, from https://lists.gnu.org/archive/html/bug-ncurses/2019-08/msg00039.html,
61 + # the patches are considered to be acceptable to use after some testing. They
62 + # are both for development but also bug fixes.
63 + #
64 + # This array should contain a list of all the snapshots since the last
65 + # release if there's no megapatch available yet.
66 + PATCH_DATES=(
67 + 20211026
68 + 20211030
69 + 20211106
70 + 20211113
71 + 20211115
72 + 20211120
73 + 20211127
74 + 20211204
75 + 20211211
76 + 20211219
77 + 20211225
78 + 20220101
79 + 20220115
80 + 20220122
81 + 20220129
82 + 20220205
83 + 20220212
84 + 20220219
85 + 20220226
86 + 20220305
87 + 20220312
88 + 20220319
89 + 20220326
90 + 20220402
91 + 20220409
92 + 20220416
93 + 20220423
94 + 20220430
95 + 20220501
96 + 20220507
97 + 20220514
98 + 20220521
99 + 20220529
100 + 20220604
101 + 20220612
102 + 20220618
103 + 20220625
104 + 20220703
105 + 20220709
106 + 20220716
107 + 20220724
108 + 20220729
109 + 20220806
110 + 20220813
111 + 20220820
112 + 20220827
113 + 20220903
114 + 20220910
115 + 20220917
116 + 20220924
117 + 20221001
118 + 20221008
119 + 20221015
120 + 20221023
121 + 20221029
122 + 20221105
123 + 20221112
124 + 20221119
125 + 20221126
126 +
127 + # Latest patch is just _pN = $(ver_cut 4)
128 + $(ver_cut 4)
129 + )
130 +
131 + if [[ -z ${PATCH_DATES[@]} ]] ; then
132 + SRC_URI+=" https://invisible-island.net/archives/${PN}/${PV/_p*}/${P/_p/-}.patch.sh.gz"
133 + SRC_URI+=" verify-sig? ( https://invisible-island.net/archives/${PN}/${PV/_p*}/${P/_p/-}.patch.sh.gz.asc"
134 +
135 + # If we have a rollup patch, use that instead of the individual ones.
136 + UPSTREAM_PATCHES+=( "${WORKDIR}"/${P/_p/-}-patch.sh )
137 + else
138 + patch_url=
139 + my_patch_index=
140 +
141 + # We keep a bunch of mirrors here as we've had reports of invisible*.net
142 + # being 403 forbidden for some users.
143 + urls=(
144 + "https://invisible-island.net/archives/${PN}/${PV/_p*}/${MY_P}-%s"
145 + "https://invisible-mirror.net/archives/${PN}/${PV/_p*}/${MY_P}-%s"
146 + "https://dev.gentoo.org/~${GENTOO_PATCH_DEV}/distfiles/${CATEGORY}/${PN}/${MY_P}-%s"
147 + )
148 +
149 + for ((my_patch_index=0; my_patch_index < "${#PATCH_DATES[@]}"; my_patch_index++)); do
150 + for url in "${urls[@]}" ; do
151 + patch_url="$(printf ${urls} ${PATCH_DATES[${my_patch_index}]}.patch.gz)"
152 + SRC_URI+=" ${patch_url}"
153 + SRC_URI+=" verify-sig? ( ${patch_url}.asc )"
154 + done
155 +
156 + UPSTREAM_PATCHES+=( "${WORKDIR}"/${MY_P}-${PATCH_DATES[${my_patch_index}]}.patch )
157 + done
158 +
159 + unset patch_url
160 + unset my_patch_index
161 + unset urls
162 + fi
163 +
164 + SRC_URI+=" https://dev.gentoo.org/~${GENTOO_PATCH_DEV}/distfiles/${CATEGORY}/${PN}/${GENTOO_PATCH_NAME}.tar.xz"
165 +fi
166 +
167 +LICENSE="MIT"
168 +# The subslot reflects the SONAME.
169 +SLOT="0/6"
170 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
171 +IUSE="ada +cxx debug doc gpm minimal profile split-usr +stack-realign static-libs test tinfo trace"
172 +RESTRICT="!test? ( test )"
173 +
174 +DEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )"
175 +# Block the older ncurses that installed all files w/SLOT=5, bug #557472
176 +RDEPEND="${DEPEND}
177 + !<=sys-libs/ncurses-5.9-r4:5
178 + !<sys-libs/slang-2.3.2_pre23
179 + !<x11-terms/rxvt-unicode-9.06-r3
180 + !<x11-terms/st-0.6-r1"
181 +BDEPEND="verify-sig? ( sec-keys/openpgp-keys-thomasdickey )"
182 +
183 +S="${WORKDIR}/${MY_P}"
184 +
185 +PATCHES=(
186 + "${UPSTREAM_PATCHES[@]}"
187 +
188 + # When rebasing Gentoo's patchset, please use git from a clean
189 + # src_prepare with upstream patches already applied. git am --reject
190 + # the existing patchset and rebase as required. This makes it easier
191 + # to manage future rebasing & adding new patches.
192 + #
193 + # For the same reasons, please include the original configure.in changes,
194 + # NOT just the generated results!
195 + "${WORKDIR}"/${GENTOO_PATCH_NAME}
196 +)
197 +
198 +src_unpack() {
199 + # Avoid trying to verify our own patchset tarball, there's no point
200 + if use verify-sig ; then
201 + local file
202 + for file in ${A} ; do
203 + if [[ ${file} == ${MY_P}.tar.gz ]] ; then
204 + verify-sig_verify_detached "${DISTDIR}"/${file} "${DISTDIR}"/${file}.sig
205 + else
206 + [[ ${file} == @(*${GENTOO_PATCH_NAME}.tar.xz|*.asc|*.sig) ]] && continue
207 +
208 + verify-sig_verify_detached "${DISTDIR}"/${file} "${DISTDIR}"/${file}.asc
209 + fi
210 + done
211 + fi
212 +
213 + default
214 +}
215 +
216 +src_configure() {
217 + # bug #115036
218 + unset TERMINFO
219 +
220 + tc-export_build_env BUILD_{CC,CXX,CPP}
221 +
222 + # bug #214642
223 + BUILD_CPPFLAGS+=" -D_GNU_SOURCE"
224 +
225 + # Build the various variants of ncurses -- narrow, wide, and threaded. #510440
226 + # Order matters here -- we want unicode/thread versions to come last so that the
227 + # binaries in /usr/bin support both wide and narrow.
228 + # The naming is also important as we use these directly with filenames and when
229 + # checking configure flags.
230 + NCURSES_TARGETS=(
231 + ncurses
232 + ncursesw
233 + ncursest
234 + ncursestw
235 + )
236 +
237 + # When installing ncurses, we have to use a compatible version of tic.
238 + # This comes up when cross-compiling, doing multilib builds, upgrading,
239 + # or installing for the first time. Build a local copy of tic whenever
240 + # the host version isn't available. bug #249363, bug #557598
241 + if ! has_version -b "~sys-libs/${P}:0" ; then
242 + local lbuildflags="-static"
243 +
244 + # some toolchains don't quite support static linking
245 + local dbuildflags="-Wl,-rpath,${WORKDIR}/lib"
246 + case ${CHOST} in
247 + *-darwin*) dbuildflags= ;;
248 + *-solaris*) dbuildflags="-Wl,-R,${WORKDIR}/lib" ;;
249 + esac
250 + echo "int main() {}" | \
251 + $(tc-getCC) -o x -x c - ${lbuildflags} -pipe >& /dev/null \
252 + || lbuildflags="${dbuildflags}"
253 +
254 + # We can't re-use the multilib BUILD_DIR because we run outside of it.
255 + BUILD_DIR="${WORKDIR}" \
256 + CC=${BUILD_CC} \
257 + CXX=${BUILD_CXX} \
258 + CPP=${BUILD_CPP} \
259 + CHOST=${CBUILD} \
260 + CFLAGS=${BUILD_CFLAGS} \
261 + CXXFLAGS=${BUILD_CXXFLAGS} \
262 + CPPFLAGS=${BUILD_CPPFLAGS} \
263 + LDFLAGS="${BUILD_LDFLAGS} ${lbuildflags}" \
264 + do_configure cross --without-shared --with-normal --with-progs
265 + fi
266 + multilib-minimal_src_configure
267 +}
268 +
269 +multilib_src_configure() {
270 + if [[ ${ABI} == x86 ]] ; then
271 + # For compatibility with older binaries at slight performance cost.
272 + # bug #616402
273 + use stack-realign && append-flags -mstackrealign
274 + fi
275 +
276 + local t
277 + for t in "${NCURSES_TARGETS[@]}" ; do
278 + do_configure "${t}"
279 + done
280 +}
281 +
282 +do_configure() {
283 + local target=$1
284 + shift
285 +
286 + mkdir "${BUILD_DIR}/${target}" || die
287 + cd "${BUILD_DIR}/${target}" || die
288 +
289 + # https://lists.gnu.org/archive/html/bug-ncurses/2022-09/msg00024.html
290 + export EGREP="grep -E"
291 + export FGREP="grep -F"
292 +
293 + local conf=(
294 + # We need the basic terminfo files in /etc, bug #37026. We will
295 + # add '--with-terminfo-dirs' and then populate /etc/terminfo in
296 + # src_install() ...
297 + --with-terminfo-dirs="${EPREFIX}/etc/terminfo:${EPREFIX}/usr/share/terminfo"
298 +
299 + # Enable installation of .pc files.
300 + --enable-pc-files
301 + # This path is used to control where the .pc files are installed.
302 + --with-pkg-config-libdir="${EPREFIX}/usr/$(get_libdir)/pkgconfig"
303 +
304 + # Now the rest of the various standard flags.
305 + --with-shared
306 + # (Originally disabled until bug #245417 is sorted out, but now
307 + # just keeping it off for good, given nobody needed it until now
308 + # (2022) and we're trying to phase out bdb.)
309 + --without-hashed-db
310 + $(use_with ada)
311 + $(use_with cxx)
312 + $(use_with cxx cxx-binding)
313 + --with-cxx-shared
314 + $(use_with debug)
315 + $(use_with profile)
316 + # The configure script uses ldd to parse the linked output which
317 + # is flaky for cross-compiling/multilib/ldd versions/etc...
318 + $(use_with gpm gpm libgpm.so.1)
319 + # Required for building on mingw-w64, and possibly other windows
320 + # platforms, bug #639670
321 + $(use_enable kernel_Winnt term-driver)
322 + --disable-termcap
323 + --enable-symlinks
324 + --with-rcs-ids
325 + --with-manpage-format=normal
326 + --enable-const
327 + --enable-colorfgbg
328 + --enable-hard-tabs
329 + --enable-echo
330 + $(use_enable !ada warnings)
331 + $(use_with debug assertions)
332 + $(use_enable !debug leaks)
333 + $(use_with debug expanded)
334 + $(use_with !debug macros)
335 + $(multilib_native_with progs)
336 + $(use_with test tests)
337 + $(use_with trace)
338 + $(use_with tinfo termlib)
339 + --disable-stripping
340 + --disable-pkg-ldflags
341 + )
342 +
343 + if [[ ${target} == ncurses*w ]] ; then
344 + conf+=( --enable-widec )
345 + else
346 + conf+=( --disable-widec )
347 + fi
348 + if [[ ${target} == ncursest* ]] ; then
349 + conf+=( --with-{pthread,reentrant} )
350 + else
351 + conf+=( --without-{pthread,reentrant} )
352 + fi
353 +
354 + # Make sure each variant goes in a unique location.
355 + if [[ ${target} == "ncurses" ]] ; then
356 + # "ncurses" variant goes into "${EPREFIX}"/usr/include
357 + # It is needed on Prefix because the configure script appends
358 + # "ncurses" to "${prefix}/include" if "${prefix}" is not /usr.
359 + conf+=( --enable-overwrite )
360 + else
361 + conf+=( --includedir="${EPREFIX}"/usr/include/${target} )
362 + fi
363 + # See comments in src_configure.
364 + if [[ ${target} != "cross" ]] ; then
365 + local cross_path="${WORKDIR}/cross"
366 + [[ -d ${cross_path} ]] && export TIC_PATH="${cross_path}/progs/tic"
367 + fi
368 +
369 + ECONF_SOURCE="${S}" econf "${conf[@]}" "$@"
370 +}
371 +
372 +src_compile() {
373 + # See comments in src_configure.
374 + if ! has_version -b "~sys-libs/${P}:0" ; then
375 + # We could possibly merge these two branches but opting to be
376 + # conservative when merging some of the Prefix changes.
377 +
378 + if [[ ${CHOST} == *-cygwin* ]] && ! multilib_is_native_abi ; then
379 + # We make 'tic$(x)' here, for Cygwin having x=".exe".
380 + BUILD_DIR="${WORKDIR}" \
381 + do_compile cross -C progs all PROGS='tic$(x)'
382 + else
383 + BUILD_DIR="${WORKDIR}" \
384 + do_compile cross -C progs tic
385 + fi
386 + fi
387 +
388 + multilib-minimal_src_compile
389 +}
390 +
391 +multilib_src_compile() {
392 + local t
393 + for t in "${NCURSES_TARGETS[@]}" ; do
394 + do_compile "${t}"
395 + done
396 +}
397 +
398 +do_compile() {
399 + local target=$1
400 + shift
401 +
402 + cd "${BUILD_DIR}/${target}" || die
403 +
404 + # A little hack to fix parallel builds ... they break when
405 + # generating sources so if we generate the sources first (in
406 + # non-parallel), we can then build the rest of the package
407 + # in parallel. This is not really a perf hit since the source
408 + # generation is quite small.
409 + emake -j1 sources
410 +
411 + # For some reason, sources depends on pc-files which depends on
412 + # compiled libraries which depends on sources which ...
413 + # Manually delete the pc-files file so the install step will
414 + # create the .pc files we want.
415 + rm -f misc/pc-files || die
416 + emake "$@"
417 +}
418 +
419 +multilib_src_install() {
420 + local target
421 + for target in "${NCURSES_TARGETS[@]}" ; do
422 + emake -C "${BUILD_DIR}/${target}" DESTDIR="${D}" install
423 + done
424 +
425 + # Move main libraries into /.
426 + if multilib_is_native_abi ; then
427 + gen_usr_ldscript -a \
428 + "${NCURSES_TARGETS[@]}" \
429 + $(usex tinfo 'tinfow tinfo' '')
430 + fi
431 +
432 + # Don't delete '*.dll.a', needed for linking, bug #631468
433 + if ! use static-libs; then
434 + find "${ED}"/usr/ -name '*.a' ! -name '*.dll.a' -delete || die
435 + fi
436 +
437 + # Build fails to create this ...
438 + # -FIXME-
439 + # Ugly hackaround for riscv having two parts libdir (bug #689240)
440 + # Replace this hack with an official solution once we have one...
441 + # -FIXME-
442 + dosym $(sed 's@[^/]\+@..@g' <<< $(get_libdir))/share/terminfo \
443 + /usr/$(get_libdir)/terminfo
444 +
445 + # Remove obsolete libcurses symlink that is created by the build
446 + # system. Technically, this could be also achieved
447 + # via --disable-overwrite but it also moves headers implicitly,
448 + # and we do not want to do this yet.
449 + # bug #836696
450 + rm "${ED}"/usr/$(get_libdir)/libcurses* || die
451 +}
452 +
453 +multilib_src_install_all() {
454 + local terms=(
455 + # Dumb/simple values that show up when using the in-kernel VT.
456 + ansi console dumb linux
457 + vt{52,100,102,200,220}
458 + # [u]rxvt users used to be pretty common. Probably should drop this
459 + # since upstream is dead and people are moving away from it.
460 + rxvt{,-unicode}{,-256color}
461 + # xterm users are common, as is terminals re-using/spoofing it.
462 + xterm xterm-{,256}color
463 + # screen is common (and reused by tmux).
464 + screen{,-256color}
465 + screen.xterm-256color
466 + )
467 + if use split-usr ; then
468 + local x
469 + # We need the basic terminfo files in /etc for embedded/recovery, bug #37026
470 + einfo "Installing basic terminfo files in /etc..."
471 + for x in "${terms[@]}"; do
472 + local termfile=$(find "${ED}"/usr/share/terminfo/ -name "${x}" 2>/dev/null)
473 + local basedir=$(basename "$(dirname "${termfile}")")
474 +
475 + if [[ -n ${termfile} ]] ; then
476 + dodir "/etc/terminfo/${basedir}"
477 + mv "${termfile}" "${ED}/etc/terminfo/${basedir}/" || die
478 + dosym "../../../../etc/terminfo/${basedir}/${x}" \
479 + "/usr/share/terminfo/${basedir}/${x}"
480 + fi
481 + done
482 +
483 + echo "CONFIG_PROTECT_MASK=\"/etc/terminfo\"" | newenvd - 50ncurses
484 +
485 + use minimal && rm -r "${ED}"/usr/share/terminfo*
486 + # Because ncurses5-config --terminfo returns the directory we keep it
487 + # bug #245374
488 + keepdir /usr/share/terminfo
489 + elif use minimal ; then
490 + # Keep only the basic terminfo files
491 + find "${ED}"/usr/share/terminfo/ \
492 + -type f ${terms[*]/#/! -name } -delete , \
493 + -type d -empty -delete || die
494 + fi
495 +
496 + cd "${S}" || die
497 + dodoc ANNOUNCE MANIFEST NEWS README* TO-DO doc/*.doc
498 + if use doc ; then
499 + docinto html
500 + dodoc -r doc/html/
501 + fi
502 +}
503 +
504 +pkg_preinst() {
505 + preserve_old_lib /$(get_libdir)/libncurses.so.5
506 + preserve_old_lib /$(get_libdir)/libncursesw.so.5
507 +}
508 +
509 +pkg_postinst() {
510 + preserve_old_lib_notify /$(get_libdir)/libncurses.so.5
511 + preserve_old_lib_notify /$(get_libdir)/libncursesw.so.5
512 +}