install-git.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.9.5"
  27. version_to_install=$default_version
  28. if [ -n "$2" ]; then
  29. version_to_install="$2"
  30. fi
  31. if [ "$version_to_install" != "2.9.5" ]; 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.9.5" ]; then
  36. # hadolint ignore=DL3003
  37. mkdir -p /tmp/git /opt/git &&
  38. curl -L -s -S https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz >/tmp/git/git-2.9.5.tar.gz &&
  39. tar xzf /tmp/git/git-2.9.5.tar.gz --strip-components 1 -C /opt/git &&
  40. cd /opt/git || exit &&
  41. make configure &&
  42. ./configure --prefix=/usr/local &&
  43. make "-j$(nproc)" &&
  44. make install &&
  45. cd /root || exit
  46. else
  47. echo "ERROR: Don't know how to install version $version_to_install"
  48. exit 1
  49. fi