install-protobuf.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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="2.5.0"
  27. version_to_install=$default_version
  28. if [ -n "$2" ]; then
  29. version_to_install="$2"
  30. fi
  31. if [ "$version_to_install" != "2.5.0" ]; 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" == "2.5.0" ]; then
  36. # hadolint ignore=DL3003
  37. mkdir -p /opt/protobuf-src \
  38. && curl -L -s -S \
  39. https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.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 install \
  45. && cd /root \
  46. && rm -rf /opt/protobuf-src
  47. else
  48. echo "ERROR: Don't know how to install version $version_to_install"
  49. exit 1
  50. fi