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