Monday, March 22, 2021

Git - Installing git using source code (Compile)

 
Installing git using source (Compile)
1. Remove old git package
$ sudo yum remove -y git

2. Install required tools on your system to complie git
$ sudo yum group install -y "development Tools"

Install other required software tools.
$ sudo yum install -y automake curl-devel gettext-devel openssl-devel perl-devel zlib-devel

3. Download git source code
$ wget https://github.com/git/git.git -O git.tar.gz
# git clone https://github.com/git/git.git
# yum remove git
# cd git

Create configure script. This checks for tools and library to complete build process
[root@worker1 git]# make configure
GIT_VERSION = 2.31.GIT
    GEN configure
[root@worker1 git]#

set /usr/local directory as install dir path for binary
[root@worker1 git]# ./configure --prefix=/usr/local
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
configure: CHECKS for programs
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking for inline... inline
checking if linker supports -R... no
checking if linker supports -Wl,-rpath,... yes
checking for gar... no
checking for ar... ar
checking for gtar... gtar
checking for gnudiff... no
checking for gdiff... no
checking for diff... diff
checking for asciidoc... asciidoc
checking for asciidoc version... asciidoc 8.6.10
Using 'grep -a' for sane_grep
configure: CHECKS for libraries
checking for SHA1_Init in -lcrypto... yes
checking for curl_global_init in -lcurl... yes
checking for curl-config... curl-config
configure: Setting CURL_LDFLAGS to '-lcurl'
checking for XML_ParserCreate in -lexpat... no
checking for iconv in -lc... yes
checking for deflateBound in -lz... yes
checking for socket in -lc... yes
checking for inet_ntop... yes
checking for inet_pton... yes
checking for hstrerror... yes
checking for basename in -lc... yes
checking if libc contains libintl... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
configure: CHECKS for header files
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking for inttypes.h... (cached) yes
checking for old iconv()... no
checking whether iconv omits bom for utf-16 and utf-32... no
configure: CHECKS for typedefs, structures, and compiler characteristics
checking for socklen_t... yes
checking for struct itimerval... yes
checking for struct stat.st_mtimespec.tv_nsec... no
checking for struct stat.st_mtim.tv_nsec... yes
checking for struct dirent.d_type... yes
checking for struct passwd.pw_gecos... yes
checking for struct sockaddr_storage... yes
checking for struct addrinfo... yes
checking for getaddrinfo... yes
checking for library containing getaddrinfo... none required
checking whether the platform regex supports REG_STARTEND... yes
checking whether system succeeds to read fopen'ed directory... yes
checking whether snprintf() and/or vsnprintf() return bogus value... no
checking whether the platform uses typical file type bits... yes
configure: CHECKS for library functions
checking libgen.h usability... yes
checking libgen.h presence... yes
checking for libgen.h... yes
checking paths.h usability... yes
checking paths.h presence... yes
checking for paths.h... yes
checking libcharset.h usability... no
checking libcharset.h presence... no
checking for libcharset.h... no
checking for strings.h... (cached) yes
checking for locale_charset in -liconv... no
checking for locale_charset in -lcharset... no
checking for clock_gettime... yes
checking for library containing clock_gettime... none required
checking for CLOCK_MONOTONIC... yes
checking for setitimer... yes
checking for library containing setitimer... none required
checking for strcasestr... yes
checking for library containing strcasestr... none required
checking for memmem... yes
checking for library containing memmem... none required
checking for strlcpy... no
checking for uintmax_t... yes
checking for strtoumax... yes
checking for library containing strtoumax... none required
checking for setenv... yes
checking for library containing setenv... none required
checking for unsetenv... yes
checking for library containing unsetenv... none required
checking for mkdtemp... yes
checking for library containing mkdtemp... none required
checking for initgroups... yes
checking for library containing initgroups... none required
checking for getdelim... yes
checking for library containing getdelim... none required
checking for BSD sysctl... no
checking for POSIX Threads with ''... no
checking for POSIX Threads with '-mt'... no
checking for POSIX Threads with '-pthread'... yes
configure: creating ./config.status
config.status: creating config.mak.autogen
config.status: executing config.mak.autogen commands
[root@worker1 git]#


Now, compile for binary

As of now,
- We are done with configuration step.
- We have a Make file.
  Make file is a configuration file of instructions for make command to process.
- Make file includes instructions on how to compile the binary.
- At this time, we need sudo or root level access to to install.



 Now let's check the version by typing in git space dash dash version and hit Enter. This should reflect the version we just compiled. We'll be using this version for the rest of this course, as it's the most current.


it may take upto 5 minutes depending speed of your system.

[root@worker1 git]# make install
    * new build flags
    CC fuzz-commit-graph.o
    CC fuzz-pack-headers.o
    CC fuzz-pack-idx.o
    CC daemon.o
    * new link flags
    CC common-main.o
    CC abspath.o
    CC add-interactive.o
    CC add-patch.o
    CC advice.o
    CC alias.o
    CC alloc.o
    CC apply.o
......
   CC ewah/ewah_io.o
    CC ewah/ewah_rlw.o
    CC exec-cmd.o
    CC fetch-negotiator.o
    CC fetch-pack.o
    CC fmt-merge-msg.o
    CC fsck.o
    CC fsmonitor.o
    CC gettext.o
    CC gpg-interface.o
    CC graph.o
    CC grep.o
    CC hash-lookup.o
    CC hashmap.o
    GEN command-list.h
    CC help.o
...
    INSTALL 644 pt_pt.msg
    INSTALL 644 fr.msg
    INSTALL 644 ru.msg
    INSTALL 644 el.msg
    INSTALL 644 vi.msg
    INSTALL 644 bg.msg
    INSTALL 644 nb.msg
make[1]: Leaving directory '/root/git/git-gui'
bindir=$(cd '/usr/local/bin' && pwd) && \
execdir=$(cd '/usr/local/libexec/git-core' && pwd) && \
destdir_from_execdir_SQ=$(echo 'libexec/git-core' | sed -e 's|[^/][^/]*|..|g') && \
{ test "$bindir/" = "$execdir/" || \
  for p in git git-shell git-cvsserver

for p in $remote_curl_aliases; do \
        rm -f "$execdir/$p" && \
        test -n "" && \
        ln -s "git-remote-http" "$execdir/$p" || \
        { test -z "" && \
          ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || \
          ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || \
          cp "$execdir/git-remote-http" "$execdir/$p" || exit; } \
done && \
./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
[root@worker1 git]#


Check the version
[root@worker1 git]# git --version
-bash: /usr/bin/git: No such file or directory
[root@worker1 git]# pwd
/root/git
[root@worker1 git]# ls -l /usr/local/
bin/     etc/     games/   include/ lib/     lib64/   libexec/ sbin/    share/   src/
[root@worker1 git]# ls -l /usr/local/bin/git
git                 gitk                git-shell           git-upload-pack
git-cvsserver       git-receive-pack    git-upload-archive
[root@worker1 git]# ls -l /usr/local/bin/git
-rwxr-xr-x. 137 root root 21184880 Mar 22 15:23 /usr/local/bin/git
[root@worker1 git]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@worker1 git]# which git
/usr/local/bin/git
[root@worker1 git]# git --version
-bash: /usr/bin/git: No such file or directory
[root@worker1 git]# /usr/local/bin/git --version
git version 2.31.GIT
[root@worker1 git]#
[root@worker1 git]# ln -s /usr/local/bin/git /usr/bin/git
[root@worker1 git]# git --version
git version 2.31.GIT
[root@worker1 git]#



No comments:

Post a Comment

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...