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