File: make_or_upd_vgversion_h

package info (click to toggle)
valgrind 1%3A3.24.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 176,332 kB
  • sloc: ansic: 795,029; exp: 26,134; xml: 23,472; asm: 14,393; cpp: 9,397; makefile: 7,464; sh: 6,122; perl: 5,446; python: 1,498; javascript: 981; awk: 166; csh: 1
file content (54 lines) | stat: -rwxr-xr-x 1,626 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
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
#!/bin/sh

extract_git_version()
{
    PREVPWD="$PWD"
    cd "$1"
    if [ -d ./.git ] || git rev-parse --is-inside-work-tree > /dev/null 2> /dev/null
    then
        REV=$(git show --format=%H#%ci -s $(git rev-parse HEAD) |
                     sed -e 's/ .*//' -e 's/[0-9a-f]\{30\}#/#/' -e 's/-//g' \
                         -e 's/#/-/')
        X=$(git status -s -uno | sed -e 's/.*/X/' | uniq)
        echo $REV$X
    else
        echo "unknown"
    fi
    cd "$PREVPWD"
}

srcdir="${1:-.}"

if [ -e "$srcdir"/include/vgversion_dist.h ]
then
    cp "$srcdir"/include/vgversion_dist.h include/vgversion.h.tmp
else
    cat > include/vgversion.h.tmp <<EOF
/* Do not edit: file generated by auxprogs/make_or_upd_vgversion_h.
   This file defines VGGIT, used to report GIT revision
   when using command line options:  -v --version
   The produced VGGIT format is
      hhhhhhhhhh-YYYYMMDDX
   where hhhhhhhhhh is the first 10 characters of the HEAD commit
         YYYYMMDD is the commit date
         Trailing X is present if there are any (non untracked) modified files.
*/
#define VGGIT "$(extract_git_version .)"
EOF
fi

if [ -f include/vgversion.h ]
then
    # There is already a vgversion.h.
    # Update it only if we found a different and real git version
    if grep -q unknown include/vgversion.h.tmp ||
       cmp -s include/vgversion.h include/vgversion.h.tmp
    then
        rm -f include/vgversion.h.tmp
    else
        mv include/vgversion.h.tmp include/vgversion.h
    fi
else
    # There is no vgversion.h. Use the one just generated, whatever it is.
    mv include/vgversion.h.tmp include/vgversion.h
fi