mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-10 05:23:03 +03:00
f606e64861
* 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>
47 lines
978 B
Bash
Executable File
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
|