Turn checkbashisms into a make target
make_gitrev.sh actually breaks checkbashisms' parser, which /insists/ that the end-of-line " is actually a string start Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12101
This commit is contained in:
parent
c3ef9f7528
commit
f7d7ee0583
25
Makefile.am
25
Makefile.am
@ -135,31 +135,6 @@ checkabi: lib
|
|||||||
storeabi: lib
|
storeabi: lib
|
||||||
$(MAKE) -C lib storeabi
|
$(MAKE) -C lib storeabi
|
||||||
|
|
||||||
PHONY += checkbashisms
|
|
||||||
checkbashisms:
|
|
||||||
@if type checkbashisms > /dev/null 2>&1; then \
|
|
||||||
checkbashisms -n -p -x \
|
|
||||||
$$(find ${top_srcdir} \
|
|
||||||
-name '.git' -prune \
|
|
||||||
-o -name 'build' -prune \
|
|
||||||
-o -name 'tests' -prune \
|
|
||||||
-o -name 'config' -prune \
|
|
||||||
-o -name 'zed-functions.sh*' -prune \
|
|
||||||
-o -name 'zfs-import*' -prune \
|
|
||||||
-o -name 'zfs-mount*' -prune \
|
|
||||||
-o -name 'zfs-zed*' -prune \
|
|
||||||
-o -name 'smart' -prune \
|
|
||||||
-o -name 'paxcheck.sh' -prune \
|
|
||||||
-o -name 'make_gitrev.sh' -prune \
|
|
||||||
-o -name '90zfs' -prune \
|
|
||||||
-o -path '*initramfs/hooks' -prune \
|
|
||||||
-o -type f ! -name 'config*' \
|
|
||||||
! -name 'libtool' \
|
|
||||||
-exec awk 'FNR==1 && /^#!.*bin\/sh/ {print FILENAME}' {} \+); \
|
|
||||||
else \
|
|
||||||
echo "skipping checkbashisms because checkbashisms is not installed"; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
PHONY += mancheck
|
PHONY += mancheck
|
||||||
mancheck:
|
mancheck:
|
||||||
@if type mandoc > /dev/null 2>&1; then \
|
@if type mandoc > /dev/null 2>&1; then \
|
||||||
|
@ -62,17 +62,14 @@ get_filename_from_dir()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
script=$(basename "$0")
|
script="${0##*/}"
|
||||||
|
|
||||||
if [ "$1" = "-h" ] ; then
|
if [ "$1" = "-h" ] ; then
|
||||||
echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
|
echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
smartctl_path=$(command -v smartctl)
|
if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then
|
||||||
|
|
||||||
# shellcheck disable=SC2015
|
|
||||||
if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ] || [ -n "$samples" ] ; then
|
|
||||||
if [ -n "$samples" ] ; then
|
if [ -n "$samples" ] ; then
|
||||||
# cat a smartctl output text file instead of running smartctl
|
# cat a smartctl output text file instead of running smartctl
|
||||||
# on a vdev (only used for developer testing).
|
# on a vdev (only used for developer testing).
|
||||||
@ -80,7 +77,7 @@ if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ] || [ -n "$samples" ] ; then
|
|||||||
echo "file=$file"
|
echo "file=$file"
|
||||||
raw_out=$(cat "$samples/$file")
|
raw_out=$(cat "$samples/$file")
|
||||||
else
|
else
|
||||||
raw_out=$(eval "sudo $smartctl_path -a $VDEV_UPATH")
|
raw_out=$(sudo smartctl -a "$VDEV_UPATH")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# What kind of drive are we? Look for the right line in smartctl:
|
# What kind of drive are we? Look for the right line in smartctl:
|
||||||
|
@ -6,3 +6,17 @@ else
|
|||||||
@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed"
|
@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed"
|
||||||
endif
|
endif
|
||||||
@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done
|
@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done
|
||||||
|
|
||||||
|
|
||||||
|
# command -v *is* specified by POSIX and every shell in existence supports it
|
||||||
|
.PHONY: checkbashisms
|
||||||
|
checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS)
|
||||||
|
if HAVE_CHECKBASHISMS
|
||||||
|
[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \
|
||||||
|
checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \
|
||||||
|
for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \
|
||||||
|
fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2
|
||||||
|
else
|
||||||
|
@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed"
|
||||||
|
endif
|
||||||
|
@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
dnl #
|
dnl #
|
||||||
dnl # Check if shellcheck is available.
|
dnl # Check if shellcheck and/or checkbashisms are available.
|
||||||
dnl #
|
dnl #
|
||||||
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SHELLCHECK], [
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SHELLCHECK], [
|
||||||
AC_CHECK_PROG([SHELLCHECK], [shellcheck], [yes])
|
AC_CHECK_PROG([SHELLCHECK], [shellcheck], [yes])
|
||||||
|
AC_CHECK_PROG([CHECKBASHISMS], [checkbashisms], [yes])
|
||||||
|
|
||||||
AM_CONDITIONAL([HAVE_SHELLCHECK], [test "x$SHELLCHECK" = "xyes"])
|
AM_CONDITIONAL([HAVE_SHELLCHECK], [test "x$SHELLCHECK" = "xyes"])
|
||||||
|
AM_CONDITIONAL([HAVE_CHECKBASHISMS], [test "x$CHECKBASHISMS" = "xyes"])
|
||||||
])
|
])
|
||||||
|
@ -18,3 +18,6 @@ pkgdracut_DATA = \
|
|||||||
zfs-rollback-bootfs.service
|
zfs-rollback-bootfs.service
|
||||||
|
|
||||||
SUBSTFILES += $(pkgdracut_SCRIPTS) $(pkgdracut_DATA)
|
SUBSTFILES += $(pkgdracut_SCRIPTS) $(pkgdracut_DATA)
|
||||||
|
|
||||||
|
# Provided by /bin/sleep, and, again, every implementation of that supports this
|
||||||
|
CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.'
|
||||||
|
@ -56,9 +56,9 @@ then
|
|||||||
# already exists (in the source)
|
# already exists (in the source)
|
||||||
if [ -f "${top_srcdir}/${GITREV}" ]
|
if [ -f "${top_srcdir}/${GITREV}" ]
|
||||||
then
|
then
|
||||||
ZFS_GITREV="$(sed -n \
|
ZFS_GITREV=$(sed -n \
|
||||||
'1s/^#define[[:blank:]]ZFS_META_GITREV "\([^"]*\)"$/\1/p' \
|
'1s/^#define[[:blank:]]ZFS_META_GITREV "\([^"]*\)"$/\1/p' \
|
||||||
"${top_srcdir}/${GITREV}")"
|
"${top_srcdir}/${GITREV}")
|
||||||
fi
|
fi
|
||||||
elif [ ${dist} = yes ]
|
elif [ ${dist} = yes ]
|
||||||
then
|
then
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# shellcheck disable=SC2039
|
if ! command -v scanelf > /dev/null; then
|
||||||
if ! type scanelf > /dev/null 2>&1; then
|
|
||||||
echo "scanelf (from pax-utils) is required for these checks." >&2
|
echo "scanelf (from pax-utils) is required for these checks." >&2
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user