2009-06-02 17:36:58 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2009-06-13 16:31:52 +04:00
|
|
|
git --version >/dev/null || exit
|
2009-06-02 17:36:58 +04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2009-06-16 21:33:24 +04:00
|
|
|
git_head=$(git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/null)
|
2009-06-02 17:36:58 +04:00
|
|
|
[ -z "${git_head}" ] && exit
|
|
|
|
|
2009-06-16 21:33:24 +04:00
|
|
|
new_version="$(git --git-dir "${src_top_dir}/.git" describe 2>/dev/null)"
|
2009-06-02 17:36:58 +04:00
|
|
|
[ -z "${new_version}" ] && exit
|
|
|
|
|
|
|
|
|
|
|
|
saved_version=
|
|
|
|
[ -r ${VERSION_FILE} ] && {
|
2009-06-13 12:14:06 +04:00
|
|
|
saved_version=$(sed -rn 's/^#define MC_CURRENT_VERSION "(.*)"$/\1/p' ${VERSION_FILE})
|
2009-06-02 17:36:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
[ -z "${saved_version}" -o "${saved_version}" != "${new_version}" ] && {
|
|
|
|
cat >${VERSION_FILE} <<EOF
|
|
|
|
#ifndef MC_CURRENT_VERSION
|
2009-06-13 12:14:13 +04:00
|
|
|
/* This is an autogenerated file. Don't edit! */
|
2009-06-02 17:36:58 +04:00
|
|
|
#define MC_CURRENT_VERSION "${new_version}"
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
exit 0
|