2012/11/25: isilmar ports for local git repositories

On a server (at least on our), you need something specific, like a customised version of the hier man page. So you write it, put it to a version control system and install it. Then you need a slightly bigger program…

Over time, we've collected quite a few local git repositories that way. To not lose track over the specifics of the various installations, we use a common mechanism to install them, our isilmar ports. Of course, for software with us being the only user, it's a bit of over-engineering to build release tar-balls for every change. Instead, we break the fetch/extract distinction and do a checkout at extract time—good enough if the master repository is on the local machine.

The interface for isilmar ports is that you set USE_GIT=YES, as well as GITREPOSITORY and GITCOMMITID to specify which commit you want to have. In order to have monotonically increasing version numbers, you set a reference date in GITDATE. Since setting commit-ids by hand is work and error-prone, we also have a maintainer target makegitcommitid which uses git ls-remote to get the latest commit on GIT_VERSION_BRANCH.

The whole work happens in a small file git.mk that is included from ports.mk, if USE_GIT is defined. Its full text is as follows.



GIT ?= git

PORTVERSION ?= ${GITDATE}.${GITCOMMITID}
DO_EXTRACT ?=  ${GIT} clone ${GITREPOSITORY} gitwork && cd gitwork && ${GIT} checkout -b githead ${GITCOMMITID}
WRKSRC ?= ${WORKDIR}/gitwork

GIT_VERSION_BRANCH ?= master

GIT_GETNEWCOMMITID = (cd / && ${GIT} ls-remote ${GITREPOSITORY} ${GIT_VERSION_BRANCH}) | cut -f 1

makegitcommitid:
    sed -i '' -e 's/GITCOMMITID *=.*/GITCOMMITID='`${GIT_GETNEWCOMMITID}`/g Makefile
    sed -i '' -e 's/GITDATE *=.*/GITDATE='`date +%Y.%m.%d`/g Makefile
download



Cross-referenced by: