File: create-build-version.sh

package info (click to toggle)
nixnote2 2.1.6%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,916 kB
  • sloc: cpp: 79,037; java: 1,096; sh: 275; ansic: 10; makefile: 6
file content (37 lines) | stat: -rwxr-xr-x 856 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

function error_exit {
    echo "$0: ***********error_exit***********"
    echo "***********" 1>&2
    echo "*********** Failed: $1" 1>&2
    echo "***********" 1>&2
    cd ${CDIR}
    exit 1
}

DESTDIR=$1
echo $0: DESTDIR=${DESTDIR}

if [ -z "${DESTDIR}" ]; then
  echo "Missing param1 (DESTDIR)"
  exit 1
fi

VERSION=$(head -n 1 ./debian/changelog|sed -E 's/^[^(]*\(([^)]*).*/\1/g')
GITHASH=$(git rev-parse --short HEAD)
if [ -z "${GITHASH}" ] ; then
  echo "Seems getting git version failed.."
  BUILDVER="${VERSION}"
else 
  BUILDVER="${VERSION}-${GITHASH}"
fi


echo Version: ${VERSION}
echo Git hash: ${GITHASH}

ODIR=${DESTDIR}/version

mkdir -p ${ODIR} || error_exit "$0: mkdir"
echo "${BUILDVER}" >${ODIR}/build-version.txt || error_exit "$0: echo build-version"
echo "${VERSION}" >${ODIR}/version.txt || error_exit "$0: echo version"