mc/maint/version.sh
Slava Zanko f606e64861 Version of project now formed automatically from current git-describe output
* File version.h will be created (or changed) automatically
 * Fixed versions for rpm packages - all '-' changed to '.' in RPM_VERSION variable
 * when version.h is changed (or deleted) ./configure script will be invoked

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2009-06-07 00:56:07 +03:00

47 lines
978 B
Bash
Executable File

#!/bin/sh
git --version &>/dev/null || exit
curr_dir=$(pwd)
src_top_dir=
[ -d ${curr_dir}/.git ] && {
src_top_dir=${curr_dir}
} || {
curr_dir=$(dirname ${curr_dir})
[ -d ${curr_dir}/.git ] && {
src_top_dir=${curr_dir}
} || {
[ -z "$1" ] && exit
src_top_dir=$1
}
}
[ -z "${src_top_dir}" ] && exit
VERSION_FILE=${src_top_dir}/version.h
pushd ${src_top_dir} &>/dev/null
git_head=$(git rev-parse --verify HEAD 2>/dev/null)
[ -z "${git_head}" ] && exit
new_version="$(git describe 2>/dev/null)"
[ -z "${new_version}" ] && exit
popd &>/dev/null
saved_version=
[ -r ${VERSION_FILE} ] && {
saved_version=$(grep '^#define MC_CURRENT_VERSION' ${VERSION_FILE}| sed -r 's/.*"(.*)"$/\1/')
}
[ -z "${saved_version}" -o "${saved_version}" != "${new_version}" ] && {
cat >${VERSION_FILE} <<EOF
#ifndef MC_CURRENT_VERSION
/* This is autogenerated file. Don't edit! */
#define MC_CURRENT_VERSION "${new_version}"
#endif
EOF
}
exit 0