install-protobuf.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. if [ $# -lt 1 ]; then
  18. echo "ERROR: Need at least 1 argument, $# were provided"
  19. exit 1
  20. fi
  21. pkg-resolver/check_platform.py "$1"
  22. if [ $? -eq 1 ]; then
  23. echo "ERROR: Unsupported platform $1"
  24. exit 1
  25. fi
  26. default_version="3.7.1"
  27. version_to_install=$default_version
  28. if [ -n "$2" ]; then
  29. version_to_install="$2"
  30. fi
  31. if [ "$version_to_install" != "3.7.1" ]; then
  32. echo "WARN: Don't know how to install version $version_to_install, installing the default version $default_version instead"
  33. version_to_install=$default_version
  34. fi
  35. if [ "$version_to_install" == "3.7.1" ]; then
  36. # hadolint ignore=DL3003
  37. mkdir -p /opt/protobuf-src &&
  38. curl -L -s -S \
  39. https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protobuf-java-3.7.1.tar.gz \
  40. -o /opt/protobuf.tar.gz &&
  41. tar xzf /opt/protobuf.tar.gz --strip-components 1 -C /opt/protobuf-src &&
  42. cd /opt/protobuf-src &&
  43. ./configure --prefix=/opt/protobuf &&
  44. make "-j$(nproc)" &&
  45. make install &&
  46. cd /root &&
  47. rm -rf /opt/protobuf-src
  48. else
  49. echo "ERROR: Don't know how to install version $version_to_install"
  50. exit 1
  51. fi