Skip to content

Detect if sed supports --in-place #9463

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

Merged
merged 1 commit into from Oct 17, 2019
Merged

Detect if sed supports --in-place #9463

merged 1 commit into from Oct 17, 2019

Conversation

ghost
Copy link

@ghost ghost commented Oct 14, 2019

Motivation and Context

Not all implementations of sed have the --in-place flag. The build system fails on these systems.

#9206 accidentally added one of the changes to the top level Makefile.am that should have been in this PR. This brings in the rest of the changes, fixing the dist-hook target.

Description

Detect support for the flag during ./configure and provide a fallback mechanism for those systems where sed's behavior differs. The autoconf variable ${ac_inplace} can be used to choose the correct flags for editing a file in place with sed.

Replace violating usages in Makefile.am with ${ac_inplace}.

How Has This Been Tested?

We have tested builds with this change on several distributions of Linux and on FreeBSD.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

@ghost
Copy link
Author

ghost commented Oct 14, 2019

I had previously closed a PR for this intending to detect and use GNU sed instead, but I'm reopening it to solve the immediate problems. Making the build depend on GNU sed can be done on top of these changes at a later time.

Not all versions of sed have the --in-place flag. Detect support for
the flag during ./configure and provide a fallback mechanism for those
systems where sed's behavior differs. The autoconf variable
${ac_inplace} can be used to choose the correct flags for editing a
file in place with sed.

Replace violating usages in Makefile.am with ${ac_inplace}.

Signed-off-by: Ryan Moeller <[email protected]>
@ghost ghost added the Status: Code Review Needed Ready for review and testing label Oct 14, 2019
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat
#
if USING_PYTHON_2
install-exec-hook:
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(bindir)/arcstat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the fallback mechanism? This looks like, if ${ac_inplace} is empty, it's just going to print the modified arcstat to stdout.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-i ''

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes - sorry, I mis-read the patch as --in-place vs nothing, rather than --in-place vs -i.

@codecov
Copy link

codecov bot commented Oct 15, 2019

Codecov Report

Merging #9463 into master will decrease coverage by 0.2%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9463      +/-   ##
==========================================
- Coverage   79.27%   79.06%   -0.21%     
==========================================
  Files         414      414              
  Lines      123635   123635              
==========================================
- Hits        98009    97754     -255     
- Misses      25626    25881     +255
Flag Coverage Δ
#kernel 79.71% <ø> (-0.06%) ⬇️
#user 66.79% <ø> (-0.57%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 177c79d...b3e98bb. Read the comment docs.

@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat
#
if USING_PYTHON_2
install-exec-hook:
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(bindir)/arcstat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes - sorry, I mis-read the patch as --in-place vs nothing, rather than --in-place vs -i.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Oct 17, 2019
@behlendorf behlendorf merged commit 4313a5b into openzfs:master Oct 17, 2019
@ghost ghost deleted the sed-inplace branch October 17, 2019 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants