adt_tree: change pathtree_add to return WERR instead of bool.
[Samba.git] / source / script / mkversion.sh
blobb67847697698fe8cc156620e1ddb45a9ae4c9e31
1 #!/bin/sh
3 VERSION_FILE=$1
4 OUTPUT_FILE=$2
6 if test -z "$VERSION_FILE";then
7 VERSION_FILE="VERSION"
8 fi
10 if test -z "$OUTPUT_FILE";then
11 OUTPUT_FILE="include/version.h"
14 SOURCE_DIR=$3
16 SAMBA_VERSION_MAJOR=`sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR$VERSION_FILE`
17 SAMBA_VERSION_MINOR=`sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR$VERSION_FILE`
18 SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
20 SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
22 SAMBA_VERSION_TP_RELEASE=`sed -n 's/^SAMBA_VERSION_TP_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
23 SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
24 SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
26 SAMBA_VERSION_IS_GIT_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_GIT_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE`
28 SAMBA_VERSION_RELEASE_NICKNAME=`sed -n 's/^SAMBA_VERSION_RELEASE_NICKNAME=//p' $SOURCE_DIR$VERSION_FILE`
30 SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE`
31 SAMBA_VERSION_VENDOR_PATCH=`sed -n 's/^SAMBA_VERSION_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE`
33 echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE
35 echo "#define SAMBA_VERSION_MAJOR ${SAMBA_VERSION_MAJOR}" >> $OUTPUT_FILE
36 echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE
37 echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
41 ## start with "3.0.22"
43 SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
47 ## maybe add "3.0.22a" or "4.0.0tp11" or "3.0.22pre1" or "3.0.22rc1"
48 ## We do not do pre or rc version on patch/letter releases
50 if test -n "${SAMBA_VERSION_REVISION}";then
51 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
52 echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
53 elif test -n "${SAMBA_VERSION_TP_RELEASE}";then
54 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}tp${SAMBA_VERSION_TP_RELEASE}"
55 echo "#define SAMBA_VERSION_TP_RELEASE ${SAMBA_VERSION_TP_RELEASE}" >> $OUTPUT_FILE
56 elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
57 ## maybe add "3.0.22pre2"
58 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
59 echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
60 elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
61 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}rc${SAMBA_VERSION_RC_RELEASE}"
62 echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE
66 ## GIT commit details
68 if test x"${SAMBA_VERSION_IS_GIT_SNAPSHOT}" = x"yes";then
69 _SAVE_LANG=${LANG}
70 LANG="C"
71 HAVEVER="no"
73 if test x"${HAVEVER}" != x"yes" -a -d "${SOURCE_DIR}../.git";then
74 HAVEGIT=no
75 GIT_INFO=`git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD 2>/dev/null`
76 GIT_COMMIT_ABBREV=`printf "%s" "${GIT_INFO}" | sed -n 1p`
77 GIT_COMMIT_TIME=`printf "%s" "${GIT_INFO}" | sed -n 2p`
78 GIT_COMMIT_FULLREV=`printf "%s" "${GIT_INFO}" | sed -n 3p`
79 GIT_COMMIT_DATE=`printf "%s" "${GIT_INFO}" | sed -n 4p`
80 if test -n "${GIT_COMMIT_ABBREV}";then
81 HAVEGIT=yes
82 HAVEVER=yes
86 if test x"${HAVEGIT}" = x"yes";then
87 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-${GIT_COMMIT_ABBREV}"
89 echo "#define SAMBA_VERSION_GIT_COMMIT_ABBREV \"${GIT_COMMIT_ABBREV}\"" >> $OUTPUT_FILE
90 echo "#define SAMBA_VERSION_GIT_COMMIT_TIME ${GIT_COMMIT_TIME}" >> $OUTPUT_FILE
91 echo "#define SAMBA_VERSION_GIT_COMMIT_FULLREV \"${GIT_COMMIT_FULLREV}\"" >> $OUTPUT_FILE
92 echo "#define SAMBA_VERSION_GIT_COMMIT_DATE \"${GIT_COMMIT_DATE}\"" >> $OUTPUT_FILE
93 else
94 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-GIT-UNKNOWN"
96 LANG=${_SAVE_LANG}
99 echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE
102 ## Add the vendor string if present
104 if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then
105 echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE
106 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_SUFFIX}"
107 if test -n "${SAMBA_VERSION_VENDOR_PATCH}";then
108 echo "#define SAMBA_VERSION_VENDOR_PATCH ${SAMBA_VERSION_VENDOR_PATCH}" >> $OUTPUT_FILE
109 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_PATCH}"
114 ## Add a release nickname
116 if test -n "${SAMBA_VERSION_RELEASE_NICKNAME}";then
117 echo "#define SAMBA_VERSION_RELEASE_NICKNAME ${SAMBA_VERSION_RELEASE_NICKNAME}" >> $OUTPUT_FILE
118 SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING} (${SAMBA_VERSION_RELEASE_NICKNAME})"
121 echo "#define SAMBA_VERSION_STRING samba_version_string()" >> $OUTPUT_FILE
123 echo "$0: '$OUTPUT_FILE' created for Samba(\"${SAMBA_VERSION_STRING}\")"
125 exit 0