From 9f1ce6d80421ec1ebe595bb430b417612a0e2887 Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Thu, 1 Jun 2023 10:32:17 -0700 Subject: [PATCH] Make `unreleased_history/release.sh` work on macOS (#11494) Summary: I got the following errors when running `unreleased_history/release.sh` on my mac. This is due to mac does not have gnu version of awk and find by default. This PR updates the script to work on macOS. ``` awk: calling undefined function strftime input record number 43, file source line number 4 find: -regextype: unknown primary or operator ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/11494 Test Plan: manually run `DRY_RUN=1 unreleased_history/release.sh | less` on macOS and CentOS8 machines. Reviewed By: ajkr Differential Revision: D46328442 Pulled By: cbi42 fbshipit-source-id: a7570cd3480fcd25ac1438beb0d59fe655f9a71a --- unreleased_history/release.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/unreleased_history/release.sh b/unreleased_history/release.sh index 4dbcec609..d9937c482 100755 --- a/unreleased_history/release.sh +++ b/unreleased_history/release.sh @@ -29,7 +29,8 @@ echo >> HISTORY.new awk '/#define ROCKSDB_MAJOR/ { major = $3 } /#define ROCKSDB_MINOR/ { minor = $3 } /#define ROCKSDB_PATCH/ { patch = $3 } - END { print "## " major "." minor "." patch " (" strftime("%F") ")" }' < include/rocksdb/version.h >> HISTORY.new + END { printf "## " major "." minor "." patch }' < include/rocksdb/version.h >> HISTORY.new +echo " (`date +%x`)" >> HISTORY.new function process_file () { # use awk to correct extra or missing newlines, missing '* ' on first line @@ -69,7 +70,12 @@ process_dir bug_fixes "Bug Fixes" # Check for unexpected files or dirs at top level. process_dir/process_file # will deal with contents of these directories EXPECTED_REGEX="[^/]*[.]sh|README[.]txt|$(echo $PROCESSED_DIRECTORIES | tr ' ' '|')" -UNEXPECTED="$(find unreleased_history/ -mindepth 1 -maxdepth 1 -regextype egrep -not -regex "[^/]*/($EXPECTED_REGEX)")" +platform=`uname` +if [ $platform = 'Darwin' ]; then + UNEXPECTED="$(find -E unreleased_history -mindepth 1 -maxdepth 1 -not -regex "[^/]*/($EXPECTED_REGEX)")" +else + UNEXPECTED="$(find unreleased_history/ -mindepth 1 -maxdepth 1 -regextype egrep -not -regex "[^/]*/($EXPECTED_REGEX)")" +fi if [ "$UNEXPECTED" ]; then echo "Unexpected files I don't know how to process:" echo "$UNEXPECTED"