]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - builder.sh
- update get_file progress in statusbar
[packages/rpm-build-tools.git] / builder.sh
CommitLineData
cd445739
AM
1#!/bin/sh
2# -----------
3# $Id$
4# Exit codes:
2a5f078d 5# 0 - succesful
6# 1 - help displayed
7# 2 - no spec file name in cmdl parameters
8# 3 - spec file not stored in repo
9# 4 - some source, patch or icon files not stored in repo
10# 5 - package build failed
11# 6 - spec file with errors
12# 7 - wrong source in /etc/poldek.conf
13# 8 - Failed installing buildrequirements and subrequirements
14# 9 - Requested tag already exist
15# 10 - Refused to build fractional release
16# 100 - Unknown error (should not happen)
cd445739
AM
17
18# Notes (todo):
f7b91886 19# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
cd445739 20# - when Icon: field is present, -5 and -a5 doesn't work
f3ada241 21# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
931a4acf 22
4003ad8c 23VERSION="\
c9acaed9 24Build package utility from PLD Linux CVS repository
7304d35c 25V 0.13 (C) 1999-2005 Free Penguins".
d6a77ddb 26PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
b03f053b 27
cd445739 28COMMAND="build"
64ea5308 29TARGET=""
cd445739 30
bde1c404 31SPECFILE=""
d287305c 32BE_VERBOSE=""
4003ad8c 33QUIET=""
cd445739
AM
34CLEAN=""
35DEBUG=""
36NOURLS=""
37NOCVS=""
38NOCVSSPEC=""
39NODIST=""
40UPDATE=""
41UPDATE5=""
42ADD5=""
43NO5=""
44ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
c8f50498 45CVSROOT=""
cd445739
AM
46
47# It can be used i.e. in log file naming.
48# See LOGFILE example.
49DATE=`date +%Y-%m-%d_%H-%M-%S`
50
51# Example: LOGFILE='../log.$PACKAGE_NAME'
52# Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
53# Yes, you can use variable name! Note _single_ quotes!
54LOGFILE=''
55
56LOGDIR=""
57LOGDIROK=""
58LOGDIRFAIL=""
59LASTLOG_FILE=""
60
61CHMOD="no"
62CHMOD_MODE="0444"
63RPMOPTS=""
64BCOND=""
65GROUP_BCONDS="no"
947025e5 66CVSIGNORE_DF="no"
d287305c 67
68PATCHES=""
69SOURCES=""
cd445739 70ICONS=""
d287305c 71PACKAGE_RELEASE=""
72PACKAGE_VERSION=""
73PACKAGE_NAME=""
cd445739
AM
74PROTOCOL="ftp"
75WGET_RETRIES=${MAX_WGET_RETRIES:-0}
76CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
77
78CVSTAG=""
79RES_FILE=""
80
81CVS_SERVER="cvs.pld-linux.org"
82DISTFILES_SERVER="://distfiles.pld-linux.org"
d4730dae 83ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
cd445739 84
36d03934 85DEF_NICE_LEVEL=19
cd445739
AM
86
87FAIL_IF_NO_SOURCES="yes"
88
18e5347d
ER
89# let get_files skip over files which are present to get those damn files fetched
90SKIP_EXISTING_FILES="no"
91
ab4a2b6e
ER
92if [ -x /usr/bin/rpm-getdeps ]; then
93 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
94else
95 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
96fi
97
cd445739
AM
98# Here we load saved user environment used to
99# predefine options set above, or passed to builder
100# in command line.
101# This one reads global system environment settings:
102if [ -f ~/etc/builderrc ]; then
103 . ~/etc/builderrc
104fi
105# And this one cascades settings using user personal
106# builder settings.
107# Example of ~/.builderrc:
108#
109#UPDATE_POLDEK_INDEXES="yes"
110#FETCH_BUILD_REQUIRES="yes"
111#REMOVE_BUILD_REQUIRES="force"
112#GROUP_BCONDS="yes"
113#LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
114#
a83e5405 115SU_SUDO=""
cd445739
AM
116if [ -n "$HOME_ETC" ]; then
117 USER_CFG="$HOME_ETC/.builderrc"
118else
119 USER_CFG=~/.builderrc
120fi
121
122[ -f "$USER_CFG" ] && . "$USER_CFG"
123
06f3864d
AM
124wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
125
ca2e6c31 126if [ -n "$USE_PROZILLA" ]; then
7e365483
KK
127 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
128 GETURI2="$GETURI"
129 OUTFILEOPT="-O"
ca2e6c31 130elif [ -n "$USE_AXEL" ]; then
cede92b3 131 GETURI="axel -a $AXEL_OPTS"
7e365483
KK
132 GETURI2="$GETURI"
133 OUTFILEOPT="-o"
ca2e6c31 134else
7e365483
KK
135 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
136 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
6f9a5d76 137
7e365483
KK
138 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
139 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
140 OUTFILEOPT="-O"
2bc5451f 141fi
11468b23 142
11468b23
AM
143GETLOCAL="cp -a"
144
145if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
146 RPM="rpm"
147 RPMBUILD="rpm"
148else
149 RPM="rpm"
150 RPMBUILD="rpmbuild"
151fi
152
153POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
a83e5405 154POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
11468b23 155
cd445739
AM
156run_poldek()
157{
158 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
159 if [ -n "$LOGFILE" ]; then
160 LOG=`eval echo $LOGFILE`
161 if [ -n "$LASTLOG_FILE" ]; then
162 echo "LASTLOG=$LOG" > $LASTLOG_FILE
163 fi
040282bb 164 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
cd445739
AM
165 return $exit_pldk
166 else
167 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
168 return `cat ${RES_FILE}`
169 rm -rf ${RES_FILE}
170 fi
171}
172
cd445739
AM
173#---------------------------------------------
174# functions
da946cd6 175
5a491465 176usage()
177{
cd445739
AM
178 if [ -n "$DEBUG" ]; then set -xv; fi
179 echo "\
180Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
81f85806 181
cd445739
AM
182[-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
183[{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
184[-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
185[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
186[-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
187[-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
188[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
dfe2cb9a 189[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
cd445739 190[--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
2a5f078d 191
cd445739
AM
192-5, --update-md5 - update md5 comments in spec, implies -nd -ncs
193-a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
194-n5, --no-md5 - ignore md5 comments in spec
9243e80b
ER
195-D, --debug - enable builder script debugging mode,
196-debug - produce rpm debug package (same as --opts -debug)
cd445739
AM
197-V, --version - output builder version
198-a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
199-b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
200 from <package>.spec,
201-bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
202 only package from <package>.spec,
c56807e0
ER
203-bp, --build-prep - execute the %prep phase of <package>.spec,
204-bc - reserved (not implemented)
205-bi reserved (not implemented)
cd445739
AM
206-bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
207 them into src.rpm,
c56807e0 208--short-circuit - reserved (not implemented)
cd445739
AM
209-B, --branch - add branch
210-c, --clean - clean all temporarily created files (in BUILD, SOURCES,
211 SPECS and \$RPM_BUILD_ROOT),
2a5f078d 212-d <cvsroot>, --cvsroot <cvsroot>
cd445739
AM
213 - setup \$CVSROOT,
214--define <macro> <value>
215 - define a macro <macro> with value <value>,
216--nodeps - rpm won't check any dependences
217-g, --get - get <package>.spec and all related files from CVS repo
218 or HTTP/FTP,
219-h, --help - this message,
220--http - use http instead of ftp,
221-l <logfile>, --logtofile <logfile>
222 - log all to file,
223-m, --mr-proper - only remove all files related to spec file and all work
224 resources,
225-nc, --no-cvs - don't download sources from CVS, if source URL is given,
226-ncs, --no-cvs-specs
227 - don't check specs in CVS
228-nd, --no-distfiles - don't download from distfiles
229-nm, --no-mirrors - don't download from mirror, if source URL is given,
230-nu, --no-urls - don't try to download from FTP/HTTP location,
231-ns, --no-srcs - don't download Sources
232-ns0, --no-source0 - don't download Source0
233-nn, --no-net - don't download anything from the net
18e5347d
ER
234-ske,
235--skip-existing-files - skip existing files in get_files
cd445739
AM
236--opts <rpm opts> - additional options for rpm
237-q, --quiet - be quiet,
238--date yyyy-mm-dd - build package using resources from specified CVS date,
239-r <cvstag>, --cvstag <cvstag>
240 - build package using resources from specified CVS tag,
241-R, --fetch-build-requires
242 - fetch what is BuildRequired,
243-RB, --remove-build-requires
244 - remove all you fetched with -R or --fetch-build-requires
245 remember, this option requires confirmation,
246-FRB, --force-remove-build-requires
247 - remove all you fetched with -R or --fetch-build-requires
248 remember, this option works without confirmation,
a7eefc54 249-sf, --source-files - list sources - bare filenames (intended for offline
250 operations; does not work when Icon field is present
251 but icon file is absent),
252-sp, --source-paths - list sources - filenames with full local paths (intended for
253 offline operations; does not work when Icon field is present
254 but icon file is absent),
2dddf439
ER
255-su, --source-urls - list urls - urls to sources and patches
256 intended for copying urls with spec with lots of macros in urls
cd445739
AM
257-T <cvstag> , --tag <cvstag>
258 - add cvs tag <cvstag> for files,
259-Tvs, --tag-version-stable
094bd95b 260 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
cd445739 261-Tvn, --tag-version-nest
1691a37b 262 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
cd445739
AM
263-Ts, --tag-stable
264 - add cvs tag STABLE for files,
265-Tn, --tag-nest
266 - add cvs tag NEST for files,
267-Tv, --tag-version
1691a37b 268 - add cvs tag NAME-VERSION-RELEASE for files,
cd445739
AM
269-Tp, --tag-prefix <prefix>
270 - add <prefix> to NAME-VERSION-RELEASE tags,
271-tt, --test-tag <prefix>
272 - fail if tag is already present,
50321881
JK
273-ir, --integer-release-only
274 - allow only integer and snapshot releases
cd445739
AM
275-v, --verbose - be verbose,
276-u, --try-upgrade - check version, and try to upgrade package
277-un, --try-upgrade-with-float-version
278 - as above, but allow float version
deccc50e 279-U, --update - refetch sources, don't use distfiles, and update md5 comments
cd445739
AM
280-Upi, --update-poldek-indexes
281 - refresh or make poldek package index files.
c890b916 282-np, --nopatch <patchnumber>
bed98670 283 - don't apply <patchnumber>
dfe2cb9a
MK
284--show-bconds - show available conditional builds, which can be used
285 - with --with and/or --without switches.
cd445739
AM
286--with/--without <feature>
287 - conditional build package depending on %_with_<feature>/
288 %_without_<feature> macro switch. You may now use
289 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
290 constructions. Set GROUP_BCONDS to yes to make use of it.
6dd19291 291--target <platform>, --target=<platform>
64ea5308 292 - build for platform <platform>.
5a491465 293"
294}
295
c890b916 296update_shell_title() {
a0d6396b 297 [ -t 1 ] || return
0b65d15e
ER
298 local len=${COLUMNS:-80}
299 local msg=$(echo "$*" | cut -c-$len)
300
f2e42a41 301 msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
c890b916
ER
302 case "$TERM" in
303 cygwin|xterm*)
2dddf439 304 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
c890b916
ER
305 ;;
306 screen*)
2dddf439 307 echo >&2 -ne "\033]0;$msg\007"
c890b916
ER
308 ;;
309 esac
310}
311
7e40520f
ER
312# set TARGET from BuildArch: from SPECFILE
313set_spec_target() {
314 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
315 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
316 if [ "$tmp" ]; then
317 TARGET="$tmp"
318 case "$RPMBUILD" in
319 "rpmbuild")
320 TARGET_SWITCH="--target $TARGET" ;;
321 "rpm")
322 TARGET_SWITCH="--target=$TARGET" ;;
323 esac
324 fi
325 fi
326}
327
cd445739 328cache_rpm_dump () {
b2aeec7d
AM
329 if [ -n "$DEBUG" ]; then
330 set -x;
331 set -v;
332 fi
7e40520f 333
cd445739
AM
334rpm_dump_cache=`
335 case "$RPMBUILD" in
336 rpm )
2a5f078d 337 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
cd445739
AM
338 ;;
339 rpmbuild )
2f810e46 340 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
cd445739
AM
341 ;;
342 esac`
343}
344
345rpm_dump () {
346 if [ -z "$rpm_dump_cache" ] ; then
347 echo "internal error: cache_rpm_dump not called!" 1>&2
348 fi
349 echo "$rpm_dump_cache"
350}
351
59398507 352parse_spec()
353{
af4d5315 354 update_shell_title "parsing specfile"
cd445739
AM
355 if [ -n "$DEBUG" ]; then
356 set -x;
357 set -v;
358 fi
b2975fc3 359
cd445739 360 cd $SPECS_DIR
4ca52257 361
cd445739 362 cache_rpm_dump
00fcec7e 363
cd445739
AM
364 if [ "$NOSRCS" != "yes" ]; then
365 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
366 fi
367 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
368 FAIL_IF_NO_SOURCES="no"
369 fi
370
371 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
372 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
373 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
374 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
375 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
376
341603cf 377# These variables may be unset after first cache_rpm_dump call
378# (because of not-yet-retrieved icon file)
379#
380# if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
381# Exit_error err_no_package_data;
382# fi
78eab2a1 383
cd445739
AM
384 if [ -n "$BE_VERBOSE" ]; then
385 echo "- Sources : `nourl $SOURCES`"
386 if [ -n "$PATCHES" ]; then
387 echo "- Patches : `nourl $PATCHES`"
388 else
389 echo "- Patches : *no patches needed*"
390 fi
391 if [ -n "$ICONS" ]; then
392 echo "- Icon : `nourl $ICONS`"
393 else
394 echo "- Icon : *no package icon*"
395 fi
396 echo "- Name : $PACKAGE_NAME"
397 echo "- Version : $PACKAGE_VERSION"
398 echo "- Release : $PACKAGE_RELEASE"
399 fi
400}
401
402Exit_error()
403{
404 if [ -n "$DEBUG" ]; then
405 set -x;
406 set -v;
407 fi
408
409 cd "$__PWD"
410
411 case "$1" in
412 "err_no_spec_in_cmdl" )
413 remove_build_requires
414 echo "ERROR: spec file name not specified.";
415 exit 2 ;;
416 "err_no_spec_in_repo" )
417 remove_build_requires
418 echo "Error: spec file not stored in CVS repo.";
419 exit 3 ;;
420 "err_no_source_in_repo" )
421 remove_build_requires
422 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
423 exit 4 ;;
424 "err_build_fail" )
425 remove_build_requires
426 echo "Error: package build failed. (${2:-no more info})";
427 exit 5 ;;
78eab2a1
AM
428 "err_no_package_data" )
429 remove_build_requires
430 echo "Error: couldn't get out package name/version/release from spec file."
431 exit 6 ;;
50321881
JK
432 "err_tag_exists" )
433 remove_build_requires
434 echo "Tag ${2} already exists (spec release: ${3}).";
435 exit 9 ;;
436 "err_fract_rel" )
437 remove_build_requires
438 echo "Release ${2} not integer and not a snapshot.";
439 exit 10 ;;
fb96e0b5
AM
440 "err_branch_exists" )
441 remove_build_requires
442 echo "Tree branch already exists (${2}).";
443 exit 11 ;;
50321881 444
cd445739 445 esac
50321881 446 echo "Unknown error."
2a5f078d 447 exit 100
cd445739
AM
448}
449
450init_builder()
451{
452 if [ -n "$DEBUG" ]; then
453 set -x;
454 set -v;
0dd6320d 455 fi
cd445739
AM
456
457 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
458 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
459
460 __PWD="`pwd`"
00fcec7e 461}
462
d6a77ddb 463get_spec()
1471f6d6 464{
c890b916 465
2e5be021 466 update_shell_title "get_spec"
c890b916 467
cd445739
AM
468 if [ -n "$DEBUG" ]; then
469 set -x;
470 set -v;
471 fi
472
473 cd "$SPECS_DIR"
474 if [ \! -f "$SPECFILE" ]; then
475 SPECFILE="`basename $SPECFILE .spec`.spec";
476 fi
477 if [ "$NOCVSSPEC" != "yes" ]; then
478 OPTIONS="up "
479
480 if [ -n "$CVSROOT" ]; then
481 OPTIONS="-d $CVSROOT $OPTIONS"
482 else
483 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
484 echo "warning: No cvs access defined - using local .spec file"
485 NOCVSSPEC="yes"
486 fi
487 fi
488
489 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
490 OPTIONS="$OPTIONS -A"
491 else
492 if [ -n "$CVSDATE" ]; then
493 OPTIONS="$OPTIONS -D $CVSDATE"
494 fi
495 if [ -n "$CVSTAG" ]; then
496 OPTIONS="$OPTIONS -r $CVSTAG"
497 fi
498 fi
499
500 result=1
501 retries_counter=0
502 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
503 do
504 retries_counter=$(( $retries_counter + 1 ))
505 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
506 result=$?
507 [ -n "$output" ] && echo "$output"
508 if [ "$result" -ne "0" ]; then
509 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
510 echo "Trying again [$SPECFILE]... ($retries_counter)"
511 sleep 2
512 continue
513 fi
514 Exit_error err_no_spec_in_repo;
515 fi
516 done
517 fi
518 if [ ! -f "$SPECFILE" ]; then
519 Exit_error err_no_spec_in_repo;
520 fi
521
522 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
523 chmod $CHMOD_MODE $SPECFILE
524 fi
525 unset OPTIONS
a7eefc54 526 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
7e40520f
ER
527
528 set_spec_target
cd445739
AM
529}
530
531find_mirror()
532{
533 cd "$SPECS_DIR"
534 url="$1"
535 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
536 cvs update mirrors >&2
537 fi
538
539 IFS="|"
540 while read origin mirror name rest
541 do
542 ol=`echo -n "$origin"|wc -c`
543 prefix="`echo -n "$url" | head -c $ol`"
544 if [ "$prefix" = "$origin" ] ; then
545 suffix="`echo "$url"|cut -b $ol-`"
546 echo -n "$mirror$suffix"
547 return 0
548 fi
549 done < mirrors
550 echo "$url"
551}
552
553src_no ()
554{
555 cd $SPECS_DIR
556 rpm_dump | \
557 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
558 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
559 head -n 1 | xargs
1471f6d6 560}
561
cd445739 562src_md5 ()
8ba5cdda 563{
cd445739
AM
564 [ X"$NO5" = X"yes" ] && return
565 no=$(src_no "$1")
566 [ -z "$no" ] && return
567 cd $SPECS_DIR
47a8df12 568 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
cd445739
AM
569 if [ -z "$spec_rev" ]; then
570 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
571 fi
572 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
573 md5=$(grep -s -v '^#' additional-md5sums | \
574 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
575 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
576 grep -E '^[0-9a-f]{32}$')
577 if [ X"$md5" = X"" ] ; then
6203ea52
AG
578 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
579 if [ ! -z "$source_md5" ] ; then
7e365483 580 echo $source_md5;
6203ea52 581 else
7e365483
KK
582 # we have empty SourceX-md5, but it is still possible
583 # that we have NoSourceX-md5 AND NoSource: X
584 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
585 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
586 echo $nosource_md5;
587 fi;
6203ea52 588 fi;
cd445739
AM
589 else
590 if [ $(echo "$md5" | wc -l) != 1 ] ; then
591 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
592 fi
593 echo "$md5" | tail -n 1
594 fi
595}
596
597distfiles_url ()
598{
1246dc2a 599 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
cd445739
AM
600}
601
602distfiles_attic_url ()
603{
1246dc2a 604 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
cd445739
AM
605}
606
607good_md5 ()
608{
609 md5=$(src_md5 "$1")
610 [ "$md5" = "" ] || \
611 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
8ba5cdda
PG
612}
613
a4b50627
AF
614good_size ()
615{
deccc50e
AM
616 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
617 [ -n "$size" -a "$size" -gt 0 ]
a4b50627
AF
618}
619
947025e5 620cvsignore_df ()
621{
622 if [ "$CVSIGNORE_DF" != "yes" ]; then
623 return
624 fi
625 cvsignore=${SOURCE_DIR}/.cvsignore
626 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
627 echo "$1" >> $cvsignore
628 fi
629}
630
cd445739
AM
631get_files()
632{
633 GET_FILES="$@"
af4d5315 634 update_shell_title "fetching sources"
cd445739
AM
635
636 if [ -n "$DEBUG" ]; then
637 set -x;
638 set -v;
639 fi
640
f09c0772 641 if [ $# -gt 0 ]; then
cd445739
AM
642 cd "$SOURCE_DIR"
643
644 OPTIONS="up "
645 if [ -n "$CVSROOT" ]; then
646 OPTIONS="-d $CVSROOT $OPTIONS"
647 else
648 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
649 echo "warning: No cvs access defined for SOURCES"
650 NOCVS="yes"
651 fi
652 fi
653 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
654 OPTIONS="$OPTIONS -A"
655 else
656 if [ -n "$CVSDATE" ]; then
657 OPTIONS="$OPTIONS -D $CVSDATE"
658 fi
659 if [ -n "$CVSTAG" ]; then
660 OPTIONS="$OPTIONS -r $CVSTAG"
661 fi
662 fi
f2e42a41
ER
663 local nf=$(echo "$GET_FILES" | wc -w)
664 local nc=0
f09c0772 665 for i in $GET_FILES; do
f2e42a41
ER
666 nc=$((nc + 1))
667 SHELL_TITLE_PREFIX="get_files[$nc/$nf]"
668 update_shell_title "$i"
f09c0772
ER
669 local fp=`nourl "$i"`
670 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
18e5347d
ER
671 continue
672 fi
cd445739
AM
673 if [ -n "$UPDATE5" ]; then
674 if [ -n "$ADD5" ]; then
f09c0772 675 [ "$fp" = "$i" ] && continue
cd445739
AM
676 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
677 else
678 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
679 fi
680 fi
681 FROM_DISTFILES=0
f09c0772 682 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
cd445739
AM
683 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
684 echo "Warning: no URL given for $i"
685 fi
686
687 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
a4b50627 688 if good_md5 "$i" && good_size "$i"; then
deccc50e 689 echo "$(nourl "$i") having proper md5sum already exists"
cd445739
AM
690 continue
691 fi
692 target=$(nourl "$i")
693 url=$(distfiles_url "$i")
694 url_attic=$(distfiles_attic_url "$i")
695 FROM_DISTFILES=1
33da77c4 696 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
f09c0772 697 update_shell_title "${GETLOCAL}: $url"
cd445739
AM
698 ${GETLOCAL} $url $target
699 else
700 if [ -z "$NOMIRRORS" ]; then
701 url="`find_mirror "$url"`"
702 fi
f09c0772 703 update_shell_title "${GETURI}: $url"
ca2e6c31 704 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 705 if [ "`echo $url | grep -E 'ftp://'`" ]; then
f09c0772 706 update_shell_title "${GETURI2}: $url"
ca2e6c31 707 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739
AM
708 fi
709 fi
710 if ! test -s "$target"; then
711 rm -f "$target"
712 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
f09c0772 713 update_shell_title "${GETLOCAL}: $url_attic"
cd445739
AM
714 ${GETLOCAL} $url_attic $target
715 else
716 if [ -z "$NOMIRRORS" ]; then
717 url_attic="`find_mirror "$url_attic"`"
718 fi
f09c0772 719 update_shell_title "${GETURI}: $url_attic"
ca2e6c31 720 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 721 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
f09c0772 722 update_shell_title "${GETURI2}: $url_attic"
ca2e6c31 723 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
724 fi
725 fi
726 fi
947025e5 727 if test -s "$target"; then
728 cvsignore_df $target
729 else
cd445739
AM
730 rm -f "$target"
731 FROM_DISTFILES=0
732 fi
733 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
734 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
735 result=1
736 retries_counter=0
737 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
738 do
739 retries_counter=$(( $retries_counter + 1 ))
f09c0772
ER
740 update_shell_title "cvs up: $fp"
741 output=$(LC_ALL=C cvs $OPTIONS "$fp" 2>&1)
cd445739
AM
742 result=$?
743 [ -n "$output" ] && echo "$output"
744 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
f09c0772 745 echo "Trying again ["$fp"]... ($retries_counter)"
cd445739
AM
746 sleep 2
747 continue
748 else
749 break
750 fi
751 done
752 fi
753
f09c0772 754 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
cd445739
AM
755 if [ -z "$NOMIRRORS" ]; then
756 im="`find_mirror "$i"`"
757 else
758 im="$i"
759 fi
f09c0772 760 update_shell_title "${GETURI}: $im"
cd445739 761 ${GETURI} "$im" || \
33da77c4 762 if [ "`echo $im | grep -E 'ftp://'`" ]; then
f09c0772 763 update_shell_title "${GETURI2}: $im"
cd445739 764 ${GETURI2} "$im"
7e365483 765 fi
cd445739
AM
766 fi
767
768 fi
769 srcno=$(src_no $i)
f09c0772 770 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
cd445739
AM
771 Exit_error err_no_source_in_repo $i;
772 elif [ -n "$UPDATE5" ] && \
773 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
774 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
775 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
776 then
deccc50e 777 echo "Updating source-$srcno md5."
f09c0772 778 md5=$(md5sum "$fp" | cut -f1 -d' ')
cd445739 779 perl -i -ne '
deccc50e
AM
780 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
781 print "# Source'$srcno'-md5:\t'$md5'\n"
cd445739
AM
782 if /^Source'$srcno'\s*:\s+/;
783 ' \
784 $SPECS_DIR/$SPECFILE
785 fi
2a5f078d 786
a4b50627 787 if good_md5 "$i" && good_size "$i"; then
cd445739
AM
788 :
789 elif [ "$FROM_DISTFILES" = 1 ]; then
deccc50e 790 # wrong md5 from distfiles: remove the file and try again
cd445739 791 # but only once ...
deccc50e 792 echo "MD5 sum mismatch. Trying full fetch."
cd445739
AM
793 FROM_DISTFILES=2
794 rm -f $target
f09c0772 795 update_shell_title "${GETURI}: $url"
ca2e6c31 796 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 797 if [ "`echo $url | grep -E 'ftp://'`" ]; then
f09c0772 798 update_shell_title "${GETURI2}: $url"
ca2e6c31 799 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739
AM
800 fi
801 if ! test -s "$target"; then
802 rm -f "$target"
f09c0772 803 update_shell_title "${GETURI}: $url_attic"
ca2e6c31 804 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 805 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
f09c0772 806 update_shell_title "${GETURI2}: $url_attic"
ca2e6c31 807 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
808 fi
809 fi
810 test -s "$target" || rm -f "$target"
811 fi
812
a4b50627 813 if good_md5 "$i" && good_size "$i" ; then
cd445739
AM
814 :
815 else
deccc50e
AM
816 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
817 echo "or -5 to update md5 sums, if you're sure files are correct."
cd445739
AM
818 Exit_error err_no_source_in_repo $i
819 fi
820 done
821
822 if [ "$CHMOD" = "yes" ]; then
823 CHMOD_FILES="`nourl $GET_FILES`"
824 if [ -n "$CHMOD_FILES" ]; then
825 chmod $CHMOD_MODE $CHMOD_FILES
826 fi
827 fi
828 unset OPTIONS
f2e42a41 829 SHELL_TITLE_PREFIX=""
cd445739
AM
830 fi
831}
832
833make_tagver() {
78eab2a1
AM
834
835 if [ -n "$DEBUG" ]; then
836 set -x;
837 set -v;
838 fi
2a5f078d 839
cd445739
AM
840 # Check whether first character of PACKAGE_NAME is legal for tag name
841 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
842 TAG_PREFIX=tag_
843 fi
844 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"`
845 # Remove #kernel.version_release from TAGVER because tagging sources
846 # could occur with different kernel-headers than kernel-headers used at build time.
847 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
848 echo -n "$TAGVER"
849}
850
851tag_files()
852{
853 TAG_FILES="$@"
854
855 if [ -n "$DEBUG" ]; then
856 set -x;
857 set -v;
858 fi
859
860 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
861 echo "Version: $PACKAGE_VERSION"
862 echo "Release: $PACKAGE_RELEASE"
863
864 TAGVER=`make_tagver`
865
866 if [ "$TAG_VERSION" = "yes" ]; then
867 echo "CVS tag: $TAGVER"
868 fi
869 if [ -n "$TAG" ]; then
870 echo "CVS tag: $TAG"
871 fi
872
873 OPTIONS="tag -F"
874 if [ -n "$CVSROOT" ]; then
875 OPTIONS="-d $CVSROOT $OPTIONS"
876 fi
877
878 cd "$SOURCE_DIR"
879 for i in $TAG_FILES
880 do
881 # don't tag files stored on distfiles
882 [ -n "`src_md5 $i`" ] && continue
883 if [ -f "`nourl $i`" ]; then
884 if [ "$TAG_VERSION" = "yes" ]; then
885 cvs $OPTIONS $TAGVER `nourl $i`
886 fi
887 if [ -n "$TAG" ]; then
888 cvs $OPTIONS $TAG `nourl $i`
889 fi
890 else
891 Exit_error err_no_source_in_repo $i
892 fi
893 done
894
895 cd "$SPECS_DIR"
896 if [ "$TAG_VERSION" = "yes" ]; then
897 cvs $OPTIONS $TAGVER $SPECFILE
898 fi
899 if [ -n "$TAG" ]; then
900 cvs $OPTIONS $TAG $SPECFILE
901 fi
902
903 unset OPTIONS
904 fi
905}
906
907branch_files()
908{
909 TAG=$1
910 echo "CVS branch tag: $TAG"
911 shift;
912
913 TAG_FILES="$@"
914
915 if [ -n "$DEBUG" ]; then
916 set -x;
917 set -v;
918 fi
919
920 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
921
922 OPTIONS="tag -b"
923 if [ -n "$CVSROOT" ]; then
924 OPTIONS="-d $CVSROOT $OPTIONS"
925 fi
926 cd "$SOURCE_DIR"
927 for i in $TAG_FILES
928 do
929 if [ -f `nourl $i` ]; then
930 cvs $OPTIONS $TAG `nourl $i`
931 else
932 Exit_error err_no_source_in_repo $i
933 fi
934 done
935 cd "$SPECS_DIR"
936 cvs $OPTIONS $TAG $SPECFILE
937
938 unset OPTIONS
939 fi
940}
941
942
943
59398507 944build_package()
945{
2e5be021 946 update_shell_title "build_package"
cd445739
AM
947 if [ -n "$DEBUG" ]; then
948 set -x;
949 set -v;
950 fi
5a491465 951
cd445739
AM
952 cd "$SPECS_DIR"
953
954 if [ -n "$TRY_UPGRADE" ]; then
2e5be021 955 update_shell_title "build_package: try_upgrade"
cd445739 956 if [ -n "$FLOAT_VERSION" ]; then
cc538c24 957 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
cd445739 958 else
cc538c24 959 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
cd445739
AM
960 fi
961
962 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
963
964 if [ -n "$TNEWVER" ]; then
965 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
966 echo "New version found, updating spec file to version " $TNEWVER
967 cp -f $SPECFILE $SPECFILE.bak
968 chmod +w $SPECFILE
969 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
f7b91886 970 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
cd445739 971 parse_spec;
7f347798 972 if [ -n "$ICONS" ]; then
973 get_files $ICONS;
974 parse_spec;
975 fi
f7b91886 976 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
cd445739
AM
977 unset TOLDVER TNEWVER TNOTIFY
978 fi
979 fi
980 cd "$SPECS_DIR"
2a5f078d 981
cd445739
AM
982 case "$COMMAND" in
983 build )
984 BUILD_SWITCH="-ba" ;;
985 build-binary )
986 BUILD_SWITCH="-bb" ;;
987 build-source )
988 BUILD_SWITCH="-bs --nodeps" ;;
989 build-prep )
990 BUILD_SWITCH="-bp --nodeps" ;;
991 esac
c890b916 992
2e5be021 993 update_shell_title "build_package: $COMMAND"
cd445739
AM
994 if [ -n "$LOGFILE" ]; then
995 LOG=`eval echo $LOGFILE`
996 if [ -d "$LOG" ]; then
997 echo "Log file $LOG is a directory."
998 echo "Parse error in the spec?"
999 Exit_error err_build_fail;
1000 fi
1001 if [ -n "$LASTLOG_FILE" ]; then
1002 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1003 fi
1004 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
21bc1a97 1005 (time eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
cd445739
AM
1006 RETVAL=`cat $RES_FILE`
1007 rm $RES_FILE
1008 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1009 if [ "$RETVAL" -eq "0" ]; then
1010 mv $LOG $LOGDIROK
1011 else
1012 mv $LOG $LOGDIRFAIL
1013 fi
1014 fi
8ba5cdda 1015 else
8f96ab6c 1016 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
cd445739 1017 RETVAL=$?
8ba5cdda 1018 fi
cd445739
AM
1019 if [ "$RETVAL" -ne "0" ]; then
1020 if [ -n "$TRY_UPGRADE" ]; then
1021 echo "\n!!! Package with new version cannot be build automagically\n"
1022 mv -f $SPECFILE.bak $SPECFILE
1023 fi
1024 Exit_error err_build_fail;
1025 fi
1026 unset BUILD_SWITCH
1027}
1028
1029nourl()
1030{
1031 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1032}
1033
cd445739
AM
1034install_required_packages()
1035{
1036 run_poldek -vi $1
1037 return $?
1038}
1039
1040set_bconds_values()
1041{
0b65d15e 1042 update_shell_title "set bcond values"
c890b916 1043
cd445739
AM
1044 AVAIL_BCONDS_WITHOUT=""
1045 AVAIL_BCONDS_WITH=""
1046 if `grep -q ^%bcond ${SPECFILE}`; then
1047 BCOND_VERSION="NEW"
36d03934 1048 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
cd445739
AM
1049 BCOND_VERSION="OLD"
1050 else
1051 BCOND_VERSION="NONE"
1052 fi
301cbfd4
ER
1053
1054 # expand bconds from ~/.bcondrc
1055 # The file structure is like gentoo's package.use:
1056 # ---
1057 # * -selinux
1058 # samba -mysql -pgsql
47a8df12 1059 # w32codec-installer license_agreement
301cbfd4
ER
1060 # php +mysqli
1061 # ---
c8a3e2ac 1062 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
301cbfd4
ER
1063 # This takes package name, first defined in spec.
1064 # so consider that when defining flags for package.
1065 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
3e1cbfe0 1066 SN=${SPECFILE%%\.spec}
301cbfd4
ER
1067 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1068
c8a3e2ac
AG
1069 BCONDRC=$HOME/.bcondrc
1070 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1071
301cbfd4
ER
1072 while read pkg flags; do
1073 # ignore comments
1074 [[ "$pkg" == \#* ]] && continue
1075
1076 # any package or current package?
3e1cbfe0 1077 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
301cbfd4
ER
1078 for flag in $flags; do
1079 opt=${flag#[+-]}
1080
1081 # use only flags which are in this package.
1082 if [[ $AVAIL = *${opt}* ]]; then
3b5101f0
ER
1083 if [[ $flag = -* ]]; then
1084 BCOND="$BCOND --without $opt"
301cbfd4 1085 else
3b5101f0 1086 BCOND="$BCOND --with $opt"
301cbfd4
ER
1087 fi
1088 fi
1089 done
1090 fi
c8a3e2ac 1091 done < $BCONDRC
301cbfd4
ER
1092 fi
1093
cd445739
AM
1094 case "${BCOND_VERSION}" in
1095 NONE)
7e365483 1096 :
cd445739 1097 ;;
7e365483 1098 OLD)
cd445739
AM
1099 echo "Warning: This spec has old style bconds. Fix it || die."
1100 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1101 do
1102 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1103 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1104 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1105 else
1106 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1107 fi
1108 done
2a5f078d 1109
cd445739
AM
1110 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1111 do
1112 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1113 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1114 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1115 else
1116 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1117 fi
1118 done
1119 ;;
1120 NEW)
1121 cond_type="" # with || without
1122 for opt in `$RPMBUILD --bcond $SPECFILE`
1123 do
1124 case "$opt" in
1125 _without)
1126 cond_type="without"
1127 ;;
1128 _with)
1129 cond_type="with"
1130 ;;
f8d24cee 1131 _without_*)
1132 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1133 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1134 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1135 else
1136 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1137 fi
1138 ;;
1139 _with_*)
1140 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1141 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1142 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1143 else
1144 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1145 fi
1146 ;;
cd445739
AM
1147 *)
1148 case "$cond_type" in
1149 with)
1150 cond_type=''
1151 AVAIL_BCOND_WITH="$opt"
1152 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1153 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1154 else
1155 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1156 fi
7e365483 1157 ;;
cd445739
AM
1158 without)
1159 cond_type=''
1160 AVAIL_BCOND_WITHOUT="$opt"
1161 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1162 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1163 else
1164 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1165 fi
1166 ;;
1167 esac
1168 ;;
1169 esac
1170 done
1171 ;;
1172 esac
1173}
1174
1175run_sub_builder()
1176{
1177 package_name="${1}"
af6b168f 1178 update_shell_title "run_sub_builder $package_name"
cd445739
AM
1179 #
1180