How to make rpm auto install dependencies - linux

I have built two RPM packages
proj1-1.0-1.x86_64.rpm
libtest1-1.0-1.x86_64.rpm
proj1 depends on the file libtest1.so being present and it is reflected correctly in the RPM packages as seen here:
user#my-pc:~$ rpm -qp --requires proj1-1.0-1.x86_64.rpm
libtest1.so()(64bit)
user#my-pc:~$ rpm -qp --provides libtest1-1.0-1.x86_64.rpm
libtest1.so()(64bit)
The installation of proj1 fails due to a missing dependency.
user#my-pc:~$ rpm -ivh proj1-1.0-1.x86_64.rpm
error: Failed dependencies:
libtest1.so()(64bit) is needed by proj1-1.0-1.x86_64.rpm
How do I ensure that libtest1-1.0-1.x86_64.rpm is installed automatically during
the installation of proj1-1.0-1.x86_64.rpm?
I did try the --aid option with rpm -i as described here but it didn't work for me.
Is there any other way?
Thanks for any help.

The link #gertvdijk provided shows a quick way to achieve the desired results without configuring a local repository:
$ yum --nogpgcheck localinstall packagename.arch.rpm
Just change packagename.arch.rpm to the RPM filename you want to install.
Edit Just a clarification, this will automatically install all dependencies that are already available via system YUM repositories.
If you have dependencies satisfied by other RPMs that are not in the system's repositories, then this method will not work unless each RPM is also specified along with packagename.arch.rpm on the command line.

Create a (local) repository and use yum to have it resolve the dependencies for you.
The CentOS wiki has a nice page providing a how-to on this. CentOS wiki HowTos/CreateLocalRepos.
Summarized and further minimized (not ideal, but quickest):
Create a directory for you local repository, e.g. /home/user/repo.
Move the RPMs into that directory.
Fix some ownership and filesystem permissions:
# chown -R root.root /home/user/repo
Install the createrepo package if not installed yet, and run
# createrepo /home/user/repo
# chmod -R o-w+r /home/user/repo
Create a repository configuration file, e.g. /etc/yum.repos.d/myrepo.repo containing
[local]
name=My Awesome Repo
baseurl=file:///home/user/repo
enabled=1
gpgcheck=0
Install your package using
# yum install packagename

For dnf users just use dnf install *.rpm, localinstall is no longer needed.

For me worked just with
# yum install ffmpeg-2.6.4-1.fc22.x86_64.rpm
And automatically asked authorization to dowload the depedencies.
Below the example, i am using fedora 22
[root#localhost lukas]# yum install ffmpeg-2.6.4-1.fc22.x86_64.rpm
Yum command has been deprecated, redirecting to '/usr/bin/dnf install ffmpeg-2.6.4-1.fc22.x86_64.rpm'.
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'
Last metadata expiration check performed 0:28:24 ago on Fri Sep 25 12:43:44 2015.
Dependencies resolved.
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
SDL x86_64 1.2.15-17.fc22 fedora 214 k
ffmpeg x86_64 2.6.4-1.fc22 #commandline 1.5 M
ffmpeg-libs x86_64 2.6.4-1.fc22 rpmfusion-free-updates 5.0 M
fribidi x86_64 0.19.6-3.fc22 fedora 69 k
lame-libs x86_64 3.99.5-5.fc22 rpmfusion-free 345 k
libass x86_64 0.12.1-1.fc22 updates 85 k
libavdevice x86_64 2.6.4-1.fc22 rpmfusion-free-updates 75 k
libdc1394 x86_64 2.2.2-3.fc22 fedora 124 k
libva x86_64 1.5.1-1.fc22 fedora 79 k
openal-soft x86_64 1.16.0-5.fc22 fedora 292 k
opencv-core x86_64 2.4.11-5.fc22 updates 1.9 M
openjpeg-libs x86_64 1.5.1-14.fc22 fedora 89 k
schroedinger x86_64 1.0.11-7.fc22 fedora 315 k
soxr x86_64 0.1.2-1.fc22 updates 83 k
x264-libs x86_64 0.142-12.20141221git6a301b6.fc22 rpmfusion-free 587 k
x265-libs x86_64 1.6-1.fc22 rpmfusion-free 486 k
xvidcore x86_64 1.3.2-6.fc22 rpmfusion-free 264 k
Transaction Summary
====================================================================================================================
Install 17 Packages
Total size: 11 M
Total download size: 9.9 M
Installed size: 35 M
Is this ok [y/N]: y

I found a simpler solution. If you have all the RPMs in the same directory, all you need to do is,
$ sudo rpm -i *.rpm
rpm seems to figure out the correct order to install these and installs the RPMs.

Matthew's answer awoke many emotions, because of the fact that it still lacks a minor detail.
The general command would be:
# yum --nogpgcheck localinstall <package1_file_name> ... <packageN_file_name>
The package_file_name above can include local absolute or relative path, or be a URL (possibly even an URI).
Yum would search for dependencies among all package files given on the command line AND IF IT FAILS to find the dependencies there, it will also use any configured and enabled yum repositories.
Neither the current working directory, nor the paths of any of package_file_name will be searched, except when any of these directories has been previously configured as an enabled yum repository.
So in the OP's case the yum command:
# cd <path with pkg files>; yum --nogpgcheck localinstall ./proj1-1.0-1.x86_64.rpm ./libtest1-1.0-1.x86_64.rpm
would do, as would do the rpm:
# cd <path with pkg files>; rpm -i proj1-1.0-1.x86_64.rpm libtest1-1.0-1.x86_64.rpm
The differencve between these yum and rpm invocations would only be visible if one of the packages listed to be installed had further dependencies on packages NOT listed on the command line.
In such a case rpm will just refuse to continue, while yum would use any configured and enabled yum repositories to search for dependencies, and may possibly succeed.
The current working directory will NOT be searched in any case, except when it has been previously configured as an enabled yum repository.

Copy all your RPMs in a directory, then install as follows:
yum install -y --cacheonly --disablerepo=* /var/rpm_dir/*.rpm
For specific packages you can use yumdownloader, example in this other thread: https://stackoverflow.com/a/66927190/5078874

I ran into this and what worked for me was to run yum localinstall enterPkgNameHere.rpm from inside the directory where the .rpm file is located.
Note: replace the enterPkgNameHere.rpm with the name of your .rpm file.

In the case of openSUSE Leap 15, I'm receiving similar error:
> sudo rpm -i opera-stable_53.0.2907.68_amd64.rpm
[sudo] password for root:
warning: opera-stable_53.0.2907.68_amd64.rpm: Header V4 RSA/SHA512 Signature, key ID a5c7ff72: NOKEY
error: Failed dependencies:
at is needed by opera-stable-53.0.2907.68-0.x86_64
I run this command to figure out what are the dependencies:
> sudo zypper install opera-stable_53.0.2907.68_amd64.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 4 NEW packages are going to be installed:
at libfl2 libHX28 opera-stable
4 new packages to install.
Overall download size: 50.3 MiB. Already cached: 0 B. After the operation, additional 176.9 MiB will be used.
Continue? [y/n/...? shows all options] (y): n
Then I run this command to install dependencies:
> sudo zypper in at
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 3 NEW packages are going to be installed:
at libfl2 libHX28
3 new packages to install.
Overall download size: 208.6 KiB. Already cached: 0 B. After the operation, additional 600.4 KiB will be used.
Continue? [y/n/...? shows all options] (y): y
Then I run this to install the rpm file:
> sudo rpm -i opera-stable_53.0.2907.68_amd64.rpm
I'm not sure if it is the best practice, however it solved my issue.

Step1: copy all the rpm pkg in given locations
Step2: if createrepo is not already installed, as it will not be by default, install it.
[root#pavangildamysql1 8.0.11_rhel7]# yum install createrepo
Step3: create repository metedata and give below permission
[root#pavangildamysql1 8.0.11_rhel7]# chown -R root.root /scratch/PVN/8.0.11_rhel7
[root#pavangildamysql1 8.0.11_rhel7]# createrepo /scratch/PVN/8.0.11_rhel7
Spawning worker 0 with 3 pkgs
Spawning worker 1 with 3 pkgs
Spawning worker 2 with 3 pkgs
Spawning worker 3 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root#pavangildamysql1 8.0.11_rhel7]# chmod -R o-w+r /scratch/PVN/8.0.11_rhel7
Step4: Create repository file with following contents at /etc/yum.repos.d/mysql.repo
[local]
name=My Awesome Repo
baseurl=file:///scratch/PVN/8.0.11_rhel7
enabled=1
gpgcheck=0
Step5 Run this command to install
[root#pavangildamysql1 local]# yum --nogpgcheck localinstall mysql-commercial-server-8.0.11-1.1.el7.x86_64.rpm

Simple just run the following command.
sudo dnf install *package.rpm
Enter your password and you are done.

Process of generating RPM from source file:
1) download source file with.gz extention.
2) install rpm-build and rpmdevtools from yum install. (rpmbuild folder will be generated...SPECS,SOURCES,RPMS.. folders will should be generated inside the rpmbuild folder).
3) copy the source code.gz to SOURCES folder.(rpmbuild/SOURCES)
4)Untar the tar ball by using the following command.
go to SOURCES folder :rpmbuild/SOURCES where tar file is present.
command: e.g tar -xvzf httpd-2.22.tar.gz
httpd-2.22 folder will be generated in the same path. Check if apr and apr-util and there in httpd-2.22/srclib folder. If apr and apr-util doesnt exist download latest version from apache site ,untar it and put it inside httpd-2.22/srclib folder. Also make sure you have pcre install in your system .
5)go to extracted folder and then type below command:
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-proxy --enable-proxy-balancer --with-mpm=worker --enable-mods-static=all
6)run below command once the configure is successful:
make
7)after successfull execution od make command run:
checkinstall
in tha same folder. (if you dont have checkinstall software please download latest version from site)
Also checkinstall software has bug which can be solved by following way:::::
locate checkinstallrc and then replace TRANSLATE = 1 to TRANSLATE=0 using vim command.
Also check for exclude package: EXCLUDE="/selinux"
8)checkinstall will ask for option (type R if you want tp build rpm for source file)
9)Done .rpm file will be built in RPMS folder inside rpmbuild/RPMS file...
ALL the BEST ....
Regards,
Prerana

Related

How to install Skopeo on AWS Linux?

I am trying to install skopeo on AWS Linux but getting error - No package found.
[root#master ~]# yum -y install skopeo
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00:00
228 packages excluded due to repository priority protections
No package skopeo available.
Error: Nothing to do
[root#master ~]#
How can I install Skopeo on AWS Linux?
Is there any other tool available on AWS linux which helps to inspect images?
Edited: This package is available in the CentOS-7 Extras repo. Enabling this repo on Amazon Linux 2 may have unintended consequences. You may want to consider running an EC2 instance of CentOS or RHEL to manage this workload. If you want to live on the edge IMO, do the below at your own risk.
You can either download (wget or curl) and install the package manually with rpm, and resolve the dependencies, or you can configure the CentOS-7 repository and try to install directly with Yum.
In order to install packages from the CentOS-7 Extras repo, you need to download the GPG key :
cd /etc/pki/rpm-gpg/
curl -s https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7
You will then need to create a repo file in /etc/yum.repos.d :
[extras]
name=CentOS-7 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/7/extras/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
priority=1
This only gets you part way there :
# yum --disablerepo='*' --enablerepo='extras' search skopeo
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
============================================================================================ N/S matched: skopeo =============================================================================================
skopeo.x86_64 : Inspect container images and repositories on registries
skopeo-containers.x86_64 : Configuration files for working with image signature
containers-common has a dependency on subscription-manager which is part of the CentOS-7 core packages, and there are related dependencies. You can download these core packages here :
http://mirror.centos.org/centos/7/os/x86_64/Packages/
You will need the following packages :
cd /tmp
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/subscription-manager-1.24.42-1.el7.centos.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/subscription-manager-plugin-ostree-1.24.42-1.el7.centos.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/subscription-manager-rhsm-1.24.42-1.el7.centos.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/subscription-manager-rhsm-certificates-1.24.42-1.el7.centos.x86_64.rpm
wget python-syspurpose-1.24.42-1.el7.centos.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-syspurpose-1.24.42-1.el7.centos.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-dmidecode-3.12.2-4.el7.x86_64.rpm
You will also need to install dependencies available from Amazon Linux 2 :
yum install dbus-python pygobject3-base python-decorator python-dmidecode python-ethtool python-inotify python-syspurpose python-gobject-base gobject-introspection
Now you can install the manually downloaded RPMs :
rpm -i *rpm
I completed all of these steps on a test server, and everything installed. I'm not familiar with the Skopeo tools, so I can't speak as to whether or not it will work.
Once word of caution, when you add third party repos to an OS, you risk unintentional upgrades of other packages during a normal OS upgrade, and this can break things.
You can avoid this by setting "enable = 0" in the Yum repo files, and enabling the repo at the command line ONLY when you want to update those packages (i.e. "yum --enablerepo=remi update skopeo")
OK, hope this helps.

dependency error while installing docker 1.12 in rhel 7

Aim: Install latest docker (v1.12) in rhel 7 in offline mode
I got dependency error while installing docker 1.12 in rhel 7, and I
tried to find those dependencies in internet but didn't found those
dependencies except selinux-policy rpm.
I tried to install after yum update.
I found dependencies of docker 1.7 on internet, installed in rhel 6.7
but could not make same way for docker 1.12 in rhel 7
I tried below things
Installed docker 1.12 when system(test machine) is connected to internet and after installing docker 1.12 all dependencies will cache in /var/cahce/yum/rhel7/ location and search for above dependencies but didn't found.
Crated local yum repo and mounted iso file and then did yum update
and tried to install docker but still give same dependencies error.
I'm not sure how above steps are correct or right procedure, I just tired but anything didn't work.
my production environment does not have internet connection and it has only intranet connection only.
Can some one provide or advice me how to solve this and how to proceed this kind of problems?
Thanks in advance!
I'm kind of surprised you can't find at least the non-docker packages here as these come from standard CentOS repositories. In general, I'd use something like:
# yum provides "*/<filename>"
e.g.
# yum provides "*/libsystemd.so.*"
This obviously won't help if you've not configured the repositories on your target system, but it's pretty easy to run a Vagrant VM and see what's required there.
$ vagrant init bento/centos-7.2
$ vagrant ssh
then follow the docs at https://docs.docker.com/engine/installation/linux/centos/:
$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
and install it:
$ sudo yum install docker-engine
On mine, this gives:
[vagrant#localhost ~]$ sudo yum install docker-engine
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.ukhost4u.com
* extras: mirror.vorboss.net
* updates: mirror.vorboss.net
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.12.1-1.el7.centos will be installed
--> Processing Dependency: docker-engine-selinux >= 1.12.1-1.el7.centos for package: docker-engine-1.12.1-1.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-engine-1.12.1-1.el7.centos.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-engine-1.12.1-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-engine-selinux.noarch 0:1.12.1-1.el7.centos will be installed
---> Package libseccomp.x86_64 0:2.2.1-1.el7 will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================
Package Arch Version Repository Size ============================================================================================================
Installing:
docker-engine x86_64 1.12.1-1.el7.centos dockerrepo 19 M Installing for dependencies:
docker-engine-selinux noarch 1.12.1-1.el7.centos dockerrepo 28 k libseccomp x86_64 2.2.1-1.el7 base 49 k libtool-ltdl x86_64 2.4.2-21.el7_2 updates 49 k
Transaction Summary
============================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 19 M
Installed size: 79 M
Running that yum provides command I gave above shows you that e.g. libsystemd.so* is in the systemd-libs package and available in the "updates" repo .. see http://mirror.centos.org/centos/7/updates/x86_64/Packages/
Try this command:
yum install libtool-ltdl
After this re-run installation command.
This will be done automatically, if you have "docker-ce" repository.
Good luck!

Why couldn't the latest version of rsync be installed on CentOS 7.2?

I am using CentOS 7.2.
I would like to install the latest version of rsync - rsync-3.1.2,
rsync-3.0.9 is on system, installed when installing mariadb with yum,
# rpm -qa |grep rsync
rsync-3.0.9-17.el7.x86_64
removing rsync-3.0.9 first,
# yum remove rsync
rsync and mariadb were removed together,
then,
installing rsync-3.1.2 from source code,
# wget https://download.samba.org/pub/rsync/src/rsync-3.1.2.tar.gz
# tar -zxvf rsync-3.1.2.tar.gz
# cd rsync-3.1.2
# ./configure
# make
# make install
then,
installing mariadb with yum again,
but rsync-3.0.9 will still be installed.
How can I solve the problem?
You can install rsync 3.1.2 from the Fedora 24 .rpm package:
wget http://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/r/rsync-3.1.2-2.fc24.x86_64.rpm
rpm -Uvh rsync-3.1.2-2.fc24.x86_64.rpm
(but that question doesn't really belong to stackoverflow)
You can install rsync 3.1.2 from the gf-plus repo. Just follow the steps below:
Install the gf-release package.
sudo rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/el/7/gf/x86_64/gf-release-7-10.gf.el7.noarch.rpm
Upgrade rsync package from the gf-plus repo.
sudo yum install -y --enablerepo=gf-plus rsync
Check rsync version.
hash -r; rsync --version | awk 'NR==1 {print $3}'
If it prints 3.1.2, rsync is upgraded.
By default, only the gf repo is enabled, which claims that it "won't overwrite core distro packages". You can disable it:
sudo yum-config-manager --disable gf
(For command not found error, run sudo yum install -y yum-utils and try again.)
Or simply remove all the gf* repos by removing the gf-release package:
sudo yum remove -y gf-release
You either need to install all of your software using packages, or install all of your software from source. Trying to mix and match is going to lead to exactly the sort of problem you are experiencing here: the mariadb package has a dependency on rsync, but the package manager doesn't know anything about the files you have installed from source.
The correct way to solve this problem is to build your own rsync package that can then be installed with yum. You can start with the source package for your distribution and then modify it for 3.1.2. You may be able to utilize a more recent package (e.g., from Fedora) and rebuild it for your system.
You can find the source RPM for rsync-3.0.9 here, and there is some documentation that will hopefully help you get started here.

xz compression install on centos

Any installation or update using yum command I ended up error: Error: xz compression not available. On website I read that Python library is missing. When you try to install a library (sudo yum update pyliblzma) again failed with error. Do not know how? Thanks.
This problem comes if you installed a wrong epel release on your machine. If so, then you need to remove the epel release by
yum remove epel-release
Sometimes that is not enough, you need to remove the cache as well by:
rm -rf /var/cache/yum/x86_64/6/epel
Then you can install the epel-release again
yum -y install epel-release
You need install the EPEL repository by downloading the appropriate RPM package for your system and installing it. For example, for CentOS and Red Hat Enterprise Linux 6.x:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm
If you get a File Not Found error message when trying to download the package, the version number might have changed. You can access the latest version of the RPM installer from the Fedora EPEL wiki page. The wiki page also includes additional instructions for Red Hat Network subscribers who are installing the EPEL repository.
Finally, install the Python library:
yum install pyliblzma
This works perfecly in my CentOS 6.x.
I've found a solution on this page of stackexchange, working in CentOS 6.X:
https://unix.stackexchange.com/a/314756
sudo rpm -e epel-release-7-5.noarch
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm
sudo yum clean all
sudo rpmdb -v --rebuilddb
sudo yum -y install libselinux-python
I was also suffering from this issue..
If you are installing packages but it is already available on your system.
Remove existing packages and then try to install new.
It will work properly...
I was able to solve this problem by installing pyliblzma using rpm instead of yum as yum is not working.
Find pyliblzma rpm package according to your architecture and install it using the command.
rpm -Uvh pyliblzma-version-release.architecture.rpm
I used the following command to install pyliblzma for my 64 bit Redhat 6.8 machine. Please check URL in the command and make changes accordingly.
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/pyliblzma-0.5.3-3.el6.x86_64.rpm
In my case the issue was caused by missing modules in python's site-packages directory. Here's what I did:
$ rpm -Va
to get a list of all files belonging to all rpms that do not verify. I got a bunch of messages about missing modules:
missing /usr/lib64/python2.7/site-packages/...
Luckily, I had an identical CentOS version elsewhere with all these packages present, so I just copied them over and ran
$ rpmdb -v --rebuilddb
to rebuild rpm database.

How to install latest version of git on CentOS 8.x/7.x/6.x

I used the usual:
yum install git
It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7.
You can use WANDisco's CentOS repository to install Git 2.x: for CentOS 6, for CentOS 7
Install WANDisco repo package:
yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
- or -
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
- or -
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
Install the latest version of Git 2.x:
yum install git
Verify the version of Git that was installed:
git --version
As of 02 Mar. 2020, the latest available version from WANDisco is 2.22.0.
Having a look at the blog here I found the solution in one of the comments. Make sure you got the rpmforge repository added to your CentOS yum and just run the flowing command:
yum --disablerepo=base,updates --enablerepo=rpmforge-extras install git
If you already have git installed then use:
yum --disablerepo=base,updates --enablerepo=rpmforge-extras update git
Related question(s):
Facing issues while upgrading git to latest version on CentOS 6.4
Note update:
Thanks to Anthony Hatzopoulos, for git v1.8x you'll need to use git18 as in:
yum --disablerepo=base,updates --enablerepo=rpmforge-extras install git18
Note update 2:
Also thanks to #Axlrod for the below hint and #Hiphip for the feedback:
Change the rpmforge.repo file to have rpmforge-extras to enabled,
yum update git. Otherwise it complained about dependency problems.
Note update 3:
Installing a specific version of git say 2.x
I found this nice and easy-to-follow guide on how to download the GIT source and compile it yourself (and install it). If the accepted answer does not give you the version you want, try the following instructions:
http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/
(And pasted/reformatted from above source in case it is removed later)
Step 1: Install Required Packages
Firstly we need to make sure that we have installed required packages on your system. Use following command to install required packages before compiling Git source.
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
Step 2: Uninstall old Git RPM
Now remove any prior installation of Git through RPM file or Yum package manager. If your older version is also compiled through source, then skip this step.
# yum remove git
Step 3: Download and Compile Git Source
Download git source code from kernel git or simply use following command to download Git 2.0.4.
# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.0.4.tar.gz
# tar xzf git-2.0.4.tar.gz
After downloading and extracting Git source code, Use following command to compile source code.
# cd git-2.0.4
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
#
# echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
# or
# echo 'export PATH=$PATH:/usr/local/git/bin' > /etc/profile.d/git.sh
#
# source /etc/bashrc
HINT 1:
Updated method of adding compiled git bin directory to bashrc. Because echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc used "" instead of '', it would expand the current session's value for $PATH instead of keeping it as a variable, and could adversely affect the entire system. At the minimum, it should use '' instead of "" and should really be a separate script in /etc/profile.d/
HINT 2 (#DJB):
/usr/local/git/bin before $PATH, since the older version of git was already on $PATH: export PATH=/usr/local/git/bin:$PATH
Step 4. Check Git Version
One completion of above steps, you have successfully install Git in your system. Let use following command to check git version
# git --version
git version 2.0.4
I also wanted to add that the "Getting Started" guide at the GIT website also includes instructions on how to download and compile it yourself:
http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Rackspace maintains the ius repository, which contains a reasonably up-to-date git, but the stock git has to first be removed.
CentOS 6 or 7 instructions (run as root or with sudo):
# retrieve and check CENTOS_MAIN_VERSION (6 or 7):
CENTOS_MAIN_VERSION=$(cat /etc/centos-release | awk -F 'release[ ]*' '{print $2}' | awk -F '.' '{print $1}')
echo $CENTOS_MAIN_VERSION
# output should be "6" or "7"
# Install IUS Repo and Epel-Release:
yum install -y https://repo.ius.io/ius-release-el${CENTOS_MAIN_VERSION}.rpm
yum install -y epel-release
# re-install git:
yum erase -y git*
yum install -y git-core
# check version:
git --version
# output: git version 2.24.3
Note: git-all instead of git-core often installs an old version. Try e.g. git224-all instead.
The script is tested on a CentOS 7 docker image (7e6257c9f8d8) and on a CentOS 6 docker image (d0957ffdf8a2).
I found this nice and easy-to-follow guide on how to download the GIT source and compile it yourself (and install it). If the accepted answer does not give you the version you want, try the following instructions:
http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/
(And pasted/reformatted from above source in case it is removed later)
Step 1: Install Required Packages
Firstly we need to make sure that we have installed required packages on your system. Use following command to install required packages before compiling Git source.
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
Step 2: Uninstall old Git RPM
Now remove any prior installation of Git through RPM file or Yum package manager. If your older version is also compiled through source, then skip this step.
# yum remove git
Step 3: Download and Compile Git Source
Download git source code from kernel git or simply use following command to download Git 2.5.3.
# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.5.3.tar.gz
# tar xzf git-2.5.3.tar.gz
After downloading and extracting Git source code, Use following command to compile source code.
# cd git-2.5.3
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo 'pathmunge /usr/local/git/bin/' > /etc/profile.d/git.sh
# chmod +x /etc/profile.d/git.sh
# source /etc/bashrc
Step 4. Check Git Version
On completion of above steps, you have successfully install Git in your system. Use the following command to check the git version
# git --version
git version 2.5.3
I also wanted to add that the "Getting Started" guide at the GIT website also includes instructions on how to download and compile it yourself:
http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
My personal preference is to build rpm packages for CentOS when installing non-standard software and replacing distributed components. For this I recommend that you use Mock to create a clean build environment.
The procedure is:
Obtain the source RPMS or a suitable SPEC file and pristine source tarball. In this case one may find source RPM packages for git2X for CentOS-6 at: http://dl.iuscommunity.org/pub/ius/archive/CentOS/6/SRPMS/. Packages for other CentOS releases are also available.
Install the necessary support software:
yum install epel-release # you need this for mock
yum install rpm-build
yum install redhat-rpm-config
yum install rpmdevtools
yum install mock
Add a rpm build user account (do not build as root or as a real user - security issues will come back to bite you).
sudo adduser builder --home-dir /home/builder \
--create-home --user-group --groups mock \
--shell /bin/bash --comment "rpm package builder"
Next we need a build environment.
su -l builder
rpmdev-setuptree
This produces the following directory structure:
~
└── rpmbuild
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
We are using a prepared SRPMS so the SOURCES tarballs can be ignored for this case and we can go direct to SRPMS.
wget http://dl.iuscommunity.org/pub/ius/archive/CentOS/6/SRPMS/git2u-2.5.3-1.ius.centos6.src.rpm \
-O ~/rpmbuild/SRPMS/git2u-2.5.3-1.ius.centos6.src.rpm
Configure mock (as root)
cd /etc/mock
rm default.cfg
ln -s epel-6-x86_64.cfg default.cfg
vim default.cfg
Disable the beta repos. Enable the base and update repos.
Initialize the build tree (/var/lib/mock is default)
mock --init
If we were building from SOURCES then this is where we would employ the SPEC file and use mock --buildsrpm . . .. But in this case we go directly to the binary build step:
mock --no-clean --rebuild ~/rpmbuild/SRPMS/git2u-2.5.3-1.ius.centos6.src.rpm
This will resolve the build dependencies and download them (about 95 or so packages) into the clean build root. It will then extract the sources and build the binary from the provided SRPM and leave it in /var/lib/mock/epel-6-x86_64/result; or in whatever custom build root location and architecture you provided. It will take a long time. There is a lot to this package; particularly documentation.
If all goes well then you should end up with a suit of RPM packages suitable for installation in place of the distro version. This is what I ended up with:
ll /var/lib/mock/epel-6-x86_64/result
total 34996
-rw-rw-r--. 1 byrnejb mock 448455 Oct 30 10:09 build.log
-rw-rw-r--. 1 byrnejb mock 52464 Oct 30 10:09 emacs-git2u-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 47228 Oct 30 10:09 emacs-git2u-el-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 8474478 Oct 30 09:57 git2u-2.5.3-1.ius.el6.src.rpm
-rw-rw-r--. 1 byrnejb mock 8877584 Oct 30 10:09 git2u-2.5.3-1.ius.el6.x86_64.rpm
-rw-rw-r--. 1 byrnejb mock 27284 Oct 30 10:09 git2u-all-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 27800 Oct 30 10:09 git2u-bzr-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 112564 Oct 30 10:09 git2u-cvs-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 436176 Oct 30 10:09 git2u-daemon-2.5.3-1.ius.el6.x86_64.rpm
-rw-rw-r--. 1 byrnejb mock 15858600 Oct 30 10:09 git2u-debuginfo-2.5.3-1.ius.el6.x86_64.rpm
-rw-rw-r--. 1 byrnejb mock 60556 Oct 30 10:09 git2u-email-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 274888 Oct 30 10:09 git2u-gui-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 79176 Oct 30 10:09 git2u-p4-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 483132 Oct 30 10:09 git2u-svn-2.5.3-1.ius.el6.x86_64.rpm
-rw-rw-r--. 1 byrnejb mock 173732 Oct 30 10:09 gitk2u-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 115692 Oct 30 10:09 gitweb2u-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 57196 Oct 30 10:09 perl-Git2u-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 89900 Oct 30 10:09 perl-Git2u-SVN-2.5.3-1.ius.el6.noarch.rpm
-rw-rw-r--. 1 byrnejb mock 101026 Oct 30 10:09 root.log
-rw-rw-r--. 1 byrnejb mock 980 Oct 30 10:09 state.log
Install using yum or rpm.
You will require git2u-2.5.3-1.ius.el6.x86_64.rpm at a minimum and such additional support packages as it requires (perl-Git2u-2.5.3-1.ius.el6.noarch.rpm) or you desire.
This build has a cyclic dependency: git2u-2.5.3-1.ius.el6.x86_64.rpm depends upon perl-Git2u-2.5.3-1.ius.el6.noarch.rpm and perl-Git2u-2.5.3-1.ius.el6.noarch.rpm depends upon git2u-2.5.3-1.ius.el6.x86_64.rpm. A straight install with rpm will thus fail.
There are two ways of dealing with it:
Install both at the same time via yum:
yum localinstall \
git2u-2.5.3-1.ius.el6.x86_64.rpm \
perl-Git2u-2.5.3-1.ius.el6.noarch.rpm`
Setup a local yum repo.
I am including my LocalFile.repo file below as it contains instructions on how to do this and provides the necessary repo file at the same time.
cat /etc/yum.repos.d/LocalFile.repo
# LocalFile.repo
#
# This repo is used with a local filesystem repo.
#
# To use this repo place the rpm package in /root/RPMS/yum.repo/Packages.
# Then run: createrepo --database --update /root/RPMS/yum.repo.
#
# To use:
# yum --enablerepo=localfile [command]
#
# or to use only ONLY this repo, do this:
#
# yum --disablerepo=\* --enablerepo=localfile [command]
[localfile]
baseurl=file:///root/RPMS/yum.repo
name=CentOS-$releasever - Local Filesystem repo
# Before persistently enabling this repo see the priority note below.
enabled=0
gpgcheck=0
# When this repo is enabled all packages in repos with priority>5
# will not be updated even when they have a more recent version.
# Be careful with this.
priority=5
You also may be required to manually pre-install additional dependency packages such as perl-TermReadKey available from the usual repositories.
To build and install modern Git on CentOS 6:
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
export GIT_VERSION=2.6.4
mkdir /root/git
cd /root/git
wget "https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz"
tar xvzf "git-${GIT_VERSION}.tar.gz"
cd git-${GIT_VERSION}
make prefix=/usr/local all
make prefix=/usr/local install
yum remove -y git
git --version # should be GIT_VERSION
as git says:
RHEL and derivatives typically ship older versions of git. You can
download a tarball and build from source, or use a 3rd-party
repository such as the IUS Community Project to obtain a more recent
version of git.
there is good tutorial here.
in my case (Centos7 server) after install had to logout and login again.
Build latest version of git on Centos 6/7
Preparing system to building rpms
Install epel:
For EL6, use:
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
For EL7, use:
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install fedpkg:
sudo yum install fedpkg
Add yourself into group mock (you might need to re-login to server after this change):
sudo usermod -a -G mock $USER
Download git
Download git sources:
fedpkg clone -a git && cd git
fedpkg sources
Verify sources:
sha512sum -c sources
Build rpm
Create srmp. Use el6 for RHEL6, el7 for RHEL7.
fedpkg --dist el7 srpm
Build package in mock:
mock -r epel-7-x86_64 git-2.16.0-1.el7.src.rpm
Install latest version of git rpm from /var/lib/mock/epel-7-x86_64/result/. Note, you might need to uninstall existing version of the git from your system first.
This instruction is based on the mailing list post by Todd Zullinger.
This guide worked:
# hostnamectl
Operating System: CentOS Linux 7 (Core)
# git --version
git version 1.8.3.1
# sudo yum remove git*
# sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
# sudo yum install git
# git --version
git version 2.24.1
Here's my method to install git on centos 6.
sudo yum groupinstall "Development Tools"
sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel curl-devel
sudo yum install wget
cd ~
wget -O git.zip https://github.com/git/git/archive/v2.7.2.zip
unzip git.zip
cd git-2.7.2
make configure
./configure --prefix=/usr/local
make all doc
sudo make install install-doc install-html
Adding a roundabout answer here. I was struggling to install git on an RHEL 6.0 Amazon instance, and what ended up saving me was ... conda, as in Anaconda Python.
I installed conda on the command line from the archives (code modeled after this):
wget http://repo.continuum.io/miniconda/Miniconda2-4.2.12-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
and then ran
conda install git
and a relatively recent version git was installed. Today is 12/26/2016 and the version is 2.9.3.
This may be irrelevant. It is for people don't want build the latest git on the host meanwhile they still can get the latest git.
I think most people don't like building the latest git on CentOS because the dependencies will contaminate the host and you have to run lots of commands. Therefore, I have an idea which is building git inside the Docker container and then install the executable via the docker volume mount. After that, you can delete the image and container.
Yes, the downside is you have to install docker. But the least dependencies are introduced to the host and you don't have to install other yum repo.
Here is my repository. https://github.com/wood1986/docker-library/tree/master/git
If git already installed first remove old git
sudo yum remove git*
And install latest version of git
yum install -y git-core
Check Version
git --version
bingo!!
It can be very confusing, and dangerous, to replace the upstream base repositories with add-on repositories without considerable testing and thought. RPMforge, in particularly, is effectively moribund and is not getting updates.
I personally publish tools for building git 2.4, wrapped as an alternatively named "git24" package, at https://github.com/nkadel/git24-srpm/. Feel free to access and fork those if you want packages distinguished from the standard system packages, much as "samba" and "samba4" packages are differentiated.

Resources