1 |
boklm |
2900 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
# To the extent possible under law, the author(s) have dedicated all |
4 |
|
|
# copyright and related and neighboring rights to this software to the |
5 |
|
|
# public domain worldwide. |
6 |
|
|
# This software is distributed without any warranty. |
7 |
|
|
|
8 |
|
|
# You should have received a copy of the CC0 Public Domain Dedication |
9 |
|
|
# along with this software. |
10 |
|
|
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. |
11 |
|
|
|
12 |
|
|
. /etc/mgasoft.conf |
13 |
|
|
|
14 |
|
|
function check_softname() |
15 |
|
|
{ |
16 |
|
|
local softname="$1" |
17 |
|
|
test -n "$softname" || return 1 |
18 |
|
|
echo "$softname" | fgrep -q .. && return 1 |
19 |
|
|
echo "$softname" | fgrep -q / && return 1 |
20 |
|
|
return 0 |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
function check_softrel() |
24 |
|
|
{ |
25 |
|
|
check_softname $@ |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
function usage() |
29 |
|
|
{ |
30 |
|
|
local cmd="$1" |
31 |
|
|
local exitval=$2 |
32 |
|
|
case "$cmd" in |
33 |
|
|
tagrelease) |
34 |
|
|
cat <<EOF |
35 |
|
|
Usage: mgasoft tag [name] [version] |
36 |
|
|
|
37 |
|
|
This command tag a version from trunk. |
38 |
|
|
EOF |
39 |
|
|
;; |
40 |
|
|
gettar) |
41 |
|
|
cat <<EOF |
42 |
|
|
Usage: mgasoft tar [name] [version] |
43 |
|
|
|
44 |
|
|
This command will create a tarball. |
45 |
|
|
EOF |
46 |
|
|
;; |
47 |
|
|
publish) |
48 |
|
|
cat <<EOF |
49 |
|
|
Usage: mgasoft publish [name] [version] |
50 |
|
|
|
51 |
|
|
This command will publish a version on mageia mirrors. |
52 |
|
|
EOF |
53 |
|
|
;; |
54 |
|
|
*) |
55 |
|
|
cat <<EOF |
56 |
|
|
Usage: mgasoft [command] [args] |
57 |
|
|
|
58 |
|
|
Available commands : |
59 |
|
|
tag |
60 |
|
|
publish |
61 |
|
|
tar |
62 |
|
|
|
63 |
|
|
For more infos about a command, use : |
64 |
|
|
mgasoft [command] --help |
65 |
|
|
EOF |
66 |
|
|
;; |
67 |
|
|
esac |
68 |
|
|
exit $exitval |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
function tagrelease() |
72 |
|
|
{ |
73 |
|
|
[ "$1" == "--help" ] && usage tagrelease 0 |
74 |
|
|
[ $# -ne 2 ] && usage tagrelease 1 |
75 |
|
|
local softname="$1" |
76 |
|
|
local softrel="$2" |
77 |
|
|
check_softname "$softname" || exit 1 |
78 |
|
|
check_softrel "$softrel" || exit 1 |
79 |
|
|
|
80 |
|
|
local softdir="$svn_soft/$softname" |
81 |
|
|
|
82 |
|
|
if ! svn ls "$softdir/trunk" > /dev/null 2>&1 |
83 |
|
|
then |
84 |
|
|
echo "error: $softname does not exists" >&2 |
85 |
|
|
exit 2 |
86 |
|
|
fi |
87 |
|
|
|
88 |
|
|
if svn ls "$softdir/tags/$softrel" > /dev/null 2>&1 |
89 |
|
|
then |
90 |
|
|
echo "error: $softname version $softrel already exists" >&2 |
91 |
|
|
exit 2 |
92 |
|
|
fi |
93 |
|
|
|
94 |
|
|
if ! svn ls "$softdir/tags" > /dev/null 2>&1 |
95 |
|
|
then |
96 |
|
|
svn mkdir -q -m "create tags directory for $softname" "$softdir/tags" |
97 |
|
|
fi |
98 |
|
|
svn cp -q -m "tag $softname version $softrel" "$softdir/trunk" "$softdir/tags/$softrel" |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
function gettar() |
102 |
|
|
{ |
103 |
|
|
[ "$1" == "--help" ] && usage gettar 0 |
104 |
|
|
[ $# -ne 2 ] && usage gettar 1 |
105 |
|
|
local softname="$1" |
106 |
|
|
local softrel="$2" |
107 |
|
|
check_softname "$softname" || exit 1 |
108 |
|
|
check_softrel "$softrel" || exit 1 |
109 |
|
|
|
110 |
|
|
local oldpwd=$PWD |
111 |
|
|
local tmpdir=$(mktemp -d) |
112 |
|
|
cd $tmpdir |
113 |
|
|
if [ "$softrel" == "trunk" ] |
114 |
|
|
then |
115 |
|
|
local svnpath="$anonsvn_soft/$softname/trunk" |
116 |
|
|
else |
117 |
|
|
local svnpath="$anonsvn_soft/$softname/tags/$softrel" |
118 |
|
|
fi |
119 |
|
|
if ! svn export -q "$svnpath" "$softname-$softrel" |
120 |
|
|
then |
121 |
|
|
echo "Error exporting $softname-$softrel" >&2 |
122 |
|
|
rm -Rf "$tmpdir" |
123 |
|
|
exit 2 |
124 |
|
|
fi |
125 |
|
|
tar cvJf "$oldpwd/$softname-$softrel.tar.xz" "$softname-$softrel" |
126 |
|
|
cd "$oldpwd" |
127 |
|
|
rm -Rf "$tmpdir" |
128 |
|
|
echo "Created $softname-$softrel.tar.xz" |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
function publishrelease() |
132 |
|
|
{ |
133 |
|
|
[ "$1" == "--help" ] && usage publish 0 |
134 |
|
|
[ $# -ne 2 ] && usage publish 1 |
135 |
|
|
local softname="$1" |
136 |
|
|
local softrel="$2" |
137 |
|
|
check_softname "$softname" || exit 1 |
138 |
|
|
check_softrel "$softrel" || exit 1 |
139 |
|
|
|
140 |
|
|
local svnpath="$svn_soft/$softname/tags/$softrel" |
141 |
|
|
if ! svn ls "$svnpath" > /dev/null 2>&1 |
142 |
|
|
then |
143 |
|
|
echo "error: $softname version $softrel does not exist" >&2 |
144 |
|
|
exit 2 |
145 |
|
|
fi |
146 |
|
|
|
147 |
|
|
local pubdir="$svn_soft_publish/$softname" |
148 |
|
|
if svn ls "$pubdir/$softrel" > /dev/null 2>&1 |
149 |
|
|
then |
150 |
|
|
echo "$softname version $softrel already published" >&2 |
151 |
|
|
exit 2 |
152 |
|
|
fi |
153 |
|
|
if ! svn ls "$pubdir" > /dev/null 2>&1 |
154 |
|
|
then |
155 |
|
|
svn mkdir -q -m "create directory for $softname" "$pubdir" |
156 |
|
|
fi |
157 |
|
|
local tmpdir=$(mktemp -d) |
158 |
|
|
pushd "$tmpdir" > /dev/null |
159 |
|
|
svn co -q "$pubdir" |
160 |
|
|
cd "$softname" |
161 |
|
|
touch "$softrel" |
162 |
|
|
svn add -q "$softrel" |
163 |
|
|
svn ci -q -m "publish $softname version $softrel" |
164 |
|
|
popd > /dev/null |
165 |
|
|
rm -Rf "$tmpdir" |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
case "$1" in |
169 |
|
|
tag) |
170 |
|
|
shift |
171 |
|
|
tagrelease $@ |
172 |
|
|
;; |
173 |
|
|
tar) |
174 |
|
|
shift |
175 |
|
|
gettar $@ |
176 |
|
|
;; |
177 |
|
|
publish) |
178 |
|
|
shift |
179 |
|
|
publishrelease $@ |
180 |
|
|
;; |
181 |
|
|
*) |
182 |
|
|
usage '' 1 |
183 |
|
|
;; |
184 |
|
|
esac |
185 |
|
|
|