Skip to content

Commit

Permalink
Canonicalize python shebangs
Browse files Browse the repository at this point in the history
Prefer Python 3 by default to satisfy rpm build.

Detect if the sed we are using supports --in-place or prefers -i '' at
configure time.

Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
  • Loading branch information
Ryan Moeller committed Jul 10, 2019
1 parent 137b90d commit 7db8ab1
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/arc_summary/arc_summary2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/env python2
#
# $Id: arc_summary.pl,v 388:e27800740aa2 2011-07-08 02:53:29Z jhell $
#
Expand Down
2 changes: 1 addition & 1 deletion cmd/arc_summary/arc_summary3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Copyright (c) 2008 Ben Rockwood <benr@cuddletech.com>,
# Copyright (c) 2010 Martin Matuska <mm@FreeBSD.org>,
Expand Down
2 changes: 1 addition & 1 deletion cmd/arcstat/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat
#
if USING_PYTHON_2
install-exec-hook:
sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(bindir)/arcstat
endif
2 changes: 1 addition & 1 deletion cmd/arcstat/arcstat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Print out ZFS ARC Statistics exported via kstat(1)
# For a definition of fields, or usage, use arctstat.pl -v
Expand Down
2 changes: 1 addition & 1 deletion cmd/dbufstat/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ dist_bin_SCRIPTS = dbufstat
#
if USING_PYTHON_2
install-exec-hook:
sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(bindir)/dbufstat
endif
2 changes: 1 addition & 1 deletion cmd/dbufstat/dbufstat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Print out statistics for all cached dmu buffers. This information
# is available through the dbufs kstat and may be post-processed as
Expand Down
16 changes: 16 additions & 0 deletions config/always-sed.m4
Original file line number Diff line number Diff line change
@@ -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])
])
1 change: 1 addition & 0 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
ZFS_AC_CONFIG_ALWAYS_ARCH
ZFS_AC_CONFIG_ALWAYS_PYTHON
ZFS_AC_CONFIG_ALWAYS_PYZFS
ZFS_AC_CONFIG_ALWAYS_SED
])

AC_DEFUN([ZFS_AC_CONFIG], [
Expand Down
2 changes: 1 addition & 1 deletion tests/test-runner/bin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dist_pkgdata_SCRIPTS = \
#
if USING_PYTHON_2
install-data-hook:
sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
$(DESTDIR)$(pkgdatadir)/test-runner.py \
$(DESTDIR)$(pkgdatadir)/zts-report.py
endif
2 changes: 1 addition & 1 deletion tests/test-runner/bin/test-runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

#
# This file and its contents are supplied under the terms of the
Expand Down
2 changes: 1 addition & 1 deletion tests/test-runner/bin/zts-report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

#
# This file and its contents are supplied under the terms of the
Expand Down

0 comments on commit 7db8ab1

Please sign in to comment.