Changeset 204 for branches/samba-3.2.x/release-scripts
- Timestamp:
- May 20, 2009, 6:46:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/release-scripts/create-tarball
r133 r204 1 1 #!/bin/bash 2 2 3 ## option defaults 4 OPT_BRANCH="" 5 OPT_DOCSDIR="" 6 OPT_TAG="" 7 OPT_KEYID="" 8 3 9 TOPDIR="`dirname $0`/.." 4 5 cd $TOPDIR 6 7 echo -n "Please enter branch to cut tarball from: " 8 read branch 9 10 if [ "x$branch" = "x" ]; then 11 echo "You must enter a name! Exiting...." 12 exit 1 13 fi 14 15 git-checkout $branch 16 if [ $? -ne 0 ]; then 17 echo "Invalid branch name! Exiting...." 18 exit 2 19 fi 20 21 VER_H=source/include/version.h 22 (cd source && ./script/mkversion.sh) 23 24 if [ ! -f $VER_H ]; then 25 echo "Failed to find $VER_H! Exiting...." 26 exit 1 27 fi 28 29 version=`grep SAMBA_VERSION_OFFICIAL_STRING $VER_H | awk '{print $3}'` 30 vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX $VER_H | awk '{print $3}'` 31 if [ -n "$vendor_version" ]; then 32 version="$version-$vendor_version" 33 fi 34 version=`echo $version | sed 's/\"//g'` 35 36 echo "Creating release tarball for Samba $version" 37 38 /bin/rm -rf ../samba-${version} 39 git-archive --format=tar --prefix=samba-${version}/ HEAD | (cd .. && tar xf -) 40 41 pushd ../samba-${version} 42 43 echo "Enter the absolute path to the generated Samba docs directory." 44 echo -n "Just hit return to exclude the docs from the generate tarball: " 45 read docsdir 46 47 if [ "x$docsdir" != "x" ]; then 48 if [ ! -d "$docsdir" ]; then 49 echo "$docsdir does not exist! Exiting...." 50 exit 1 51 fi 52 53 /bin/rm -rf docs 54 mkdir docs 55 rsync -a --exclude=.svn $docsdir/ docs/ 56 57 cd docs 58 /bin/rm -rf test.pdf Samba4*pdf htmldocs/Samba4* htmldocs/test 59 /bin/mv manpages-3 manpages 60 /bin/mv htmldocs/manpages-3 htmldocs/manpages 61 cd .. 62 fi 63 64 cd source 65 ./autogen.sh 66 cd .. 67 68 cd .. 69 tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version} 70 gpg --detach-sign --armor samba-${version}.tar 71 gzip -9 samba-${version}.tar 72 73 popd 74 echo -n "Enter tag name (or hit <enter> to skip): " 75 read tagname 76 77 if [ "x$tagname" != "x" ]; then 78 if [ "x`git-tag -l $tagname`" != "x" ]; then 79 echo -n "Tag exists. Do you wish to overwrite? (y/N): " 80 read answer 81 82 if [ "x$answer" != "xy" ]; then 83 echo "Tag creation aborted." 84 exit 1 85 fi 86 fi 87 88 echo -n "Enter the keyid:" 89 read keyid 90 if [ x"$keyid" = x"" ];then 91 echo "no keyid" 92 exit 1 93 fi 94 git-tag -u $keyid ${tagname} 95 fi 96 97 echo "Done!" 98 exit 0 10 VER_H="${TOPDIR}/source/include/version.h" 11 12 function exitOnError 13 { 14 local _error="$1" 15 local _msg="$2" 16 17 if [ ${_error} -eq 0 ]; then 18 return 0 19 fi 20 21 echo "FAILURE: ${_msg}" 22 exit ${_error} 23 } 24 25 ## 26 ## Print help usage 27 ## 28 29 function printUsage 30 { 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 "" 38 } 39 40 ## 41 ## Parse the command line options 42 ## 43 44 function parseOptions 45 { 46 while [ -n "$1" ]; do 47 case "$1" in 48 --help) 49 printUsage 50 exit 0 51 ;; 52 --branch) 53 shift 54 if [ -z "$1" ]; then 55 printUsage 56 return 1 57 fi 58 OPT_BRANCH="$1" 59 shift 60 ;; 61 --copy-docs) 62 shift 63 if [ -z "$1" ]; then 64 printUsage 65 return 1 66 fi 67 OPT_DOCSDIR="$1" 68 shift 69 ;; 70 --tag) 71 shift 72 if [ -z "$1" ]; then 73 printUsage 74 return 1 75 fi 76 OPT_TAG="$1" 77 shift 78 ;; 79 --keyid) 80 shift 81 if [ -z "$1" ]; then 82 printUsage 83 return 1 84 fi 85 OPT_KEYID="$1" 86 shift 87 ;; 88 *) 89 printUsage 90 return 1 91 ;; 92 esac 93 done 94 95 if [ -z "${OPT_BRANCH}" ]; then 96 echo "You must specify a branch name!" 97 printUsage 98 return 1 99 fi 100 } 101 102 ## 103 ## Build the dopcumentation (may be a no-op) 104 ## 105 106 function buildDocs 107 { 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." 111 fi 112 113 mkdir docs 114 exitOnError $? "Failed to create docs directory" 115 116 rsync -av "${OPT_DOCSDIR}"/ docs/ 117 exitOnError $? "Failed top copy docs from ${OPT_DOCSDIR}" 118 119 return 0 120 fi 121 122 echo "Building documentation. This may take a while. Log file in /tmp/docs-build.log.$$" 123 124 ${TOPDIR}/release-scripts/build-docs 2> /tmp/docs-build.log.$$ 125 return $? 126 127 } 128 129 130 ## 131 ## Create a release tag 132 ## 133 function createReleaseTag 134 { 135 if [ -z "${OPT_TAG}" ]; then 136 echo "Tagging disabled" 137 return 0 138 fi 139 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 143 144 if [ "x$answer" != "xy" ]; then 145 echo "Tag creation aborted." 146 exit 1 147 fi 148 fi 149 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" 155 fi 156 fi 157 158 git-tag -u ${OPT_KEYID} ${OPT_TAG} 159 exitOnError $? "Failed to create tag" 160 161 return 0 162 } 163 ## 164 ## Main driver 165 ## 166 function main 167 { 168 parseOptions "$@" 169 exitOnError $? "Failed to parse options" 170 171 cd $TOPDIR 172 173 git-checkout ${OPT_BRANCH} 174 exitOnError $? "Invalid branch name \"${OPT_BRANCH}\"" 175 176 (cd source && ./script/mkversion.sh) 177 if [ ! -f $VER_H ]; then 178 exitOnError 1 "Failed to find ${VER_H}!" 179 fi 180 181 version=`grep SAMBA_VERSION_OFFICIAL_STRING $VER_H | awk '{print $3}'` 182 vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX $VER_H | awk '{print $3}'` 183 if [ -n "$vendor_version" ]; then 184 version="$version-$vendor_version" 185 fi 186 version=`echo $version | sed 's/\"//g'` 187 188 echo "Creating release tarball for Samba $version" 189 190 /bin/rm -rf ../samba-${version} 191 git-archive --format=tar --prefix=samba-${version}/ HEAD | (cd .. && tar xf -) 192 exitOnError $? "Failed to create release directory tree" 193 194 pushd ../samba-${version} 195 196 packaging/bin/update-pkginfo ${version} 1 "" 197 198 buildDocs 199 exitOnError $? "Failed to build documentation" 200 201 ( cd source && ./autogen.sh ) 202 203 cd .. 204 tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version} 205 exitOnError $? "Failed to create tarball from git tree" 206 207 gpg --detach-sign --armor samba-${version}.tar 208 ## exitOnError $? "Failed to sign tarball" 209 210 gzip -9 samba-${version}.tar 211 exitOnError $? "Failed to compress archive" 212 213 popd 214 215 createReleaseTag 216 exitOnError $? "Failed to create release tag" 217 218 return 0 219 } 220 221 main "$@" 222 exit $?
Note:
See TracChangeset
for help on using the changeset viewer.