Gentoo Archives: gentoo-dev

From: Ionen Wolkens <ionen@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 0/2] Add esed.eclass for sed that dies if caused no changes
Date: Sat, 04 Jun 2022 16:53:18
Message-Id: YpuN9CMi1s+ROr5w@eversor
In Reply to: Re: [gentoo-dev] [PATCH 0/2] Add esed.eclass for sed that dies if caused no changes by Alessandro Barbieri
1 On Sat, Jun 04, 2022 at 06:19:30PM +0200, Alessandro Barbieri wrote:
2 > When I use sed is for dynamic content and mostly like to do this:
3 > s|lib|$(get_libdir)|g
4 > In this case esed would be deleterious because it would fail on 32 bit
5 > arches
6
7 This case is noted in the docs fwiw. How to handle will depend on
8 preference but best route to ensure the change is always right
9 would be either to patch to replace lib by e.g. @GENTOO_LIBDIR@,
10 /then/ sed, or insert a variable/option that could be passed and
11 perhaps even upstreamed.
12
13 Lazier approach that use esed (or upcoming erepl) could be:
14
15 [[ $(get_libdir) != lib ]] && erepl /lib /$(get_libdir) file
16
17 This also avoids unnecessarily editing files when there's nothing,
18 albeit more invasive and runs get_libdir twice. EPREFIX is a bit
19 nicer given we can use `use prefix`:
20
21 use prefix && erepl /usr "${EPREFIX}"/usr file
22
23 This is a bit like replacing
24 rm -f exists-with-USE-gui-only
25 by
26 use !gui || rm exists-with-USE-gui-only || die
27 (bash exit code logic always fun wrt that double negation...)
28
29 Both are going to do the job at first, but one may end up missing
30 that the file was moved in another directory on bump and is now
31 getting wrongly installed.
32
33 --
34 ionen

Attachments

File name MIME type
signature.asc application/pgp-signature