File: getversion.sh

package info (click to toggle)
coreboot 24.12%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 210,640 kB
  • sloc: ansic: 1,640,478; sh: 15,676; python: 10,743; perl: 10,186; asm: 8,483; makefile: 5,097; cpp: 4,724; pascal: 2,327; ada: 1,928; yacc: 1,264; lex: 731; sed: 75; lisp: 5; ruby: 5; awk: 4
file content (31 lines) | stat: -rwxr-xr-x 923 bytes parent folder | download
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
#!/usr/bin/env bash
#
# Copyright 2014 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Generate version information

if ghash=$(git rev-parse --short=12 --verify HEAD 2>/dev/null); then
  if gdesc=$(git describe --dirty --match='v*' 2>/dev/null); then
    IFS="-" fields=($gdesc)
    tag="${fields[0]}"
    IFS="." vernum=($tag)
    numcommits=$((${vernum[2]}+${fields[1]:-0}))
    ver_major="${vernum[0]}"
    ver_branch="${vernum[1]}"
  else
    numcommits=$(git rev-list HEAD | wc -l)
    ver_major="v0"
    ver_branch="0"
  fi
  # avoid putting the -dirty attribute if only the timestamp
  # changed
  dirty=$(sh -c "[ '$(git diff-index --name-only HEAD)' ] \
                && echo '-dirty'")
  ver="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
else
  ver="unknown"
fi

echo "const char futility_version[] = \"${ver}\";";