Skip to content

Commit

Permalink
Allow copy-builtin to work with modified sources.
Browse files Browse the repository at this point in the history
`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).

Closes: openzfs#8022
  • Loading branch information
prometheanfire committed Oct 15, 2018
1 parent 0aa5916 commit 4d473fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion copy-builtin
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ then
fi

make clean || true
scripts/make_gitrev.sh
scripts/make_gitrev.sh || true

rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
cp --recursive include "$KERNEL_DIR/include/zfs"
Expand Down
34 changes: 12 additions & 22 deletions scripts/make_gitrev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,19 @@
# `configure` is run.
#

BASE_DIR=$(dirname "$0")
set -e -u

file=${BASE_DIR}/../include/zfs_gitrev.h
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

#
# Set default file contents in case we bail.
#
rm -f "$file"
# shellcheck disable=SC2039
/bin/echo -e "#define\tZFS_META_GITREV \"unknown\"" >>"$file"

#
# 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)

0 comments on commit 4d473fe

Please sign in to comment.