From: Ionen Wolkens <ionen@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [PATCH v3 0/2] Add esed.eclass for modifying with checks for no-op
Date: Sat, 4 Jun 2022 16:46:32 -0400 [thread overview]
Message-ID: <20220604204634.27567-1-ionen@gentoo.org> (raw)
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
next reply other threads:[~2022-06-04 20:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-04 20:46 Ionen Wolkens [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220604204634.27567-1-ionen@gentoo.org \
--to=ionen@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox