1 |
Hi, Gentoo-Dev. |
2 |
|
3 |
A while ago, I had a bit of a rant on Gentoo-User regarding the current issues |
4 |
with `app-portage/euses`. Specifically, the fact that it does not work on newer |
5 |
Gentoo-like systems which have moved away from PORTDIR and conform to the |
6 |
repos.conf/ syntax [1, 2, 3]. There are also some bugs/issues in the code, such |
7 |
as malloc(3)'ing without checking the result, et cetera. |
8 |
|
9 |
Over the past month or so, I've completed a ground-up rewrite which provides a |
10 |
similar interface and functionality, that remedies all of these issues, and adds |
11 |
a few useful features on top; it is also written in standard C with no |
12 |
dependencies other than the standard library. In addition to processing all the |
13 |
repositories described in the repos.conf directory, it is also written to be |
14 |
remarkably robust, optionally working from the PORTDIR make.conf key-value pair |
15 |
or environment variable for legacy systems. (As an initial user pointed out, |
16 |
make.conf cannot be used if it is a directory, and will only touched at all if |
17 |
the legacy option is enabled and the $PORTDIR environment variable is unset or |
18 |
infeasible.) |
19 |
|
20 |
Almost all of the features from the original euses tool are present, with extras |
21 |
to facilitate multi-repo searching (in the rare event that a non-Gentoo.git |
22 |
repository has USE-description files). From my testing, it is equally, if not |
23 |
more, performant than the original tool, despite the extra work of traversing |
24 |
the meta-repository description files. A copy of the help page is included here, |
25 |
for convenience (run with the `-h` or `--help` option): |
26 |
|
27 |
ash-euses command-line argument summary. |
28 |
Syntax: ./ash-euses [options] substrings |
29 |
|
30 |
--list-repos -r Prepend a list of located repositories (repos.conf/ only). |
31 |
--repo-names -n Print repository names for each match. |
32 |
--repo-paths -p Print repository details for each match (implies repo-names). |
33 |
--help -h Print this help information and exit. |
34 |
--version -v Prepend version and license information to the output. |
35 |
--strict -s Search only in the flag field, excluding the description. |
36 |
--portdir -d Attempt to use the PORTDIR value. |
37 |
--quiet -q Do not complain about PORTDIR. |
38 |
--no-case -c Perform a case-insensitive search across the files. |
39 |
--print-needles -e Prepend each match with the relevant needle substring. |
40 |
--no-interrupt -i Do not interrupt the search results with warnings. |
41 |
--package -k Restrict the search to category-package description files. |
42 |
--colour -o Print the package, flag, and description in distinct colours. |
43 |
-- Consider all further arguments as substrings/queries. |
44 |
|
45 |
There's also a man page in the tree, providing deeper explanations for these |
46 |
command-line arguments: `ash-euses.1`. |
47 |
|
48 |
Off-line, I'm working on a strstr(3) (and strcasestr) reimplementation using the |
49 |
Two-Way string-matching algorithm [4] and shift tables, to remove the dependency |
50 |
on _GNU_SOURCE for the case-insensitive variant (it is very annoying that this |
51 |
is not a standard function, as it only defines CANON_ELEMENT to tolower(3) and |
52 |
calls glibc strstr [5]). |
53 |
|
54 |
For all my tests, the search yield is generally identical to euses(1). An ebuild |
55 |
is also included in the tree, however I am hardly experienced with writing them, |
56 |
so I'm not entirely sure if it respects the globally defined compiler flags. |
57 |
Regardless, I am posting here for anyone who is interested in using/testing this |
58 |
program, with the hope that it can provide an alternative for quick flag-lookup |
59 |
on newer, standards-conformant Gentoo-like systems. |
60 |
|
61 |
The source code is at [6], and a gzipped tarball of the latest release (v0.3) |
62 |
can be found at [7]. Thank you in advance to all interested parties. |
63 |
|
64 |
Cheers, |
65 |
Ashley. |
66 |
|
67 |
P.S. I really need a better name for this. A portmanteau of my first name, and |
68 |
the tool of which the program is a replica, doesn't seem very creative. |
69 |
|
70 |
[1] https://bugs.gentoo.org/546210 |
71 |
[2] https://bugs.gentoo.org/378603 |
72 |
[3] https://bugs.gentoo.org/663706#c4 |
73 |
[4] https://dl.acm.org/doi/abs/10.1145/116825.116845 |
74 |
[5] https://sourceware.org/git/?p=glibc.git;a=blob;f=string/strcasestr.c;h=d2964c5548b9ea7a68fc5b18b25ddfe7ddd6835c;hb=HEAD#l45 |
75 |
[6] http://git.suugaku.co.uk/ash-euses/tree/ |
76 |
[7] http://git.suugaku.co.uk/ash-euses/snapshot/ash-euses-0.3.tar.gz |
77 |
|
78 |
-- |
79 |
|
80 |
Ashley Dixon |
81 |
suugaku.co.uk |
82 |
|
83 |
2A9A 4117 |
84 |
DA96 D18A |
85 |
8A7B B0D2 |
86 |
A30E BF25 |
87 |
F290 A8AA |