github.com/confluentinc/confluent-kafka-go@v1.9.2/kafka/librdkafka_vendor/import.sh (about) 1 #!/bin/bash 2 # 3 # 4 # Import a new version of librdkafka based on a librdkafka static bundle. 5 # This will create a separate branch, import librdkafka, make a commit, 6 # and then ask you to push the branch to github, have it reviewed, 7 # and then later merged (NOT squashed or rebased). 8 # Having a merge per import allows future shallow clones to skip and ignore 9 # older imports, hopefully reducing the amount of git history data 'go get' 10 # needs to download. 11 12 set -e 13 14 usage() { 15 echo "Usage: $0 [--devel] path/to/librdkafka-static-bundle-<VERSION>.tgz" 16 echo "" 17 echo "This tool must be run from the TOPDIR/kafka/librdkafka directory" 18 echo "" 19 echo "Options:" 20 echo " --devel - Development use: No branch checks and does not push to github" 21 exit 1 22 } 23 24 error_cleanup() { 25 echo "Error occurred, cleaning up" 26 git checkout $currbranch 27 git branch -D $import_branch 28 exit 1 29 } 30 31 devel=0 32 if [[ $1 == --devel ]]; then 33 devel=1 34 shift 35 fi 36 37 bundle="$1" 38 [[ -f $bundle ]] || usage 39 40 # Parse the librdkafka version from the bundle 41 bundlename=$(basename $bundle) 42 version=${bundlename#librdkafka-static-bundle-} 43 version=${version%.tgz} 44 45 if [[ -z $version ]]; then 46 echo "Error: Could not parse version from bundle $bundle" 47 exit 1 48 fi 49 50 # Verify branch state 51 curr_branch=$(git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-) 52 uncommitted=$(git status --untracked-files=no --porcelain) 53 54 if [[ ! -z $uncommitted ]]; then 55 echo "Error: This script must be run on a clean branch with no uncommitted changes" 56 echo "Uncommitted files:" 57 echo "$uncommitted" 58 exit 1 59 fi 60 61 if [[ $devel != 1 ]] && [[ $curr_branch != master ]] ; then 62 echo "Error: This script must be run on an up-to-date, clean, master branch" 63 exit 1 64 fi 65 66 67 # Create import branch, import bundle, commit. 68 import_branch="import_$version" 69 70 exists=$(git branch -rlq | grep "/$import_branch\$" || true) 71 if [[ ! -z $exists ]]; then 72 echo "Error: This version branch already seems to exist: $exists: already imorted?" 73 [[ $devel != 1 ]] && exit 1 74 fi 75 76 echo "Checking for existing commits that match this version (should be none)" 77 git log --oneline | grep "^librdkafka static bundle $version\$" && exit 1 78 79 80 echo "Creating import branch $import_branch" 81 git checkout -b $import_branch 82 83 echo "Importing bundle $bundle" 84 ./bundle-import.sh "$bundle" || error_cleanup 85 86 echo "Committing $version" 87 git commit -a -m "librdkafka static bundle $version" || error_cleanup 88 89 echo "Updating error codes and docs" 90 pushd ../../ 91 make -f mk/Makefile docs || error_cleanup 92 git commit -a -m "Documentation and error code update for librdkafka $version" \ 93 || error_cleanup 94 popd 95 96 if [[ $devel != 1 ]]; then 97 echo "Pushing branch" 98 git push origin $import_branch || error_cleanup 99 fi 100 101 git checkout $curr_branch 102 103 if [[ $devel != 1 ]]; then 104 git branch -D $import_branch 105 fi 106 107 echo "" 108 echo "############## IMPORT OF $version COMPLETE ##############" 109 if [[ $devel != 1 ]]; then 110 echo "Branch $import_branch has been pushed." 111 echo "Create a PR, have it reviewed and then merge it (do NOT squash or rebase)." 112 fi 113