I am stuck in an effort to provide an maintain an up-to-date git release for a collection of CentOS Linux servers. I was hoping to be able to create binary RPMs that I could just have published to a local yum mirror - in order to simply installs, and to easily keep everything up-to-date as part of regular maintenance along with the rest of the OS.
It is a common recommendation to simply install the git binaries from the OS's package manager (yum). However, even under the latest CentOS / RHEL 7, the latest provided packages are stuck at a relatively ancient 1.8.3.1 - compared to the latest 2.7.1. It seems that RPMForge used to provide some updated git packages, but not since EL 6. So it seems that building from source is really the only remaining option here - but using a custom RPM package here to maintain this would be a good idea.
- References:
- https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
- https://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-6-x-7-x
- https://stackoverflow.com/questions/28365026/update-to-latest-git-version-2-2-x-in-centos
- https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7
- https://serverfault.com/questions/709433/install-a-newer-version-of-git-on-centos-7
It looks like using Fedora's "mock" for RPM packaging will be the best way of handling this. It seems that the worst of this would be obtaining / creating / maintaining a SPEC file. Fortunately, it seems that Fedora Rawhide will be invaluable for this - as available at https://rpmfind.net/linux/RPM/fedora/devel/rawhide/src/g/git-2.7.0-1.fc24.src.html .
I had success doing a simple rebuild from the SRPM:
$ mock -r epel-7-x86_64 rebuild /tmp/git-2.7.0-1.fc24.src.rpm
However, installation fails due to many conflicts from the existing OS-provided git installation. I wouldn't want to remove / replace the OS-provided versions anyway, at risk of running into compatibility or dependency issues down the road with other OS-provided packages that may expect the older git version. I'd prefer a custom RPM that uses a /usr/local
prefix.
Using rpm -qpi
against any of native RPMs report that they are (not relocatable)
- meaning I can't run rpm with a --prefix
flag to install in such an alternate location. However, I don't believe I'd want to depend upon using this anyway, as it would complicate being able to run default installs from yum. I would think that this could be easily customized into the source RPM build, so that the resulting RPMs don't conflict.
I thought this would be as simple as defining an alternate value for the _prefix
macro in the SPEC file, as such:
$ mock -r epel-7-x86_64 -D "_prefix /usr/local" rebuild /tmp/git-2.7.0-1.fc24.src.rpm
This looked like it was progressing nicely, until it failed spectacularly - ending with the following errors:
+ sed -e 's@^/builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64@@'
find: '/builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/share/perl5/vendor_perl': No such file or directory
+ find /builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/share/perl5/vendor_perl -mindepth 1 -type d
+ sed -e 's@^/builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64@%dir @'
find: '/builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/share/perl5/vendor_perl': No such file or directory
+ grep Git/SVN perl-git-files
error: Bad exit status from /var/tmp/rpm-tmp.sw2Kfy (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.sw2Kfy (%install)
ERROR: Exception(/tmp/git-2.7.0-1.fc24.src.rpm) Config(epel-7-x86_64) 2 minutes 39 seconds
INFO: Results and/or logs in: /var/lib/mock/epel-7-x86_64/result
ERROR: Command failed. See logs for output.
# bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/git.spec
Alternatively, if I first extract the SPECS and SOURCES, change prefix
to /usr/local
(from %{_prefix}
) in SPECS/git.spec
, then rebuild, things still fail - but at a different spot:
+ install -pm 644 contrib/emacs/git.el /builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/share/emacs/site-lisp/git
+ install -Dpm 644 /builddir/build/SOURCES/git-init.el /builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/share/emacs/site-lisp/site-start.d/git-init.el
+ install -pm 755 contrib/credential/gnome-keyring/git-credential-gnome-keyring /builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/libexec/git-core
install: cannot create regular file '/builddir/build/BUILDROOT/git-2.7.0-1.el7.centos.x86_64/usr/libexec/git-core': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.CJFTef (%install)
Bad exit status from /var/tmp/rpm-tmp.CJFTef (%install)
RPM build errors:
ERROR: Exception(git-build/2/git-2.7.0-1.el7.centos.src.rpm) Config(epel-7-x86_64) 1 minutes 37 seconds
INFO: Results and/or logs in: /var/lib/mock/epel-7-x86_64/result
ERROR: Command failed. See logs for output.
# bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/git.spec
(I'm guessing the former attempt with defining the _prefix
macro was closer to success than forcefully changing prefix
in the SPEC file - as there may now be other usages of _prefix
that are still using the default value.)
- References:
- https://fedoraproject.org/wiki/How_to_create_an_RPM_package
- https://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
- https://wiki.centos.org/HowTos/RebuildSRPM
- http://www.thegeekstuff.com/2015/02/rpm-build-package-example/
- (Disqualified, builds source RPMs as root!)
- http://blog.packagecloud.io/eng/2015/05/11/building-rpm-packages-with-mock/
I'm not exactly sure how to proceed. Is there a different way I should be specifying an alternate installation prefix, or is there something else I can try?