Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 143 lines (124 sloc) 3.371 kb
ef23fb2 Add helper script for release package creation
giallu authored
1 #!/bin/bash
2 #
3 # Original script supplied by:
4 # Tais M. Hansen <tais.hansen@osd.dk>#
5 #
6
7 SVNREPOS="http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/tags"
8
9 function digest {
10 file=$(basename $1)
11 path=$(dirname $1)
12 pushd $path >/dev/null
13 cat > $file.DIGESTS << EODIGESTS
14 # MD5 HASH
15 $(md5sum --binary $file)
16 # SHA1 HASH
17 $(sha1sum --binary $file)
18 EODIGESTS
19 popd >/dev/null
20 }
21
22 function usage {
23 cat << EOUSAGE
24 Syntax: $0 [options] <tag>
25
26 Options:
27 -h This help.
28 -r name Release name. Defaults to MANTIS_VERSION in core/constant_inc.php
29 for the given <tag>.
30 -c Remove downloaded directory after package creation
31 EOUSAGE
32 }
33
34 # Options.
35 declare tag=""
36 declare tag_path=""
37 declare release=""
38 declare release_path=""
39 declare cleanup=""
40
41 # Parse commandline options.
42 while getopts hcr: opt; do
43 case ${opt} in
44 r)
45 release="${OPTARG}"
46 ;;
47 c)
48 cleanup="yes"
49 ;;
50 h|?)
51 usage
52 exit 1
53 ;;
54 esac
55 done
56
57 # Remaining argument should be the requested tag.
58 shift $((${OPTIND}-1))
59 tag="$1"
60
61 # Make sure we have a tag before continuing.
62 if [ -z "${tag}" ]; then
63 echo "Error: Tag not specified."
64 usage
65 exit 1
66 fi
67
68 # Retrieve code, if we don't have it already.
69 echo "Retrieving ${tag} from ${SVNREPOS}."
70 tag_path="$(pwd)/mantis-${tag}"
71 if [[ -d "${tag_path}" ]]; then
704f45e Some fixes, check for "zip" avaliability before using it, remove dep on ...
giallu authored
72 if [[ -n $cleanup ]]; then
73 rm -rf ${tag_path}
74 else
75 echo "Error: Tag directory already exists: ${tag_path}"
76 exit 1
77 fi
ef23fb2 Add helper script for release package creation
giallu authored
78 fi
79 svn export --quiet --native-eol LF "${SVNREPOS}/${tag}" "${tag_path}"
80
81 # Retrieve release name.
82 if [[ -z "${release}" ]]; then
83 echo "Attempting to retrieve release name."
84 pushd ${tag_path} >/dev/null
704f45e Some fixes, check for "zip" avaliability before using it, remove dep on ...
giallu authored
85 #release=$(php -r 'include "core/constant_inc.php"; echo MANTIS_VERSION;')
86 release=$(awk "/MANTIS_VERSION/{if(match(\$0, /define\(.*'MANTIS_VERSION'.*'([^']+)'.*\);/, m)){print m[1];}}" core/constant_inc.php)
ef23fb2 Add helper script for release package creation
giallu authored
87 popd >/dev/null
88 if [[ -z "${release}" ]]; then
89 echo "Error: Failed to parse MANTIS_VERSION in core/constant_inc.php"
90 exit 1
91 fi
92 fi
93 echo "Release: ${release}"
94
95 # Prepare release dir.
96 echo "Preparing release directory."
97 release_name="mantis-${release}"
98 release_path="$(pwd)/${release_name}"
99 if [[ -d "${release_path}" ]]; then
704f45e Some fixes, check for "zip" avaliability before using it, remove dep on ...
giallu authored
100 if [[ -n $cleanup ]]; then
101 rm -rf ${release_path}
102 else
103 echo "Error: Release directory already exists: ${release_path}"
104 exit 1
105 fi
ef23fb2 Add helper script for release package creation
giallu authored
106 fi
107 mv "${tag_path}" "${release_path}"
108
109 # Sanitize.
110 echo "Sanitizing."
111 pushd "${release_path}" >/dev/null
112 rm -rf packages
113
114 echo "Looking for executable files..."
115 find . -type f -perm /111 -print -exec chmod -x {} \;
116 popd >/dev/null
117
118 # Generate archives and digests.
119 echo "Generating tar-archive and digests."
120 tar czf "${release_name}.tar.gz" "${release_name}"
121 digest "${release_name}.tar.gz"
122
704f45e Some fixes, check for "zip" avaliability before using it, remove dep on ...
giallu authored
123 type zip > /dev/null
124 if [ $? != "0" ]; then
125 echo "Can not find 'zip' command in path: skipping creation."
126 else
127 echo "Generating zip-archive and digests."
128 zip -qr "${release_name}.zip" "${release_name}"
129 digest "${release_name}.zip"
130 fi
ef23fb2 Add helper script for release package creation
giallu authored
131
132 # Show resulting archives and digest-files.
133 ls -l ${release_name}.tar.gz*
134 ls -l ${release_name}.zip*
135
136 # Cleanup.
137 if [[ -n $cleanup ]]; then
138 echo "Cleaning up."
139 rm -rf "${release_path}"
140 fi
141
142 echo "All done."
Something went wrong with that request. Please try again.