s3:libsmb: don't require a pinbuf in cli_smb_recv() to keep the memory
[Samba/gebeck_regimport.git] / release-scripts / create-tarball
blobe6a515f48a646c57777c983c4b7895695000871b
1 #!/bin/bash
3 ## option defaults
4 OPT_BRANCH=""
5 OPT_DOCSDIR=""
6 OPT_KEYID=""
8 TOPDIR="`dirname $0`/.."
9 VER_H="${TOPDIR}/source3/include/version.h"
11 function exitOnError
13 local _error="$1"
14 local _msg="$2"
16 if [ ${_error} -eq 0 ]; then
17 return 0
20 echo "FAILURE: ${_msg}"
21 exit ${_error}
25 ## Print help usage
28 function printUsage
30 echo "Usage $0 [options]"
31 echo " --help Print command usage"
32 echo " --branch <name> Specify the branch to to create the archive file from"
33 echo " --copy-docs <dir> Copy documentation from <dir> rather than building"
34 echo " --keyid <email> The GnuPG key ID used to sign the release tag"
35 echo ""
39 ## Parse the command line options
42 function parseOptions
44 while [ -n "$1" ]; do
45 case "$1" in
46 --help)
47 printUsage
48 exit 0
50 --branch)
51 shift
52 if [ -z "$1" ]; then
53 printUsage
54 return 1
56 OPT_BRANCH="$1"
57 shift
59 --copy-docs)
60 shift
61 if [ -z "$1" ]; then
62 printUsage
63 return 1
65 OPT_DOCSDIR="$1"
66 shift
68 --keyid)
69 shift
70 if [ -z "$1" ]; then
71 printUsage
72 return 1
74 OPT_KEYID="$1"
75 shift
78 printUsage
79 return 1
81 esac
82 done
84 if [ -z "${OPT_BRANCH}" ]; then
85 echo "You must specify a branch name!"
86 printUsage
87 return 1
92 ## Build the documentation (may be a no-op)
95 function buildDocs
97 if [ -n "${OPT_DOCSDIR}" ]; then
98 if [ ! -d "${OPT_DOCSDIR}" ]; then
99 exitOnError 1 "${OPT_DOCSDIR} does not exist. Please specify the absolute path."
102 mkdir docs
103 exitOnError $? "Failed to create docs directory"
105 rsync -av "${OPT_DOCSDIR}"/ docs/
106 exitOnError $? "Failed top copy docs from ${OPT_DOCSDIR}"
108 cd docs/
109 /bin/rm -rf test.pdf Samba4*pdf htmldocs/Samba4* htmldocs/test
110 if [ -d manpages-3 ]; then
111 mv manpages-3 manpages
113 if [ -d htmldocs/manpages-3 ]; then
114 mv htmldocs/manpages-3 htmldocs/manpages
116 # Sync thanks, history and registry/ into the docs dir
117 rsync -Ca --exclude=.svn ../../$OPT_BRANCH/docs-xml/registry ../docs/
118 rsync -Ca --exclude=.svn ../../$OPT_BRANCH/docs-xml/archives/ ../docs/
119 cd ../
121 return 0
124 echo "Building documentation. This may take a while. Log file in /tmp/docs-build.log.$$"
126 ${TOPDIR}/release-scripts/build-docs 2> /tmp/docs-build.log.$$
127 return $?
133 ## Create a release tag
135 function createReleaseTag
137 tagname="$1"
139 if [ "x`git tag -l ${tagname}`" != "x" ]; then
140 echo -n "Tag '${tagname}' exists. Do you wish to overwrite? (y/N): "
141 read answer
143 if [ "x$answer" != "xy" ]; then
144 echo "Tag creation aborted."
145 exit 1
149 if [ -z "${OPT_KEYID}" ]; then
150 echo -n "Enter the keyid:"
151 read OPT_KEYID
152 if [ -z "${OPT_KEYID}" ]; then
153 exitOnError 1 "No keyid specified"
157 git tag -u ${OPT_KEYID} ${tagname}
158 exitOnError $? "Failed to create tag '${tagname}'"
160 return 0
163 ## Main driver
165 function main
167 parseOptions "$@"
168 exitOnError $? "Failed to parse options"
170 cd $TOPDIR
172 git checkout ${OPT_BRANCH}
173 exitOnError $? "Invalid branch name \"${OPT_BRANCH}\""
175 (cd source3 && ./script/mkversion.sh)
176 if [ ! -f $VER_H ]; then
177 exitOnError 1 "Failed to find ${VER_H}!"
180 version=`grep "define SAMBA_VERSION_OFFICIAL_STRING" $VER_H | awk '{print $3}'`
181 vendor_version=`grep "define SAMBA_VERSION_VENDOR_SUFFIX" $VER_H | awk '{print $3}'`
182 if [ -n "$vendor_version" ]; then
183 version="$version-$vendor_version"
185 vendor_patch=`grep "define SAMBA_VERSION_VENDOR_PATCH_STRING" $VER_H | awk '{print $3}'`
186 if [ -n "$vendor_patch" ]; then
187 version="$version-$vendor_patch"
189 version=`echo $version | sed 's/\"//g'`
191 echo "Creating release tarball for Samba $version"
193 /bin/rm -rf ../samba-${version}
194 git archive --format=tar --prefix=samba-${version}/ HEAD | (cd .. && tar xf -)
195 exitOnError $? "Failed to create release directory tree"
197 pushd ../samba-${version}
199 # Remove RFCs as they are non-free content (with a strict interpretation of
200 # the DFSG)
202 if [ -d source4 ]; then
203 echo "Removing RFCs"
204 find source4/ -name "rfc*.txt" -exec rm -f {} \;
205 rm -f source4/ldap_server/devdocs/draft-armijo-ldap-syntax-00.txt
206 rm -f source4/ldap_server/devdocs/ldapext-ldapv3-vlv-04.txt
209 packaging/bin/update-pkginfo ${version} 1 ""
211 buildDocs
212 exitOnError $? "Failed to build documentation"
214 ( cd source3 && ./autogen.sh )
216 cd ..
217 tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version}
218 exitOnError $? "Failed to create tarball from git tree"
220 gpg --detach-sign --armor samba-${version}.tar
221 ## exitOnError $? "Failed to sign tarball"
223 gzip -9 samba-${version}.tar
224 exitOnError $? "Failed to compress archive"
226 popd
228 createReleaseTag "samba-${version}"
229 exitOnError $? "Failed to create release tag"
231 return 0
234 main "$@"
235 exit $?