forked from mooffie/mc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Signed-off-by: Slava Zanko <[email protected]>
- Loading branch information
Showing
1 changed file
with
39 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,47 @@ | ||
#!/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 | ||
} | ||
if [ -z "$1" ] | ||
then | ||
echo "usage: $0 <toplevel-source-dir>" | ||
exit 1 | ||
fi | ||
|
||
src_top_dir="$1" | ||
|
||
VERSION_FILE="${src_top_dir}/version.h" | ||
PREV_MC_VERSION="unknown" | ||
CURR_MC_VERSION="${PREV_MC_VERSION}" | ||
|
||
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 | ||
|
||
mc_print_version(){ | ||
|
||
if [ ! -f "${VERSION_FILE}" \ | ||
-o "${PREV_MC_VERSION}" != "${CURR_MC_VERSION}" ] | ||
then | ||
cat >"${VERSION_FILE}" <<EOF | ||
#ifndef MC_CURRENT_VERSION | ||
/* This is an autogenerated file. Don't edit! */ | ||
#define MC_CURRENT_VERSION "${CURR_MC_VERSION}" | ||
#endif | ||
EOF | ||
fi | ||
exit | ||
} | ||
[ -z "${src_top_dir}" ] && exit | ||
|
||
|
||
VERSION_FILE=${src_top_dir}/version.h | ||
|
||
git_head=$(git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/null) | ||
[ -z "${git_head}" ] && exit | ||
|
||
new_version="$(git --git-dir "${src_top_dir}/.git" describe 2>/dev/null)" | ||
[ -z "${new_version}" ] && exit | ||
[ -z "${git_head}" ] && mc_print_version | ||
|
||
# try to store sha1 | ||
CURR_MC_VERSION="${git_head}" | ||
|
||
saved_version= | ||
[ -r ${VERSION_FILE} ] && { | ||
saved_version=$(sed -rn 's/^#define MC_CURRENT_VERSION "(.*)"$/\1/p' ${VERSION_FILE}) | ||
} | ||
new_version="$(git --git-dir "${src_top_dir}/.git" describe 2>/dev/null)" | ||
[ -z "${new_version}" ] && mc_print_version | ||
|
||
[ -z "${saved_version}" -o "${saved_version}" != "${new_version}" ] && { | ||
cat >${VERSION_FILE} <<EOF | ||
#ifndef MC_CURRENT_VERSION | ||
/* This is an autogenerated file. Don't edit! */ | ||
#define MC_CURRENT_VERSION "${new_version}" | ||
#endif | ||
EOF | ||
} | ||
exit 0 | ||
# store pretty tagged version | ||
CURR_MC_VERSION="${new_version}" | ||
mc_print_version |