Installing Git, Curl, and Expat from Source

Mat*_*sen 7 source rhel git

I have a RHEL 6.4 VM provisioned by my company's internal KVM.

We are having some trouble using yum (Cannot retrieve repository metadata, which I've confirmed in this case is peculiar to my company's internal cloud), so I have to build Git from source.

Downloading the RPM file and issuing

sudo yum localinstall ....rpm
Run Code Online (Sandbox Code Playgroud)

Gives me the same Cannot retrieve repository metadata error.

Issuing

sudo rpm -ivh ....rpm
Run Code Online (Sandbox Code Playgroud)

Fails with an error: Failed dependencies and then lists all the packages I need to install. I assume I could find the download links for all of them, but I've tried this before and was unable to find the download links for the right versions for the right packages.

The following code actually works, thanks to @slm's answer:

wget ftp://fr2.rpmfind.net/linux/dag/redhat/el6/en/x86_64/extras/RPMS/perl-Git-1.7.9.6-1.el6.rfx.x86_64.rpm
wget http://pkgs.repoforge.org/git/git-1.7.9.6-1.el6.rfx.x86_64.rpm
rpm -ivh perl-Git-1.7.9.6-1.el6.rfx.x86_64.rpm git-1.7.9.6-1.el6.rfx.x86_64.rpm
Run Code Online (Sandbox Code Playgroud)

If I just download the git code, untar it, and build it, like:

wget https://www.kernel.org/pub/software/scm/git/git-1.8.5.tar.gz
tar -xvf git-1.8.5.tar.gz
cd git-1.8.5
./configure
make
make install
Run Code Online (Sandbox Code Playgroud)

I receive the following error when cloning from the http:// protocol:

fatal: Unable to find remote helper for 'http'
Run Code Online (Sandbox Code Playgroud)

Googling told me that I needed curl-devel and expat. I can not use yum, so I went and built those as well:

cd ..
wget http://curl.haxx.se/download/curl-7.34.0.tar.gz
tar -xvf curl-7.34.0.tar.gz
cd curl-7.34.0
./configure
make
make install

cd ..
wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
tar expat-2.1.0.tar.gz
cd expat-2.1.0
./configure
make
make install
Run Code Online (Sandbox Code Playgroud)

However, upon rebuilding Git, I receive the same error. After Googling more I determined that I needed to pass the following parameters to Git's ./configure:

cd git-1.8.5
./configure --with-curl=<curl_install_path> --with-expat=<expat_install_path> 
Run Code Online (Sandbox Code Playgroud)

However, I couldn't determine where the curl and expat install paths were located.

So what I did instead was build Git, curl, and expat using the ./configure --prefix=/path/to/desired/install/path

mkdir curl
cd curl-7.34.0
./configure --prefix=/home/downloads/curl
...
mkdir expat
cd expat-2.1.0
./configure --prefix=/home/downloads/expat
...
mkdir git
cd git-1.8.5
./configure --prefix=/home/downloads/git --with-curl=/home/downloads/curl --with-expat=/home/downloads/expat
...
Run Code Online (Sandbox Code Playgroud)

and from this I was able to clone with Git from the http protocol. However, this violates the Linux file structure.

Two Questions:

  1. When building Git from source, you need to include the curl and expat install paths to ./configure. Where are these install paths when installing curl and expat without the prefix argument?
  2. I learned that I needed curl and expat's install paths when I got an error and searched for it. Are there any other programs I need to tell Git so I don't get errors in the future?

slm*_*slm 3

我想我建议不要直接从源代码安装这些项目,而是利用包管理器的功能来仍然维护这些包。

本地安装

您可以使用命令行工具(例如curl或 )仍然使用或直接wget下载安装它们所需的软件包。yumrpm

$ sudo yum localinstall some.rpm
-or-
$ sudo rpm -ivh some.rpm
Run Code Online (Sandbox Code Playgroud)

我建议在RepoForgeEPEL存储库中查找RPM。例如,git包在这里。

终端中的一个简单命令即可下载它:

$ wget http://pkgs.repoforge.org/git/git-1.7.10.4-1.el6.rfx.x86_64.rpm
Run Code Online (Sandbox Code Playgroud)

重建源 RPM

如果您必须拥有最新版本,您仍然可以使用 RPM,但.rpm您需要获取该版本,而不是下载软件包的版本.src.rpm。可以使用以下命令重建它们:

$ rpmbuild --rebuild some.src.rpm
Run Code Online (Sandbox Code Playgroud)

使用捐赠源 RPM 重建 tar.gz

您还可以获取.tar.gztarball 并重新使用.spec上面包含的文件.src.rpm。您可以通过以下命令来执行此操作。

$ mkdir -p ~/rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
Run Code Online (Sandbox Code Playgroud)

然后创建一个~/.rpmmacros文件。

%packager Your Name
%_topdir /home/YOUR HOME DIR/rpm
%_tmppath /home/YOUR HOME DIR/rpm/tmp
Run Code Online (Sandbox Code Playgroud)

现在我们准备好“安装”捐赠者了.src.rpm

$ rpm -ivh some.src.rpm
Run Code Online (Sandbox Code Playgroud)

这将在您的目录中存放一个 tarball 和一个.spec文件~/rpm。然后,您可以编辑此.spec文件并将 tarball 替换为较新的 tarball。

现在重建它:

$ rpmbuild -ba ~/rpm/SPECS/some.spec
Run Code Online (Sandbox Code Playgroud)

完成后,这将创建.rpm一个新文件。.src.rpm

附加提示

您可以使用该工具yum-builddep来确保在开始之前安装了所有必需的 RPM。

$ sudo yum-builddep some.src.rpm
Run Code Online (Sandbox Code Playgroud)