I use github.com for all of my source code source version control. I noticed that in the past few days git push had stopped working for me on the Beaglebone Black (BBB) for one of my repositories. I decided to build git from source to see if it was a version issue. The version of git on the BBB is version 1.7.7 and it appears that this is quite old. A “opkg install git” keeps it a slightly higher revision of version 1.7.7.
There were quite a number of small issues to resolve, so I have written this up to remember them for the future and make them available to all.
Building Git for the Beaglebone
Find the version of git that you would like to install: https://www.kernel.org/pub/software/scm/git/
I’m going to build and install 1.8.3, a fair update from 1.7.7.
First we need to download the source code. I cannot get wget to work with https links on the beaglebone, so I use curl; however, on the Beaglebone black I find that I have to add a “-k” to get curl to work with https sites, otherwise I get an error “curl (77) problem with the ssl ca cert“. However, the downside of “-k” is that you are using curl in insecure mode, allowing connections so SSL sites without certificates. I’m not having much luck with certificates on the beaglebone and need to give this some attention.
This is not a long term fix to the problem as it could leave you vulnerable to man-in-the-middle attacks. However, lets take a chance on kernel.org! At some stage in the future I will look into a proper solution for this.
So, to get started:
root@beaglebone:~/git# curl -k -O https://www.kernel.org/pub/software/scm/git/git-1.8.3.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4365k 100 4365k 0 0 7145 0 0:10:25 0:10:25 --:--:-- 7664
root@beaglebone:~/git# tar xvf git-1.8.3.tar.gz
root@beaglebone:~/git# cd git-1.8.3
You are now in the source directory ~/git/git-1.8.3/ . If you are using the Beaglebone black standard image then you should have all of the dependencies that you need (in particular, build-essentials, ssh, tk, python etc.). You do need python-pyserial and python-distutils. Ensure that you install these before you call make.
root@beaglebone:~/git/git-1.8.3# opkg update
root@beaglebone:~/git/git-1.8.3# opkg install python
root@beaglebone:~/git/git-1.8.3# opkg install python-pyserial
root@beaglebone:~/git/git-1.8.3# opkg install python-distutils
Now this part is a bit of a hack and I’m not sure if there is a better way. py_compile.py was missing from my python install and not being a python user I had to hack my version to add the missing script. I did it by:
# cd /usr/lib/python2.7
# curl -k -O https://raw.github.com/pypy/pypy/master/lib-python/2.7/py_compile.py
Before you do the next step, make sure that your time is correct as the make is doing a time check. Use “date” to check your time. If you haven’t set your clock for NTP, see my guide: Setting the Beaglebone Black time using NTP
Next, I need to remove the current git version – do this before the make install step, which is next:
opkg remove git
Back to my downloaded git source folder to do a .configure. I’m doing this without tcltk as I don’t need a front-end UI:
root@beaglebone:~/git/git-1.8.3# ./configure --without-tcltk
root@beaglebone:~/git/git-1.8.3# make NO_TCLTK=Yes NO_MSGFMT=Yes NO_GETTEXT=Yes install
This takes quite some time on the BBB – maybe 20 minutes + (Note: My build went into an infinite loop that I had to kill and then run the make step again) The options NO_MSGFMT and NO_GETTEXT were added to remove problems that I had during build. They may be release specific and may not be required in later versions/Angstrom distributions.
Okay, the build ends with a simple prompt, with no errors thankfully. The install at the end of the make call installs the new version of git on your system. Don’t do a make install afterwards, without listing the options as above as it will be seen as a new build configuration.
I am finished, and just to check:
root@beaglebone:~# git version
git version 1.8.3