[429] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | ## option defaults
|
---|
| 4 | OPT_BRANCH=""
|
---|
| 5 | OPT_DOCSDIR=""
|
---|
| 6 | OPT_KEYID=""
|
---|
| 7 |
|
---|
| 8 | TOPDIR="`dirname $0`/.."
|
---|
| 9 | VER_H="${TOPDIR}/source3/include/version.h"
|
---|
| 10 |
|
---|
| 11 | function exitOnError
|
---|
| 12 | {
|
---|
| 13 | local _error="$1"
|
---|
| 14 | local _msg="$2"
|
---|
| 15 |
|
---|
| 16 | if [ ${_error} -eq 0 ]; then
|
---|
| 17 | return 0
|
---|
| 18 | fi
|
---|
| 19 |
|
---|
| 20 | echo "FAILURE: ${_msg}"
|
---|
| 21 | exit ${_error}
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | ##
|
---|
| 25 | ## Print help usage
|
---|
| 26 | ##
|
---|
| 27 |
|
---|
| 28 | function printUsage
|
---|
| 29 | {
|
---|
| 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 ""
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | ##
|
---|
| 39 | ## Parse the command line options
|
---|
| 40 | ##
|
---|
| 41 |
|
---|
| 42 | function parseOptions
|
---|
| 43 | {
|
---|
| 44 | while [ -n "$1" ]; do
|
---|
| 45 | case "$1" in
|
---|
| 46 | --help)
|
---|
| 47 | printUsage
|
---|
| 48 | exit 0
|
---|
| 49 | ;;
|
---|
| 50 | --branch)
|
---|
| 51 | shift
|
---|
| 52 | if [ -z "$1" ]; then
|
---|
| 53 | printUsage
|
---|
| 54 | return 1
|
---|
| 55 | fi
|
---|
| 56 | OPT_BRANCH="$1"
|
---|
| 57 | shift
|
---|
| 58 | ;;
|
---|
| 59 | --copy-docs)
|
---|
| 60 | shift
|
---|
| 61 | if [ -z "$1" ]; then
|
---|
| 62 | printUsage
|
---|
| 63 | return 1
|
---|
| 64 | fi
|
---|
| 65 | OPT_DOCSDIR="$1"
|
---|
| 66 | shift
|
---|
| 67 | ;;
|
---|
| 68 | --keyid)
|
---|
| 69 | shift
|
---|
| 70 | if [ -z "$1" ]; then
|
---|
| 71 | printUsage
|
---|
| 72 | return 1
|
---|
| 73 | fi
|
---|
| 74 | OPT_KEYID="$1"
|
---|
| 75 | shift
|
---|
| 76 | ;;
|
---|
| 77 | *)
|
---|
| 78 | printUsage
|
---|
| 79 | return 1
|
---|
| 80 | ;;
|
---|
| 81 | esac
|
---|
| 82 | done
|
---|
| 83 |
|
---|
| 84 | if [ -z "${OPT_BRANCH}" ]; then
|
---|
| 85 | echo "You must specify a branch name!"
|
---|
| 86 | printUsage
|
---|
| 87 | return 1
|
---|
| 88 | fi
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | ##
|
---|
[745] | 92 | ## Build the documentation (may be a no-op)
|
---|
[429] | 93 | ##
|
---|
| 94 |
|
---|
| 95 | function buildDocs
|
---|
| 96 | {
|
---|
| 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."
|
---|
| 100 | fi
|
---|
| 101 |
|
---|
| 102 | mkdir docs
|
---|
| 103 | exitOnError $? "Failed to create docs directory"
|
---|
| 104 |
|
---|
| 105 | rsync -av "${OPT_DOCSDIR}"/ docs/
|
---|
| 106 | exitOnError $? "Failed top copy docs from ${OPT_DOCSDIR}"
|
---|
| 107 |
|
---|
| 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
|
---|
| 112 | fi
|
---|
| 113 | if [ -d htmldocs/manpages-3 ]; then
|
---|
| 114 | mv htmldocs/manpages-3 htmldocs/manpages
|
---|
| 115 | fi
|
---|
| 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 ../
|
---|
| 120 |
|
---|
| 121 | return 0
|
---|
| 122 | fi
|
---|
| 123 |
|
---|
| 124 | echo "Building documentation. This may take a while. Log file in /tmp/docs-build.log.$$"
|
---|
| 125 |
|
---|
| 126 | ${TOPDIR}/release-scripts/build-docs 2> /tmp/docs-build.log.$$
|
---|
| 127 | return $?
|
---|
| 128 |
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | ##
|
---|
| 133 | ## Create a release tag
|
---|
| 134 | ##
|
---|
| 135 | function createReleaseTag
|
---|
| 136 | {
|
---|
[745] | 137 | tagname="$1"
|
---|
[429] | 138 |
|
---|
[745] | 139 | if [ "x`git tag -l ${tagname}`" != "x" ]; then
|
---|
| 140 | echo -n "Tag '${tagname}' exists. Do you wish to overwrite? (y/N): "
|
---|
[429] | 141 | read answer
|
---|
| 142 |
|
---|
| 143 | if [ "x$answer" != "xy" ]; then
|
---|
| 144 | echo "Tag creation aborted."
|
---|
| 145 | exit 1
|
---|
| 146 | fi
|
---|
| 147 | fi
|
---|
| 148 |
|
---|
| 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"
|
---|
| 154 | fi
|
---|
| 155 | fi
|
---|
| 156 |
|
---|
[745] | 157 | git tag -u ${OPT_KEYID} ${tagname}
|
---|
| 158 | exitOnError $? "Failed to create tag '${tagname}'"
|
---|
[429] | 159 |
|
---|
| 160 | return 0
|
---|
| 161 | }
|
---|
| 162 | ##
|
---|
| 163 | ## Main driver
|
---|
| 164 | ##
|
---|
| 165 | function main
|
---|
| 166 | {
|
---|
| 167 | parseOptions "$@"
|
---|
| 168 | exitOnError $? "Failed to parse options"
|
---|
| 169 |
|
---|
| 170 | cd $TOPDIR
|
---|
| 171 |
|
---|
| 172 | git checkout ${OPT_BRANCH}
|
---|
| 173 | exitOnError $? "Invalid branch name \"${OPT_BRANCH}\""
|
---|
| 174 |
|
---|
| 175 | (cd source3 && ./script/mkversion.sh)
|
---|
| 176 | if [ ! -f $VER_H ]; then
|
---|
| 177 | exitOnError 1 "Failed to find ${VER_H}!"
|
---|
| 178 | fi
|
---|
| 179 |
|
---|
| 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"
|
---|
| 184 | fi
|
---|
| 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"
|
---|
| 188 | fi
|
---|
| 189 | version=`echo $version | sed 's/\"//g'`
|
---|
| 190 |
|
---|
| 191 | echo "Creating release tarball for Samba $version"
|
---|
| 192 |
|
---|
| 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"
|
---|
| 196 |
|
---|
| 197 | pushd ../samba-${version}
|
---|
| 198 |
|
---|
| 199 | # Remove RFCs as they are non-free content (with a strict interpretation of
|
---|
| 200 | # the DFSG)
|
---|
| 201 |
|
---|
[745] | 202 | if [ -d source4 ]; then
|
---|
| 203 | echo "Removing RFCs"
|
---|
| 204 | find source4/ -name "rfc*.txt" -exec /bin/rm -f {} \;
|
---|
| 205 | /bin/rm -f source4/ldap_server/devdocs/draft-armijo-ldap-syntax-00.txt
|
---|
| 206 | /bin/rm -f source4/ldap_server/devdocs/ldapext-ldapv3-vlv-04.txt
|
---|
| 207 | fi
|
---|
[429] | 208 |
|
---|
[745] | 209 | /bin/rm -f Makefile configure configure.developer
|
---|
| 210 |
|
---|
[429] | 211 | packaging/bin/update-pkginfo ${version} 1 ""
|
---|
| 212 |
|
---|
| 213 | buildDocs
|
---|
| 214 | exitOnError $? "Failed to build documentation"
|
---|
| 215 |
|
---|
| 216 | ( cd source3 && ./autogen.sh )
|
---|
| 217 |
|
---|
| 218 | cd ..
|
---|
| 219 | tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version}
|
---|
| 220 | exitOnError $? "Failed to create tarball from git tree"
|
---|
| 221 |
|
---|
| 222 | gpg --detach-sign --armor samba-${version}.tar
|
---|
| 223 | ## exitOnError $? "Failed to sign tarball"
|
---|
| 224 |
|
---|
| 225 | gzip -9 samba-${version}.tar
|
---|
| 226 | exitOnError $? "Failed to compress archive"
|
---|
| 227 |
|
---|
| 228 | popd
|
---|
| 229 |
|
---|
[745] | 230 | createReleaseTag "samba-${version}"
|
---|
[429] | 231 | exitOnError $? "Failed to create release tag"
|
---|
| 232 |
|
---|
| 233 | return 0
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | main "$@"
|
---|
| 237 | exit $?
|
---|