2004-01-28 15:47:52 +03:00
#!/bin/sh
VERSION_FILE = $1
OUTPUT_FILE = $2
if test -z " $VERSION_FILE " ; then
VERSION_FILE = "VERSION"
fi
if test -z " $OUTPUT_FILE " ; then
2006-05-15 17:03:44 +04:00
OUTPUT_FILE = "version.h"
2004-01-28 15:47:52 +03:00
fi
SOURCE_DIR = $3
SAMBA_VERSION_MAJOR = ` sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR $VERSION_FILE `
SAMBA_VERSION_MINOR = ` sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR $VERSION_FILE `
SAMBA_VERSION_RELEASE = ` sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
2005-08-04 06:59:19 +04:00
SAMBA_VERSION_REVISION = ` sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR $VERSION_FILE `
2006-01-23 14:23:39 +03:00
SAMBA_VERSION_TP_RELEASE = ` sed -n 's/^SAMBA_VERSION_TP_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
2007-08-31 05:52:37 +04:00
SAMBA_VERSION_ALPHA_RELEASE = ` sed -n 's/^SAMBA_VERSION_ALPHA_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
2004-01-28 15:47:52 +03:00
SAMBA_VERSION_PRE_RELEASE = ` sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
SAMBA_VERSION_RC_RELEASE = ` sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR $VERSION_FILE `
2004-04-14 11:59:07 +04:00
SAMBA_VERSION_IS_SVN_SNAPSHOT = ` sed -n 's/^SAMBA_VERSION_IS_SVN_SNAPSHOT=//p' $SOURCE_DIR $VERSION_FILE `
2004-01-28 15:47:52 +03:00
2006-01-23 14:23:39 +03:00
SAMBA_VERSION_RELEASE_NICKNAME = ` sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//p' $SOURCE_DIR $VERSION_FILE `
2004-01-28 15:47:52 +03:00
SAMBA_VERSION_VENDOR_SUFFIX = ` sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR $VERSION_FILE `
2006-01-24 21:35:01 +03:00
SAMBA_VERSION_VENDOR_PATCH = ` sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR $VERSION_FILE `
2004-01-28 15:47:52 +03:00
echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
echo " #define SAMBA_VERSION_MAJOR ${ SAMBA_VERSION_MAJOR } " >> $OUTPUT_FILE
echo " #define SAMBA_VERSION_MINOR ${ SAMBA_VERSION_MINOR } " >> $OUTPUT_FILE
echo " #define SAMBA_VERSION_RELEASE ${ SAMBA_VERSION_RELEASE } " >> $OUTPUT_FILE
2006-01-24 21:35:01 +03:00
##
## start with "3.0.22"
##
2004-01-28 15:47:52 +03:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_MAJOR } . ${ SAMBA_VERSION_MINOR } . ${ SAMBA_VERSION_RELEASE } "
2006-01-24 21:35:01 +03:00
##
2007-08-31 05:52:37 +04:00
## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "3.0.22pre1" or "3.0.22rc1"
2006-01-24 21:35:01 +03:00
## We do not do pre or rc version on patch/letter releases
##
2005-08-04 06:59:19 +04:00
if test -n " ${ SAMBA_VERSION_REVISION } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } ${ SAMBA_VERSION_REVISION } "
echo " #define SAMBA_VERSION_REVISION \" ${ SAMBA_VERSION_REVISION } \" " >> $OUTPUT_FILE
2006-01-23 14:23:39 +03:00
elif test -n " ${ SAMBA_VERSION_TP_RELEASE } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } tp ${ SAMBA_VERSION_TP_RELEASE } "
echo " #define SAMBA_VERSION_TP_RELEASE ${ SAMBA_VERSION_TP_RELEASE } " >> $OUTPUT_FILE
2007-08-31 05:52:37 +04:00
elif test -n " ${ SAMBA_VERSION_ALPHA_RELEASE } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } alpha ${ SAMBA_VERSION_ALPHA_RELEASE } "
echo " #define SAMBA_VERSION_ALPHA_RELEASE ${ SAMBA_VERSION_ALPHA_RELEASE } " >> $OUTPUT_FILE
2005-08-04 06:59:19 +04:00
elif test -n " ${ SAMBA_VERSION_PRE_RELEASE } " ; then
2006-01-24 21:35:01 +03:00
## maybe add "3.0.22pre2"
2004-01-28 15:47:52 +03:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } pre ${ SAMBA_VERSION_PRE_RELEASE } "
echo " #define SAMBA_VERSION_PRE_RELEASE ${ SAMBA_VERSION_PRE_RELEASE } " >> $OUTPUT_FILE
elif test -n " ${ SAMBA_VERSION_RC_RELEASE } " ; then
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } rc ${ SAMBA_VERSION_RC_RELEASE } "
echo " #define SAMBA_VERSION_RC_RELEASE ${ SAMBA_VERSION_RC_RELEASE } " >> $OUTPUT_FILE
2006-01-24 21:35:01 +03:00
fi
##
## SVN revision number?
##
if test x" ${ SAMBA_VERSION_IS_SVN_SNAPSHOT } " = x"yes" ; then
2005-04-15 19:36:53 +04:00
_SAVE_LANG = ${ LANG }
LANG = ""
2006-10-10 19:19:56 +04:00
HAVEVER = "no"
if test x" ${ HAVEVER } " != x"yes" ; then
HAVESVN = no
SVN_INFO = ` svn info ${ SOURCE_DIR } 2>/dev/null`
TMP_REVISION = ` echo -e " ${ SVN_INFO } " | grep 'Last Changed Rev.*:' | sed -e 's/Last Changed Rev.*: \([0-9]*\).*/\1/' `
if test -n " $TMP_REVISION " ; then
HAVESVN = yes
HAVEVER = yes
fi
2006-05-08 17:09:09 +04:00
fi
2006-10-10 19:19:56 +04:00
if test x" ${ HAVEVER } " != x"yes" ; then
2004-04-14 17:45:51 +04:00
HAVESVK = no
2006-05-08 17:09:09 +04:00
SVK_INFO = ` svk info ${ SOURCE_DIR } 2>/dev/null`
TMP_REVISION = ` echo -e " ${ SVK_INFO } " | grep 'Last Changed Rev.*:' | sed -e 's/Last Changed Rev.*: \([0-9]*\).*/\1/' `
if test -n " $TMP_REVISION " ; then
HAVESVK = yes
2006-10-10 19:19:56 +04:00
HAVEVER = yes
2005-05-20 17:49:14 +04:00
fi
2006-05-08 17:09:09 +04:00
TMP_MIRRORED_REVISION = ` echo -e " ${ SVK_INFO } " | grep 'Mirrored From:.*samba\.org.*' | sed -e 's/Mirrored From: .* Rev\..* \([0-9]*\).*/\1/' `
2004-04-14 17:00:22 +04:00
fi
2007-07-03 18:44:27 +04:00
if test x" ${ HAVEVER } " != x"yes" -a -d " ${ SOURCE_DIR } ../.bzr " ; then
2006-10-10 19:19:56 +04:00
HAVEBZR = no
BZR_INFO = ` bzr version-info --check-clean ${ SOURCE_DIR } 2>/dev/null`
TMP_REVISION = ` echo -e " ${ BZR_INFO } " | grep 'revno:' | sed -e 's/revno: \([0-9]*\).*/\1/' `
if test -n " $TMP_REVISION " ; then
HAVEBZR = yes
HAVEVER = yes
fi
TMP_MIRRORED_REVISION = ` echo -e " ${ BZR_INFO } " | grep 'revision-id: svn-v1:.*@0c0555d6-39d7-0310-84fc-f1cc0bd64818' | sed -e 's/revision-id: svn-v1:\([0-9]*\)@0c0555d6-39d7-0310-84fc-f1cc0bd64818.*/\1/' `
TMP_BRANCH_NICK = ` echo -e " ${ BZR_INFO } " | grep 'branch-nick:' | sed -e 's/branch-nick: \(.*\)$/\1/' `
TMP_CLEAN_TREE = ` echo -e " ${ BZR_INFO } " | grep 'clean:' | sed -e 's/clean: \([a-zA-Z]*\).*/\1/' `
fi
2007-07-03 18:44:27 +04:00
if test x" ${ HAVEVER } " != x"yes" -a -d " ${ SOURCE_DIR } ../.git " ; then
2007-06-26 10:04:14 +04:00
HAVEGIT = no
GIT_INFO = ` git show --abbrev-commit HEAD 2>/dev/null`
2007-09-29 03:40:47 +04:00
TMP_REVISION = ` echo -e " ${ GIT_INFO } " | sed 1q | grep 'commit ' | sed -e 's/commit \([0-9a-f]*\).*/\1/' `
2007-06-26 10:04:14 +04:00
if test -n " $TMP_REVISION " ; then
HAVEGIT = yes
HAVEVER = yes
fi
TMP_MIRRORED_REVISION = ` echo -e " ${ GIT_INFO } " | grep 'git-svn-id' | sed -e 's#^[ ^t]*git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/\(SAMBA_[34]_[0-9]\(_[0-9]\+\)\?@[0-9]*\).*#\1#' `
fi
2004-04-14 17:00:22 +04:00
if test x" ${ HAVESVN } " = x"yes" ; then
2006-05-08 17:09:09 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -SVN-build- ${ TMP_REVISION } "
echo " #define SAMBA_VERSION_SVN_REVISION ${ TMP_REVISION } " >> $OUTPUT_FILE
2004-04-14 17:00:22 +04:00
elif test x" ${ HAVESVK } " = x"yes" ; then
2006-05-08 17:09:09 +04:00
if test -n " $TMP_MIRRORED_REVISION " ; then
TMP_SVK_REVISION_STR = " ${ TMP_REVISION } - ${ USER } @ ${ HOSTNAME } -[SVN- ${ TMP_MIRRORED_REVISION } ] "
else
TMP_SVK_REVISION_STR = " ${ TMP_REVISION } - ${ USER } @ ${ HOSTNAME } "
fi
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -SVK-build- ${ TMP_SVK_REVISION_STR } "
2006-10-10 19:19:56 +04:00
elif test x" ${ HAVEBZR } " = x"yes" ; then
TMP_BZR_REVISION_STR = " ${ TMP_REVISION } "
if test -n " $TMP_BRANCH_NICK " ; then
TMP_BZR_REVISION_STR = " ${ TMP_BZR_REVISION_STR } ${ TMP_MOD_STR } @ ${ TMP_BRANCH_NICK } "
fi
if test -n " $TMP_MIRRORED_REVISION " ; then
TMP_BZR_REVISION_STR = " ${ TMP_BZR_REVISION_STR } -[SVN- ${ TMP_MIRRORED_REVISION } ] "
fi
if test x" $TMP_CLEAN_TREE " != x"True" ; then
TMP_BZR_REVISION_STR = " ${ TMP_BZR_REVISION_STR } -[modified] "
fi
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -BZR- ${ TMP_BZR_REVISION_STR } "
2007-06-26 10:04:14 +04:00
elif test x" ${ HAVEGIT } " = x"yes" ; then
TMP_GIT_REVISION_STR = " ${ TMP_REVISION } "
if test -n " $TMP_MIRRORED_REVISION " ; then
TMP_GIT_REVISION_STR = " ${ TMP_GIT_REVISION_STR } -[SVN- ${ TMP_MIRRORED_REVISION } ] "
fi
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -GIT- ${ TMP_GIT_REVISION_STR } "
2004-04-14 11:59:07 +04:00
else
2006-05-08 17:09:09 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } -SVN-build-UNKNOWN "
2004-04-14 11:59:07 +04:00
fi
2005-04-15 19:36:53 +04:00
LANG = ${ _SAVE_LANG }
2004-01-28 15:47:52 +03:00
fi
2006-05-08 12:27:22 +04:00
echo " #define SAMBA_VERSION_OFFICIAL_STRING \" ${ SAMBA_VERSION_STRING } \" " >> $OUTPUT_FILE
2006-01-23 14:23:39 +03:00
2006-01-24 21:35:01 +03:00
##
## Add the vendor string if present
##
2004-01-28 15:47:52 +03:00
if test -n " ${ SAMBA_VERSION_VENDOR_SUFFIX } " ; then
echo " #define SAMBA_VERSION_VENDOR_SUFFIX ${ SAMBA_VERSION_VENDOR_SUFFIX } " >> $OUTPUT_FILE
2006-05-08 12:27:22 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } - ${ SAMBA_VERSION_VENDOR_SUFFIX } "
2006-01-24 21:35:01 +03:00
if test -n " ${ SAMBA_VERSION_VENDOR_PATCH } " ; then
echo " #define SAMBA_VERSION_VENDOR_PATCH ${ SAMBA_VERSION_VENDOR_PATCH } " >> $OUTPUT_FILE
2006-05-08 12:27:22 +04:00
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } - ${ SAMBA_VERSION_VENDOR_PATCH } "
2006-01-24 21:35:01 +03:00
fi
2004-01-28 15:47:52 +03:00
fi
2007-08-31 06:44:56 +04:00
echo "/* Version for mkrelease.sh: " >> $OUTPUT_FILE
echo " SAMBA_VERSION_STRING= $SAMBA_VERSION_STRING " >> $OUTPUT_FILE
echo "*/" >> $OUTPUT_FILE
2006-05-08 12:27:22 +04:00
##
## Add a release nickname
##
2006-01-23 14:23:39 +03:00
if test -n " ${ SAMBA_VERSION_RELEASE_NICKNAME } " ; then
2006-05-08 12:27:22 +04:00
echo " #define SAMBA_VERSION_RELEASE_NICKNAME ${ SAMBA_VERSION_RELEASE_NICKNAME } " >> $OUTPUT_FILE
SAMBA_VERSION_STRING = " ${ SAMBA_VERSION_STRING } ( ${ SAMBA_VERSION_RELEASE_NICKNAME } ) "
2006-01-23 14:23:39 +03:00
fi
2006-05-08 12:27:22 +04:00
echo " #define SAMBA_VERSION_STRING \" ${ SAMBA_VERSION_STRING } \" " >> $OUTPUT_FILE
2006-06-27 14:55:19 +04:00
echo " $0 : ' $OUTPUT_FILE ' created for Samba(\" ${ SAMBA_VERSION_STRING } \") "
2004-01-28 15:47:52 +03:00
exit 0