Thursday, February 20, 2014

How to install GIT on Oracle Enterprise Linux

GIT is a distributed version control system developed by Linux development community. Below are the steps to install (binary install) git on Oracle Enterprise Linux.  Ideally it should be as simple as running "yum install git". But I ran in to multiple issues. So thought of sharing...


Ran below command as root to install git.

# yum install git


Got below error

Existing lock /var/run/yum.pid: another copy is running as pid 3438.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum-updatesd-he
    Memory :  21 M RSS (247 MB VSZ)
    Started: Wed Feb 19 16:51:14 2014 - 01:32 ago
    State  : Sleeping, pid: 3438
....

yum-updatesd is the yum update demon.Stop this demon and start it after git installation.

# cd /etc/init.d/

# ./yum-updatesd stop

Stopping yum-updatesd:

But don't forget to start the service after installing GIT !

Again tried 'yum install git'

# yum install git


http://public-yum.oracle.com/repo/OracleLinux/OL5/8/base/x86_64/repodata/repomd.xml: [Errno 4] IOError:
Trying other mirror.

Basically I am behind proxy. Need to add proxy server details in /etc/yum.conf.

edit  /etc/yum.conf  and add below lines:

proxy=http://host:port 

provide actual proxy host name and port above.


#yum install git

yum install git
base                                                     | 1.4 kB     00:00
base/primary                                             | 1.5 MB     00:00
base                                                                  4639/4639
Setting up Install Process
No package git available.
Nothing to do
 The "No package git available." message was surprising.

Get epel-release-5-4.noarch.rpm and install

After some googling figured out that GIT package is not distributed as part of Oracle Linux. But there is a fedora project called "Extra Packages for Enterprise Linux" (EPEL). This can be installed on top of Oracle Liunx but not supported by Oracle Linux. To know more visit below links
EPEL
EPEL with Oracle Linux

# cd /scratch/softwares

# wget http://epel.mirror.net.in/epel/5/x86_64/epel-release-5-4.noarch.rpm


--2014-02-19 16:52:04--  http://epel.mirror.net.in/epel/5/x86_64/epel-release-5-4.noarch.rpm
Resolving ...
Connecting to ... connected.
Proxy request sent, awaiting response... 200 OK
Length: 12232 (12K) [application/x-redhat-package-manager]
Saving to: `epel-release-5-4.noarch.rpm'

100%[======================================>] 12,232      27.5K/s   in 0.4s

2014-02-19 16:52:06 (27.5 KB/s) - `epel-release-5-4.noarch.rpm' saved [12232/12232]


# rpm -ivh epel-release-5-4.noarch.rpm
warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

# yum install git
base                                                     | 1.4 kB     00:00
el5_latest                                               | 1.4 kB     00:00
el5_latest/primary                                       |  19 MB     01:06
el5_latest                                                          12730/12730
epel                                                     | 3.6 kB     00:00
epel/primary_db                                          | 3.9 MB     00:14
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.2.1-1.el5 set to be updated
--> Processing Dependency: perl-Git = 1.8.2.1-1.el5 for package: git
--> Processing Dependency: perl(Term::ReadKey) for package: git
--> Processing Dependency: perl(Git) for package: git
--> Processing Dependency: perl(Error) for package: git
--> Running transaction check
---> Package perl-Error.noarch 1:0.17010-1.el5 set to be updated
---> Package perl-Git.x86_64 0:1.8.2.1-1.el5 set to be updated
---> Package perl-TermReadKey.x86_64 0:2.30-4.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch          Version                Repository   Size
================================================================================
Installing:
 git                     x86_64        1.8.2.1-1.el5          epel        7.4 M
Installing for dependencies:
 perl-Error              noarch        1:0.17010-1.el5        epel         26 k
 perl-Git                x86_64        1.8.2.1-1.el5          epel         49 k
 perl-TermReadKey        x86_64        2.30-4.el5             epel         32 k

Transaction Summary
================================================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 7.5 M
Is this ok [y/N]: Y
Downloading Packages:
(1/4): perl-Error-0.17010-1.el5.noarch.rpm               |  26 kB     00:00
(2/4): perl-TermReadKey-2.30-4.el5.x86_64.rpm            |  32 kB     00:00
(3/4): perl-Git-1.8.2.1-1.el5.x86_64.rpm                 |  49 kB     00:00
(4/4): git-1.8.2.1-1.el5.x86_64.rpm                                                   | 7.4 MB     00:25
-------------------------------------------------------------------------------------------------------------
Total                                                                        257 kB/s | 7.5 MB     00:29
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey                                                                           | 1.7 kB     00:00
Importing GPG key 0x217521F6 "Fedora EPEL " from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : perl-TermReadKey                                                                      1/4
  Installing     : perl-Error                                                                            2/4
  Installing     : git                                                                                   3/4
  Installing     : perl-Git                                                                              4/4

Installed:
  git.x86_64 0:1.8.2.1-1.el5

Dependency Installed:
  perl-Error.noarch 1:0.17010-1.el5  perl-Git.x86_64 0:1.8.2.1-1.el5  perl-TermReadKey.x86_64 0:2.30-4.el5

Complete!


Start  yum-updatesd again:


# cd /etc/init.d/
# ./yum-updatesd start


Run git command


# git
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=] [--work-tree=] [--namespace=]
           []

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

See 'git help ' for more information on a specific command