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