1 |
Semi-new take on the eclass, also incorporating mgorny's erepl idea |
2 |
making this more or less a toolbox for replacements with no-op checks |
3 |
(still named esed.eclass, but could be reconsidered if seems better). |
4 |
|
5 |
See @EXAMPLE in eclass for quick usage overview, and below for |
6 |
nvidia-drivers ebuild change example. |
7 |
|
8 |
Please try it in real ebuilds so can get a better idea of anything |
9 |
lacking or potentially broken that tests/esed.sh doesn't pickup. |
10 |
|
11 |
Anything is still up for debate/review, unlikely to be final |
12 |
(if even added at all). |
13 |
|
14 |
Updated version also available from github PR[1] |
15 |
|
16 |
Changelog from v2: |
17 |
- esed simplified to take only specific arguments |
18 |
(parsing can still be a bit jarring, but more linear/deterministic) |
19 |
- remove esedexps, unneeded given esed now understands -e |
20 |
- simplified enewsed by using cp and removing concat support |
21 |
(with the 3 above, is essentially a rewrite) |
22 |
- add simple bash-based erepl / erepld / ereplp + enew variants |
23 |
- convert esedfind to "efind" so it's usable by all functions |
24 |
(perhaps feel a bit out of place in this eclass now, albeit similar |
25 |
theme given dies if no-ops without files) |
26 |
- no longer hide null byte warnings and indicate this eclass is |
27 |
not for binary files (very uncommon usage either way) |
28 |
- several new/modified esed.sh tests, also now verifies die |
29 |
messages to ensure died in the right place |
30 |
|
31 |
As an usage example, here's differences for nvidia-drivers ebuild |
32 |
(these could of course be handled other ways / patched, but between |
33 |
conditionals, rebasing, and basic things like __USER__, can also |
34 |
be annoying to): |
35 |
|
36 |
-sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ |
37 |
- -i kernel{,-module-source/kernel-open}/conftest.sh || die |
38 |
+erepl 'defined(CONFIG_DRM' 'defined(CONFIG_DRM_KMS_HELPER' \ |
39 |
+ kernel{,-module-source/kernel-open}/conftest.sh |
40 |
|
41 |
-sed 's/__USER__/nvpd/' \ |
42 |
- nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ |
43 |
- > "${T}"/nvidia-persistenced.service || die |
44 |
+enewrepl __USER__ nvpd \ |
45 |
+ nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ |
46 |
+ "${T}"/nvidia-persistenced.service |
47 |
|
48 |
-use !amd64 || sed -i "s|/usr|${EPREFIX}/opt|" \ |
49 |
- systemd/system/nvidia-powerd.service || die |
50 |
+use amd64 && erepl /usr "${EPREFIX}"/opt \ |
51 |
+ systemd/system/nvidia-powerd.service |
52 |
|
53 |
-use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die |
54 |
+use wayland && ereplp modeset=1 '#' '' "${T}"/nvidia.conf |
55 |
(almost made this one esed, but ereplp does the uncommenting job too -- |
56 |
also double negation was to skip if/then given `false && true || die` |
57 |
would die, but is now unneeded without || die) |
58 |
|
59 |
-use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ |
60 |
- nvidia-settings/src/Makefile || die |
61 |
+use wayland || ereplp ^install: WAYLAND_LIB_install '' \ |
62 |
+ nvidia-settings/src/Makefile |
63 |
(not essential but make it safer by checking for ^install: too) |
64 |
|
65 |
... fairly simple cases so no real need for esed over erepl here. |
66 |
|
67 |
With ESED_VERBOSE=1 exported, in the build.log there's: |
68 |
|
69 |
* ereplp ^install: WAYLAND_LIB_install nvidia-settings/src/Makefile |
70 |
[snip] |
71 |
-install: NVIDIA_SETTINGS_install NVIDIA_GTKLIB_install WAYLAND_LIB_install |
72 |
+install: NVIDIA_SETTINGS_install NVIDIA_GTKLIB_install |
73 |
[snip] |
74 |
|
75 |
And if I rewrite it as `ereplp ^instypo: WYALAND_LIB_isntall ''`: |
76 |
|
77 |
* ERROR: x11-drivers/nvidia-drivers-515.48.07::gentoo failed (prepare phase): |
78 |
* no-op: ereplp ^instypo: WYALAND_LIB_isntall nvidia-settings/src/Makefile |
79 |
|
80 |
[1] https://github.com/gentoo/gentoo/pull/25662 |
81 |
|
82 |
Ionen Wolkens (2): |
83 |
esed.eclass: new eclass |
84 |
eclass/tests/esed.sh: tests for esed.eclass |
85 |
|
86 |
eclass/esed.eclass | 265 +++++++++++++++++++++++++++++++++++++++++++ |
87 |
eclass/tests/esed.sh | 263 ++++++++++++++++++++++++++++++++++++++++++ |
88 |
2 files changed, 528 insertions(+) |
89 |
create mode 100644 eclass/esed.eclass |
90 |
create mode 100755 eclass/tests/esed.sh |
91 |
|
92 |
-- |
93 |
2.35.1 |