If you compiled OpenWRT’s Chaos Calmer 15.05.1 stable release from source and installed git by opkg, you will get a git version which is both outdated (version 2.3.5-1 while the current version at the time of writing is 2.8.4) and “crippled”. This post shows how to get a more recent version without any limitations.
Major turn-offs of OpenWRT’s default git package
If you want to install git on your OpenWRT router, you have two options:
- Either you use the
opkg install
command to add the git package to a running router or… - …you compile it from the package sources after you activated the package in the menuconfig.
If you go for option 1 as recommended in my contribution about setting up a git server on OpenWRT, the drawback is that you will get a ridiculously outdated version (something around 2.3.5 while the current version at the time of writing is 2.8.4) and your git installation will be crippled in the sense that essential parts like the templates will not be installed.
If you go for option 2, at least there is a more recent vesion (2.8.2 at the time of writing), but the installation will still be crippled. For instance, gitolite which runs on top of git was unable to create new repos. You will get some kind of warning and FATAL messages which include some hint that git lacks a template
folder:
1 |
warning: templates not found /usr/share/git-core/templates |
Solution
Strangely the maintainer of the oWRT git package deliberately removed the template files from the installation. The idea therefore is a to create a simplified Makefile
ressembling the one which was in place prior to the modifications done in the commit linked above.
So we checkout the current package sources for git:
1 2 3 4 5 6 7 8 |
ilek@i7:~/myowrt/custpacks$ svn checkout https://github.com/openwrt/packages/trunk/net/git A git/Makefile A git/patches A git/patches/100-convert_builtin.patch A git/patches/200-disable_fasthash.patch A git/patches/300-configure_for_crosscompiling A git/patches/400-imapsend_without_curl.patch Checked out revision 6018. |
And then change the Makefile
to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# Copyright (C) 2009-2015 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # include $(TOPDIR)/rules.mk PKG_NAME:=git PKG_VERSION:=2.8.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/software/scm/git/ PKG_MD5SUM:=b8edb4ae34828fda6aa2a4478089b107 PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/package.mk define Package/git SECTION:=net CATEGORY:=Network SUBMENU:=Version Control Systems DEPENDS:=+libopenssl +libpthread +librt TITLE:=The fast version control system URL:=http://git-scm.com MAINTAINER:=Peter Wagner <tripolar@gmx.at> endef define Package/git/description 2.8.2 is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. endef MAKE_FLAGS := \ CC="$(TARGET_CC)" \ CFLAGS="$(TARGET_CFLAGS)" \ CPPFLAGS="$(TARGET_CPPFLAGS)" \ LDFLAGS="$(TARGET_LDFLAGS)" \ NO_EXPAT="YesPlease" \ NO_MKSTEMPS="YesPlease" \ NO_GETTEXT="YesPlease" \ NO_UNIX_SOCKETS="YesPlease" \ NO_ICONV="YesPlease" \ NO_NSEC="YesPlease" \ NO_PERL="YesPlease" \ NO_PYTHON="YesPlease" \ NO_TCLTK="YesPlease" \ NO_INSTALL_HARDLINKS="yes" \ CONFIGURE_ARGS += \ --without-iconv \ define Build/Configure $(MAKE) -C $(PKG_BUILD_DIR) \ configure ( cd $(PKG_BUILD_DIR); \ ./configure --prefix=/usr \ ); endef define Package/git/install $(INSTALL_DIR) $(1) $(RM) $(PKG_INSTALL_DIR)/usr/bin/git-cvsserver $(CP) $(PKG_INSTALL_DIR)/* $(1)/ endef $(eval $(call BuildPackage,git)) |
In order to avoid collisions between our customized git and the default git which ships with oWRT, we first uninstall the default git from the menuconfig:
1 2 |
ilek@i7:~/codelab/openwrt$ ./scripts/feeds uninstall git Uninstalling package 'git' |
We then physically remove the default oWRT git feed:
1 |
ilek@i7:~/codelab/openwrt/feeds/packages/net$ rm -rf git |
And then activate our own git feed from the menuconfig:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
ilek@i7:~/codelab/openwrt$ ./scripts/feeds update custom Updating feed 'custom' from '/home/ilek/myowrt/custpacks' ... Create index file './feeds/custom.index' Collecting package info: done ilek@i7:~/codelab/openwrt$ ./scripts/feeds install git Installing package 'git' ilek@i7:~/codelab/openwrt$ ./scripts/feeds update -i Create index file './feeds/packages.index' Collecting package info: done Create index file './feeds/luci.index' Create index file './feeds/routing.index' Create index file './feeds/telephony.index' Create index file './feeds/management.index' Create index file './feeds/custom.index' ilek@i7:~/codelab/openwrt$ scripts/feeds install -p custom git |
Once the correct git appears in your menuconfig, M-select the package. There is no need to add the git-http package. Then trigger a build run by issuing make package/git/compile
.