• [gentoo-dev] [PATCH 0/2] Add esed.eclass for sed that dies if caused no

    From Ionen Wolkens@21:1/5 to All on Tue May 31 13:30:01 2022
    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die.
    (see @EXAMPLE in eclass for a quick usage overview).

    Implementation / available wrappers / usefulness still up for debate,
    but without further comments I consider this ready (albeit first time
    touching / making an eclass, so I could be overlooking simple things).
    Also partly uses >=bash-4.4, so EAPI-7 is not considered.

    See github PR[1] for old changelog background.

    Up to maintainers but personally would encourage to slowly replace
    (almost) all use of sed with either this or patches. Some cases
    where it can be inconvenient like eclasses "guessing" that a package
    may or may not have something to replace, and that nothing happened
    is not an issue.

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

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

    eclass/esed.eclass | 199 +++++++++++++++++++++++++++++++++++++++++++
    eclass/tests/esed.sh | 173 +++++++++++++++++++++++++++++++++++++
    2 files changed, 372 insertions(+)
    create mode 100644 eclass/esed.eclass
    create mode 100755 eclass/tests/esed.sh

    --
    2.35.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to All on Tue May 31 13:30:01 2022
    Bit sloppy, but should pickup most regressions.

    Signed-off-by: Ionen Wolkens <[email protected]>
    ---
    eclass/tests/esed.sh | 173 +++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 173 insertions(+)
    create mode 100755 eclass/tests/esed.sh

    diff --git a/eclass/tests/esed.sh b/eclass/tests/esed.sh
    new file mode 100755
    index 00000000000..fad1319ea13
    --- /dev/null
    +++ b/eclass/tests/esed.sh
    @@ -0,0 +1,173 @@
    +#!/usr/bin/env bash
    +# Copyright 2022 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +EAPI=8
    +source tests-common.sh || exit
    +
    +inherit esed
    +
    +cd "${WORKDIR:-/dev/null}" || exit 1
    +
    +tsddied=n
    +tsddie() {
    + tsddied=y
    + echo "would die: $*" >&2
    + # silence further errors given didn't actually die
    + sed() { :; }
    + die() { :; }
    +}
    +
    +tsdbegin() {
    + tbegin "${1}"
    + tsddied=n
    + unset -f sed
    + die() { tsddie "${@}"; }
    +}
    +
    +tsdend() {
    + if [[ ${1} == fatal && ${tsddied} == n ]]; then
    + tend 127 "should have died"
    + elif [[ ${1} == nonfatal && ${tsddied} == y ]]; then
    + tend 128 "should not have died"
    + else
    + tend
  • From Anna@21:1/5 to Ionen Wolkens on Tue May 31 16:00:01 2022
    On 2022-05-31 07:23, Ionen Wolkens wrote:
    Implementation / available wrappers / usefulness still up for debate,
    but without further comments I consider this ready (albeit first time touching / making an eclass, so I could be overlooking simple things).
    Also partly uses >=bash-4.4, so EAPI-7 is not considered.

    From ebuild(5):
    Beginning with EAPI 4, the dosed helper no longer exists
    Ebuilds should call sed(1) directly (and assume that it is GNU
    sed).

    What were the reasons to remove this helper? Do they still apply to esed
    as an eclass?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jaco Kroon@21:1/5 to Ionen Wolkens on Tue May 31 16:50:02 2022
    Hi,

    On 2022/05/31 16:29, Ionen Wolkens wrote:
    esed does bring back the -i/die skipping but that's not its inherent
    purpose and GNU sed currently does not support a mean to report if
    changes occurred (if this happens, esed may well become obsolete too).

    Haven't checked the code to validate.  But I'm in support of esed eclass
    for the sole reason it ensures the sed actually still changes
    something.  Not that it verifies the change is actually intended mind
    you, so it doesn't completely take away the due diligence checks, but
    the verbose options should help devs to ensure the changes are the
    intended at testing time.

    One *could* also add a change-counter check, eg, count the number of
    lines starting with + and - (but not +++ and ---) from diff, and ensure
    they match the expected count.  Just to catch further possible cases.

    Kind Regards,
    Jaco

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Anna on Tue May 31 16:30:01 2022
    On Tue, May 31, 2022 at 06:54:21PM +0500, Anna wrote:
    On 2022-05-31 07:23, Ionen Wolkens wrote:
    Implementation / available wrappers / usefulness still up for debate,
    but without further comments I consider this ready (albeit first time touching / making an eclass, so I could be overlooking simple things).
    Also partly uses >=bash-4.4, so EAPI-7 is not considered.

    From ebuild(5):
    Beginning with EAPI 4, the dosed helper no longer exists
    Ebuilds should call sed(1) directly (and assume that it is GNU
    sed).

    What were the reasons to remove this helper? Do they still apply to esed
    as an eclass?

    Haven't looked up exact history, but afaik dosed existed because of sed formerly not having -i. And editing files in-place was tedious in
    ebuilds with cp/mv. With -i becoming commonplace (PMS also requires
    GNU sed) it lost its purpose beside just allowing to skip -i/||die.

    esed does bring back the -i/die skipping but that's not its inherent
    purpose and GNU sed currently does not support a mean to report if
    changes occurred (if this happens, esed may well become obsolete too).

    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKWJlUACgkQskQGsLCs QzS3tQf+OcTy3bLVOrBQpXADAQ8Vdt6MdtmDnh5/9W3bnEGey/xQ6bvFejJPeWuQ R7CrnVNXJiA0yFp02R17Cs45U/6IVRaLbuuzesYPw8cY693n/A3Gfxdd7HE2/2H3 oV5JSNQwwN5VKZOSsKZ/dClUkkooi9YyCg4fBlEwxTD+U6jwH+qNyxxZh+s+A6Rc 7mR920m2CRH7ql0A/NwkHlRiiRNKoievt0e7vNRNknZQHujF8UqgChkqiqhLVSHU Tnew4h1S65Xw3uWTFZLza0tDnu9Au89bWhYtR69N9B3zuuTtmnAmuJQ8hkUWg+Ip ZdciGPVObIF3m/Hhhhr0gb8QQNd1bA==
    =u9mi
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to Ionen Wolkens on Fri Jun 3 06:10:01 2022
    On Tue, 2022-05-31 at 07:23 -0400, Ionen Wolkens wrote:
    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die.
    (see @EXAMPLE in eclass for a quick usage overview).


    To be honest, I strongly dislike this. It really feels like trying to
    make an adapter for a square wheel, while the right solution would be to replace the wheel. On top of that, ton of evals which are pretty much
    a huge "no-no".

    Perhaps it would be better to forget about trying to work miracles with
    sed and instead write a trivial shell replacement for the most common
    use cases. One thing I'd love to see is a simple substitution command
    that would work for paths/CFLAGS on RHS without having to worry about
    them conflicting with the pattern delimiter.

    --
    Best regards,
    Michał Górny

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anna V@21:1/5 to Ionen Wolkens on Fri Jun 3 06:50:01 2022
    On 2022-06-03 00:45, Ionen Wolkens wrote:
    On Fri, Jun 03, 2022 at 06:09:38AM +0200, Michał Górny wrote:
    On Tue, 2022-05-31 at 07:23 -0400, Ionen Wolkens wrote:
    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die. (see @EXAMPLE in eclass for a quick usage overview).


    To be honest, I strongly dislike this. It really feels like trying to
    make an adapter for a square wheel, while the right solution would be to replace the wheel. On top of that, ton of evals which are pretty much
    a huge "no-no".

    About evals, the two eval is just to silence this:

    var=$(printf "\0")

    printf -v var "\0"

    The 2>/dev/null doesn't work without wrapping it, aka

    eval 'var=$(printf "\0")' 2>/dev/null

    No variables are expanded pre-eval so it's just evaluating a
    static statement. eval can be removed, but it'll be noisy
    if someone happens to sed binary files.


    Perhaps it would be better to forget about trying to work miracles with
    sed and instead write a trivial shell replacement for the most common
    use cases. One thing I'd love to see is a simple substitution command
    that would work for paths/CFLAGS on RHS without having to worry about
    them conflicting with the pattern delimiter.

    --
    Best regards,
    Michał Górny



    --
    ionen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to All on Fri Jun 3 06:50:01 2022
    On Fri, Jun 03, 2022 at 06:09:38AM +0200, Michał Górny wrote:
    On Tue, 2022-05-31 at 07:23 -0400, Ionen Wolkens wrote:
    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die.
    (see @EXAMPLE in eclass for a quick usage overview).


    To be honest, I strongly dislike this. It really feels like trying to
    make an adapter for a square wheel, while the right solution would be to replace the wheel. On top of that, ton of evals which are pretty much
    a huge "no-no".

    About evals, the two eval is just to silence this:

    var=$(printf "\0")

    The 2>/dev/null doesn't work without wrapping it, aka

    eval 'var=$(printf "\0")' 2>/dev/null

    No variables are expanded pre-eval so it's just evaluating a
    static statement. eval can be removed, but it'll be noisy
    if someone happens to sed binary files.


    Perhaps it would be better to forget about trying to work miracles with
    sed and instead write a trivial shell replacement for the most common
    use cases. One thing I'd love to see is a simple substitution command
    that would work for paths/CFLAGS on RHS without having to worry about
    them conflicting with the pattern delimiter.

    --
    Best regards,
    Michał Górny



    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKZkfsACgkQskQGsLCs QzQEvAf7B+YmxsXISNCZGR5SSiycLaCLpuYh6QcCxStkoepu/PNuzy394jYGFfMt zLzSemzpomg58GuN6jybauog6vhqdwTqiJBMGvecmRutowBwfHSTYFiaOEVBXI6g 4YAuZJv0lGP1HjmqYeRGgyWrrGwzbI4UzHJJCKWdofwuQlskyrNj0ruEQ5aCshJ/ 8eQ8bDh7ooCGOZW0k5LDN+BbqCV9SA8ODqc6ObPkLpJeu4XEYUArFqMD249BWqrm IdqUQLGwDKNqYvAU08Eb1pC+lIwqFUdwJBnwgABDMn9UEN30FKX4ZTwLYeGobD6l zO5l9ITcxWY2nlTZ/4SEJeg0jfCmYA==
    =P+w1
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to All on Fri Jun 3 07:10:01 2022
    On 31 May 2022, at 12:23, Ionen Wolkens <[email protected]> wrote:

    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die.
    (see @EXAMPLE in eclass for a quick usage overview).

    Implementation / available wrappers / usefulness still up for debate,
    but without further comments I consider this ready (albeit first time touching / making an eclass, so I could be overlooking simple things).
    Also partly uses >=bash-4.4, so EAPI-7 is not considered.

    See github PR[1] for old changelog background.

    Up to maintainers but personally would encourage to slowly replace
    (almost) all use of sed with either this or patches. Some cases
    where it can be inconvenient like eclasses "guessing" that a package
    may or may not have something to replace, and that nothing happened
    is not an issue.


    I like it. I'd prefer it if GNU sed supported it by itself (exit code indicating
    if any changes were made) but it doesn't right now.

    Ebuilds use sed aplenty and making it easier to be "less bad" is a good
    thing. It's a practical solution to a real problem we have (zombie seds,
    or more rarely, overzealous-and-not-realising-it seds).

    I don't want us to have to keep it forever and I wouldn't want
    people to actively use this instead of patches, but they certainly should instead of sed.

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

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

    eclass/esed.eclass | 199 +++++++++++++++++++++++++++++++++++++++++++ eclass/tests/esed.sh | 173 +++++++++++++++++++++++++++++++++++++
    2 files changed, 372 insertions(+)
    create mode 100644 eclass/esed.eclass
    create mode 100755 eclass/tests/esed.sh

    --
    2.35.1


    best,
    sam


    -----BEGIN PGP SIGNATURE-----

    iNUEARYKAH0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCYpmVTF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MAAKCRBzhAn1IN+R kE+5AP47g111zL7hcYEmms0UAEPr/WdU6KOzRer7HIfXlRFcVQD/V0PMA6bo/fPr IblfQk95CB/jNJlZ2l3dn7JuYBz3JAo=
    =WVWv
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Anna V on Fri Jun 3 07:10:01 2022
    On Fri, Jun 03, 2022 at 09:47:51AM +0500, Anna V wrote:
    On 2022-06-03 00:45, Ionen Wolkens wrote:
    On Fri, Jun 03, 2022 at 06:09:38AM +0200, Michał Górny wrote:
    On Tue, 2022-05-31 at 07:23 -0400, Ionen Wolkens wrote:
    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die. (see @EXAMPLE in eclass for a quick usage overview).


    To be honest, I strongly dislike this. It really feels like trying to make an adapter for a square wheel, while the right solution would be to replace the wheel. On top of that, ton of evals which are pretty much
    a huge "no-no".

    About evals, the two eval is just to silence this:

    var=$(printf "\0")

    printf -v var "\0"

    That was just for the sake of showing what happens, the eclass is
    reading a file and isn't using printf. aka: var=$(<file)


    The 2>/dev/null doesn't work without wrapping it, aka

    eval 'var=$(printf "\0")' 2>/dev/null

    No variables are expanded pre-eval so it's just evaluating a
    static statement. eval can be removed, but it'll be noisy
    if someone happens to sed binary files.


    Perhaps it would be better to forget about trying to work miracles with sed and instead write a trivial shell replacement for the most common
    use cases. One thing I'd love to see is a simple substitution command that would work for paths/CFLAGS on RHS without having to worry about them conflicting with the pattern delimiter.

    --
    Best regards,
    Michał Górny



    --
    ionen




    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKZlZcACgkQskQGsLCs QzTlUQf+K+MKnZl2TkNKkb4sps+C/dItdWDYDlIqzn38pZJhIbSfG1Hy1Mc4D223 qWnGSKU0N2Vlt7eGq/JrW1Ra6d/Q9QE5u+j5/cjO6xlSBezG8EzZ6PBCq63ApiUq 1ROYx6wsBTqVoQd2TgVZy4XGev4nKyc9VegPv/DvK0T8/BPWQX4GBjNt6wgR3KIt i8u5FiR7ozIIvjyO0uqH75dcB3o2asUH1IlRcNEbQqhGVVMPKmwE+s/qrZeiysk9 hwhaIgBH3Af6yl3nuBtxPSzjGdCJsIt2mS/TbMXBPPXYxX5/IEyg/N8YBzykJjIr mPr12+f7qTYtuBHrMeMFztdz3qgvlw==
    =vxGh
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to All on Fri Jun 3 07:10:02 2022
    On Fri, Jun 03, 2022 at 06:09:38AM +0200, Michał Górny wrote:
    On Tue, 2022-05-31 at 07:23 -0400, Ionen Wolkens wrote:
    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die.
    (see @EXAMPLE in eclass for a quick usage overview).


    To be honest, I strongly dislike this. It really feels like trying to
    make an adapter for a square wheel, while the right solution would be to replace the wheel. On top of that, ton of evals which are pretty much
    a huge "no-no".

    As for using this or not, I don't overly mind ether way. I felt like
    giving it a try given it's been requested but if there's not much
    interest that's fine too (there's still qa-sed fwiw, with some
    limitations).


    Perhaps it would be better to forget about trying to work miracles with
    sed and instead write a trivial shell replacement for the most common
    use cases. One thing I'd love to see is a simple substitution command
    that would work for paths/CFLAGS on RHS without having to worry about
    them conflicting with the pattern delimiter.

    --
    Best regards,
    Michał Górny



    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKZlpAACgkQskQGsLCs QzS8EwgAgCrdjt3gOKJ9ydTcE5SNDhh0PfIZsy0g/7WpiNuvUezFAui4mKi3v6tX GgGMnlnPFPFZ50kqT9d5Bil0oNFk9vADpNz2y0lWghR4MZ3oNOEDnLuXj8/SiOV+ W5ifIrHXBMATVaVHBJmoUaBI4f+W1WkWF0Hq1UVWGm1xW2oI4V3flJHxS+twB6BX xR6A8y2QkrRw+8u8e5FdEfP4lJaupsBG5oShoPyc0lqRiz6gRU432vN5mto2vIqu zmXI62difujaNk5LEF+ScVXNBp6D0XORJ6DdIGQCUfwKjJcejmVb+Mb8bZIWP8dO JJo2UKs/Rox9L0bh5GMOAhEvpjj/Ow==
    =LNJP
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to All on Fri Jun 3 13:40:01 2022
    Nothing fundamentally different until further feedback,
    mostly to get eval out of the way.

    Changelog
    v2:
    - replace use of eval (realized another way works)
    - add missing quotes around one _esed_output
    - move diff checks inside comparison blocks

    Ionen Wolkens (1):
    esed.eclass: new eclass

    eclass/esed.eclass | 201 +++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 201 insertions(+)
    create mode 100644 eclass/esed.eclass

    --
    2.35.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Ionen Wolkens on Fri Jun 3 16:20:01 2022
    On Fri, Jun 03, 2022 at 07:36:45AM -0400, Ionen Wolkens wrote:
    Nothing fundamentally different until further feedback,
    mostly to get eval out of the way.

    Changelog
    v2:
    - replace use of eval (realized another way works)
    - add missing quotes around one _esed_output
    - move diff checks inside comparison blocks

    For the record, more work planned so please wait for v3 for
    further review (may be a bit), albeit any feedback / ideas welcome.

    Right now looking at:
    - some enewsed fixes or perhaps reimplementation (noticed a meh flaw)
    - adding a pure bash non-sed replacer suggested by mgorny, e.g. erepl
    this would be useful to use for simple operations not crippled by sed
    delimiters, and generally preferable unless need fancy sed stuff
    - perhaps cut support for some unlikely-anyone-will-need features,
    like at least `sed s/// file1 file2 > file3` concat, and perhaps
    requiring files to be always at end of command line or others
    things which may help simplify (without going full minimal, erepl
    will be for that).


    Ionen Wolkens (1):
    esed.eclass: new eclass

    eclass/esed.eclass | 201 +++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 201 insertions(+)
    create mode 100644 eclass/esed.eclass

    --
    2.35.1



    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKaFvEACgkQskQGsLCs QzS6CwgAmL83rLK/9yLzlgg0NslrMcUkKk+cZdOnJkea5qNVsrPc/RTZvpmiZY76 9WRPletwjjW4P0h8uvst0pgRquN0UdEIS/Ch72e2qCQjGzxLHYHCHSiey+Vq/2v5 zi+h2b6rqps+bQG+LVD/LaR0rV/xixdWrSJ8OSlN2G+WI+zQyEq9MzHMxoUJgGg8 CpU8wyBEDDFczH6oY8cdtheN6jv2uCesHdI066VLma7kDaJs2gZKFoRckF1fFrz9 0XIEaa70jdBdcbcikmWN9B8/04KPL9+NOj52Oimr8fZmcSSJGMxDZxy8rbn3ujML gQpeZMaaj+04PRYEpUMfSb3hBNMY/g==
    =LL4r
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alessandro Barbieri@21:1/5 to All on Sat Jun 4 18:20:01 2022
    Il giorno mar 31 mag 2022 alle ore 13:23 Ionen Wolkens <[email protected]>
    ha scritto:

    Often preferable to use patches so this happens, but sed have its uses/convenience and this intend to help reduce the amount of old
    broken seds causing issues that go unnoticed on bumps.

    Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
    this is for more deterministic use in ebuilds.

    Also slightly shortens sed use, -i is default, and no need to || die.
    (see @EXAMPLE in eclass for a quick usage overview).

    Implementation / available wrappers / usefulness still up for debate,
    but without further comments I consider this ready (albeit first time touching / making an eclass, so I could be overlooking simple things).
    Also partly uses >=bash-4.4, so EAPI-7 is not considered.

    See github PR[1] for old changelog background.

    Up to maintainers but personally would encourage to slowly replace
    (almost) all use of sed with either this or patches. Some cases
    where it can be inconvenient like eclasses "guessing" that a package
    may or may not have something to replace, and that nothing happened
    is not an issue.

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

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

    eclass/esed.eclass | 199 +++++++++++++++++++++++++++++++++++++++++++
    eclass/tests/esed.sh | 173 +++++++++++++++++++++++++++++++++++++
    2 files changed, 372 insertions(+)
    create mode 100644 eclass/esed.eclass
    create mode 100755 eclass/tests/esed.sh

    --
    2.35.1



    I use patches for static content, not a big fan of wall of sed in ebuilds
    When I use sed is for dynamic content and mostly like to do this: s|lib|$(get_libdir)|g
    In this case esed would be deleterious because it would fail on 32 bit
    arches

    <div dir="ltr"><div dir="ltr">Il giorno mar 31 mag 2022 alle ore 13:23 Ionen Wolkens &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; ha scritto:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.
    8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Often preferable to use patches so this happens, but sed have its<br>
    uses/convenience and this intend to help reduce the amount of old<br>
    broken seds causing issues that go unnoticed on bumps.<br>

    Inspired by app-portage/iwdevtools&#39; qa-sed (warns on any seds), but<br> this is for more deterministic use in ebuilds.<br>

    Also slightly shortens sed use, -i is default, and no need to || die.<br>
    (see @EXAMPLE in eclass for a quick usage overview).<br>

    Implementation / available wrappers / usefulness still up for debate,<br>
    but without further comments I consider this ready (albeit first time<br> touching / making an eclass, so I could be overlooking simple things).<br>
    Also partly uses &gt;=bash-4.4, so EAPI-7 is not considered.<br>

    See github PR[1] for old changelog background.<br>

    Up to maintainers but personally would encourage to slowly replace<br>
    (almost) all use of sed with either this or patches. Some cases<br>
    where it can be inconvenient like eclasses &quot;guessing&quot; that a package<br>
    may or may not have something to replace, and that nothing happened<br>
    is not an issue.<br>

    [1] <a href="https://github.com/gentoo/gentoo/pull/25662" rel="noreferrer" target="_blank">https://github.com/gentoo/gentoo/pull/25662</a><br>

    Ionen Wolkens (2):<br>
      esed.eclass: new eclass<br>
      eclass/tests/esed.sh: basic tests for esed.eclass<br>

     eclass/esed.eclass   | 199 +++++++++++++++++++++++++++++++++++++++++++<br>  eclass/tests/esed.sh | 173 +++++++++++++++++++++++++++++++++++++<br>
     2 files changed, 372 insertions(+)<br>
     create mode 100644 eclass/esed.eclass<br>
     create mode 100755 eclass/tests/esed.sh<br>

    -- <br>
    2.35.1<br>

    <br></blockquote><div><br></div><div>I use patches for static content, not a big fan of wall of sed in ebuilds</div><div>When I use sed is for dynamic content and mostly like to do this: s|lib|$(get_libdir)|g</div><div>In this case esed would be
    deleterious because it would fail on 32 bit arches<br></div></div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Alessandro Barbieri on Sat Jun 4 19:00:01 2022
    On Sat, Jun 04, 2022 at 06:19:30PM +0200, Alessandro Barbieri wrote:
    When I use sed is for dynamic content and mostly like to do this: s|lib|$(get_libdir)|g
    In this case esed would be deleterious because it would fail on 32 bit
    arches

    This case is noted in the docs fwiw. How to handle will depend on
    preference but best route to ensure the change is always right
    would be either to patch to replace lib by e.g. @GENTOO_LIBDIR@,
    /then/ sed, or insert a variable/option that could be passed and
    perhaps even upstreamed.

    Lazier approach that use esed (or upcoming erepl) could be:

    [[ $(get_libdir) != lib ]] && erepl /lib /$(get_libdir) file

    This also avoids unnecessarily editing files when there's nothing,
    albeit more invasive and runs get_libdir twice. EPREFIX is a bit
    nicer given we can use `use prefix`:

    use prefix && erepl /usr "${EPREFIX}"/usr file

    This is a bit like replacing
    rm -f exists-with-USE-gui-only
    by
    use !gui || rm exists-with-USE-gui-only || die
    (bash exit code logic always fun wrt that double negation...)

    Both are going to do the job at first, but one may end up missing
    that the file was moved in another directory on bump and is now
    getting wrongly installed.

    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmKbjfMACgkQskQGsLCs QzRckgf/Y8NPJMNDepH0STQyB8fUOj/N0qPwXSVoPWlIPORF50UG879n5Fry/P3U 4+ami1+A6/VcZINlGii4KLcx/QNNmdTuquXch/fRpjflDSfp3FzvxIQR/cL2SJyz v/jzlRp30hyHUC095MgiKzbA++Z73zbr7TZwsr1ZQOpgI5mGBLWH+seIXRx4W9PS jVAgkOCXu8pmZK4ePPMtcVmhCvu9V4rGbFZ0HL9YtMVTKo9neAdl8P41We5lFSVA P2qqLLtdWiELZOkUOBkaGZvfGHEHlOV7jw129Q7DKALljQJhQIU9RFzwqoz5Jov7 E9pOfm5MxNh60LqN972+iIAn/2YYjw==
    =nSXt
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)