1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
samba-mirror/source3/script/mkversion.sh
Stefan Metzmacher f8c418a0af r208: merge the version schema changes from 4_0
metze
(This used to be commit 4d9d8e83aa)
2007-10-10 10:51:14 -05:00

80 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
#
VERSION_FILE=$1
OUTPUT_FILE=$2
if test -z "$VERSION_FILE";then
VERSION_FILE="VERSION"
fi
if test -z "$OUTPUT_FILE";then
OUTPUT_FILE="include/version.h"
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`
SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
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`
SAMBA_VERSION_IS_SVN_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_SVN_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
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
SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
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
elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
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
fi
if test x"${SAMBA_VERSION_IS_SVN_SNAPSHOT}" = x"yes";then
TMP_SVN_REVISION=`(svn info ${SOURCE_DIR} 2>/dev/null || svk info ${SOURCE_DIR} 2>/dev/null) |grep Revision: |sed -e 's/Revision: \([0-9]*\).*/\1/'`
TMP_SVN_REVISION_STR=""
if test -n "${TMP_SVN_REVISION}";then
TMP_SVN_REVISION_STR="-${TMP_SVN_REVISION}"
else
TMP_SVN_REVISION=0
fi
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-SVN-build${TMP_SVN_REVISION_STR}"
echo "#define SAMBA_VERSION_SVN_REVISION ${TMP_SVN_REVISION}" >> $OUTPUT_FILE
fi
if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
fi
echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
echo "#define SAMBA_VERSION_STRING samba_version_string()" >> $OUTPUT_FILE
echo "$0: 'include/version.h' created for Samba(\"${SAMBA_VERSION_STRING}\")"
if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
echo "$0: with VENDOR_SUFFIX = ${SAMBA_VERSION_VENDOR_SUFFIX}"
fi
exit 0