| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # To override version/release from git, |
| 4 | # create VERSION file containing text with version/release |
| 5 | # eg. v3.4.0-1 |
| 6 | |
| 7 | # One thing to note, If one does 'git clone --depth N glusterfs.git', |
| 8 | # the git describe command doesn't work. Hence you notice below that |
| 9 | # we have added timestamp as version (YYYY.MM.DD) and release (HH.mmss) |
| 10 | PKG_VERSION=`catscip-shell system . . cat. VERSION 2> /dev/nullscip-shell filesystem . . `/dev/null`. || gitscip-shell system . . git. describe --tags --match "v[0-9]*" 2>/dev/nullscip-shell filesystem . . `/dev/null`.` |
| 11 | |
| 12 | get_versionscip-shell shell shell-project 0.0.0 get_version().() |
| 13 | { |
| 14 | # tags and output versions: |
| 15 | # - v3.4.0 => 3.4.0 (upstream clean) |
| 16 | # - v3.4.0-1 => 3.4.0 (downstream clean) |
| 17 | # - v3.4.0-2-g34e62f => 3.4.0 (upstream dirty) |
| 18 | # - v3.4.0-1-2-g34e62f => 3.4.0 (downstream dirty) |
| 19 | AWK_VERSION=' |
| 20 | BEGIN { FS="-" } |
| 21 | /^v[0-9]/ { |
| 22 | sub(/^v/,"") ; print $1 |
| 23 | }' |
| 24 | |
| 25 | version=$(echoscip-shell system . . echo. $PKG_VERSION | awkscip-shell system . . awk. "$AWK_VERSION" | trscip-shell system . . tr. -cd '[:alnum:].') |
| 26 | if [scip-shell system . . `[`. "x${version}" == "x" ] ; then |
| 27 | version=$(datescip-shell system . . date. +%Y.%m.%d | trscip-shell system . . tr. -d '\n') |
| 28 | fi |
| 29 | echoscip-shell system . . echo. $version | trscip-shell system . . tr. -d '\n' |
| 30 | } |
| 31 | |
| 32 | get_releasescip-shell shell shell-project 0.0.0 get_release().() |
| 33 | { |
| 34 | # tags and output releases: |
| 35 | # - v3.4.0 => 0 (upstream clean) |
| 36 | # - v3.4.0-1 => 1 (downstream clean) |
| 37 | # - v3.4.0-2-g34e62f1 => 2.git34e62f1 (upstream dirty) |
| 38 | # - v3.4.0-1-2-g34e62f1 => 1.2.git34e62f1 (downstream dirty) |
| 39 | AWK_RELEASE=' |
| 40 | BEGIN { FS="-"; OFS="." } |
| 41 | /^v[0-9]/ { |
| 42 | if (NF == 1) print 0 |
| 43 | else if (NF == 2) print $2 |
| 44 | else if (NF == 3) print $2, "git" substr($3, 2) |
| 45 | else if (NF == 4) print $2, $3, "git" substr($4, 2) |
| 46 | }' |
| 47 | |
| 48 | release=$(echoscip-shell system . . echo. $PKG_VERSION | awkscip-shell system . . awk. "$AWK_RELEASE" | trscip-shell system . . tr. -cd '[:alnum:].') |
| 49 | if [scip-shell system . . `[`. "x${release}" == "x" ] ; then |
| 50 | release=$(datescip-shell system . . date. +%H.%M%S | trscip-shell system . . tr. -d '\n') |
| 51 | fi |
| 52 | echoscip-shell system . . echo. $release | trscip-shell system . . tr. -d '\n' |
| 53 | } |
| 54 | |
| 55 | if testscip-shell system . . test. "x$1" = "x--full"; then |
| 56 | echoscip-shell system . . echo. -n "v$(get_versionscip-shell shell shell-project 0.0.0 get_version().)-$(get_releasescip-shell shell shell-project 0.0.0 get_release().)" |
| 57 | elif testscip-shell system . . test. "x$1" = "x--version"; then |
| 58 | get_versionscip-shell shell shell-project 0.0.0 get_version(). |
| 59 | elif testscip-shell system . . test. "x$1" = "x--release"; then |
| 60 | get_releasescip-shell shell shell-project 0.0.0 get_release(). |
| 61 | else |
| 62 | echoscip-shell system . . echo. "usage: $0 [--full|--version|--release]" |
| 63 | exit 1 |
| 64 | fi |