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