Make sure that version_detail.sh script always:

* Uses proper directory name for source files. This approach should be portable, I think.
* Always uses LANG=C for obtaining data, because in non-US environments it will not capture branch name, for example.
This commit is contained in:
pztrn 2015-12-14 22:10:04 +05:00
parent e824a2faea
commit 8fe9e9e791
2 changed files with 25 additions and 9 deletions

View File

@ -3,6 +3,12 @@
#don't exit even if a command fails #don't exit even if a command fails
set +e set +e
SCRIPT_PATH=$(dirname "`readlink -f "${0}"`")
OLDLANG=${LANG}
export LANG=C
if ( git log -n 1 &> /dev/null); then if ( git log -n 1 &> /dev/null); then
#retrieve git information #retrieve git information
version="$(git log --pretty=format:"%H" | head -1 | cut -c1-8)" version="$(git log --pretty=format:"%H" | head -1 | cut -c1-8)"
@ -22,7 +28,9 @@ fi
if [[ ${version} != '' ]]; then if [[ ${version} != '' ]]; then
echo "Writing version to retroshare/rsversion.h : ${version}" echo "Writing version to retroshare/rsversion.h : ${version}"
sed -e "s%RS_REVISION_NUMBER.*%RS_REVISION_NUMBER 0x${version}%" retroshare/rsversion.in >retroshare/rsversion.h sed -e "s%RS_REVISION_NUMBER.*%RS_REVISION_NUMBER 0x${version}%" ${SCRIPT_PATH}/retroshare/rsversion.in >${SCRIPT_PATH}/retroshare/rsversion.h
fi fi
export LANG=${OLDLANG}
echo "script version_detail.sh finished normally" echo "script version_detail.sh finished normally"
exit 0 exit 0

View File

@ -5,26 +5,34 @@
#don't exit even if a command fails #don't exit even if a command fails
set +e set +e
OLDLANG=${LANG}
export LANG=C
SCRIPT_PATH=$(dirname "`readlink -f "${0}"`")
if (ls &> /dev/null); then if (ls &> /dev/null); then
echo "Retroshare Gui version : " > gui/help/version.html echo "Retroshare Gui version : " > ${SCRIPT_PATH}/gui/help/version.html
if ( /usr/bin/git log -n 1 &> /dev/null); then if ( /usr/bin/git log -n 1 &> /dev/null); then
#retrieve git information #retrieve git information
echo "Git version : $(git status | grep branch | cut -c 3-) $(git log -n 1 | grep commit)" >> gui/help/version.html echo "Git version : $(git status | grep branch | head -n 1 | cut -c 4-) $(git log -n 1 | grep commit)" >> ${SCRIPT_PATH}/gui/help/version.html
fi fi
if ( /usr/bin/git log -n 1 | grep svn &> /dev/null); then if ( /usr/bin/git log -n 1 | grep svn &> /dev/null); then
#retrieve git svn information #retrieve git svn information
echo "Svn version : $(git log -n 1 | awk '/svn/ {print $2}' | head -1)" >> gui/help/version.html echo "Svn version : $(git log -n 1 | awk '/svn/ {print $2}' | head -1)" >> ${SCRIPT_PATH}/gui/help/version.html
elif ( /usr/bin/git log -n 10 | grep svn &> /dev/null); then elif ( /usr/bin/git log -n 10 | grep svn &> /dev/null); then
#retrieve git svn information #retrieve git svn information
echo "Svn closest version : $(git log -n 10 | awk '/svn/ {print $2}' | head -1)" >> gui/help/version.html echo "Svn closest version : $(git log -n 10 | awk '/svn/ {print $2}' | head -1)" >> ${SCRIPT_PATH}/gui/help/version.html
fi fi
if ( /usr/bin/svn info &> /dev/null); then if ( /usr/bin/svn info &> /dev/null); then
echo "Svn version : $(svn info | awk '/^Revision:/ {print $NF}')" >> gui/help/version.html echo "Svn version : $(svn info | awk '/^Revision:/ {print $NF}')" >> ${SCRIPT_PATH}/gui/help/version.html
fi fi
date >> gui/help/version.html date >> ${SCRIPT_PATH}/gui/help/version.html
echo "" >> gui/help/version.html echo "" >> ${SCRIPT_PATH}/gui/help/version.html
echo "" >> gui/help/version.html echo "" >> ${SCRIPT_PATH}/gui/help/version.html
fi fi
export LANG=${OLDLANG}
echo "version_detail.sh scripts finished" echo "version_detail.sh scripts finished"
exit 0 exit 0