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