File: mkgitver

package info (click to toggle)
rsync 3.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,032 kB
  • sloc: ansic: 43,496; sh: 5,985; python: 1,621; asm: 829; perl: 550; makefile: 367; cpp: 298; awk: 191
file content (22 lines) | stat: -rwxr-xr-x 664 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

srcdir=`dirname $0`

if [ ! -f git-version.h ]; then
    touch git-version.h
fi

if test -d "$srcdir/.git" || test -f "$srcdir/.git"; then
    gitver=`git describe --abbrev=8 2>/dev/null`
    # NOTE: I'm avoiding "|" in sed since I'm not sure if sed -r is portable and "\|" fails on some OSes.
    verchk=`echo "$gitver-" | sed -n '/^v3\.[0-9][0-9]*\.[0-9][0-9]*\(pre[0-9]*\)*-/p'`
    if [ -n "$verchk" ]; then
	echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h.new
	if ! diff git-version.h.new git-version.h >/dev/null; then
	    echo "Updating git-version.h"
	    mv git-version.h.new git-version.h
	else
	    rm git-version.h.new
	fi
    fi
fi