[CentOS] Download and build the specified version of Git

I made a script because I forget it every time.

Conclusion

We have released a program that allows you to install Git by specifying the version name as shown below. Repository: Polarbear08/centos-git-installer

# ./installer.sh 2.29.2

See the README for details.

motivation

Script content

installer.sh


#!/bin/bash

# verify input
VERSION=$1
if [[ $VERSION =~ [1-9]+\.[0-9]+\.[0-9] ]]; then
        GIT_DIR=git-$VERSION
        GIT_TAR=$GIT_DIR.tar.gz
        URL="https://mirrors.edge.kernel.org/pub/software/scm/git/$GIT_TAR"
else
        echo -e "Usage:\t $0 <VERSION>"
        echo -e "e.g.)\t $0 2.29.2"
        exit 1
fi

# install wget for downloading git
yum install -y wget

# confirm installation
wget -q --spider $URL
if [ $? = 0 ]; then
        echo "install git version $VERSION"
else
        echo "something seems wrong with URL: $URL"
        exit 1
fi

# install dependencies
yum install -y \
        curl-devel \
        expat-devel \
        gettext-devel \
        openssl-devel \
        perl-devel \
        zlib-devel \
        gcc \
        make

# download and install git
mkdir -p /usr/local/src
cd /usr/local/src
wget https://mirrors.edge.kernel.org/pub/software/scm/git/${GIT_TAR}
tar xf ${GIT_TAR}
rm -f ${GIT_TAR}

cd ${GIT_DIR}
make prefix=/usr/local all
make prefix=/usr/local install

# completion notice
git version > /dev/null  && echo "$(git version) was successfully installed"

I don't want to step on a strange error with the character code, so I only use ASCII characters.

reference

Recommended Posts

[CentOS] Download and build the specified version of Git
Check the version of the JDK installed and the version of the JDK enabled
How to download the old version of Apache Tomcat
Switch the version of bundler
[Java version] The story of serialization
Check the version of Cent OS
This and that of the JDK
Build a container version of Minecraft server and use https-enabled Dynmap
Make a daily build of the TOPPERS kernel with Gitlab and Docker
Automatically assign date and build number for the day to Maven version
[Error] Error during Docker build (solved by pulling the latest version of image)
Folding and unfolding the contents of the Recyclerview
About the operation of next () and nextLine ()
Build DNS server with CentOS8 and bind
Japanese localization of CentOS 8 and Japanese keyboard layout
Download and install Eclipse (Java) (Mac version)
About the mechanism of the Web and HTTP
Check the version of the standard Web software.
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC
Compare the speed of the for statement and the extended for statement.
[Java] Access the signed URL of s3 (signed version 2)
[Java] The confusing part of String and StringBuilder
I compared the characteristics of Java and .NET
Manage the version of Ruby itself with rbenv
Try the free version of Progate [Java II]
Learn the rudimentary mechanism and usage of Gradle 4.4
About next () and nextLine () of the Scanner class
Install the latest version of Jenkins on Ubuntu 16
[CentOS7] Install aws cli regardless of python version
Prepare the environment of CentOS 8 with Sakura VPS
What are the advantages of DI and Thymeleaf?
Try the free version of Progate [Java I]
I specified the version and rails new, but for some reason the latest version is included ~
Library not loaded when trying to upgrade the version of ruby and rails s