diff options
author | Matthew Thode <[email protected]> | 2018-10-17 14:06:05 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-10-17 12:06:05 -0700 |
commit | 8d431940038c4a668abdac40b5853b269d49253e (patch) | |
tree | d39a51d1224022ec55a92f16686295dcc7fa731c /scripts | |
parent | 2e55034471413fb668d0d910b2c083610b386127 (diff) |
Allow copy-builtin to work with modified sources
`scripts/make_gitrev.sh` had 'set -e' so if any command failed it would
fail and cause copy-builtin to fail (copy-builtin also has `set -e`.
This commit also simplifies scripts/make_gitrev.sh to always write a
file by using a cleanup function. It also simplifies other areas of
the script as well (making it much shorter).
Reviewed-by: John Kennedy <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matthew Thode <[email protected]>
Closes #8022
Closes #8025
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/make_gitrev.sh | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/scripts/make_gitrev.sh b/scripts/make_gitrev.sh index 04be09595..757f00fbc 100755 --- a/scripts/make_gitrev.sh +++ b/scripts/make_gitrev.sh @@ -15,9 +15,8 @@ # CDDL HEADER END # -# # Copyright (c) 2018 by Delphix. All rights reserved. -# +# Copyright (c) 2018 by Matthew Thode. All rights reserved. # # Generate zfs_gitrev.h. Note that we need to do this for every @@ -26,29 +25,19 @@ # `configure` is run. # -BASE_DIR=$(dirname "$0") - -file=${BASE_DIR}/../include/zfs_gitrev.h +set -e -u -# -# Set default file contents in case we bail. -# -rm -f "$file" -# shellcheck disable=SC2039 -/bin/echo -e "#define\tZFS_META_GITREV \"unknown\"" >>"$file" +cleanup() { + ZFS_GIT_REV=${ZFS_GIT_REV:-"unknown"} + cat << EOF > "$(dirname "$0")"/../include/zfs_gitrev.h +#define ZFS_META_GITREV "${ZFS_GIT_REV}" +EOF +} +trap cleanup EXIT -# # Check if git is installed and we are in a git repo. -# -git rev-parse --git-dir > /dev/null 2>&1 || exit - -# +git rev-parse --git-dir > /dev/null 2>&1 # Check if there are uncommitted changes -# -git diff-index --quiet HEAD || exit - -rev=$(git describe 2>/dev/null) || exit - -rm -f "$file" -# shellcheck disable=SC2039 -/bin/echo -e "#define\tZFS_META_GITREV \"${rev}\"" >>"$file" +git diff-index --quiet HEAD +# Get the git current git revision +ZFS_GIT_REV=$(git describe 2>/dev/null) |