Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: x11-wm/i3/, x11-wm/i3/files/
Date: Fri, 28 Jul 2017 11:33:23
Message-Id: 1501241592.a3dbdbc5eefa388846591a72ec6a48bfa2db82a9.polynomial-c@gentoo
1 commit: a3dbdbc5eefa388846591a72ec6a48bfa2db82a9
2 Author: Nelo-T. Wallus <nelo <AT> wallus <DOT> de>
3 AuthorDate: Thu Jul 13 19:17:15 2017 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 28 11:33:12 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a3dbdbc5
7
8 x11-wm/i3: Add GLOB_TILDE patch for musl
9
10 Package-Manager: Portage-2.3.6, Repoman-2.3.1
11 Closes: https://github.com/gentoo/gentoo/pull/5230
12
13 x11-wm/i3/files/i3-musl-GLOB_TILDE.patch | 86 ++++++++++++++++++++++++++++++++
14 x11-wm/i3/i3-4.13-r1.ebuild | 1 +
15 x11-wm/i3/i3-9999.ebuild | 6 ++-
16 3 files changed, 92 insertions(+), 1 deletion(-)
17
18 diff --git a/x11-wm/i3/files/i3-musl-GLOB_TILDE.patch b/x11-wm/i3/files/i3-musl-GLOB_TILDE.patch
19 new file mode 100644
20 index 00000000000..d241a748186
21 --- /dev/null
22 +++ b/x11-wm/i3/files/i3-musl-GLOB_TILDE.patch
23 @@ -0,0 +1,86 @@
24 +From: Natanael Copa <ncopa@×××××××××××.org>
25 +Patch-Source: https://git.alpinelinux.org/cgit/aports/tree/community/i3wm/musl.patch
26 +Project-Bug-URL: https://github.com/i3/i3/issues/1859
27 +Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=609306
28 +
29 +Musl doesn't implement GLOB_TILDE, which is used by i3 when expanding paths.
30 +
31 +This patch replaces usage of GLOB_TILDE in glob() by replacing tilde
32 +with the content of $HOME - if set - manually.
33 +
34 +As mentioned in the i3 bugtracker this is an issue that should be solved by musl.
35 +
36 +A patch has been sent to musl upstream, but it hasn't been merged yet:
37 +http://www.openwall.com/lists/musl/2017/01/17/1
38 +---
39 +--- i3-4.11/i3bar/src/main.c
40 ++++ i3-4.11/i3bar/src/main.c
41 +@@ -45,14 +45,20 @@ void debuglog(char *fmt, ...) {
42 + *
43 + */
44 + char *expand_path(char *path) {
45 +- static glob_t globbuf;
46 +- if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0) {
47 +- ELOG("glob() failed\n");
48 +- exit(EXIT_FAILURE);
49 ++ char *home, *expanded;
50 ++
51 ++ if (strncmp(path, "~/", 2) == 0) {
52 ++ home = getenv("HOME");
53 ++ if (home != NULL) {
54 ++ /* new length: sum - 1 (omit '~') + 1 (for '\0') */
55 ++ expanded = scalloc(strlen(home)+strlen(path), 1);
56 ++ strcpy(expanded, home);
57 ++ strcat(expanded, path+1);
58 ++ return expanded;
59 ++ }
60 + }
61 +- char *result = sstrdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path);
62 +- globfree(&globbuf);
63 +- return result;
64 ++
65 ++ return sstrdup(path);
66 + }
67 +
68 + void print_usage(char *elf_name) {
69 +--- i3-4.11/libi3/resolve_tilde.c
70 ++++ i3-4.11/libi3/resolve_tilde.c
71 +@@ -19,27 +19,18 @@
72 + *
73 + */
74 + char *resolve_tilde(const char *path) {
75 +- static glob_t globbuf;
76 +- char *head, *tail, *result;
77 ++ char *home, *expanded;
78 +
79 +- tail = strchr(path, '/');
80 +- head = sstrndup(path, tail ? (size_t)(tail - path) : strlen(path));
81 +-
82 +- int res = glob(head, GLOB_TILDE, NULL, &globbuf);
83 +- free(head);
84 +- /* no match, or many wildcard matches are bad */
85 +- if (res == GLOB_NOMATCH || globbuf.gl_pathc != 1)
86 +- result = sstrdup(path);
87 +- else if (res != 0) {
88 +- err(EXIT_FAILURE, "glob() failed");
89 +- } else {
90 +- head = globbuf.gl_pathv[0];
91 +- result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1, 1);
92 +- strncpy(result, head, strlen(head));
93 +- if (tail)
94 +- strncat(result, tail, strlen(tail));
95 ++ if (strncmp(path, "~/", 2) == 0) {
96 ++ home = getenv("HOME");
97 ++ if (home != NULL) {
98 ++ /* new length: sum - 1 (omit '~') + 1 (for '\0') */
99 ++ expanded = scalloc(strlen(home)+strlen(path), 1);
100 ++ strcpy(expanded, home);
101 ++ strcat(expanded, path+1);
102 ++ return expanded;
103 ++ }
104 + }
105 +- globfree(&globbuf);
106 +
107 +- return result;
108 ++ return sstrdup(path);
109 + }
110
111 diff --git a/x11-wm/i3/i3-4.13-r1.ebuild b/x11-wm/i3/i3-4.13-r1.ebuild
112 index 2311d42860a..047df54a6e2 100644
113 --- a/x11-wm/i3/i3-4.13-r1.ebuild
114 +++ b/x11-wm/i3/i3-4.13-r1.ebuild
115 @@ -38,6 +38,7 @@ RDEPEND="${CDEPEND}
116 DOCS=( RELEASE-NOTES-${PV} )
117 PATCHES=(
118 "${FILESDIR}/${P}-remove-git-polling.patch"
119 + "${FILESDIR}/${PN}-musl-GLOB_TILDE.patch"
120 )
121
122 src_prepare() {
123
124 diff --git a/x11-wm/i3/i3-9999.ebuild b/x11-wm/i3/i3-9999.ebuild
125 index 1e6ce9e0da2..09c27735f9e 100644
126 --- a/x11-wm/i3/i3-9999.ebuild
127 +++ b/x11-wm/i3/i3-9999.ebuild
128 @@ -1,4 +1,4 @@
129 -# Copyright 1999-2016 Gentoo Foundation
130 +# Copyright 1999-2017 Gentoo Foundation
131 # Distributed under the terms of the GNU General Public License v2
132
133 EAPI=6
134 @@ -37,6 +37,10 @@ RDEPEND="${CDEPEND}
135 dev-perl/AnyEvent-I3
136 dev-perl/JSON-XS"
137
138 +PATCHES=(
139 + "${FILESDIR}/${PN}-musl-GLOB_TILDE.patch"
140 +)
141 +
142 src_prepare() {
143 default