1 |
commit: 76eb7a1b115968e0b879a5c00cee64da1cdf92b5 |
2 |
Author: Arsen Arsenović <arsen <AT> aarsen <DOT> me> |
3 |
AuthorDate: Sat Feb 12 22:12:23 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 21 01:51:01 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76eb7a1b |
7 |
|
8 |
sys-apps/coreutils: add $COLORTERM support to 9.0-r2 |
9 |
|
10 |
Package-Manager: Portage-3.0.30, Repoman-3.0.3 |
11 |
Signed-off-by: Arsen Arsenović <arsen <AT> aarsen.me> |
12 |
Closes: https://github.com/gentoo/gentoo/pull/24174 |
13 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
14 |
|
15 |
sys-apps/coreutils/coreutils-9.0-r2.ebuild | 228 +++++++++++++++++++++ |
16 |
...s-consider-COLORTERM-sufficient-for-color.patch | 130 ++++++++++++ |
17 |
2 files changed, 358 insertions(+) |
18 |
|
19 |
diff --git a/sys-apps/coreutils/coreutils-9.0-r2.ebuild b/sys-apps/coreutils/coreutils-9.0-r2.ebuild |
20 |
new file mode 100644 |
21 |
index 000000000000..c8d7eca8e649 |
22 |
--- /dev/null |
23 |
+++ b/sys-apps/coreutils/coreutils-9.0-r2.ebuild |
24 |
@@ -0,0 +1,228 @@ |
25 |
+# Copyright 1999-2022 Gentoo Authors |
26 |
+# Distributed under the terms of the GNU General Public License v2 |
27 |
+ |
28 |
+EAPI=7 |
29 |
+ |
30 |
+PYTHON_COMPAT=( python3_{8..10} ) |
31 |
+ |
32 |
+inherit flag-o-matic python-any-r1 toolchain-funcs |
33 |
+ |
34 |
+PATCH="${PN}-8.30-patches-01" |
35 |
+DESCRIPTION="Standard GNU utilities (chmod, cp, dd, ls, sort, tr, head, wc, who,...)" |
36 |
+HOMEPAGE="https://www.gnu.org/software/coreutils/" |
37 |
+SRC_URI="mirror://gnu/${PN}/${P}.tar.xz |
38 |
+ !vanilla? ( |
39 |
+ mirror://gentoo/${PATCH}.tar.xz |
40 |
+ https://dev.gentoo.org/~polynomial-c/dist/${PATCH}.tar.xz |
41 |
+ )" |
42 |
+ |
43 |
+LICENSE="GPL-3" |
44 |
+SLOT="0" |
45 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x86-linux" |
46 |
+IUSE="acl caps gmp hostname kill multicall nls selinux +split-usr static test vanilla xattr" |
47 |
+RESTRICT="!test? ( test )" |
48 |
+ |
49 |
+LIB_DEPEND="acl? ( sys-apps/acl[static-libs] ) |
50 |
+ caps? ( sys-libs/libcap ) |
51 |
+ gmp? ( dev-libs/gmp:=[static-libs] ) |
52 |
+ xattr? ( sys-apps/attr[static-libs] )" |
53 |
+RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs]} ) |
54 |
+ selinux? ( sys-libs/libselinux ) |
55 |
+ nls? ( virtual/libintl )" |
56 |
+DEPEND=" |
57 |
+ ${RDEPEND} |
58 |
+ static? ( ${LIB_DEPEND} ) |
59 |
+" |
60 |
+BDEPEND=" |
61 |
+ app-arch/xz-utils |
62 |
+ dev-lang/perl |
63 |
+ test? ( |
64 |
+ dev-lang/perl |
65 |
+ dev-perl/Expect |
66 |
+ dev-util/strace |
67 |
+ ${PYTHON_DEPS} |
68 |
+ ) |
69 |
+" |
70 |
+RDEPEND+=" |
71 |
+ hostname? ( !sys-apps/net-tools[hostname] ) |
72 |
+ kill? ( |
73 |
+ !sys-apps/util-linux[kill] |
74 |
+ !sys-process/procps[kill] |
75 |
+ ) |
76 |
+ !app-misc/realpath |
77 |
+ !<sys-apps/util-linux-2.13 |
78 |
+ !<sys-apps/sandbox-2.10-r4 |
79 |
+ !sys-apps/stat |
80 |
+ !net-mail/base64 |
81 |
+ !sys-apps/mktemp |
82 |
+ !<app-forensics/tct-1.18-r1 |
83 |
+ !<net-fs/netatalk-2.0.3-r4" |
84 |
+ |
85 |
+pkg_setup() { |
86 |
+ if use test ; then |
87 |
+ python-any-r1_pkg_setup |
88 |
+ fi |
89 |
+} |
90 |
+ |
91 |
+src_prepare() { |
92 |
+ local PATCHES=( |
93 |
+ # Upstream patches |
94 |
+ "${FILESDIR}"/${P}-fix-chmod-symlink-exit.patch |
95 |
+ ) |
96 |
+ |
97 |
+ if ! use vanilla ; then |
98 |
+ PATCHES+=( "${WORKDIR}"/patch ) |
99 |
+ PATCHES+=( "${FILESDIR}"/${PN}-8.32-sandbox-env-test.patch ) |
100 |
+ PATCHES+=( "${FILESDIR}"/${PN}-9.0-r1-0001-dircolors-consider-COLORTERM-sufficient-for-color.patch ) |
101 |
+ fi |
102 |
+ |
103 |
+ default |
104 |
+ |
105 |
+ # Since we've patched many .c files, the make process will try to |
106 |
+ # re-build the manpages by running `./bin --help`. When doing a |
107 |
+ # cross-compile, we can't do that since 'bin' isn't a native bin. |
108 |
+ # |
109 |
+ # Also, it's not like we changed the usage on any of these things, |
110 |
+ # so let's just update the timestamps and skip the help2man step. |
111 |
+ set -- man/*.x |
112 |
+ touch ${@/%x/1} || die |
113 |
+ |
114 |
+ # Avoid perl dep for compiled in dircolors default (bug #348642) |
115 |
+ if ! has_version dev-lang/perl ; then |
116 |
+ touch src/dircolors.h || die |
117 |
+ touch ${@/%x/1} || die |
118 |
+ fi |
119 |
+} |
120 |
+ |
121 |
+src_configure() { |
122 |
+ local myconf=( |
123 |
+ --with-packager="Gentoo" |
124 |
+ --with-packager-version="${PVR} (p${PATCH_VER:-0})" |
125 |
+ --with-packager-bug-reports="https://bugs.gentoo.org/" |
126 |
+ # kill/uptime - procps |
127 |
+ # groups/su - shadow |
128 |
+ # hostname - net-tools |
129 |
+ --enable-install-program="arch,$(usev hostname),$(usev kill)" |
130 |
+ --enable-no-install-program="groups,$(usev !hostname),$(usev !kill),su,uptime" |
131 |
+ --enable-largefile |
132 |
+ $(usex caps '' --disable-libcap) |
133 |
+ $(use_enable nls) |
134 |
+ $(use_enable acl) |
135 |
+ $(use_enable multicall single-binary) |
136 |
+ $(use_enable xattr) |
137 |
+ $(use_with gmp libgmp) |
138 |
+ ) |
139 |
+ |
140 |
+ if use gmp ; then |
141 |
+ myconf+=( --with-libgmp-prefix="${ESYSROOT}"/usr ) |
142 |
+ fi |
143 |
+ |
144 |
+ if tc-is-cross-compiler && [[ ${CHOST} == *linux* ]] ; then |
145 |
+ # bug #311569 |
146 |
+ export fu_cv_sys_stat_statfs2_bsize=yes |
147 |
+ # bug #416629 |
148 |
+ export gl_cv_func_realpath_works=yes |
149 |
+ fi |
150 |
+ |
151 |
+ # bug #409919 |
152 |
+ export gl_cv_func_mknod_works=yes |
153 |
+ |
154 |
+ if use static ; then |
155 |
+ append-ldflags -static |
156 |
+ # bug #321821 |
157 |
+ sed -i '/elf_sys=yes/s:yes:no:' configure || die |
158 |
+ fi |
159 |
+ |
160 |
+ if ! use selinux ; then |
161 |
+ # bug #301782 |
162 |
+ export ac_cv_{header_selinux_{context,flash,selinux}_h,search_setfilecon}=no |
163 |
+ fi |
164 |
+ |
165 |
+ econf "${myconf[@]}" |
166 |
+} |
167 |
+ |
168 |
+src_test() { |
169 |
+ # Known to fail with FEATURES=usersandbox (bug #439574): |
170 |
+ # - tests/du/long-from-unreadable.sh} (bug #413621) |
171 |
+ # - tests/rm/deep-2.sh (bug #413621) |
172 |
+ # - tests/dd/no-allocate.sh (bug #629660) |
173 |
+ if has usersandbox ${FEATURES} ; then |
174 |
+ ewarn "You are emerging ${P} with 'usersandbox' enabled." \ |
175 |
+ "Expect some test failures or emerge with 'FEATURES=-usersandbox'!" |
176 |
+ fi |
177 |
+ |
178 |
+ # Non-root tests will fail if the full path isn't |
179 |
+ # accessible to non-root users |
180 |
+ chmod -R go-w "${WORKDIR}" || die |
181 |
+ chmod a+rx "${WORKDIR}" || die |
182 |
+ |
183 |
+ # coreutils tests like to do `mount` and such with temp dirs, |
184 |
+ # so make sure: |
185 |
+ # - /etc/mtab is writable (bug #265725) |
186 |
+ # - /dev/loop* can be mounted (bug #269758) |
187 |
+ mkdir -p "${T}"/mount-wrappers || die |
188 |
+ mkwrap() { |
189 |
+ local w ww |
190 |
+ for w in "${@}" ; do |
191 |
+ ww="${T}/mount-wrappers/${w}" |
192 |
+ cat <<-EOF > "${ww}" |
193 |
+ #!${EPREFIX}/bin/sh |
194 |
+ exec env SANDBOX_WRITE="\${SANDBOX_WRITE}:/etc/mtab:/dev/loop" $(type -P ${w}) "\$@" |
195 |
+ EOF |
196 |
+ chmod a+rx "${ww}" || die |
197 |
+ done |
198 |
+ } |
199 |
+ mkwrap mount umount |
200 |
+ |
201 |
+ addwrite /dev/full |
202 |
+ #export RUN_EXPENSIVE_TESTS="yes" |
203 |
+ #export FETISH_GROUPS="portage wheel" |
204 |
+ env PATH="${T}/mount-wrappers:${PATH}" \ |
205 |
+ emake -j1 -k check |
206 |
+} |
207 |
+ |
208 |
+src_install() { |
209 |
+ default |
210 |
+ |
211 |
+ insinto /etc |
212 |
+ newins src/dircolors.hin DIR_COLORS |
213 |
+ |
214 |
+ if use split-usr ; then |
215 |
+ cd "${ED}"/usr/bin || die |
216 |
+ dodir /bin |
217 |
+ |
218 |
+ # Move critical binaries into /bin (required by FHS) |
219 |
+ local fhs="cat chgrp chmod chown cp date dd df echo false ln ls |
220 |
+ mkdir mknod mv pwd rm rmdir stty sync true uname" |
221 |
+ mv ${fhs} ../../bin/ || die "Could not move FHS bins!" |
222 |
+ |
223 |
+ if use hostname ; then |
224 |
+ mv hostname ../../bin/ || die |
225 |
+ fi |
226 |
+ |
227 |
+ if use kill ; then |
228 |
+ mv kill ../../bin/ || die |
229 |
+ fi |
230 |
+ |
231 |
+ # Move critical binaries into /bin (common scripts) |
232 |
+ # (Why are these required for booting?) |
233 |
+ local com="basename chroot cut dir dirname du env expr head mkfifo |
234 |
+ mktemp readlink seq sleep sort tail touch tr tty vdir wc yes" |
235 |
+ mv ${com} ../../bin/ || die "Could not move common bins!" |
236 |
+ |
237 |
+ # Create a symlink for uname in /usr/bin/ since autotools require it. |
238 |
+ # (Other than uname, we need to figure out why we are |
239 |
+ # creating symlinks for these in /usr/bin instead of leaving |
240 |
+ # the files there in the first place...) |
241 |
+ local x |
242 |
+ for x in ${com} uname ; do |
243 |
+ dosym ../../bin/${x} /usr/bin/${x} |
244 |
+ done |
245 |
+ fi |
246 |
+} |
247 |
+ |
248 |
+pkg_postinst() { |
249 |
+ ewarn "Make sure you run 'hash -r' in your active shells." |
250 |
+ ewarn "You should also re-source your shell settings for LS_COLORS" |
251 |
+ ewarn " changes, such as: source /etc/profile" |
252 |
+} |
253 |
|
254 |
diff --git a/sys-apps/coreutils/files/coreutils-9.0-r1-0001-dircolors-consider-COLORTERM-sufficient-for-color.patch b/sys-apps/coreutils/files/coreutils-9.0-r1-0001-dircolors-consider-COLORTERM-sufficient-for-color.patch |
255 |
new file mode 100644 |
256 |
index 000000000000..e77766cbfe3a |
257 |
--- /dev/null |
258 |
+++ b/sys-apps/coreutils/files/coreutils-9.0-r1-0001-dircolors-consider-COLORTERM-sufficient-for-color.patch |
259 |
@@ -0,0 +1,130 @@ |
260 |
+From cbb451b63faee375415691c1abc8a6fd3e1677a9 Mon Sep 17 00:00:00 2001 |
261 |
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@××××××××××.com> |
262 |
+Date: Sat, 12 Feb 2022 22:54:07 +0100 |
263 |
+Subject: [PATCH] dircolors: consider COLORTERM as well as TERM env vars |
264 |
+ |
265 |
+COLORTERM is an environment used usually to expose truecolor support in |
266 |
+terminal emulators. Therefore support matches on that in addition |
267 |
+to TERM. Also set the default COLORTERM match pattern so that |
268 |
+we apply colors if COLORTERM is any value. |
269 |
+ |
270 |
+This implicitly supports a terminal like "foot" |
271 |
+without a need for an explicit TERM entry. |
272 |
+ |
273 |
+* NEWS: Mention the new feature. |
274 |
+* src/dircolors.c (main): Match COLORTERM like we do for TERM. |
275 |
+* src/dircolors.hin: Add default config to match any COLORTERM. |
276 |
+* tests/misc/dircolors.pl: Add test cases. |
277 |
+--- |
278 |
+Backported from coreutils 75c9fc6740e93dba95f63a1e5e92bd5cf17f1743. |
279 |
+See also https://lists.gnu.org/archive/html/coreutils/2022-02/msg00019.html |
280 |
+ |
281 |
+ NEWS | 3 +++ |
282 |
+ src/dircolors.c | 15 ++++++++++++++- |
283 |
+ src/dircolors.hin | 7 +++++-- |
284 |
+ tests/misc/dircolors.pl | 14 ++++++++++++++ |
285 |
+ 4 files changed, 36 insertions(+), 3 deletions(-) |
286 |
+ |
287 |
+diff --git a/NEWS b/NEWS |
288 |
+index f2fbcbb..646c132 100644 |
289 |
+--- a/NEWS |
290 |
++++ b/NEWS |
291 |
+@@ -64,6 +64,9 @@ GNU coreutils NEWS -*- outline -*- |
292 |
+ on (1024*5) buffer boundaries |
293 |
+ [bug introduced in coreutils-8.31] |
294 |
+ |
295 |
++ dircolors will now also match COLORTERM in addition to TERM environment |
296 |
++ variables. The default config will apply colors with any COLORTERM set. |
297 |
++ |
298 |
+ ** Changes in behavior |
299 |
+ |
300 |
+ cp and install now default to copy-on-write (COW) if available. |
301 |
+diff --git a/src/dircolors.c b/src/dircolors.c |
302 |
+index b765ded..64ff665 100644 |
303 |
+--- a/src/dircolors.c |
304 |
++++ b/src/dircolors.c |
305 |
+@@ -243,6 +243,7 @@ dc_parse_stream (FILE *fp, char const *filename) |
306 |
+ size_t input_line_size = 0; |
307 |
+ char const *line; |
308 |
+ char const *term; |
309 |
++ char const *colorterm; |
310 |
+ bool ok = true; |
311 |
+ |
312 |
+ /* State for the parser. */ |
313 |
+@@ -253,6 +254,11 @@ dc_parse_stream (FILE *fp, char const *filename) |
314 |
+ if (term == NULL || *term == '\0') |
315 |
+ term = "none"; |
316 |
+ |
317 |
++ /* Also match $COLORTERM. */ |
318 |
++ colorterm = getenv ("COLORTERM"); |
319 |
++ if (colorterm == NULL) |
320 |
++ colorterm = ""; /* Doesn't match default "?*" */ |
321 |
++ |
322 |
+ while (true) |
323 |
+ { |
324 |
+ char *keywd, *arg; |
325 |
+@@ -299,10 +305,17 @@ dc_parse_stream (FILE *fp, char const *filename) |
326 |
+ else if (state != ST_TERMSURE) |
327 |
+ state = ST_TERMNO; |
328 |
+ } |
329 |
++ else if (c_strcasecmp (keywd, "COLORTERM") == 0) |
330 |
++ { |
331 |
++ if (fnmatch (arg, colorterm, 0) == 0) |
332 |
++ state = ST_TERMSURE; |
333 |
++ else if (state != ST_TERMSURE) |
334 |
++ state = ST_TERMNO; |
335 |
++ } |
336 |
+ else |
337 |
+ { |
338 |
+ if (state == ST_TERMSURE) |
339 |
+- state = ST_TERMYES; /* Another TERM can cancel */ |
340 |
++ state = ST_TERMYES; /* Another {COLOR,}TERM can cancel. */ |
341 |
+ |
342 |
+ if (state != ST_TERMNO) |
343 |
+ { |
344 |
+diff --git a/src/dircolors.hin b/src/dircolors.hin |
345 |
+index b5d6452..6d2d3a4 100644 |
346 |
+--- a/src/dircolors.hin |
347 |
++++ b/src/dircolors.hin |
348 |
+@@ -8,8 +8,11 @@ |
349 |
+ # The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the |
350 |
+ # slackware version of dircolors) are recognized but ignored. |
351 |
+ |
352 |
+-# Below are TERM entries, which can be a glob patterns, to match |
353 |
+-# against the TERM environment variable to determine if it is colorizable. |
354 |
++# Global config options can be specified before TERM or COLORTERM entries |
355 |
++ |
356 |
++# Below are TERM or COLORTERM entries, which can be glob patterns, which |
357 |
++# restrict following config to systems with matching environment variables. |
358 |
++COLORTERM ?* |
359 |
+ TERM Eterm |
360 |
+ TERM ansi |
361 |
+ TERM *color* |
362 |
+diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl |
363 |
+index 2c57104..464acfd 100755 |
364 |
+--- a/tests/misc/dircolors.pl |
365 |
++++ b/tests/misc/dircolors.pl |
366 |
+@@ -42,6 +42,20 @@ my @Tests = |
367 |
+ ['term-4', '-b', {IN => "TERM N*match\nowt 40;33\n"}, |
368 |
+ {OUT => "LS_COLORS='';\nexport LS_COLORS\n"}], |
369 |
+ |
370 |
++ ['print-clash1', '-p', '--print-ls', |
371 |
++ {ERR => "dircolors: options --print-database and --print-ls-colors " . |
372 |
++ "are mutually exclusive\n" . |
373 |
++ "Try 'dircolors --help' for more information.\n"}, |
374 |
++ {EXIT => 1}], |
375 |
++ ['print-clash2', '-b', '--print-database', |
376 |
++ {ERR => "dircolors: the options to output non shell syntax,\n" . |
377 |
++ "and to select a shell syntax are mutually exclusive\n" . |
378 |
++ "Try 'dircolors --help' for more information.\n"}, |
379 |
++ {EXIT => 1}], |
380 |
++ |
381 |
++ ['print-ls-colors', '--print-ls-colors', {IN => "OWT 40;33\n"}, |
382 |
++ {OUT => "\x1B[40;33mtw\t40;33\x1B[0m\n"}], |
383 |
++ |
384 |
+ # CAREFUL: always specify the -b option, unless explicitly testing |
385 |
+ # for csh syntax output. |
386 |
+ ); |
387 |
+-- |
388 |
+2.34.1 |
389 |
+ |