s3:docs: Public is not a synonym for access based shareenum.
[Samba/fernandojvsilva.git] / release-scripts / create-tarball
blob5c9df90d8dcb9505f7387a696d7b7d28fb3f8ff4
1 #!/bin/bash
3 ## option defaults
4 OPT_BRANCH=""
5 OPT_DOCSDIR=""
6 OPT_TAG=""
7 OPT_KEYID=""
9 TOPDIR="`dirname $0`/.."
10 VER_H="${TOPDIR}/source3/include/version.h"
12 function exitOnError
14 local _error="$1"
15 local _msg="$2"
17 if [ ${_error} -eq 0 ]; then
18 return 0
21 echo "FAILURE: ${_msg}"
22 exit ${_error}
26 ## Print help usage
29 function printUsage
31 echo "Usage $0 [options]"
32 echo " --help Print command usage"
33 echo " --branch <name> Specify the branch to to create the archive file from"
34 echo " --copy-docs <dir> Copy documentation from <dir> rather than building"
35 echo " --tag <name> Tag name for release"
36 echo " --keyid <email> The GnuPG key ID used to sign the release tag"
37 echo ""
41 ## Parse the command line options
44 function parseOptions
46 while [ -n "$1" ]; do
47 case "$1" in
48 --help)
49 printUsage
50 exit 0
52 --branch)
53 shift
54 if [ -z "$1" ]; then
55 printUsage
56 return 1
58 OPT_BRANCH="$1"
59 shift
61 --copy-docs)
62 shift
63 if [ -z "$1" ]; then
64 printUsage
65 return 1
67 OPT_DOCSDIR="$1"
68 shift
70 --tag)
71 shift
72 if [ -z "$1" ]; then
73 printUsage
74 return 1
76 OPT_TAG="$1"
77 shift
79 --keyid)
80 shift
81 if [ -z "$1" ]; then
82 printUsage
83 return 1
85 OPT_KEYID="$1"
86 shift
89 printUsage
90 return 1
92 esac
93 done
95 if [ -z "${OPT_BRANCH}" ]; then
96 echo "You must specify a branch name!"
97 printUsage
98 return 1
103 ## Build the dopcumentation (may be a no-op)
106 function buildDocs
108 if [ -n "${OPT_DOCSDIR}" ]; then
109 if [ ! -d "${OPT_DOCSDIR}" ]; then
110 exitOnError 1 "${OPT_DOCSDIR} does not exist. Please specify the absolute path."
113 mkdir docs
114 exitOnError $? "Failed to create docs directory"
116 rsync -av "${OPT_DOCSDIR}"/ docs/
117 exitOnError $? "Failed top copy docs from ${OPT_DOCSDIR}"
119 return 0
122 echo "Building documentation. This may take a while. Log file in /tmp/docs-build.log.$$"
124 ${TOPDIR}/release-scripts/build-docs 2> /tmp/docs-build.log.$$
125 return $?
131 ## Create a release tag
133 function createReleaseTag
135 if [ -z "${OPT_TAG}" ]; then
136 echo "Tagging disabled"
137 return 0
140 if [ "x`git tag -l ${OPT_TAG}`" != "x" ]; then
141 echo -n "Tag exists. Do you wish to overwrite? (y/N): "
142 read answer
144 if [ "x$answer" != "xy" ]; then
145 echo "Tag creation aborted."
146 exit 1
150 if [ -z "${OPT_KEYID}" ]; then
151 echo -n "Enter the keyid:"
152 read OPT_KEYID
153 if [ -z "${OPT_KEYID}" ]; then
154 exitOnError 1 "No keyid specified"
158 git tag -u ${OPT_KEYID} ${OPT_TAG}
159 exitOnError $? "Failed to create tag"
161 return 0
164 ## Main driver
166 function main
168 parseOptions "$@"
169 exitOnError $? "Failed to parse options"
171 cd $TOPDIR
173 git checkout ${OPT_BRANCH}
174 exitOnError $? "Invalid branch name \"${OPT_BRANCH}\""
176 (cd source3 && ./script/mkversion.sh)
177 if [ ! -f $VER_H ]; then
178 exitOnError 1 "Failed to find ${VER_H}!"
181 version=`grep "define SAMBA_VERSION_OFFICIAL_STRING" $VER_H | awk '{print $3}'`
182 vendor_version=`grep "define SAMBA_VERSION_VENDOR_SUFFIX" $VER_H | awk '{print $3}'`
183 if [ -n "$vendor_version" ]; then
184 version="$version-$vendor_version"
186 vendor_patch=`grep "define SAMBA_VERSION_VENDOR_PATCH" $VER_H | awk '{print $3}'`
187 if [ -n "$vendor_patch" ]; then
188 version="$version-$vendor_patch"
190 version=`echo $version | sed 's/\"//g'`
192 echo "Creating release tarball for Samba $version"
194 /bin/rm -rf ../samba-${version}
195 git archive --format=tar --prefix=samba-${version}/ HEAD | (cd .. && tar xf -)
196 exitOnError $? "Failed to create release directory tree"
198 pushd ../samba-${version}
200 # Remove RFCs as they are non-free content (with a strict interpretation of
201 # the DFSG)
203 if [ -d source4 ]; then
204 echo "Removing RFCs"
205 find source4/ -name "rfc*.txt" -exec rm -f {} \;
208 packaging/bin/update-pkginfo ${version} 1 ""
210 buildDocs
211 exitOnError $? "Failed to build documentation"
213 ( cd source3 && ./autogen.sh )
215 cd ..
216 tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version}
217 exitOnError $? "Failed to create tarball from git tree"
219 gpg --detach-sign --armor samba-${version}.tar
220 ## exitOnError $? "Failed to sign tarball"
222 gzip -9 samba-${version}.tar
223 exitOnError $? "Failed to compress archive"
225 popd
227 createReleaseTag
228 exitOnError $? "Failed to create release tag"
230 return 0
233 main "$@"
234 exit $?