Detect if sed supports --in-place
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}. Reviewed-by: Chris Dunlop <chris@onthe.net.au> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@ixsystems.com> Closes #9463
This commit is contained in:
parent
08f530c699
commit
4313a5b4c5
|
@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat
|
||||||
#
|
#
|
||||||
if USING_PYTHON_2
|
if USING_PYTHON_2
|
||||||
install-exec-hook:
|
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
|
$(DESTDIR)$(bindir)/arcstat
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -8,6 +8,6 @@ dist_bin_SCRIPTS = dbufstat
|
||||||
#
|
#
|
||||||
if USING_PYTHON_2
|
if USING_PYTHON_2
|
||||||
install-exec-hook:
|
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)/dbufstat
|
$(DESTDIR)$(bindir)/dbufstat
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
dnl #
|
||||||
|
dnl # Set the flags used for sed in-place edits.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SED], [
|
||||||
|
ac_inplace=""
|
||||||
|
AC_CACHE_CHECK([for sed --in-place], [ac_cv_path_SED],
|
||||||
|
[AC_PATH_PROGS_FEATURE_CHECK([SED], [sed],
|
||||||
|
[[tmpfile=$(mktemp)
|
||||||
|
echo foo > $tmpfile
|
||||||
|
$ac_path_SED --in-place 's#foo#bar#' $tmpfile \
|
||||||
|
&& ac_cv_path_SED=$ac_path_SED
|
||||||
|
rm $tmpfile]],
|
||||||
|
[ac_inplace="-i ''"])])
|
||||||
|
AS_IF([test "x$ac_inplace" = "x"], [ac_inplace="--in-place"])
|
||||||
|
AC_SUBST([ac_inplace])
|
||||||
|
])
|
|
@ -164,6 +164,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
|
||||||
ZFS_AC_CONFIG_ALWAYS_ARCH
|
ZFS_AC_CONFIG_ALWAYS_ARCH
|
||||||
ZFS_AC_CONFIG_ALWAYS_PYTHON
|
ZFS_AC_CONFIG_ALWAYS_PYTHON
|
||||||
ZFS_AC_CONFIG_ALWAYS_PYZFS
|
ZFS_AC_CONFIG_ALWAYS_PYZFS
|
||||||
|
ZFS_AC_CONFIG_ALWAYS_SED
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([ZFS_AC_CONFIG], [
|
AC_DEFUN([ZFS_AC_CONFIG], [
|
||||||
|
|
|
@ -9,7 +9,7 @@ dist_pkgdata_SCRIPTS = \
|
||||||
#
|
#
|
||||||
if USING_PYTHON_2
|
if USING_PYTHON_2
|
||||||
install-data-hook:
|
install-data-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)$(pkgdatadir)/test-runner.py \
|
$(DESTDIR)$(pkgdatadir)/test-runner.py \
|
||||||
$(DESTDIR)$(pkgdatadir)/zts-report.py
|
$(DESTDIR)$(pkgdatadir)/zts-report.py
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in New Issue