Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions hbase-common/src/saveVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ nativeOutputDirectory="$2/native/utils/"
pushd .
cd ..

user=`whoami | sed -n -e 's/\\\/\\\\\\\\/p'`
user=$(whoami | sed -n -e "s/\\\/\\\\\\\\/p")
if [ "$user" == "" ]
then
user=`whoami`
user=$(whoami)
fi
date=`date`
cwd=`pwd`
date=$(date)
cwd=$(pwd)
if [ -d .svn ]; then
revision=`(svn info | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p') || true`
url=`(svn info | sed -n -e 's/^URL: \(.*\)/\1/p') || true`
revision=$( (svn info | sed -n -e "s/Last Changed Rev: \(.*\)/\1/p") || true)
url=$( (svn info | sed -n -e 's/^URL: \(.*\)/\1/p') || true)
elif [ -d .git ]; then
revision=`git log -1 --no-show-signature --pretty=format:"%H" || true`
hostname=`hostname`
revision=$(git log -1 --no-show-signature --pretty=format:"%H" || true)
hostname=$(hostname)
url="git://${hostname}${cwd}"
fi
if [ -z "${revision}" ]; then
echo "[WARN] revision info is empty! either we're not in VCS or VCS commands failed." >&2
revision="Unknown"
url="file://$cwd"
fi
if ! [ -x "$(command -v openssl)" ]; then
if ! [ -x "$(command -v openssl)" ]; then
if ! [ -x "$(command -v gpg)" ]; then
srcChecksum="Unknown"
else
srcChecksum=`find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs gpg --print-md sha512 | gpg --print-md sha512 | cut -d ' ' -f 1`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous use of cut here at the end is surprising. It took only the first block...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on history it was used for md5 and md5sum commands but it wasn't removed when SHA512 was introduced in saveVersion.sh.

root@8224f4c69e6f:/# echo "foo" | md5sum
d3b07384d113edec49eaa6238ad5ff00  -

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does tr -d '[:space:]' work? It's simpler and shorter than tr '\n' ' ' | sed 's/[[:space:]]*//g'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a different output from your command, an extra %.

find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs gpg --print-md sha512 | gpg --print-md sha512 | tr -d '[:space:]'
3BF4CCC275112769C7AB0EDC302793FB81005BDC9681E1604BD965918363FC93311FC60B24000563DD4D3EFDA10685F549721A28428F23487813A7397FBC9BD0%
ind hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs gpg --print-md sha512 | gpg --print-md sha512 | tr '\n' ' ' | sed 's/[[:space:]]*//g'
3BF4CCC275112769C7AB0EDC302793FB81005BDC9681E1604BD965918363FC93311FC60B24000563DD4D3EFDA10685F549721A28428F23487813A7397FBC9BD0

Copy link
Member

@liuml07 liuml07 Jul 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird. I did not see in my macOS and Ubuntu Linux. But since this is not reliable, I guess we can stay with your script tr and sed - which works for me on both macOS and Ubuntu.

srcChecksum=$(find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs gpg --print-md sha512 | gpg --print-md sha512 | tr '\n' ' ' | sed 's/[[:space:]]*//g')
fi
else
srcChecksum=`find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs openssl dgst -sha512 | openssl dgst -sha512 | cut -d ' ' -f 1`
srcChecksum=$(find hbase-*/src/main/ | grep -e "\.java" -e "\.proto" | LC_ALL=C sort | xargs openssl dgst -sha512 | openssl dgst -sha512 | sed 's/^.* //')
fi
popd

Expand Down