New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: improve sed robustness by not using sed #19761
Conversation
Concept ACK |
Concept ACK. This will make simple bumps more complicated, but arguably that's a good thing. Also +1 for self-documentation. |
Lovely PR title 😄 Concept ACK. I remember having some discussions about this in the past (with @dongcarl ?). It has always bothered me that sed can fail silently. This is especially problematic because changes can be lost without noticing when bumping versions. This has in the past resulted in losing propagation of hardening flags and such. |
Concept ACK. |
Concept ACK! One q: I often see |
950179e
to
0b0f480
Compare
I'm glad everyone agrees with the approach. I've pushed a fix the docs in one patch file.
I've done some testing and think it could be a worthwhile addition. It seems if anything it causes patch to "fail faster". i.e chain applying the same patch with and without it: # no -N
patch -p1 -i a.patch && patch -p1 -i a.patch && patch -p1 -i a.patch
patching file test.cpp
patching file test.cpp
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file test.cpp.rej
# reset
git stash
Saved working directory and index state WIP on master: cdb5127 init
# Using -N
patch -N -p1 -i a.patch && patch -N -p1 -i a.patch && patch -N -p1 -i a.patch
patching file test.cpp
patching file test.cpp
Reversed (or previously applied) patch detected! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file test.cpp.rej So without |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Reviewing commits:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK 0b0f480.
I've verified that patch
changes are equal to sed
changes.
I've verified that dropped workarounds are effectively noop.
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
The depends comment is actually incorrect, and this can be dropped once we move to 1.71.0 or later.
This was fixed upstream in c45595d64831990311f92fcebc4e34e2797f5352.
Summary: ``` While using sed can be handy to use for a quick-fix, these instances accumulate, and can become unmaintainable. Not only that, but using sed isn't necessarily robust and it can fail silently. Most of our usage is also missing any documentation explaining why something is being done, when it should be updated/removed etc. Rather than relying on sed going forward, where possible, I've converted our sed usage into patches. These are easier to maintain, contain documentation, and should fail loudly when they don't apply. The remaining sed usage, (1 in miniupnpc, the rest in qt), are non-trivial to remove, as they are using build-time variables, or some input from the environment. ``` Backport of core [[bitcoin/bitcoin#19761 | PR19761]], slightly updated to match our depends. Depends on D7760. Test Plan: make build-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D7763
depends: Use patch rather than sed in bdb package This converts a sed command within a makefile into a static patch file in the `./depends` system for `bdb`. We use `sed` in some dependencies to replace some "dynamic" stuff, where regular expressions are necessary (such as to remove build-non-reproducibility, I believe). However, whenever we can use a patchfile, I feel that's superior because it's easier to manually read a patch file and it's known that the change is "static". Equivalent to the first commit in bitcoin/bitcoin#19761
e1f2553 build: remove global_init_link_order from mac qt qmake.conf (fanquake) 498fa16 build: document preprocessing steps in qt package (fanquake) bd5d933 build: don't copy Info.plist.* into mkspec for macOS qt build (fanquake) bfd7e33 build: remove plugin_no_soname from mac qt qmake.conf (fanquake) fdde4c7 build: pass XCODE_VERSION through to qt macOS cross compile conf (fanquake) 49473ef build: convert "echo" usage into a patch in qt package (fanquake) Pull request description: Follow up on removing `sed` usage in #19761. Also nice to revisit & cleanup before 5.15.x. ACKs for top commit: laanwj: Code review ACK e1f2553 Tree-SHA512: 4e6489d877aaa300f69e091d7117136da49611bd80afd45adfbd7ddeb5b3c9c76fb0f87a3249cbe63ba93129df56281fd4a9389daadc852211325c5ca9ac6567
Summary: ``` While using sed can be handy to use for a quick-fix, these instances accumulate, and can become unmaintainable. Not only that, but using sed isn't necessarily robust and it can fail silently. Most of our usage is also missing any documentation explaining why something is being done, when it should be updated/removed etc. Rather than relying on sed going forward, where possible, I've converted our sed usage into patches. These are easier to maintain, contain documentation, and should fail loudly when they don't apply. The remaining sed usage, (1 in miniupnpc, the rest in qt), are non-trivial to remove, as they are using build-time variables, or some input from the environment. ``` Backport of core [[bitcoin/bitcoin#19761 | PR19761]], slightly updated to match our depends. Depends on D7760. Test Plan: make build-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D7763
While using
sed
can be handy to use for a quick-fix, these instances accumulate, and can become unmaintainable. Not only that, but using sed isn't necessarily robust and it can fail silently. Most of our usage is also missing any documentation explaining why something is being done, when it should be updated/removed etc.Rather than relying on sed going forward, where possible, I've converted our sed usage into patches. These are easier to maintain, contain documentation, and should fail loudly when they don't apply.
The remaining sed usage, (1 in miniupnpc, the rest in qt), are non-trivial to remove, as they are using build-time variables, or some input from the environment.
This also steals 2 related commits out of #19716.
Related to #16838.