]>
Commit | Line | Data |
---|---|---|
b054f772 | 1 | #!/bin/sh |
33f5276d | 2 | # ----------- |
25fa34fe | 3 | # $Id$ |
33f5276d | 4 | # Exit codes: |
5 | # 0 - succesful | |
10b4dd7f | 6 | # 1 - help displayed |
33f5276d | 7 | # 2 - no spec file name in cmdl parameters |
8 | # 3 - spec file not stored in repo | |
0ad50ce9 | 9 | # 4 - some source, patch or icon files not stored in repo |
10 | # 5 - package build failed | |
10b4dd7f | 11 | # 6 - spec file with errors |
5a491465 | 12 | |
931a4acf TP |
13 | # Notes (todo): |
14 | # - builder -u fetches current version first | |
15 | # - tries to get new version from distfiles without new md5 | |
16 | # - after fetching new version doesn't update md5 | |
2837871a | 17 | # - doesn't get sources for specs with %include /usr/lib/rpm/macros.python |
9308ddd0 | 18 | # when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway) |
2837871a | 19 | # - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov |
931a4acf | 20 | |
4003ad8c | 21 | VERSION="\ |
22 | Build package utility from PLD CVS repository | |
6cb7df6d | 23 | V 0.11 (C) 1999-2003 Free Penguins". |
5a491465 | 24 | PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" |
a7af9862 | 25 | |
b03f053b | 26 | COMMAND="build" |
27 | ||
bde1c404 | 28 | SPECFILE="" |
d287305c | 29 | BE_VERBOSE="" |
4003ad8c | 30 | QUIET="" |
5dd89621 | 31 | CLEAN="" |
7c2dd1b2 | 32 | DEBUG="" |
cc97f1f3 | 33 | NOURLS="" |
157dc315 | 34 | NOCVS="" |
6fc910c7 | 35 | NOCVSSPEC="" |
fc0e5bb5 | 36 | NODIST="" |
b130abf2 | 37 | UPDATE="" |
a9d9a79a | 38 | UPDATE5="" |
de6b5b2a | 39 | ADD5="" |
81474543 | 40 | ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"} |
c61a8d10 AM |
41 | if [ -s CVS/Root ]; then |
42 | CVSROOT=$(cat CVS/Root) | |
43 | else | |
44 | CVSROOT=${CVSROOT:-""} | |
45 | fi | |
d6a75d60 | 46 | # Example: LOGFILE='../log.$PACKAGE_NAME' |
47 | # Yes, you can use variable name! Note _single_ quotes! | |
48 | LOGFILE='' | |
00fcec7e | 49 | |
50 | LOGDIR="" | |
51 | LOGDIROK="" | |
52 | LOGDIRFAIL="" | |
53 | LASTLOG_FILE="" | |
54 | LTAG="" | |
79d76918 | 55 | CHMOD="no" |
d6a75d60 | 56 | CHMOD_MODE="0444" |
33a9d2d1 | 57 | RPMOPTS="" |
6049c3d1 | 58 | BCOND="" |
d287305c | 59 | |
60 | PATCHES="" | |
61 | SOURCES="" | |
7053d3fd | 62 | ICONS="" |
d287305c | 63 | PACKAGE_RELEASE="" |
64 | PACKAGE_VERSION="" | |
65 | PACKAGE_NAME="" | |
d7f490f3 | 66 | PROTOCOL="ftp" |
34c911e6 | 67 | WGET_RETRIES=${MAX_WGET_RETRIES:-0} |
b92ecfc9 | 68 | CVS_RETRIES=${MAX_CVS_RETRIES:-1000} |
5a491465 | 69 | |
00fcec7e | 70 | CVSTAG="" |
71 | RES_FILE="" | |
72 | ||
62546902 | 73 | CVS_SERVER="cvs.pld-linux.org" |
d7f490f3 | 74 | DISTFILES_SERVER="://distfiles.pld-linux.org" |
ea15df77 | 75 | |
3ae81a20 | 76 | DEF_NICE_LEVEL=0 |
77 | ||
c6a390a1 AM |
78 | FAIL_IF_NO_SOURCES="yes" |
79 | ||
8f7b338e | 80 | GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES --inet" |
81 | GETURI2="wget -c -nd -t$WGET_RETRIES --inet" | |
6aefe77b | 82 | GETLOCAL="cp -a" |
11f33a0c | 83 | |
7147050f AM |
84 | if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then |
85 | RPM="rpm" | |
86 | RPMBUILD="rpm" | |
87 | else | |
88 | RPM="rpm" | |
89 | RPMBUILD="rpmbuild" | |
90 | fi | |
91 | ||
6eb44b93 | 92 | if [ -f ~/etc/builderrc ]; then |
7922b3ec | 93 | . ~/etc/builderrc |
6eb44b93 | 94 | elif [ -f ~/.builderrc ]; then |
7922b3ec | 95 | . ~/.builderrc |
5aa0ef93 AF |
96 | fi |
97 | ||
da946cd6 | 98 | #--------------------------------------------- |
99 | # functions | |
100 | ||
5a491465 | 101 | usage() |
102 | { | |
7c2dd1b2 | 103 | if [ -n "$DEBUG" ]; then set -xv; fi |
104 | echo "\ | |
7922b3ec | 105 | Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] |
81f85806 | 106 | |
107 | [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade] | |
108 | [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get] | |
d7f490f3 | 109 | [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper] |
00fcec7e | 110 | [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>] |
a2164135 MM |
111 | [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest] |
112 | [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] | |
81f85806 | 113 | [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] |
c9ff8825 | 114 | [--with/--without <feature>] [--define <macro> <value>] <package>[.spec] |
5a491465 | 115 | |
de6b5b2a | 116 | -5, --update-md5 |
afade7dd JB |
117 | - update md5 comments in spec, implies -nd -ncs |
118 | -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs | |
a2a9c8df | 119 | -D, --debug - enable script debugging mode, |
5a491465 | 120 | -V, --version - output builder version |
62546902 | 121 | -a, --as_anon - get files via pserver as cvs@$CVS_SERVER, |
79b2ec0e | 122 | -b, -ba, |
cc97f1f3 | 123 | --build - get all files from CVS repo or HTTP/FTP and build |
5a491465 | 124 | package from <package>.spec, |
7922b3ec | 125 | -bb, --build-binary |
126 | - get all files from CVS repo or HTTP/FTP and build | |
79b2ec0e | 127 | binary only package from <package>.spec, |
128 | -bs, | |
cc97f1f3 SZ |
129 | --build-source - get all files from CVS repo or HTTP/FTP and only |
130 | pack them into src.rpm, | |
8ba5cdda | 131 | -B, --branch - add branch |
7922b3ec | 132 | -c, --clean - clean all temporarily created files (in BUILD, |
79b2ec0e | 133 | SOURCES, SPECS and \$RPM_BUILD_ROOT), |
7922b3ec | 134 | -d <cvsroot>, --cvsroot <cvsroot> |
135 | - setup \$CVSROOT, | |
e7bdc1b4 | 136 | --define <macro> <value> |
81f85806 | 137 | - define a macro <macro> with value <value>, |
7922b3ec | 138 | -g, --get - get <package>.spec and all related files from |
cc97f1f3 | 139 | CVS repo or HTTP/FTP, |
5a491465 | 140 | -h, --help - this message, |
d7f490f3 | 141 | --http - use http instead of ftp, |
7922b3ec | 142 | -l <logfile>, --logtofile <logfile> |
143 | - log all to file, | |
ff45a501 | 144 | -m, --mr-proper - only remove all files related to spec file and |
8bc51224 | 145 | all work resources, |
6fc910c7 | 146 | -nc, --no-cvs - don't download sources from CVS, if source URL is |
147 | given, | |
148 | -ncs, --no-cvs-specs | |
149 | - don't check specs in CVS | |
fc0e5bb5 TP |
150 | -nd, --no-distfiles |
151 | - don't download from distfiles | |
4ca52257 | 152 | -nm, --no-mirrors - don't download from mirror, if source URL is given, |
157dc315 | 153 | -nu, --no-urls - don't try to download from FTP/HTTP location, |
0143ec80 | 154 | -ns, --no-srcs - don't download Sources |
fd2b5687 | 155 | -ns0, --no-source0 |
0143ec80 | 156 | - don't download Source0 |
7922b3ec | 157 | --opts <rpm opts> |
158 | - additional options for rpm | |
5a491465 | 159 | -q, --quiet - be quiet, |
448deaa0 | 160 | --date yyyy-mm-dd |
161 | - build package using resources from specified CVS | |
162 | date, | |
7922b3ec | 163 | -r <cvstag>, --cvstag <cvstag> |
164 | - build package using resources from specified CVS | |
67fcd1e4 | 165 | tag, |
7922b3ec | 166 | -T <cvstag> , --tag <cvstag> |
167 | - add cvs tag <cvstag> for files, | |
78ce14b3 | 168 | -Tvs, --tag-version-stable |
169 | - add cvs tags STABLE and NAME-VERSION-RELESE for files, | |
a2164135 MM |
170 | -Tvn, --tag-version-nest |
171 | - add cvs tags NEST and NAME-VERSION-RELESE for files, | |
78ce14b3 | 172 | -Ts, --tag-stable |
173 | - add cvs tag STABLE for files, | |
a2164135 MM |
174 | -Tn, --tag-nest |
175 | - add cvs tag NEST for files, | |
7922b3ec | 176 | -Tv, --tag-version |
177 | - add cvs tag NAME-VERSION-RELESE for files, | |
5a491465 | 178 | -v, --verbose - be verbose, |
81f85806 | 179 | -u, --try-upgrade |
180 | - check version, and try to upgrade package | |
b130abf2 TP |
181 | -un, --try-upgrade-with-float-version |
182 | - as above, but allow float version | |
183 | -U, --update | |
de6b5b2a MM |
184 | - refetch sources, don't use distfiles, and update md5 |
185 | comments | |
d5787aec | 186 | --with/--without <feature> |
81f85806 | 187 | - conditional build package depending on |
d5787aec | 188 | %_with_<feature>/%_without_<feature> macro |
81f85806 | 189 | switch |
5a491465 | 190 | " |
191 | } | |
192 | ||
5f26c239 MM |
193 | cache_rpm_dump () { |
194 | rpm_dump_cache=` | |
ad6f43de MM |
195 | case "$RPMBUILD" in |
196 | rpm ) | |
ecfecee9 | 197 | rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1 |
ad6f43de MM |
198 | ;; |
199 | rpmbuild ) | |
5f26c239 | 200 | rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 |
ad6f43de | 201 | ;; |
15a71f66 | 202 | esac` |
10b4dd7f | 203 | if [ $? -ne 0 ]; then |
204 | echo $rpm_dump_cache | |
205 | exit 6 | |
206 | fi | |
5f26c239 MM |
207 | } |
208 | ||
209 | rpm_dump () { | |
210 | if [ -z "$rpm_dump_cache" ] ; then | |
211 | echo "internal error: cache_rpm_dump not called!" 1>&2 | |
15a71f66 MM |
212 | fi |
213 | echo "$rpm_dump_cache" | |
ad6f43de MM |
214 | } |
215 | ||
59398507 | 216 | parse_spec() |
217 | { | |
c3428d50 | 218 | if [ -n "$DEBUG" ]; then |
a7af9862 | 219 | set -x; |
220 | set -v; | |
71d62f04 | 221 | fi |
7c2dd1b2 | 222 | |
25fa34fe | 223 | cd $SPECS_DIR |
5f26c239 MM |
224 | |
225 | cache_rpm_dump | |
226 | ||
72fb89b5 | 227 | if [ "$NOSRCS" != "yes" ]; then |
ad6f43de | 228 | SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`" |
72fb89b5 | 229 | fi |
ad6f43de | 230 | if (rpm_dump | grep -qEi ":.*nosource.*1"); then |
a7af9862 | 231 | FAIL_IF_NO_SOURCES="no" |
c6a390a1 AM |
232 | fi |
233 | ||
ad6f43de | 234 | PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`" |
cc97f1f3 | 235 | ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`" |
7147050f AM |
236 | PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`" |
237 | PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`" | |
238 | PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`" | |
79379585 | 239 | |
9e06e5c3 | 240 | if [ -n "$BE_VERBOSE" ]; then |
00fcec7e | 241 | echo "- Sources : `nourl $SOURCES`" |
cc97f1f3 | 242 | if [ -n "$PATCHES" ]; then |
a7af9862 | 243 | echo "- Patches : `nourl $PATCHES`" |
cc97f1f3 | 244 | else |
a7af9862 | 245 | echo "- Patches : *no patches needed*" |
cc97f1f3 | 246 | fi |
7053d3fd | 247 | if [ -n "$ICONS" ]; then |
a7af9862 | 248 | echo "- Icon : `nourl $ICONS`" |
a3df415f | 249 | else |
a7af9862 | 250 | echo "- Icon : *no package icon*" |
a3df415f | 251 | fi |
9e06e5c3 | 252 | echo "- Name : $PACKAGE_NAME" |
253 | echo "- Version : $PACKAGE_VERSION" | |
39cbc282 | 254 | echo "- Release : $PACKAGE_RELEASE" |
d287305c | 255 | fi |
33f5276d | 256 | } |
257 | ||
258 | Exit_error() | |
259 | { | |
00fcec7e | 260 | if [ -n "$DEBUG" ]; then |
0dd6320d | 261 | set -x; |
00fcec7e | 262 | set -v; |
71d62f04 | 263 | fi |
7c2dd1b2 | 264 | |
33f5276d | 265 | cd $__PWD |
266 | ||
4849ca8d | 267 | case "$1" in |
33f5276d | 268 | "err_no_spec_in_cmdl" ) |
269 | echo "ERROR: spec file name not specified."; | |
270 | exit 2 ;; | |
271 | "err_no_spec_in_repo" ) | |
272 | echo "Error: spec file not stored in CVS repo."; | |
273 | exit 3 ;; | |
274 | "err_no_source_in_repo" ) | |
4849ca8d | 275 | echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"; |
33f5276d | 276 | exit 4 ;; |
277 | "err_build_fail" ) | |
298c753e | 278 | echo "Error: package build failed. (${2:-no more info})"; |
33f5276d | 279 | exit 5 ;; |
280 | esac | |
281 | } | |
bc8d444f | 282 | |
33f5276d | 283 | init_builder() |
284 | { | |
00fcec7e | 285 | if [ -n "$DEBUG" ]; then |
0dd6320d | 286 | set -x; |
00fcec7e | 287 | set -v; |
71d62f04 | 288 | fi |
7c2dd1b2 | 289 | |
7147050f AM |
290 | SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`" |
291 | SPECS_DIR="`$RPM --eval '%{_specdir}'`" | |
bc8d444f | 292 | |
33f5276d | 293 | __PWD=`pwd` |
59398507 | 294 | } |
295 | ||
296 | get_spec() | |
297 | { | |
00fcec7e | 298 | if [ -n "$DEBUG" ]; then |
0dd6320d | 299 | set -x; |
00fcec7e | 300 | set -v; |
71d62f04 | 301 | fi |
7c2dd1b2 | 302 | |
6fc910c7 | 303 | if [ "$NOCVSSPEC" != "yes" ]; then |
304 | cd $SPECS_DIR | |
5644bf7e | 305 | |
6fc910c7 | 306 | OPTIONS="up " |
67fcd1e4 | 307 | |
6fc910c7 | 308 | if [ -n "$CVSROOT" ]; then |
309 | OPTIONS="-d $CVSROOT $OPTIONS" | |
310 | else | |
311 | if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then | |
312 | echo "warning: No cvs access defined - using local .spec file" | |
313 | NOCVSSPEC="yes" | |
314 | fi | |
315 | fi | |
00fcec7e | 316 | |
72e08ca8 | 317 | if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then |
6fc910c7 | 318 | OPTIONS="$OPTIONS -A" |
72e08ca8 AM |
319 | else |
320 | if [ -n "$CVSDATE" ]; then | |
0dd6320d | 321 | OPTIONS="$OPTIONS -D $CVSDATE" |
72e08ca8 AM |
322 | fi |
323 | if [ -n "$CVSTAG" ]; then | |
0dd6320d | 324 | OPTIONS="$OPTIONS -r $CVSTAG" |
72e08ca8 | 325 | fi |
6fc910c7 | 326 | fi |
33f5276d | 327 | |
b92ecfc9 AM |
328 | result=1 |
329 | retries_counter=0 | |
330 | while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do | |
331 | retries_counter=$(( $retries_counter + 1 )) | |
332 | output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1) | |
333 | result=$? | |
fef1dc85 | 334 | [ -n "$output" ] && echo "$output" |
b92ecfc9 | 335 | if [ "$result" -ne "0" ]; then |
67a44175 | 336 | if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then |
ee004885 | 337 | echo "Trying again [$SPECFILE]... ($retries_counter)" |
96686ae5 | 338 | sleep 2 |
b92ecfc9 | 339 | continue |
0dd6320d | 340 | fi |
341 | Exit_error err_no_spec_in_repo; | |
b92ecfc9 AM |
342 | fi |
343 | done | |
33f5276d | 344 | fi |
6fc910c7 | 345 | if [ ! -f "$SPECFILE" ]; then |
b857906d | 346 | Exit_error err_no_spec_in_repo; |
6fc910c7 | 347 | fi |
a7af9862 | 348 | |
d013b3df | 349 | if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then |
7922b3ec | 350 | chmod $CHMOD_MODE $SPECFILE |
5aa0ef93 | 351 | fi |
7c2dd1b2 | 352 | unset OPTIONS |
67da0368 | 353 | grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE |
59398507 | 354 | } |
355 | ||
4ca52257 JK |
356 | find_mirror(){ |
357 | ||
358 | cd "$SPECS_DIR" | |
00fcec7e | 359 | url="$1" |
6631fc57 | 360 | if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then |
00fcec7e | 361 | cvs update mirrors >&2 |
4ca52257 JK |
362 | fi |
363 | ||
364 | IFS="|" | |
365 | while read origin mirror name rest; do | |
00fcec7e | 366 | ol=`echo -n "$origin"|wc -c` |
4ca52257 JK |
367 | prefix="`echo -n "$url" | head -c $ol`" |
368 | if [ "$prefix" = "$origin" ] ; then | |
6fc910c7 | 369 | suffix="`echo "$url"|cut -b $ol-`" |
370 | echo -n "$mirror$suffix" | |
371 | return 0 | |
4ca52257 JK |
372 | fi |
373 | done < mirrors | |
374 | echo "$url" | |
375 | } | |
376 | ||
00fcec7e | 377 | src_no () |
378 | { | |
379 | cd $SPECS_DIR | |
ad6f43de | 380 | rpm_dump | \ |
0dd6320d | 381 | grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \ |
382 | sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \ | |
383 | head -1 | xargs | |
00fcec7e | 384 | } |
385 | ||
386 | src_md5 () | |
387 | { | |
388 | no=$(src_no "$1") | |
389 | [ -z "$no" ] && return | |
390 | cd $SPECS_DIR | |
0dd6320d | 391 | spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::) |
392 | if [ -z "$spec_rev" ]; then | |
393 | spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')" | |
394 | fi | |
395 | spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')" | |
80dcd8ed | 396 | md5=$(grep -s -v '^#' additional-md5sums | \ |
0dd6320d | 397 | grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \ |
398 | sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \ | |
399 | grep -E '^[0-9a-f]{32}$') | |
6d2b8f55 | 400 | if [ X"$md5" = X"" ] ; then |
0dd6320d | 401 | grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs |
6d2b8f55 | 402 | else |
0dd6320d | 403 | if [ $(echo "$md5" | wc -l) != 1 ] ; then |
404 | echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2 | |
405 | fi | |
406 | echo "$md5" | tail -1 | |
6d2b8f55 | 407 | fi |
00fcec7e | 408 | } |
409 | ||
410 | distfiles_url () | |
411 | { | |
d7f490f3 | 412 | echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")" |
00fcec7e | 413 | } |
414 | ||
d99ac371 MM |
415 | good_md5 () |
416 | { | |
417 | md5=$(src_md5 "$1") | |
418 | [ "$md5" = "" ] || \ | |
419 | [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ] | |
420 | } | |
421 | ||
25fa34fe | 422 | get_files() |
59398507 | 423 | { |
25fa34fe AM |
424 | GET_FILES="$@" |
425 | ||
00fcec7e | 426 | if [ -n "$DEBUG" ]; then |
0dd6320d | 427 | set -x; |
00fcec7e | 428 | set -v; |
71d62f04 | 429 | fi |
7c2dd1b2 | 430 | |
25fa34fe | 431 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then |
7053d3fd | 432 | cd $SOURCE_DIR |
33f5276d | 433 | |
82c46005 | 434 | OPTIONS="up " |
7053d3fd | 435 | if [ -n "$CVSROOT" ]; then |
c1e79fcd | 436 | OPTIONS="-d $CVSROOT $OPTIONS" |
6fc910c7 | 437 | else |
438 | if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then | |
439 | echo "warning: No cvs access defined for SOURCES" | |
440 | NOCVS="yes" | |
441 | fi | |
67fcd1e4 | 442 | fi |
0dd6320d | 443 | if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then |
444 | OPTIONS="$OPTIONS -A" | |
445 | else | |
446 | if [ -n "$CVSDATE" ]; then | |
447 | OPTIONS="$OPTIONS -D $CVSDATE" | |
448 | fi | |
449 | if [ -n "$CVSTAG" ]; then | |
450 | OPTIONS="$OPTIONS -r $CVSTAG" | |
451 | fi | |
452 | fi | |
25fa34fe | 453 | for i in $GET_FILES; do |
2daea751 TP |
454 | if [ -n "$UPDATE5" ]; then |
455 | if [ -n "$ADD5" ]; then | |
456 | [ `nourl $i` = "$i" ] && continue | |
457 | grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue | |
458 | else | |
459 | grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue | |
460 | fi | |
461 | fi | |
2837871a | 462 | FROM_DISTFILES=0 |
81474543 | 463 | if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then |
4a0bb672 | 464 | if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then |
6fc910c7 | 465 | echo "Warning: no URL given for $i" |
157dc315 | 466 | fi |
a7af9862 | 467 | |
fc0e5bb5 | 468 | if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then |
d99ac371 | 469 | if good_md5 "$i"; then |
f67349b7 | 470 | echo "$(nourl "$i") having proper md5sum already exists" |
471 | continue | |
472 | fi | |
00fcec7e | 473 | target=$(nourl "$i") |
474 | url=$(distfiles_url "$i") | |
2837871a | 475 | if [ `echo $url | grep -E '^(\.|/)'` ]; then |
6aefe77b JR |
476 | ${GETLOCAL} $url $target |
477 | else | |
2837871a | 478 | FROM_DISTFILES=1 |
479 | if [ -z "$NOMIRRORS" ]; then | |
6aefe77b | 480 | url="`find_mirror "$url"`" |
00fcec7e | 481 | fi |
6aefe77b JR |
482 | ${GETURI} -O "$target" "$url" || \ |
483 | if [ `echo $url | grep -E 'ftp://'` ]; then | |
484 | ${GETURI2} -O "$target" "$url" | |
485 | fi | |
486 | test -s "$target" || rm -f "$target" | |
487 | fi | |
075be2f7 JR |
488 | elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ] && \ |
489 | ( echo $i | grep -qvE '(ftp|http|https)://' ); then | |
b92ecfc9 | 490 | result=1 |
0dd6320d | 491 | retries_counter=0 |
492 | while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do | |
493 | retries_counter=$(( $retries_counter + 1 )) | |
b92ecfc9 | 494 | output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1) |
0dd6320d | 495 | result=$? |
fef1dc85 | 496 | [ -n "$output" ] && echo "$output" |
67a44175 | 497 | if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then |
ee004885 | 498 | echo "Trying again [`nourl $i`]... ($retries_counter)" |
96686ae5 | 499 | sleep 2 |
b92ecfc9 | 500 | continue |
711eb1e4 AM |
501 | else |
502 | break | |
b92ecfc9 AM |
503 | fi |
504 | done | |
157dc315 | 505 | fi |
a7af9862 | 506 | |
b130abf2 | 507 | if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then |
2837871a | 508 | if [ -z "$NOMIRRORS" ]; then |
3428d253 JB |
509 | im="`find_mirror "$i"`" |
510 | else | |
511 | im="$i" | |
6fc910c7 | 512 | fi |
3428d253 JB |
513 | ${GETURI} "$im" || \ |
514 | if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi | |
157dc315 SZ |
515 | fi |
516 | ||
de6b5b2a | 517 | |
422fbc56 TP |
518 | fi |
519 | srcno=$(src_no $i) | |
520 | if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then | |
521 | Exit_error err_no_source_in_repo $i; | |
522 | elif [ -n "$UPDATE5" ] && \ | |
523 | ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \ | |
524 | [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \ | |
525 | grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE ) | |
526 | then | |
527 | echo "Updating source-$srcno md5." | |
528 | md5=$(md5sum `nourl $i` | cut -f1 -d' ') | |
82db6b8d MM |
529 | perl -i -ne ' |
530 | print unless /^\s*#\s*Source'$srcno'-md5\s*:/i; | |
531 | print "# Source'$srcno'-md5:\t'$md5'\n" | |
532 | if /^Source'$srcno'\s*:\s+/; | |
533 | ' \ | |
422fbc56 TP |
534 | $SPECS_DIR/$SPECFILE |
535 | fi | |
536 | ||
2837871a | 537 | if good_md5 "$i"; then |
538 | : | |
539 | elif [ "$FROM_DISTFILES" = 1 ]; then | |
540 | # wrong md5 from distfiles: remove the file and try again | |
541 | # but only once ... | |
97c857d8 | 542 | echo "MD5 sum mismatch. Trying full fetch." |
2837871a | 543 | FROM_DISTFILES=2 |
544 | rm -f $target | |
545 | ${GETURI} -O "$target" "$url" || \ | |
546 | if [ `echo $url | grep -E 'ftp://'` ]; then | |
547 | ${GETURI2} -O "$target" "$url" | |
548 | fi | |
549 | test -s "$target" || rm -f "$target" | |
550 | fi | |
551 | ||
422fbc56 TP |
552 | if good_md5 "$i"; then |
553 | : | |
554 | else | |
555 | echo "MD5 sum mismatch. Use -U to refetch sources," | |
556 | echo "or -5 to update md5 sums, if you're sure files are correct." | |
557 | Exit_error err_no_source_in_repo $i | |
3ae81a20 | 558 | fi |
cc97f1f3 | 559 | done |
a7af9862 | 560 | |
5aa0ef93 | 561 | if [ "$CHMOD" = "yes" ]; then |
d013b3df AM |
562 | CHMOD_FILES="`nourl $GET_FILES`" |
563 | if [ -n "$CHMOD_FILES" ]; then | |
6fc910c7 | 564 | chmod $CHMOD_MODE $CHMOD_FILES |
d013b3df | 565 | fi |
5aa0ef93 | 566 | fi |
7c2dd1b2 | 567 | unset OPTIONS |
7053d3fd | 568 | fi |
59398507 | 569 | } |
570 | ||
1471f6d6 | 571 | tag_files() |
572 | { | |
573 | TAG_FILES="$@" | |
574 | ||
00fcec7e | 575 | if [ -n "$DEBUG" ]; then |
0dd6320d | 576 | set -x; |
00fcec7e | 577 | set -v; |
1471f6d6 | 578 | fi |
579 | ||
580 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then | |
0b9271b0 PG |
581 | echo "Version: $PACKAGE_VERSION" |
582 | echo "Release: $PACKAGE_RELEASE" | |
b4fd0ec0 | 583 | TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"` |
01de2036 JB |
584 | if [ "$TAG_VERSION" = "yes" ]; then |
585 | echo "CVS tag: $TAGVER" | |
586 | fi | |
587 | if [ -n "$TAG" ]; then | |
588 | echo "CVS tag: $TAG" | |
589 | fi | |
1471f6d6 | 590 | |
591 | OPTIONS="tag -F" | |
592 | if [ -n "$CVSROOT" ]; then | |
593 | OPTIONS="-d $CVSROOT $OPTIONS" | |
594 | fi | |
595 | ||
596 | cd $SOURCE_DIR | |
597 | for i in $TAG_FILES; do | |
598 | if [ -f `nourl $i` ]; then | |
f02788de JB |
599 | if [ "$TAG_VERSION" = "yes" ]; then |
600 | cvs $OPTIONS $TAGVER `nourl $i` | |
601 | fi | |
602 | if [ -n "$TAG" ]; then | |
603 | cvs $OPTIONS $TAG `nourl $i` | |
604 | fi | |
1471f6d6 | 605 | else |
4849ca8d | 606 | Exit_error err_no_source_in_repo $i |
1471f6d6 | 607 | fi |
608 | done | |
609 | ||
610 | cd $SPECS_DIR | |
f02788de JB |
611 | if [ "$TAG_VERSION" = "yes" ]; then |
612 | cvs $OPTIONS $TAGVER $SPECFILE | |
613 | fi | |
614 | if [ -n "$TAG" ]; then | |
615 | cvs $OPTIONS $TAG $SPECFILE | |
616 | fi | |
1471f6d6 | 617 | |
618 | unset OPTIONS | |
619 | fi | |
620 | } | |
621 | ||
8ba5cdda PG |
622 | branch_files() |
623 | { | |
a7af9862 | 624 | TAG=$1 |
625 | echo "CVS branch tag: $TAG" | |
626 | shift; | |
8ba5cdda | 627 | |
a7af9862 | 628 | TAG_FILES="$@" |
8ba5cdda | 629 | |
a7af9862 | 630 | if [ -n "$DEBUG" ]; then |
631 | set -x; | |
632 | set -v; | |
633 | fi | |
8ba5cdda | 634 | |
a7af9862 | 635 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then |
636 | ||
637 | OPTIONS="tag -b" | |
638 | if [ -n "$CVSROOT" ]; then | |
639 | OPTIONS="-d $CVSROOT $OPTIONS" | |
8ba5cdda | 640 | fi |
a7af9862 | 641 | cd $SOURCE_DIR |
642 | for i in $TAG_FILES; do | |
643 | if [ -f `nourl $i` ]; then | |
644 | cvs $OPTIONS $TAG `nourl $i` | |
645 | else | |
646 | Exit_error err_no_source_in_repo $i | |
647 | fi | |
648 | done | |
649 | cd $SPECS_DIR | |
650 | cvs $OPTIONS $TAG $SPECFILE | |
651 | ||
652 | unset OPTIONS | |
653 | fi | |
8ba5cdda PG |
654 | } |
655 | ||
f308b816 | 656 | |
657 | ||
59398507 | 658 | build_package() |
659 | { | |
00fcec7e | 660 | if [ -n "$DEBUG" ]; then |
7922b3ec | 661 | set -x; |
00fcec7e | 662 | set -v; |
71d62f04 | 663 | fi |
7c2dd1b2 | 664 | |
33f5276d | 665 | cd $SPECS_DIR |
3d97a432 | 666 | |
00fcec7e | 667 | if [ -n "$TRY_UPGRADE" ]; then |
a7af9862 | 668 | |
669 | if [ -n "FLOAT_VERSION" ]; then | |
670 | TNOTIFY=`./pldnotify.awk $SPECFILE -n` | |
671 | else | |
672 | TNOTIFY=`./pldnotify.awk $SPECFILE` | |
673 | fi | |
674 | ||
3d97a432 | 675 | TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'` |
a7af9862 | 676 | |
0096b1ae | 677 | if [ -n "$TNEWVER" ]; then |
a7af9862 | 678 | |
3d97a432 | 679 | TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'` |
a7af9862 | 680 | |
3d97a432 | 681 | echo "New version found, updating spec file to version " $TNEWVER |
a7af9862 | 682 | |
3d97a432 | 683 | cp -f $SPECFILE $SPECFILE.bak |
a7af9862 | 684 | |
3d97a432 | 685 | chmod +w $SPECFILE |
a7af9862 | 686 | |
3d97a432 MK |
687 | eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE" |
688 | eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE" | |
a7af9862 | 689 | |
3d97a432 | 690 | parse_spec; |
a7af9862 | 691 | |
3d97a432 | 692 | get_files "$SOURCES $PATCHES"; |
a7af9862 | 693 | |
3d97a432 MK |
694 | unset TOLDVER TNEWVER TNOTIFY |
695 | fi | |
00fcec7e | 696 | |
3d97a432 MK |
697 | fi |
698 | ||
699 | ||
700 | cd $SPECS_DIR | |
701 | ||
79b2ec0e | 702 | case "$COMMAND" in |
703 | build ) | |
7922b3ec | 704 | BUILD_SWITCH="-ba" ;; |
79b2ec0e | 705 | build-binary ) |
706 | BUILD_SWITCH="-bb" ;; | |
707 | build-source ) | |
956d1492 | 708 | BUILD_SWITCH="-bs --nodeps" ;; |
79b2ec0e | 709 | esac |
d6a75d60 | 710 | if [ -n "$LOGFILE" ]; then |
00fcec7e | 711 | if [ -n "$CVSTAG" ]; then |
712 | LTAG="r_`echo $CVSTAG|sed -e 's/\./_/g'`_" | |
713 | else | |
714 | LTAG="" | |
715 | fi | |
972bd3c3 | 716 | LOG=`eval echo $LOGFILE` |
00fcec7e | 717 | if [ -n "$LASTLOG_FILE" ]; then |
718 | echo "LASTLOG=$LOG" > $LASTLOG_FILE | |
719 | fi | |
720 | RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM | |
721 | (nice -n ${DEF_NICE_LEVEL} time $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG | |
722 | RETVAL=`cat $RES_FILE` | |
723 | rm $RES_FILE | |
724 | if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then | |
0dd6320d | 725 | if [ "$RETVAL" -eq "0" ]; then |
00fcec7e | 726 | mv $LOG $LOGDIROK |
0dd6320d | 727 | else |
728 | mv $LOG $LOGDIRFAIL | |
00fcec7e | 729 | fi |
730 | fi | |
d6a75d60 | 731 | else |
7147050f | 732 | eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE |
f308b816 | 733 | RETVAL=$? |
d6a75d60 | 734 | fi |
33f5276d | 735 | |
f308b816 | 736 | if [ "$RETVAL" -ne "0" ]; then |
a7af9862 | 737 | |
00fcec7e | 738 | if [ -n "$TRY_UPGRADE" ]; then |
3d97a432 | 739 | echo "\n!!! Package with new version cannot be build automagically\n" |
3d97a432 | 740 | mv -f $SPECFILE.bak $SPECFILE |
3d97a432 | 741 | fi |
a7af9862 | 742 | |
33f5276d | 743 | Exit_error err_build_fail; |
744 | fi | |
a7af9862 | 745 | |
79b2ec0e | 746 | unset BUILD_SWITCH |
59398507 | 747 | } |
748 | ||
cc97f1f3 SZ |
749 | nourl() |
750 | { | |
a7af9862 | 751 | echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g' |
cc97f1f3 | 752 | } |
2daea751 | 753 | |
da946cd6 | 754 | #--------------------------------------------- |
755 | # main() | |
756 | ||
ba877a00 | 757 | if [ "$#" = 0 ]; then |
da946cd6 | 758 | usage; |
d764d255 | 759 | exit 1 |
da946cd6 | 760 | fi |
761 | ||
5a491465 | 762 | while test $# -gt 0 ; do |
763 | case "${1}" in | |
de6b5b2a | 764 | -5 | --update-md5 ) |
a9d9a79a TP |
765 | COMMAND="get"; |
766 | NODIST="yes" | |
afade7dd | 767 | NOCVSSPEC="yes" |
a9d9a79a TP |
768 | UPDATE5="yes" |
769 | shift ;; | |
de6b5b2a MM |
770 | -a5 | --add-md5 ) |
771 | COMMAND="get"; | |
772 | NODIST="yes" | |
773 | NOCVS="yes" | |
afade7dd | 774 | NOCVSSPEC="yes" |
de6b5b2a MM |
775 | UPDATE5="yes" |
776 | ADD5="yes" | |
777 | shift ;; | |
7c2dd1b2 | 778 | -D | --debug ) |
779 | DEBUG="yes"; shift ;; | |
bde1c404 | 780 | -V | --version ) |
4003ad8c | 781 | COMMAND="version"; shift ;; |
bde1c404 | 782 | -a | --as_anon ) |
62546902 | 783 | CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;; |
79b2ec0e | 784 | -b | -ba | --build ) |
4003ad8c | 785 | COMMAND="build"; shift ;; |
79b2ec0e | 786 | -bb | --build-binary ) |
787 | COMMAND="build-binary"; shift ;; | |
788 | -bs | --build-source ) | |
789 | COMMAND="build-source"; shift ;; | |
8ba5cdda PG |
790 | -B | --branch ) |
791 | COMMAND="branch"; shift; TAG="${1}"; shift;; | |
5dd89621 | 792 | -c | --clean ) |
793 | CLEAN="--clean --rmspec --rmsource"; shift ;; | |
bde1c404 | 794 | -d | --cvsroot ) |
4003ad8c | 795 | shift; CVSROOT="${1}"; shift ;; |
bde1c404 | 796 | -g | --get ) |
797 | COMMAND="get"; shift ;; | |
798 | -h | --help ) | |
799 | COMMAND="usage"; shift ;; | |
d7f490f3 | 800 | --http ) |
801 | PROTOCOL="http"; shift ;; | |
5a491465 | 802 | -l | --logtofile ) |
4003ad8c | 803 | shift; LOGFILE="${1}"; shift ;; |
3ae81a20 | 804 | -ni| --nice ) |
805 | shift; DEF_NICE_LEVEL=${1}; shift ;; | |
8bc51224 | 806 | -m | --mr-proper ) |
807 | COMMAND="mr-proper"; shift ;; | |
157dc315 SZ |
808 | -nc | --no-cvs ) |
809 | NOCVS="yes"; shift ;; | |
37f54b4a | 810 | -ncs | --no-cvs-specs ) |
6fc910c7 | 811 | NOCVSSPEC="yes"; shift ;; |
fc0e5bb5 TP |
812 | -nd | --no-distfiles ) |
813 | NODIST="yes"; shift ;; | |
4ca52257 JK |
814 | -nm | --no-mirrors ) |
815 | NOMIRRORS="yes"; shift ;; | |
157dc315 SZ |
816 | -nu | --no-urls ) |
817 | NOURLS="yes"; shift ;; | |
72fb89b5 | 818 | -ns | --no-srcs ) |
819 | NOSRCS="yes"; shift ;; | |
fd2b5687 MM |
820 | -ns0 | --no-source0 ) |
821 | NOSOURCE0="yes"; shift ;; | |
33a9d2d1 SZ |
822 | --opts ) |
823 | shift; RPMOPTS="${1}"; shift ;; | |
6049c3d1 | 824 | --with | --without ) |
a2d6aca2 | 825 | BCOND="$BCOND $1 $2" ; shift 2 ;; |
bde1c404 | 826 | -q | --quiet ) |
33f5276d | 827 | QUIET="--quiet"; shift ;; |
448deaa0 | 828 | --date ) |
829 | CVSDATE="${2}"; shift 2 ;; | |
67fcd1e4 | 830 | -r | --cvstag ) |
831 | shift; CVSTAG="${1}"; shift ;; | |
78ce14b3 | 832 | -Tvs | --tag-version-stable ) |
7922b3ec | 833 | COMMAND="tag"; |
78ce14b3 | 834 | TAG="STABLE" |
7922b3ec | 835 | TAG_VERSION="yes" |
836 | shift;; | |
a2164135 | 837 | -Tvn | --tag-version-nest ) |
7922b3ec | 838 | COMMAND="tag"; |
a2164135 | 839 | TAG="NEST" |
7922b3ec | 840 | TAG_VERSION="yes" |
841 | shift;; | |
78ce14b3 | 842 | -Ts | --tag-stable ) |
7922b3ec | 843 | COMMAND="tag"; |
78ce14b3 | 844 | TAG="STABLE" |
7922b3ec | 845 | TAG_VERSION="no" |
846 | shift;; | |
a2164135 | 847 | -Tn | --tag-nest ) |
7922b3ec | 848 | COMMAND="tag"; |
a2164135 | 849 | TAG="NEST" |
7922b3ec | 850 | TAG_VERSION="no" |
851 | shift;; | |
852 | -Tv | --tag-version ) | |
853 | COMMAND="tag"; | |
f02788de | 854 | TAG="" |
7922b3ec | 855 | TAG_VERSION="yes" |
856 | shift;; | |
1471f6d6 | 857 | -T | --tag ) |
7922b3ec | 858 | COMMAND="tag"; |
859 | shift | |
860 | TAG="$1" | |
861 | TAG_VERSION="no" | |
862 | shift;; | |
b130abf2 | 863 | -U | --update ) |
2daea751 | 864 | COMMAND="get" |
de6b5b2a MM |
865 | UPDATE="yes" |
866 | NODIST="yes" | |
867 | UPDATE5="yes" | |
de6b5b2a | 868 | shift ;; |
0096b1ae | 869 | -u | --try-upgrade ) |
3d97a432 | 870 | TRY_UPGRADE="1"; shift ;; |
a7af9862 | 871 | -un | --try-upgrade-with-float-version ) |
872 | TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;; | |
b130abf2 TP |
873 | -v | --verbose ) |
874 | BE_VERBOSE="1"; shift ;; | |
c7ab67cf | 875 | --define) |
c24b056c | 876 | shift |
c7ab67cf SZ |
877 | MACRO="${1}" |
878 | VALUE="${2}" | |
879 | shift 2 | |
880 | RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\"" | |
881 | ;; | |
bde1c404 | 882 | * ) |
0fc6e9ec | 883 | SPECFILE="`basename ${1} .spec`.spec"; shift ;; |
5a491465 | 884 | esac |
885 | done | |
886 | ||
00fcec7e | 887 | if [ -n "$DEBUG" ]; then |
a7af9862 | 888 | set -x; |
00fcec7e | 889 | set -v; |
71d62f04 | 890 | fi |
7c2dd1b2 | 891 | |
bde1c404 | 892 | case "$COMMAND" in |
79b2ec0e | 893 | "build" | "build-binary" | "build-source" ) |
33f5276d | 894 | init_builder; |
8a7fc6f7 | 895 | if [ -n "$SPECFILE" ]; then |
59398507 | 896 | get_spec; |
897 | parse_spec; | |
298c753e AM |
898 | |
899 | if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then | |
b4fd0ec0 | 900 | TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"` |
298c753e | 901 | CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }') |
1f188001 | 902 | TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g') |
298c753e AM |
903 | |
904 | if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then | |
905 | Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL" | |
906 | fi | |
907 | fi | |
908 | ||
25fa34fe | 909 | if [ -n "$ICONS" ]; then |
0dd6320d | 910 | get_files $ICONS; |
911 | parse_spec; | |
25fa34fe | 912 | fi |
f9a62a6a | 913 | if [ -n "$NOSOURCE0" ] ; then |
914 | SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'` | |
915 | fi | |
25fa34fe | 916 | get_files "$SOURCES $PATCHES"; |
59398507 | 917 | build_package; |
918 | else | |
33f5276d | 919 | Exit_error err_no_spec_in_cmdl; |
59398507 | 920 | fi |
921 | ;; | |
8ba5cdda | 922 | "branch" ) |
0dd6320d | 923 | init_builder; |
8ba5cdda PG |
924 | if [ -n "$SPECFILE" ]; then |
925 | get_spec; | |
926 | parse_spec; | |
927 | if [ -n "$ICONS" ]; then | |
928 | get_files $ICONS | |
929 | parse_spec; | |
930 | fi | |
931 | get_files $SOURCES $PATCHES; | |
932 | branch_files $TAG "$SOURCES $PATCHES $ICONS"; | |
933 | else | |
934 | Exit_error err_no_spec_in_cmdl; | |
935 | fi | |
0dd6320d | 936 | ;; |
bde1c404 | 937 | "get" ) |
33f5276d | 938 | init_builder; |
8a7fc6f7 | 939 | if [ -n "$SPECFILE" ]; then |
59398507 | 940 | get_spec; |
941 | parse_spec; | |
25fa34fe | 942 | if [ -n "$ICONS" ]; then |
7922b3ec | 943 | get_files $ICONS |
944 | parse_spec; | |
25fa34fe | 945 | fi |
fd2b5687 MM |
946 | if [ -n "$NOSOURCE0" ] ; then |
947 | SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'` | |
948 | fi | |
bc441b0c | 949 | get_files $SOURCES $PATCHES |
bde1c404 | 950 | else |
33f5276d | 951 | Exit_error err_no_spec_in_cmdl; |
bde1c404 | 952 | fi |
953 | ;; | |
1471f6d6 | 954 | "tag" ) |
955 | init_builder; | |
956 | if [ -n "$SPECFILE" ]; then | |
957 | get_spec; | |
958 | parse_spec; | |
959 | if [ -n "$ICONS" ]; then | |
7922b3ec | 960 | get_files $ICONS |
961 | parse_spec; | |
1471f6d6 | 962 | fi |
bc441b0c | 963 | get_files $SOURCES $PATCHES; |
1471f6d6 | 964 | tag_files "$SOURCES $PATCHES $ICONS"; |
965 | else | |
966 | Exit_error err_no_spec_in_cmdl; | |
967 | fi | |
968 | ;; | |
8bc51224 | 969 | "mr-proper" ) |
7147050f | 970 | $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE |
8bc51224 | 971 | ;; |
bde1c404 | 972 | "usage" ) |
973 | usage;; | |
4003ad8c | 974 | "version" ) |
975 | echo "$VERSION";; | |
bde1c404 | 976 | esac |
9e06e5c3 | 977 | |
978 | cd $__PWD |