~ chicken-core (chicken-5) /identify.sh
Trap1#!/bin/sh -e
2#
3# identify.sh - check for .git directory and obtain checked out revision and branch
4#
5# usage: identify.sh SOURCEDIR
6
7
8# make sure file exists anyway, since branchname is a special case
9if test \! -f "buildbranch"; then
10 touch buildbranch
11fi
12
13rev0=`cat buildid || echo ""`
14branchname0=`cat buildbranch || echo ""`
15buildtime=`date +%Y-%m-%d`
16host=`hostname`
17usys=`uname`
18
19if test -d "$1/.git"; then
20 rev=`GIT_DIR="$1/.git" git rev-parse --short HEAD 2>/dev/null`
21 branchname=`GIT_DIR="$1/.git" git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
22elif test -d "$1/manual-html"; then
23 # Assume this is a snapshot or release build; don't touch
24 # identifying files to avoid a rebuild which needs chicken
25 exit
26else
27 branchname=${branchname:-"custom"}
28fi
29
30case "${branchname}" in
31 "") branchname="";;
32 "(no branch)") branchname="";;
33 "master") branchname="";;
34 "release") branchname="";;
35esac
36if test "x${rev0}" \!= "x${rev}"; then
37 echo ${rev} >buildid
38fi
39if test "x${branchname0}" \!= "x${branchname}"; then
40 echo ${branchname} >buildbranch
41fi