mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
version.sh: Ticket 411 (make loops, rerunning configure ad infinitum)
version.h is dumped even when git is unavailable or broken buildbot dislikes to fetch tags (git fetch --tags) => version.sh failure. version.sh refused to create version.h when git is unavailable. All those cases are hopefully fixed. Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru> Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
4a58bd3a14
commit
d9a72ea8c9
@ -1,44 +1,47 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
git --version >/dev/null || exit
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "usage: $0 <toplevel-source-dir>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
curr_dir=$(pwd)
|
src_top_dir="$1"
|
||||||
|
|
||||||
src_top_dir=
|
VERSION_FILE="${src_top_dir}/version.h"
|
||||||
[ -d ${curr_dir}/.git ] && {
|
PREV_MC_VERSION="unknown"
|
||||||
src_top_dir=${curr_dir}
|
CURR_MC_VERSION="${PREV_MC_VERSION}"
|
||||||
} || {
|
|
||||||
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
|
|
||||||
|
|
||||||
|
if [ -r ${VERSION_FILE} ]
|
||||||
|
then
|
||||||
|
PREV_MC_VERSION=`sed -rn 's/^#define MC_CURRENT_VERSION "(.*)"$/\1/p' "${VERSION_FILE}"`
|
||||||
|
CURR_MC_VERSION="${PREV_MC_VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
VERSION_FILE=${src_top_dir}/version.h
|
mc_print_version(){
|
||||||
|
|
||||||
git_head=$(git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/null)
|
if [ ! -f "${VERSION_FILE}" \
|
||||||
[ -z "${git_head}" ] && exit
|
-o "${PREV_MC_VERSION}" != "${CURR_MC_VERSION}" ]
|
||||||
|
then
|
||||||
new_version="$(git --git-dir "${src_top_dir}/.git" describe 2>/dev/null)"
|
cat >"${VERSION_FILE}" <<EOF
|
||||||
[ -z "${new_version}" ] && exit
|
|
||||||
|
|
||||||
|
|
||||||
saved_version=
|
|
||||||
[ -r ${VERSION_FILE} ] && {
|
|
||||||
saved_version=$(sed -rn 's/^#define MC_CURRENT_VERSION "(.*)"$/\1/p' ${VERSION_FILE})
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -z "${saved_version}" -o "${saved_version}" != "${new_version}" ] && {
|
|
||||||
cat >${VERSION_FILE} <<EOF
|
|
||||||
#ifndef MC_CURRENT_VERSION
|
#ifndef MC_CURRENT_VERSION
|
||||||
/* This is an autogenerated file. Don't edit! */
|
/* This is an autogenerated file. Don't edit! */
|
||||||
#define MC_CURRENT_VERSION "${new_version}"
|
#define MC_CURRENT_VERSION "${CURR_MC_VERSION}"
|
||||||
#endif
|
#endif
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
exit 0
|
|
||||||
|
git_head=$(git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/null)
|
||||||
|
[ -z "${git_head}" ] && mc_print_version
|
||||||
|
|
||||||
|
# try to store sha1
|
||||||
|
CURR_MC_VERSION="${git_head}"
|
||||||
|
|
||||||
|
new_version="$(git --git-dir "${src_top_dir}/.git" describe 2>/dev/null)"
|
||||||
|
[ -z "${new_version}" ] && mc_print_version
|
||||||
|
|
||||||
|
# store pretty tagged version
|
||||||
|
CURR_MC_VERSION="${new_version}"
|
||||||
|
mc_print_version
|
||||||
|
Loading…
Reference in New Issue
Block a user