public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH v3 0/2] Add esed.eclass for modifying with checks for no-op
@ 2022-06-04 20:46 Ionen Wolkens
  2022-06-04 20:46 ` [gentoo-dev] [PATCH v3 1/2] esed.eclass: new eclass Ionen Wolkens
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ionen Wolkens @ 2022-06-04 20:46 UTC (permalink / raw
  To: gentoo-dev

Semi-new take on the eclass, also incorporating mgorny's erepl idea
making this more or less a toolbox for replacements with no-op checks
(still named esed.eclass, but could be reconsidered if seems better).

See @EXAMPLE in eclass for quick usage overview, and below for
nvidia-drivers ebuild change example.

Please try it in real ebuilds so can get a better idea of anything
lacking or potentially broken that tests/esed.sh doesn't pickup.

Anything is still up for debate/review, unlikely to be final
(if even added at all).

Updated version also available from github PR[1]

Changelog from v2:
- esed simplified to take only specific arguments
 (parsing can still be a bit jarring, but more linear/deterministic)
- remove esedexps, unneeded given esed now understands -e
- simplified enewsed by using cp and removing concat support
 (with the 3 above, is essentially a rewrite)
- add simple bash-based erepl / erepld / ereplp + enew variants
- convert esedfind to "efind" so it's usable by all functions
 (perhaps feel a bit out of place in this eclass now, albeit similar
  theme given dies if no-ops without files)
- no longer hide null byte warnings and indicate this eclass is
  not for binary files (very uncommon usage either way)
- several new/modified esed.sh tests, also now verifies die
  messages to ensure died in the right place

As an usage example, here's differences for nvidia-drivers ebuild
(these could of course be handled other ways / patched, but between
conditionals, rebasing, and basic things like __USER__, can also
be annoying to):

-sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \
-	-i kernel{,-module-source/kernel-open}/conftest.sh || die
+erepl 'defined(CONFIG_DRM' 'defined(CONFIG_DRM_KMS_HELPER' \
+	kernel{,-module-source/kernel-open}/conftest.sh

-sed 's/__USER__/nvpd/' \
-	nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
-	> "${T}"/nvidia-persistenced.service || die
+enewrepl __USER__ nvpd \
+	nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
+	"${T}"/nvidia-persistenced.service

-use !amd64 || sed -i "s|/usr|${EPREFIX}/opt|" \
-	systemd/system/nvidia-powerd.service || die
+use amd64 && erepl /usr "${EPREFIX}"/opt \
+	systemd/system/nvidia-powerd.service

-use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die
+use wayland && ereplp modeset=1 '#' '' "${T}"/nvidia.conf
(almost made this one esed, but ereplp does the uncommenting job too --
 also double negation was to skip if/then given `false && true || die`
 would die, but is now unneeded without || die)

-use wayland || sed -i 's/ WAYLAND_LIB_install$//' \
-	nvidia-settings/src/Makefile || die
+use wayland || ereplp ^install: WAYLAND_LIB_install '' \
+	nvidia-settings/src/Makefile
(not essential but make it safer by checking for ^install: too)

... fairly simple cases so no real need for esed over erepl here.

With ESED_VERBOSE=1 exported, in the build.log there's:

 * ereplp ^install: WAYLAND_LIB_install  nvidia-settings/src/Makefile 
[snip]
-install: NVIDIA_SETTINGS_install NVIDIA_GTKLIB_install WAYLAND_LIB_install
+install: NVIDIA_SETTINGS_install NVIDIA_GTKLIB_install 
[snip]

And if I rewrite it as `ereplp ^instypo: WYALAND_LIB_isntall ''`:

 * ERROR: x11-drivers/nvidia-drivers-515.48.07::gentoo failed (prepare phase):
 *   no-op: ereplp ^instypo: WYALAND_LIB_isntall  nvidia-settings/src/Makefile

[1] https://github.com/gentoo/gentoo/pull/25662

Ionen Wolkens (2):
  esed.eclass: new eclass
  eclass/tests/esed.sh: tests for esed.eclass

 eclass/esed.eclass   | 265 +++++++++++++++++++++++++++++++++++++++++++
 eclass/tests/esed.sh | 263 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 528 insertions(+)
 create mode 100644 eclass/esed.eclass
 create mode 100755 eclass/tests/esed.sh

-- 
2.35.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-14 11:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-04 20:46 [gentoo-dev] [PATCH v3 0/2] Add esed.eclass for modifying with checks for no-op Ionen Wolkens
2022-06-04 20:46 ` [gentoo-dev] [PATCH v3 1/2] esed.eclass: new eclass Ionen Wolkens
2022-06-05 19:42   ` Oskari Pirhonen
2022-06-07  4:59     ` Oskari Pirhonen
2022-06-04 20:46 ` [gentoo-dev] [PATCH v3 2/2] eclass/tests/esed.sh: tests for esed.eclass Ionen Wolkens
2022-06-05 11:17 ` [gentoo-dev] [PATCH v3 0/2] Add esed.eclass for modifying with checks for no-op Ionen Wolkens
2022-07-14 11:24 ` Florian Schmaus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox