Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Input: version.h.in that includes $VERSION
- # Output: version.h
- version_file='path/to/version.h'
- # Useful for e.g. Jenkins builds. Pass "b$BUILD_INFO" as an argument...
- while [ $# != 0 ] ; do
- ver="$ver-$1"
- shift
- done
- ver=$(git describe --tags)
- stash_hash=$(git stash create)
- if [ -n "$stash_hash" ]; then
- ver=$(echo "$ver" | sed "s/-g[^-]*$/-s${stash_hash:0:7}/")
- fi
- echo Using version: $ver
- sed "s/\$VERSION/$ver/g" "$version_file.in" > "$version_file.tmp"
- if [ ! -f "$version_file" ] || ! diff -q "$version_file.tmp" "$version_file" &> /dev/null; then
- mv "$version_file.tmp" "$version_file"
- else
- rm -f "$version_file.tmp"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement