]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - builder.sh
- pass --target to --showrc to give proper macros (fixes kernel-desktop noarch build...
[packages/rpm-build-tools.git] / builder.sh
CommitLineData
1d7abbe3 1#!/bin/ksh
44058243 2#
dece74ed
AM
3# This program is free software, distributed under the terms of
4# the GNU General Public License Version 2.
5#
cd445739 6# -----------
cd445739 7# Exit codes:
2a5f078d 8# 0 - succesful
9# 1 - help displayed
10# 2 - no spec file name in cmdl parameters
11# 3 - spec file not stored in repo
12# 4 - some source, patch or icon files not stored in repo
13# 5 - package build failed
14# 6 - spec file with errors
15# 7 - wrong source in /etc/poldek.conf
16# 8 - Failed installing buildrequirements and subrequirements
17# 9 - Requested tag already exist
18# 10 - Refused to build fractional release
19# 100 - Unknown error (should not happen)
cd445739
AM
20
21# Notes (todo):
f7b91886 22# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
cd445739 23# - when Icon: field is present, -5 and -a5 doesn't work
f3ada241 24# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
931a4acf 25
d43959a2
ER
26RCSID='$Id$'
27r=${RCSID#* * }
28rev=${r%% *}
4062d64a 29VERSION="v0.22/$rev"
d43959a2 30VERSIONSTRING="\
c9acaed9 31Build package utility from PLD Linux CVS repository
4062d64a 32$VERSION (C) 1999-2008 Free Penguins".
d43959a2 33
d6a77ddb 34PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
b03f053b 35
cd445739 36COMMAND="build"
64ea5308 37TARGET=""
cd445739 38
bde1c404 39SPECFILE=""
d287305c 40BE_VERBOSE=""
4003ad8c 41QUIET=""
cd445739
AM
42CLEAN=""
43DEBUG=""
44NOURLS=""
45NOCVS=""
46NOCVSSPEC=""
47NODIST=""
47761337 48NOINIT=""
bc10f694 49PREFMIRRORS=""
cd445739 50UPDATE=""
cd445739
AM
51ADD5=""
52NO5=""
53ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
c8f50498 54CVSROOT=""
cdbd30e8 55GREEDSRC=""
cd445739 56
6c1b2e7d
PZ
57# use rpm 4.4.6+ digest format instead of comments if non-zero
58USEDIGEST=
59
e3aa6f5e
ER
60# user agent when fetching files
61USER_AGENT="PLD/Builder($VERSION)"
62
cd445739
AM
63# It can be used i.e. in log file naming.
64# See LOGFILE example.
65DATE=`date +%Y-%m-%d_%H-%M-%S`
66
67# Example: LOGFILE='../log.$PACKAGE_NAME'
68# Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
69# Yes, you can use variable name! Note _single_ quotes!
70LOGFILE=''
71
72LOGDIR=""
73LOGDIROK=""
74LOGDIRFAIL=""
75LASTLOG_FILE=""
76
77CHMOD="no"
1da227e8 78CHMOD_MODE="0644"
cd445739 79RPMOPTS=""
d1c5a9a7 80RPMBUILDOPTS=""
cd445739
AM
81BCOND=""
82GROUP_BCONDS="no"
947025e5 83CVSIGNORE_DF="no"
d287305c 84
85PATCHES=""
86SOURCES=""
cd445739 87ICONS=""
d287305c 88PACKAGE_RELEASE=""
89PACKAGE_VERSION=""
90PACKAGE_NAME=""
14bead22 91ASSUMED_NAME=""
cd445739
AM
92PROTOCOL="ftp"
93WGET_RETRIES=${MAX_WGET_RETRIES:-0}
94CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
95
96CVSTAG=""
97RES_FILE=""
39dcc7de 98CVS_FORCE=""
cd445739
AM
99
100CVS_SERVER="cvs.pld-linux.org"
101DISTFILES_SERVER="://distfiles.pld-linux.org"
d4730dae 102ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
cd445739 103
36d03934 104DEF_NICE_LEVEL=19
86aafdbe 105SCHEDTOOL="auto"
cd445739
AM
106
107FAIL_IF_NO_SOURCES="yes"
108
18e5347d
ER
109# let get_files skip over files which are present to get those damn files fetched
110SKIP_EXISTING_FILES="no"
111
975d7b23 112TRY_UPGRADE=""
257af81b
ER
113# should the specfile be restored if upgrade failed?
114REVERT_BROKEN_UPGRADE="yes"
115
90baf90b
ER
116if rpm --specsrpm 2>/dev/null; then
117 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
ce40491a 118 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
90baf90b
ER
119else
120 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
121 if [ -x /usr/bin/rpm-getdeps ]; then
122 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
123 else
124 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
125 fi
ab4a2b6e
ER
126fi
127
90baf90b 128
cd445739
AM
129# Here we load saved user environment used to
130# predefine options set above, or passed to builder
131# in command line.
132# This one reads global system environment settings:
133if [ -f ~/etc/builderrc ]; then
134 . ~/etc/builderrc
135fi
136# And this one cascades settings using user personal
137# builder settings.
138# Example of ~/.builderrc:
139#
140#UPDATE_POLDEK_INDEXES="yes"
141#FETCH_BUILD_REQUIRES="yes"
142#REMOVE_BUILD_REQUIRES="force"
143#GROUP_BCONDS="yes"
144#LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
982e358c 145#TITLECHANGE=no
cd445739 146#
a83e5405 147SU_SUDO=""
cd445739
AM
148if [ -n "$HOME_ETC" ]; then
149 USER_CFG="$HOME_ETC/.builderrc"
20117088 150 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
cd445739
AM
151else
152 USER_CFG=~/.builderrc
20117088 153 BUILDER_MACROS=~/.builder-rpmmacros
cd445739
AM
154fi
155
156[ -f "$USER_CFG" ] && . "$USER_CFG"
157
86aafdbe
ER
158if [ "$SCHEDTOOL" = "auto" ]; then
159 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
160 SCHEDTOOL="schedtool -B -e"
161 else
162 SCHEDTOOL="no"
163 fi
164fi
165
ca2e6c31 166if [ -n "$USE_PROZILLA" ]; then
7e365483
KK
167 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
168 GETURI2="$GETURI"
169 OUTFILEOPT="-O"
ca2e6c31 170elif [ -n "$USE_AXEL" ]; then
cede92b3 171 GETURI="axel -a $AXEL_OPTS"
7e365483
KK
172 GETURI2="$GETURI"
173 OUTFILEOPT="-o"
ca2e6c31 174else
5700ee32
ER
175 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
176 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
177 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
e3aa6f5e 178 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
6f9a5d76 179
7e365483
KK
180 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
181 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
182 OUTFILEOPT="-O"
2bc5451f 183fi
11468b23 184
11468b23
AM
185GETLOCAL="cp -a"
186
187if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
188 RPM="rpm"
189 RPMBUILD="rpm"
190else
191 RPM="rpm"
192 RPMBUILD="rpmbuild"
193fi
194
28c23a72
AG
195#
196# are we using cvs-nserver ?
197#
e21039da
AG
198CVS_NSERVER=0
199cvs --version 2>&1 | grep -q 'CVS-nserver'
200[ $? -eq 0 ] && CVS_NSERVER=1
28c23a72 201
a8c9a155 202POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
a83e5405 203POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
11468b23 204
cd445739
AM
205run_poldek()
206{
525bf240 207 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
cd445739
AM
208 if [ -n "$LOGFILE" ]; then
209 LOG=`eval echo $LOGFILE`
210 if [ -n "$LASTLOG_FILE" ]; then
211 echo "LASTLOG=$LOG" > $LASTLOG_FILE
212 fi
86aafdbe 213 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
cd445739
AM
214 return $exit_pldk
215 else
86aafdbe 216 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
cd445739
AM
217 return `cat ${RES_FILE}`
218 rm -rf ${RES_FILE}
219 fi
220}
221
cd445739
AM
222#---------------------------------------------
223# functions
da946cd6 224
5a491465 225usage()
226{
cd445739
AM
227 if [ -n "$DEBUG" ]; then set -xv; fi
228 echo "\
d43959a2 229Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
6594293d 230[-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
4efa0b98 231[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
19dc5591 232[-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
233[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
a7b2951c 234[-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
f8dba812 235[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
6594293d 236[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
3009b80d 237[--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
6594293d 238<package>[.spec][:cvstag]
2a5f078d 239
cd445739
AM
240-5, --update-md5 - update md5 comments in spec, implies -nd -ncs
241-a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
242-n5, --no-md5 - ignore md5 comments in spec
9243e80b
ER
243-D, --debug - enable builder script debugging mode,
244-debug - produce rpm debug package (same as --opts -debug)
d43959a2
ER
245-V, --version - output builder version string
246--short-version - output builder short version
cd445739
AM
247-a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
248-b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
249 from <package>.spec,
250-bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
251 only package from <package>.spec,
c56807e0 252-bp, --build-prep - execute the %prep phase of <package>.spec,
6594293d
AG
253-bc - execute the %build phase of <package>.spec,
254-bi - execute the %install phase of <package>.spec
255-bl - execute the %files phase of <package>.spec
cd445739
AM
256-bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
257 them into src.rpm,
6594293d 258--short-circuit - short-circuit build
cd445739
AM
259-B, --branch - add branch
260-c, --clean - clean all temporarily created files (in BUILD, SOURCES,
6f10b394
ER
261 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
262-m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
263 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
264 any rpm building.
39dcc7de 265-cf, --cvs-force - use -F when tagging (useful when moving branches)
2a5f078d 266-d <cvsroot>, --cvsroot <cvsroot>
cd445739
AM
267 - setup \$CVSROOT,
268--define <macro> <value>
269 - define a macro <macro> with value <value>,
44058243
ER
270--alt_kernel <kernel>
271 - same as --define 'alt_kernel <kernel>'
cd445739
AM
272--nodeps - rpm won't check any dependences
273-g, --get - get <package>.spec and all related files from CVS repo
274 or HTTP/FTP,
275-h, --help - this message,
276--http - use http instead of ftp,
277-l <logfile>, --logtofile <logfile>
278 - log all to file,
cd445739
AM
279-nc, --no-cvs - don't download sources from CVS, if source URL is given,
280-ncs, --no-cvs-specs
281 - don't check specs in CVS
282-nd, --no-distfiles - don't download from distfiles
283-nm, --no-mirrors - don't download from mirror, if source URL is given,
284-nu, --no-urls - don't try to download from FTP/HTTP location,
285-ns, --no-srcs - don't download Sources
286-ns0, --no-source0 - don't download Source0
287-nn, --no-net - don't download anything from the net
a93e8cdf 288-pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
b572253e 289--no-init - don't initialize builder paths (SPECS and SOURCES)
18e5347d
ER
290-ske,
291--skip-existing-files - skip existing files in get_files
cd445739
AM
292--opts <rpm opts> - additional options for rpm
293-q, --quiet - be quiet,
294--date yyyy-mm-dd - build package using resources from specified CVS date,
295-r <cvstag>, --cvstag <cvstag>
296 - build package using resources from specified CVS tag,
5323fffd 297-A - build package using CVS resources as any sticky tags/date/kopts being reset.
cd445739
AM
298-R, --fetch-build-requires
299 - fetch what is BuildRequired,
300-RB, --remove-build-requires
301 - remove all you fetched with -R or --fetch-build-requires
302 remember, this option requires confirmation,
303-FRB, --force-remove-build-requires
304 - remove all you fetched with -R or --fetch-build-requires
305 remember, this option works without confirmation,
06541433
JR
306-sd, --source-distfiles - list sources available from distfiles (intended for offline
307 operations; does not work when Icon field is present
308 but icon file is absent),
e15852ab 309-sc, --source-cvs - list sources available from CVS
06541433
JR
310-sdp, --source-distfiles-paths - list sources available from distfiles -
311 paths relative to distfiles directory (intended for offline
312 operations; does not work when Icon field is present
313 but icon file is absent),
a7eefc54 314-sf, --source-files - list sources - bare filenames (intended for offline
315 operations; does not work when Icon field is present
3621e588 316 but icon file is absent),
a7eefc54 317-sp, --source-paths - list sources - filenames with full local paths (intended for
318 offline operations; does not work when Icon field is present
3621e588 319 but icon file is absent),
2dddf439
ER
320-su, --source-urls - list urls - urls to sources and patches
321 intended for copying urls with spec with lots of macros in urls
cd445739
AM
322-T <cvstag> , --tag <cvstag>
323 - add cvs tag <cvstag> for files,
324-Tvs, --tag-version-stable
094bd95b 325 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
cd445739
AM
326-Ts, --tag-stable
327 - add cvs tag STABLE for files,
cd445739 328-Tv, --tag-version
1691a37b 329 - add cvs tag NAME-VERSION-RELEASE for files,
cd445739
AM
330-Tp, --tag-prefix <prefix>
331 - add <prefix> to NAME-VERSION-RELEASE tags,
332-tt, --test-tag <prefix>
333 - fail if tag is already present,
50321881
JK
334-ir, --integer-release-only
335 - allow only integer and snapshot releases
cd445739
AM
336-v, --verbose - be verbose,
337-u, --try-upgrade - check version, and try to upgrade package
338-un, --try-upgrade-with-float-version
339 - as above, but allow float version
f8dba812 340--use-greed-sources
341 - try download source from tag head if don't find it in
f5141bbc 342 current tag
deccc50e 343-U, --update - refetch sources, don't use distfiles, and update md5 comments
cd445739
AM
344-Upi, --update-poldek-indexes
345 - refresh or make poldek package index files.
c890b916 346-np, --nopatch <patchnumber>
bed98670 347 - don't apply <patchnumber>
dfe2cb9a
MK
348--show-bconds - show available conditional builds, which can be used
349 - with --with and/or --without switches.
9b78be50
ER
350--show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
351 ./repackage.sh script. in other words, the output is
352 parseable by scripts.
cd445739
AM
353--with/--without <feature>
354 - conditional build package depending on %_with_<feature>/
355 %_without_<feature> macro switch. You may now use
356 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
357 constructions. Set GROUP_BCONDS to yes to make use of it.
6dd19291 358--target <platform>, --target=<platform>
3621e588
ER
359 - build for platform <platform>.
360--init-rpm-dir - initialize ~/rpm directory structure
5a491465 361"
362}
363
31d2bd0b
ER
364# change dependency to specname
365# common changes:
366# - perl(Package::Name) -> perl-Package-Name
367depspecname() {
368 local package="$1"
369
370 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
371 echo "$package"
372}
373
c890b916 374update_shell_title() {
a0d6396b 375 [ -t 1 ] || return
0b65d15e
ER
376 local len=${COLUMNS:-80}
377 local msg=$(echo "$*" | cut -c-$len)
378
e225de91
ER
379 if [ -n "$BE_VERBOSE" ]; then
380 echo >&2 "$(date +%s.%N) $*"
381 fi
382
982e358c 383 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
138bbc98
ER
384 local pkg
385 if [ -n "$PACKAGE_NAME" ]; then
386 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
387 else
388 pkg=${SPECFILE}
389 fi
390
391 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
a8c9a155 392 msg=$(echo $msg | tr -d '\n\r')
982e358c
MP
393 case "$TERM" in
394 cygwin|xterm*)
395 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
396 ;;
397 screen*)
398 echo >&2 -ne "\033]0;$msg\007"
399 ;;
400 esac
401 fi
c890b916
ER
402}
403
7e40520f
ER
404# set TARGET from BuildArch: from SPECFILE
405set_spec_target() {
ce40491a
ER
406 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
407 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
408 if [ "$tmp" ]; then
f9109a96 409 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
7e40520f
ER
410 TARGET="$tmp"
411 case "$RPMBUILD" in
412 "rpmbuild")
f9109a96 413 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
7e40520f 414 "rpm")
ce40491a 415 TARGET_SWITCH="--target=$TARGET" ;;
7e40520f 416 esac
ce40491a
ER
417 fi
418 fi
7e40520f
ER
419}
420
ace3fd80
ER
421# runs rpm with minimal macroset
422minirpm() {
fa4bf1df 423 # we reset macros not to contain macros.build as all the %() macros are
559d511f 424 # executed here, while none of them are actually needed.
559d511f 425 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
525bf240 426 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
ace3fd80
ER
427
428 # TODO: move these to /usr/lib/rpm/macros
20117088 429 cat > $BUILDER_MACROS <<'EOF'
5b5e5f7f 430%x8664 x86_64 amd64 ia32e
f78a0bb7 431%alt_kernel %{nil}
432%_alt_kernel %{nil}
fb198857
ER
433%requires_releq_kernel_up %{nil}
434%requires_releq_kernel_smp %{nil}
1b2bbc99 435%requires_releq_kernel %{nil}
6b8134e3 436%requires_releq() %{nil}
bb01dee9 437%pyrequires_eq() %{nil}
559d511f 438%requires_eq() %{nil}
c13be3d1 439%requires_eq_to() %{nil}
fb198857
ER
440%releq_kernel_up ERROR
441%releq_kernel_smp ERROR
1b2bbc99 442%releq_kernel ERROR
74d9fd14 443%kgcc_package ERROR
237bd3f1 444%_fontsdir ERROR
7141278d 445%ruby_version ERROR
446%ruby_ver_requires_eq() %{nil}
447%ruby_mod_ver_requires_eq() %{nil}
c13be3d1 448%__php_api_requires() %{nil}
7141278d 449%php_major_version ERROR
450%php_api_version ERROR
99f819cf
AM
451%requires_xorg_xserver_extension %{nil}
452%requires_xorg_xserver_xinput %{nil}
453%requires_xorg_xserver_font %{nil}
454%requires_xorg_xserver_videodrv %{nil}
7141278d 455%py_ver ERROR
41035426
ER
456%perl_vendorarch ERROR
457%perl_vendorlib ERROR
703ae20b
ER
458# damn. need it here! - copied from /usr/lib/rpm/macros.build
459%tmpdir %(echo "${TMPDIR:-/tmp}")
1f28fcb7
ER
460%patchset_source(f:b:) %(
461 base=%{-b*}%{!-b*:10000};
462 start=$(expr $base + %1);
463 end=$(expr $base + %{?2}%{!?2:%{1}});
464 # we need to call seq twice as it doesn't allow two formats
465 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
466 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
467 paste %{tmpdir}/__ps{1,2};
468 rm -f %{tmpdir}/__ps{1,2};
469) \
470%{nil}
fb198857 471EOF
3d12d055 472 if [ "$NOINIT" = "yes" ] ; then
20117088 473 cat >> $BUILDER_MACROS <<'EOF'
3d12d055
JR
474%_specdir ./
475%_sourcedir ./
476EOF
c039643c 477 fi
20117088 478 eval $RPMBUILD --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
ace3fd80
ER
479}
480
481cache_rpm_dump() {
482 if [ -n "$DEBUG" ]; then
483 set -x
484 set -v
485 fi
486
d1d24c14 487 if [ -x /usr/bin/rpm-specdump ]; then
525bf240
ER
488 update_shell_title "cache_rpm_dump using rpm-specdump command"
489 rpm_dump_cache=$(rpm-specdump $BCOND $TARGET_SWITCH $SPECFILE)
d1d24c14 490 else
525bf240 491 update_shell_title "cache_rpm_dump using rpmbuild command"
d1d24c14
ER
492 local rpm_dump
493 rpm_dump=`
494 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
495 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
496 case "$RPMBUILD" in
497 rpm)
498 ARGS='-bp'
499 ;;
500 rpmbuild)
501 ARGS='--nodigest --nosignature --nobuild'
502 ;;
503 esac
504 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
505 `
506 if [ $? -gt 0 ]; then
507 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
508 echo "$error" >&2
509 Exit_error err_build_fail
510 fi
d05e8080 511
d1d24c14
ER
512 # make small dump cache
513 rpm_dump_cache=`echo "$rpm_dump" | awk '
514 $2 ~ /^SOURCEURL/ {print}
515 $2 ~ /^PATCHURL/ {print}
516 $2 ~ /^nosource/ {print}
517 $2 ~ /^PACKAGE_/ {print}
518 '`
519 fi
d05e8080 520
13974367 521 update_shell_title "cache_rpm_dump: OK!"
cd445739
AM
522}
523
ace3fd80 524rpm_dump() {
cd445739 525 if [ -z "$rpm_dump_cache" ] ; then
45e2a818 526 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
cd445739
AM
527 fi
528 echo "$rpm_dump_cache"
529}
530
d05e8080
ER
531get_icons()
532{
533 update_shell_title "get icons"
a8c9a155 534 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
d05e8080
ER
535 if [ -z "$ICONS" ]; then
536 return
537 fi
538
975d7b23 539 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
d05e8080
ER
540}
541
59398507 542parse_spec()
543{
af4d5315 544 update_shell_title "parsing specfile"
cd445739 545 if [ -n "$DEBUG" ]; then
518ff1fb
ER
546 set -x
547 set -v
cd445739 548 fi
b2975fc3 549
d05e8080 550 # icons are needed for successful spec parse
518ff1fb 551 get_icons
d05e8080 552
01fa66fc 553 cd $SPEC_DIR
cd445739 554 cache_rpm_dump
00fcec7e 555
cd445739 556 if [ "$NOSRCS" != "yes" ]; then
a8c9a155 557 SOURCES=$(rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}')
cd445739 558 fi
7cb24972 559
cd445739
AM
560 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
561 FAIL_IF_NO_SOURCES="no"
562 fi
563
a8c9a155
ER
564 PATCHES=$(rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}')
565 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
dfe2b2d9
ER
566 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
567 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
568 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
78eab2a1 569
0b4119a2 570 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
7854d40c 571 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
0b4119a2
JR
572 fi
573
cd445739
AM
574 if [ -n "$BE_VERBOSE" ]; then
575 echo "- Sources : `nourl $SOURCES`"
576 if [ -n "$PATCHES" ]; then
577 echo "- Patches : `nourl $PATCHES`"
578 else
579 echo "- Patches : *no patches needed*"
580 fi
581 if [ -n "$ICONS" ]; then
582 echo "- Icon : `nourl $ICONS`"
583 else
584 echo "- Icon : *no package icon*"
585 fi
586 echo "- Name : $PACKAGE_NAME"
587 echo "- Version : $PACKAGE_VERSION"
588 echo "- Release : $PACKAGE_RELEASE"
589 fi
13974367
ER
590
591 update_shell_title "parse_spec: OK!"
cd445739
AM
592}
593
594Exit_error()
595{
596 if [ -n "$DEBUG" ]; then
518ff1fb
ER
597 set -x
598 set -v
cd445739
AM
599 fi
600
601 cd "$__PWD"
602
603 case "$1" in
604 "err_no_spec_in_cmdl" )
605 remove_build_requires
45e2a818 606 echo >&2 "ERROR: spec file name not specified."
cd445739 607 exit 2 ;;
a08d92fc 608 "err_invalid_cmdline" )
45e2a818 609 echo >&2 "ERROR: invalid command line arg ($2)."
a08d92fc 610 exit 2 ;;
cd445739
AM
611 "err_no_spec_in_repo" )
612 remove_build_requires
45e2a818 613 echo >&2 "Error: spec file not stored in CVS repo."
cd445739
AM
614 exit 3 ;;
615 "err_no_source_in_repo" )
616 remove_build_requires
45e2a818 617 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
cd445739
AM
618 exit 4 ;;
619 "err_build_fail" )
620 remove_build_requires
45e2a818 621 echo >&2 "Error: package build failed. (${2:-no more info})"
cd445739 622 exit 5 ;;
78eab2a1
AM
623 "err_no_package_data" )
624 remove_build_requires
45e2a818 625 echo >&2 "Error: couldn't get out package name/version/release from spec file."
78eab2a1 626 exit 6 ;;
ce40491a 627 "err_tag_exists" )
50321881 628 remove_build_requires
45e2a818 629 echo >&2 "Tag ${2} already exists (spec release: ${3})."
50321881 630 exit 9 ;;
ce40491a 631 "err_fract_rel" )
50321881 632 remove_build_requires
45e2a818 633 echo >&2 "Release ${2} not integer and not a snapshot."
50321881 634 exit 10 ;;
fb96e0b5
AM
635 "err_branch_exists" )
636 remove_build_requires
45e2a818 637 echo >&2 "Tree branch already exists (${2})."
fb96e0b5 638 exit 11 ;;
cfc497c0
ER
639 "err_acl_deny" )
640 remove_build_requires
45e2a818 641 echo >&2 "Error: conditions reject building this spec (${2})."
cfc497c0 642 exit 12 ;;
cd445739 643 esac
45e2a818 644 echo >&2 "Unknown error."
73848362 645 exit 100
cd445739
AM
646}
647
648init_builder()
649{
650 if [ -n "$DEBUG" ]; then
518ff1fb
ER
651 set -x
652 set -v
0dd6320d 653 fi
cd445739 654
4aeb9973 655 if [ "$NOINIT" != "yes" ] ; then
a08cc47e
ER
656 local extra
657 if [ "$ASSUMED_NAME" ]; then
658 extra="--define 'name $ASSUMED_NAME'"
659 fi
a8c9a155
ER
660 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
661 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
29e90b02
JR
662 else
663 SOURCE_DIR="."
01fa66fc 664 SPEC_DIR="."
29e90b02 665 fi
cd445739 666
a8c9a155 667 __PWD=$(pwd)
00fcec7e 668}
669
d6a77ddb 670get_spec()
1471f6d6 671{
c890b916 672
2e5be021 673 update_shell_title "get_spec"
c890b916 674
cd445739 675 if [ -n "$DEBUG" ]; then
518ff1fb
ER
676 set -x
677 set -v
cd445739
AM
678 fi
679
01fa66fc 680 cd "$SPEC_DIR"
049ab214 681 if [ ! -f "$SPECFILE" ]; then
a8c9a155 682 SPECFILE="$(basename $SPECFILE .spec).spec"
cd445739
AM
683 fi
684 if [ "$NOCVSSPEC" != "yes" ]; then
cd445739 685
049ab214
ER
686 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
687 echo "Warning: No CVS access defined - using local .spec file"
688 NOCVSSPEC="yes"
cd445739
AM
689 fi
690
049ab214 691 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
cd445739 692 fi
049ab214 693
cd445739 694 if [ ! -f "$SPECFILE" ]; then
518ff1fb 695 Exit_error err_no_spec_in_repo
cd445739
AM
696 fi
697
698 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
699 chmod $CHMOD_MODE $SPECFILE
700 fi
701 unset OPTIONS
a7eefc54 702 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
7e40520f 703
ce40491a 704 set_spec_target
cd445739
AM
705}
706
707find_mirror()
708{
01fa66fc 709 cd "$SPEC_DIR"
782518da 710 local url="$1"
cd445739
AM
711 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
712 cvs update mirrors >&2
713 fi
714
715 IFS="|"
782518da
ER
716 local origin mirror name rest ol prefix
717 while read origin mirror name rest; do
718 # skip comments and empty lines
719 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
720 continue
721 fi
a8c9a155
ER
722 ol=$(echo -n "$origin" | wc -c)
723 prefix=$(echo -n "$url" | head -c $ol)
cd445739 724 if [ "$prefix" = "$origin" ] ; then
a8c9a155 725 suffix=$(echo "$url" | cut -b $((ol+1))-)
cd445739
AM
726 echo -n "$mirror$suffix"
727 return 0
728 fi
729 done < mirrors
730 echo "$url"
731}
732
e7e0d4ec 733# Warning: unpredictable results if same URL used twice
cd445739
AM
734src_no ()
735{
01fa66fc 736 cd $SPEC_DIR
cd445739
AM
737 rpm_dump | \
738 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
739 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
740 head -n 1 | xargs
1471f6d6 741}
742
e7e0d4ec 743src_md5()
8ba5cdda 744{
e7e0d4ec 745 [ "$NO5" = "yes" ] && return
cd445739
AM
746 no=$(src_no "$1")
747 [ -z "$no" ] && return
01fa66fc 748 cd $SPEC_DIR
e7e0d4ec
ER
749 local md5
750
751 if [ -f additional-md5sums ]; then
752 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
753 if [ -z "$spec_rev" ]; then
a8c9a155 754 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
e7e0d4ec
ER
755 fi
756 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
757 md5=$(grep -s -v '^#' additional-md5sums | \
758 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
759 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
760 grep -E '^[0-9a-f]{32}$')
761
762 if [ "$md5" ]; then
763 if [ $(echo "$md5" | wc -l) != 1 ] ; then
764 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
765 fi
766 echo "$md5" | tail -n 1
767 return
768 fi
cd445739 769 fi
e7e0d4ec
ER
770
771 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
772 if [ -n "$source_md5" ]; then
773 echo $source_md5
cd445739 774 else
7805dcb4
PZ
775 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
776 if [ -n "$source_md5" ]; then
777 echo $source_md5
778 else
779 # we have empty SourceX-md5, but it is still possible
780 # that we have NoSourceX-md5 AND NoSource: X
781 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
782 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
783 echo $nosource_md5
784 fi
cd445739 785 fi
cd445739
AM
786 fi
787}
788
06541433
JR
789distfiles_path ()
790{
791 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
792}
793
cd445739
AM
794distfiles_url ()
795{
06541433 796 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
cd445739
AM
797}
798
799distfiles_attic_url ()
800{
06541433 801 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
cd445739
AM
802}
803
804good_md5 ()
805{
806 md5=$(src_md5 "$1")
807 [ "$md5" = "" ] || \
808 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
8ba5cdda
PG
809}
810
a4b50627
AF
811good_size ()
812{
a8c9a155 813 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
ce40491a 814 [ -n "$size" -a "$size" -gt 0 ]
a4b50627
AF
815}
816
947025e5 817cvsignore_df ()
818{
819 if [ "$CVSIGNORE_DF" != "yes" ]; then
820 return
821 fi
822 cvsignore=${SOURCE_DIR}/.cvsignore
823 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
824 echo "$1" >> $cvsignore
825 fi
826}
827
e7fa3b9f
ER
828cvsup()
829{
ce40491a
ER
830 update_shell_title "cvsup"
831 local OPTIONS="up "
832 if [ -n "$CVSROOT" ]; then
833 OPTIONS="-d $CVSROOT $OPTIONS"
834 fi
b1c6aace 835
ce40491a
ER
836 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
837 OPTIONS="$OPTIONS -A"
838 else
839 if [ -n "$CVSDATE" ]; then
840 OPTIONS="$OPTIONS -D $CVSDATE"
841 fi
842 if [ -n "$CVSTAG" ]; then
843 OPTIONS="$OPTIONS -r $CVSTAG"
844 fi
845 fi
e7fa3b9f 846
ce40491a
ER
847 local result=1
848 local retries_counter=0
849 if [ $# = 1 ]; then
850 update_shell_title "cvsup: $*"
851 else
852 update_shell_title "cvsup: $# files"
853 fi
854 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
855 retries_counter=$(( $retries_counter + 1 ))
856 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
857 result=$?
858 [ -n "$output" ] && echo "$output"
859 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
860 echo "Trying again [$*]... ($retries_counter)"
861 update_shell_title "cvsup: retry #$retries_counter"
862 sleep 2
863 continue
864 else
865 break
866 fi
867 done
868 update_shell_title "cvsup: done!"
869 return $result
e7fa3b9f
ER
870}
871
71f8e908
ER
872# returns true if "$1" is ftp, http or https protocol url
873is_url()
874{
875 case "$1" in
876 ftp://*|http://*|https://*)
877 return 0
878 ;;
879 esac
880 return 1
881}
882
ecba6ad5
ER
883update_md5()
884{
885 if [ $# -eq 0 ]; then
886 return
887 fi
888
889 update_shell_title "update md5"
890 if [ -n "$DEBUG" ]; then
518ff1fb
ER
891 set -x
892 set -v
ecba6ad5
ER
893 fi
894
895 cd "$SOURCE_DIR"
896
897 # pass 1: check files to be fetched
898 local todo
899 local need_files
900 for i in "$@"; do
901 local fp=$(nourl "$i")
902 local srcno=$(src_no "$i")
6392b5fd
ER
903 if [ -n "$ADD5" ]; then
904 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
01fa66fc 905 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
6c1b2e7d 906 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
6392b5fd 907 else
6c1b2e7d 908 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
ecba6ad5
ER
909 fi
910 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
911 need_files="$need_files $i"
912 fi
913 done
914
915 # pass 1a: get needed files
916 if [ "$need_files" ]; then
917 get_files $need_files
918 fi
919
920 # pass 2: proceed with md5 adding or updating
921 for i in "$@"; do
922 local fp=$(nourl "$i")
923 local srcno=$(src_no "$i")
01fa66fc 924 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
e19ad799 925 if [ -z "$md5" ]; then
6c1b2e7d
PZ
926 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
927 fi
71f8e908 928 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
6c1b2e7d 929 local tag="# Source$srcno-md5:\t"
71f8e908 930 if [[ "$md5" == *NoSource* ]]; then
6c1b2e7d
PZ
931 tag="# NoSource$srcno-md5:\t"
932 elif [ -n "$USEDIGEST" ]; then
933 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
71f8e908 934 fi
ecba6ad5 935 md5=$(md5sum "$fp" | cut -f1 -d' ')
15bf3e99 936 echo "Updating Source$srcno ($md5: $fp)."
ecba6ad5 937 perl -i -ne '
6c1b2e7d
PZ
938 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
939 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
ecba6ad5 940 ' \
01fa66fc 941 $SPEC_DIR/$SPECFILE
ecba6ad5
ER
942 fi
943 done
944}
945
946check_md5()
947{
3fbff8b8
ER
948 [ "$NO5" = "yes" ] && return
949
ecba6ad5
ER
950 update_shell_title "check md5"
951
952 for i in "$@"; do
953 if good_md5 "$i" && good_size "$i"; then
954 continue
955 fi
956
957 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
958 echo "or -5 to update md5 sums, if you're sure files are correct."
959 Exit_error err_no_source_in_repo $i
960 done
961}
962
cd445739
AM
963get_files()
964{
7cb24972 965 update_shell_title "get_files"
cd445739
AM
966
967 if [ -n "$DEBUG" ]; then
518ff1fb
ER
968 set -x
969 set -v
cd445739
AM
970 fi
971
f09c0772 972 if [ $# -gt 0 ]; then
cd445739
AM
973 cd "$SOURCE_DIR"
974
b1c6aace 975 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
049ab214 976 echo "Warning: No CVS access defined for SOURCES"
b1c6aace
ER
977 NOCVS="yes"
978 fi
979
f2e42a41 980 local nc=0
e7fa3b9f 981 local get_files_cvs=""
3815b69a 982 for i in "$@"; do
f2e42a41 983 nc=$((nc + 1))
dcebdffb 984 local cvsup=0
3815b69a 985 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
f2e42a41 986 update_shell_title "$i"
f09c0772 987 local fp=`nourl "$i"`
ecba6ad5 988 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
ce40491a 989 continue
18e5347d 990 fi
ecba6ad5 991
cd445739 992 FROM_DISTFILES=0
e7e0d4ec 993 local srcmd5=$(src_md5 "$i")
ecba6ad5
ER
994
995 # we know if source/patch is present in cvs/distfiles
996 # - has md5 (in distfiles)
997 # - in cvs... ideas?
998
999 # CHECK: local file didn't exist or always cvs up (first) requested.
f09c0772 1000 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
cd445739
AM
1001 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1002 echo "Warning: no URL given for $i"
1003 fi
1004
e7e0d4ec 1005 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
a4b50627 1006 if good_md5 "$i" && good_size "$i"; then
e7e0d4ec 1007 echo "$fp having proper md5sum already exists"
cd445739
AM
1008 continue
1009 fi
4ea1c265 1010 target="$fp"
28b34560 1011
bc10f694 1012 # optionally prefer mirror over distfiles if there's mirror
28b34560 1013 # TODO: build url list and then try each url from the list
bc10f694 1014 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
28b34560
ER
1015 url="$im"
1016 else
1017 url=$(distfiles_url "$i")
1018 fi
1019
cd445739
AM
1020 url_attic=$(distfiles_attic_url "$i")
1021 FROM_DISTFILES=1
ecba6ad5
ER
1022 # is $url local file?
1023 if [[ "$url" = [./]* ]]; then
18a52930 1024 update_shell_title "${GETLOCAL%% *}: $url"
cd445739
AM
1025 ${GETLOCAL} $url $target
1026 else
1027 if [ -z "$NOMIRRORS" ]; then
9e9f8920 1028 url=$(find_mirror "$url")
cd445739 1029 fi
9e9f8920
ER
1030
1031 local uri=${url}
1032 # make shorter message for distfiles urls
1033 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1034 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1035 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1036 uri="df: $uri"
1037 fi
1038 update_shell_title "${GETURI%% *}: $uri"
ca2e6c31 1039 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 1040 if [ "`echo $url | grep -E 'ftp://'`" ]; then
18a52930 1041 update_shell_title "${GETURI2%% *}: $url"
ca2e6c31 1042 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739
AM
1043 fi
1044 fi
ecba6ad5
ER
1045
1046 # is it empty file?
1047 if [ ! -s "$target" ]; then
cd445739
AM
1048 rm -f "$target"
1049 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
18a52930 1050 update_shell_title "${GETLOCAL%% *}: $url_attic"
cd445739
AM
1051 ${GETLOCAL} $url_attic $target
1052 else
1053 if [ -z "$NOMIRRORS" ]; then
a8c9a155 1054 url_attic=$(find_mirror "$url_attic")
cd445739 1055 fi
18a52930 1056 update_shell_title "${GETURI%% *}: $url_attic"
ca2e6c31 1057 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 1058 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
ce40491a 1059 update_shell_title "${GETURI2%% *}: $url_attic"
ca2e6c31 1060 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
1061 fi
1062 fi
1063 fi
ecba6ad5
ER
1064
1065 if [ -s "$target" ]; then
947025e5 1066 cvsignore_df $target
1067 else
cd445739
AM
1068 rm -f "$target"
1069 FROM_DISTFILES=0
1070 fi
e7e0d4ec 1071 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
d05e8080
ER
1072 if [ $# -gt 1 ]; then
1073 get_files_cvs="$get_files_cvs $fp"
1074 update_shell_title "$fp (will cvs up later)"
1075 cvsup=1
1076 else
1077 cvsup $fp
1078 fi
cd445739
AM
1079 fi
1080
f09c0772 1081 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
cd445739 1082 if [ -z "$NOMIRRORS" ]; then
a8c9a155 1083 im=$(find_mirror "$i")
cd445739
AM
1084 else
1085 im="$i"
1086 fi
ce40491a 1087 update_shell_title "${GETURI%% *}: $im"
cd445739 1088 ${GETURI} "$im" || \
33da77c4 1089 if [ "`echo $im | grep -E 'ftp://'`" ]; then
ce40491a 1090 update_shell_title "${GETURI2%% *}: $im"
cd445739 1091 ${GETURI2} "$im"
7e365483 1092 fi
cd445739
AM
1093 fi
1094
dcebdffb
ER
1095 if [ "$cvsup" = 1 ]; then
1096 continue
1097 fi
1098
cd445739 1099 fi
ecba6ad5
ER
1100
1101 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
f09c0772 1102 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
cdbd30e8 1103 if [ -n "GREEDSRC" ]; then
1104 get_greed_sources $i
1105 else
1106 Exit_error err_no_source_in_repo $i
1107 fi
cd445739 1108 fi
2a5f078d 1109
ecba6ad5 1110 # we check md5 here just only to refetch immediately
a4b50627 1111 if good_md5 "$i" && good_size "$i"; then
cd445739
AM
1112 :
1113 elif [ "$FROM_DISTFILES" = 1 ]; then
deccc50e 1114 # wrong md5 from distfiles: remove the file and try again
cd445739 1115 # but only once ...
deccc50e 1116 echo "MD5 sum mismatch. Trying full fetch."
cd445739
AM
1117 FROM_DISTFILES=2
1118 rm -f $target
18a52930 1119 update_shell_title "${GETURI%% *}: $url"
ca2e6c31 1120 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 1121 if [ "`echo $url | grep -E 'ftp://'`" ]; then
ce40491a 1122 update_shell_title "${GETURI2%% *}: $url"
ca2e6c31 1123 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739 1124 fi
ecba6ad5 1125 if [ ! -s "$target" ]; then
cd445739 1126 rm -f "$target"
18a52930 1127 update_shell_title "${GETURI%% *}: $url_attic"
ca2e6c31 1128 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 1129 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
ce40491a 1130 update_shell_title "${GETURI2%% *}: $url_attic"
ca2e6c31 1131 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
1132 fi
1133 fi
1134 test -s "$target" || rm -f "$target"
1135 fi
cd445739 1136 done
e7fa3b9f
ER
1137 SHELL_TITLE_PREFIX=""
1138
1139 if [ "$get_files_cvs" ]; then
ce40491a 1140 cvsup $get_files_cvs
e7fa3b9f 1141 fi
cd445739
AM
1142
1143 if [ "$CHMOD" = "yes" ]; then
a8c9a155 1144 CHMOD_FILES=$(nourl "$@")
cd445739
AM
1145 if [ -n "$CHMOD_FILES" ]; then
1146 chmod $CHMOD_MODE $CHMOD_FILES
1147 fi
1148 fi
cd445739
AM
1149 fi
1150}
1151
1152make_tagver() {
ce40491a 1153 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1154 set -x
1155 set -v
ce40491a 1156 fi
78eab2a1 1157
ce40491a
ER
1158 # Check whether first character of PACKAGE_NAME is legal for tag name
1159 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1160 TAG_PREFIX=tag_
1161 fi
d712cc12
ER
1162
1163 # NOTE: CVS tags may must not contain the characters `$,.:;@'
392187d9 1164 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
d712cc12 1165
ce40491a
ER
1166 # Remove #kernel.version_release from TAGVER because tagging sources
1167 # could occur with different kernel-headers than kernel-headers used at build time.
d712cc12
ER
1168 # besides, %{_kernel_ver_str} is not expanded.
1169
1170 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1171 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1172
1173 TAGVER=${TAGVER%#*}
ce40491a 1174 echo -n "$TAGVER"
cd445739
AM
1175}
1176
c713aac3
AG
1177# bool is_tag_a_branch(tag)
1178#
1179# returns 1 if a tag is a branch set on SPECFILE
1180is_tag_a_branch() {
1181 if [ -n "$DEBUG" ]; then
1182 set -x
1183 set -v
1184 fi
1185
1186 if [ $# -ne 1 ]; then
1187 return 0;
1188 fi
1189
1190 TAG=$1
f5141bbc 1191
c713aac3
AG
1192 cd "$SPEC_DIR"
1193 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1194 return $?
1195}
1196
cd445739
AM
1197tag_files()
1198{
1199 TAG_FILES="$@"
1200
1201 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1202 set -x
1203 set -v
cd445739
AM
1204 fi
1205
73ef63d8
ER
1206 echo "Version: $PACKAGE_VERSION"
1207 echo "Release: $PACKAGE_RELEASE"
cd445739 1208
a18a9761 1209 local TAGVER
73ef63d8 1210 if [ "$TAG_VERSION" = "yes" ]; then
a18a9761 1211 TAGVER=`make_tagver`
73ef63d8
ER
1212 echo "CVS tag: $TAGVER"
1213 fi
1214 if [ -n "$TAG" ]; then
1215 echo "CVS tag: $TAG"
1216 fi
cd445739 1217
39dcc7de 1218 local OPTIONS="tag $CVS_FORCE"
73ef63d8
ER
1219 if [ -n "$CVSROOT" ]; then
1220 OPTIONS="-d $CVSROOT $OPTIONS"
1221 fi
cd445739 1222
c713aac3
AG
1223 # if a tagname we are about to set already exists
1224 # and happens to be a branch (common case with AC-branch)
1225 # pass -B (allows -F to disturb branch tag)
1226 local _tag=$TAG
1227 if [ "$TAG_VERSION" = "yes" ]; then
1228 _tag=$TAGVER
1229 fi;
1230 is_tag_a_branch $_tag
28c23a72 1231 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
c713aac3
AG
1232 OPTIONS="$OPTIONS -B"
1233 fi;
1234
73ef63d8
ER
1235 cd "$SOURCE_DIR"
1236 local tag_files
1237 for i in $TAG_FILES; do
1238 # don't tag files stored on distfiles
1239 [ -n "`src_md5 $i`" ] && continue
1240 local fp=`nourl "$i"`
1241 if [ -f "$fp" ]; then
1242 tag_files="$tag_files $fp"
cdbd30e8 1243 elif [ -n "GREEDSRC" ]; then
1244 get_greed_sources $i
73ef63d8
ER
1245 else
1246 Exit_error err_no_source_in_repo $i
03db3356 1247 fi
73ef63d8 1248 done
03db3356 1249
73ef63d8 1250 if [ "$tag_files" ]; then
cd445739 1251 if [ "$TAG_VERSION" = "yes" ]; then
73ef63d8 1252 update_shell_title "tag sources: $TAGVER"
19ca62ef 1253 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
c7e6ee9b 1254 cvs $OPTIONS $TAGVER $tag_files || exit
cd445739
AM
1255 fi
1256 if [ -n "$TAG" ]; then
73ef63d8 1257 update_shell_title "tag sources: $TAG"
c4ff623e
ER
1258
1259 while [ "$tag_files" ]; do
1260 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1261 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1262 cvs $OPTIONS $TAG $chunk || exit
1263 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1264 done
cd445739 1265 fi
73ef63d8
ER
1266 fi
1267
01fa66fc 1268 cd "$SPEC_DIR"
73ef63d8
ER
1269 if [ "$TAG_VERSION" = "yes" ]; then
1270 update_shell_title "tag spec: $TAGVER"
c7e6ee9b 1271 cvs $OPTIONS $TAGVER $SPECFILE || exit
73ef63d8
ER
1272 fi
1273 if [ -n "$TAG" ]; then
1274 update_shell_title "tag spec: $TAG"
c7e6ee9b 1275 cvs $OPTIONS $TAG $SPECFILE || exit
73ef63d8 1276 fi
cd445739
AM
1277}
1278
1279branch_files()
1280{
1281 TAG=$1
1282 echo "CVS branch tag: $TAG"
518ff1fb 1283 shift
cd445739
AM
1284
1285 TAG_FILES="$@"
1286
1287 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1288 set -x
1289 set -v
cd445739
AM
1290 fi
1291
78a5a506
ER
1292 local OPTIONS="tag $CVS_FORCE -b"
1293 if [ -n "$CVSROOT" ]; then
1294 OPTIONS="-d $CVSROOT $OPTIONS"
1295 fi
1296 cd "$SOURCE_DIR"
1297 local tag_files
1298 for i in $TAG_FILES; do
1299 local fp=`nourl "$i"`
1300 if [ -f "$fp" ]; then
1301 tag_files="$tag_files $fp"
cdbd30e8 1302 elif [ -n "GREEDSRC" ]; then
1303 get_greed_sources $i
78a5a506
ER
1304 else
1305 Exit_error err_no_source_in_repo $i
c10fa4fa 1306 fi
78a5a506
ER
1307 done
1308 if [ "$tag_files" ]; then
c7e6ee9b 1309 cvs $OPTIONS $TAG $tag_files || exit
78a5a506 1310 fi
c10fa4fa 1311
01fa66fc 1312 cd "$SPEC_DIR"
c7e6ee9b 1313 cvs $OPTIONS $TAG $SPECFILE || exit
cd445739
AM
1314}
1315
1316
3009b80d
ER
1317# this function should exit early if package can't be built for this arch
1318# this avoids unneccessary BR filling.
1319check_buildarch() {
1320 local out ret
13c3c336 1321 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
3009b80d
ER
1322 ret=$?
1323 if [ $ret -ne 0 ]; then
1324 echo >&2 "$out"
1325 exit $ret
1326 fi
1327}
1328
cd445739 1329
59398507 1330build_package()
1331{
2e5be021 1332 update_shell_title "build_package"
cd445739 1333 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1334 set -x
1335 set -v
cd445739 1336 fi
5a491465 1337
01fa66fc 1338 cd "$SPEC_DIR"
cd445739
AM
1339
1340 if [ -n "$TRY_UPGRADE" ]; then
ce40491a 1341 update_shell_title "build_package: try_upgrade"
cd445739 1342 if [ -n "$FLOAT_VERSION" ]; then
45e2a818 1343 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
cd445739 1344 else
45e2a818 1345 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
cd445739
AM
1346 fi
1347
45e2a818 1348 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
cd445739
AM
1349
1350 if [ -n "$TNEWVER" ]; then
1351 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1352 echo "New version found, updating spec file to version " $TNEWVER
257af81b
ER
1353 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1354 cp -f $SPECFILE $SPECFILE.bak
1355 fi
cd445739
AM
1356 chmod +w $SPECFILE
1357 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
f7b91886 1358 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
518ff1fb
ER
1359 parse_spec
1360 NODIST="yes" get_files $SOURCES $PATCHES
6392b5fd 1361 update_md5 $SOURCES
975d7b23 1362
cd445739
AM
1363 unset TOLDVER TNEWVER TNOTIFY
1364 fi
1365 fi
01fa66fc 1366 cd "$SPEC_DIR"
2a5f078d 1367
cd445739
AM
1368 case "$COMMAND" in
1369 build )
1370 BUILD_SWITCH="-ba" ;;
1371 build-binary )
1372 BUILD_SWITCH="-bb" ;;
1373 build-source )
1374 BUILD_SWITCH="-bs --nodeps" ;;
1375 build-prep )
1376 BUILD_SWITCH="-bp --nodeps" ;;
6594293d
AG
1377 build-build )
1378 BUILD_SWITCH="-bc" ;;
1379 build-install )
1380 BUILD_SWITCH="-bi" ;;
1381 build-list )
1382 BUILD_SWITCH="-bl" ;;
1383
cd445739 1384 esac
c890b916 1385
2e5be021 1386 update_shell_title "build_package: $COMMAND"
cd445739
AM
1387 if [ -n "$LOGFILE" ]; then
1388 LOG=`eval echo $LOGFILE`
1389 if [ -d "$LOG" ]; then
1390 echo "Log file $LOG is a directory."
1391 echo "Parse error in the spec?"
518ff1fb 1392 Exit_error err_build_fail
cd445739
AM
1393 fi
1394 if [ -n "$LASTLOG_FILE" ]; then
1395 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1396 fi
525bf240
ER
1397 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1398
86aafdbe 1399 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
cd445739
AM
1400 RETVAL=`cat $RES_FILE`
1401 rm $RES_FILE
1402 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1403 if [ "$RETVAL" -eq "0" ]; then
1404 mv $LOG $LOGDIROK
1405 else
1406 mv $LOG $LOGDIRFAIL
1407 fi
1408 fi
8ba5cdda 1409 else
86aafdbe 1410 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
cd445739 1411 RETVAL=$?
8ba5cdda 1412 fi
cd445739
AM
1413 if [ "$RETVAL" -ne "0" ]; then
1414 if [ -n "$TRY_UPGRADE" ]; then
796a8a95 1415 echo "\n!!! Package with new version cannot be built automagically\n"
257af81b
ER
1416 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1417 mv -f $SPECFILE.bak $SPECFILE
1418 fi
cd445739 1419 fi
518ff1fb 1420 Exit_error err_build_fail
cd445739
AM
1421 fi
1422 unset BUILD_SWITCH
1423}
1424
1425nourl()
1426{
1427 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1428}
1429
cd445739
AM
1430install_required_packages()
1431{
1432 run_poldek -vi $1
1433 return $?
1434}
1435
fa4bf1df
ER
1436find_spec_bcond() {
1437 # taken from find-spec-bcond, but with just getting the list
1438 local SPEC="$1"
fa4bf1df
ER
1439 awk -F"\n" '
1440 /^%changelog/ { exit }
1441 /_with(out)?_[_a-zA-Z0-9]+/{
1442 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1443 print substr($0, RSTART, RLENGTH);
1444 }
1445 /^%bcond_with/{
1446 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1447 bcond = substr($0, RSTART +5 , RLENGTH -5);
1448 gsub(/[ \t]+/,"_",bcond);
1449 print bcond
1450 }' $SPEC | LC_ALL=C sort -u
1451}
1452
117d9861 1453process_bcondrc() {
301cbfd4
ER
1454 # expand bconds from ~/.bcondrc
1455 # The file structure is like gentoo's package.use:
1456 # ---
1457 # * -selinux
1458 # samba -mysql -pgsql
47a8df12 1459 # w32codec-installer license_agreement
301cbfd4
ER
1460 # php +mysqli
1461 # ---
fa4bf1df 1462 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
117d9861
ER
1463 :
1464 else
1465 return
1466 fi
301cbfd4 1467
117d9861 1468 SN=${SPECFILE%%\.spec}
c8a3e2ac 1469
117d9861
ER
1470 local bcondrc=$HOME/.bcondrc
1471 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
301cbfd4 1472
117d9861 1473 local bcond_avail=$(find_spec_bcond $SPECFILE)
301cbfd4 1474
117d9861
ER
1475 while read pkg flags; do
1476 # ignore comments
1477 [[ "$pkg" == \#* ]] && continue
1478
1479 # any package or current package?
1480 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1481 for flag in $flags; do
1482 local opt=${flag#[+-]}
1483
1484 # use only flags which are in this package.
1485 if [[ $bcond_avail = *${opt}* ]]; then
1486 if [[ $flag = -* ]]; then
1487 if [[ $BCOND != *--with?${opt}* ]]; then
1488 BCOND="$BCOND --without $opt"
1489 fi
1490 else
1491 if [[ $BCOND != *--without?${opt}* ]]; then
1492 BCOND="$BCOND --with $opt"
301cbfd4
ER
1493 fi
1494 fi
117d9861
ER
1495 fi
1496 done
1497 fi
1498 done < $bcondrc
1499 update_shell_title "parse ~/.bcondrc: DONE!"
1500}
1501
1502set_bconds_values()
1503{
1504 update_shell_title "set bcond values"
1505
1506 AVAIL_BCONDS_WITHOUT=""
1507 AVAIL_BCONDS_WITH=""
1508 if `grep -q ^%bcond ${SPECFILE}`; then
1509 BCOND_VERSION="NEW"
1510 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1511 BCOND_VERSION="OLD"
1512 else
1513 return
301cbfd4
ER
1514 fi
1515
117d9861
ER
1516 local bcond_avail=$(find_spec_bcond $SPECFILE)
1517 process_bcondrc "$SPECFILE"
1518
fa4bf1df 1519 update_shell_title "parse bconds"
cd445739 1520 case "${BCOND_VERSION}" in
fa4bf1df 1521 NONE)
7e365483 1522 :
cd445739 1523 ;;
7e365483 1524 OLD)
cd445739 1525 echo "Warning: This spec has old style bconds. Fix it || die."
fa4bf1df 1526 for opt in `echo "$bcond_avail" | grep ^_without_`
cd445739 1527 do
fa4bf1df
ER
1528 AVAIL_BCOND_WITHOUT=${opt#_without_}
1529 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
cd445739
AM
1530 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1531 else
1532 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1533 fi
1534 done
2a5f078d 1535
fa4bf1df 1536 for opt in `echo "$bcond_avail" | grep ^_with_`
cd445739 1537 do
fa4bf1df
ER
1538 AVAIL_BCOND_WITH=${opt#_with_}
1539 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
cd445739
AM
1540 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1541 else
1542 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1543 fi
1544 done
1545 ;;
1546 NEW)
fa4bf1df
ER
1547 local cond_type="" # with || without
1548 for opt in $bcond_avail; do
cd445739
AM
1549 case "$opt" in
1550 _without)
1551 cond_type="without"
1552 ;;
1553 _with)
1554 cond_type="with"
1555 ;;
f8d24cee 1556 _without_*)
fa4bf1df
ER
1557 AVAIL_BCOND_WITHOUT=${opt#_without_}
1558 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
f8d24cee 1559 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1560 else
1561 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1562 fi
1563 ;;
1564 _with_*)
fa4bf1df
ER
1565 AVAIL_BCOND_WITH=${opt#_with_}
1566 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
f8d24cee 1567 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1568 else
1569 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1570 fi
1571 ;;
cd445739
AM
1572 *)
1573 case "$cond_type" in
1574 with)
1575 cond_type=''
1576 AVAIL_BCOND_WITH="$opt"
fa4bf1df 1577 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
cd445739
AM
1578 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1579 else
1580 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1581 fi
7e365483 1582 ;;
cd445739
AM
1583 without)
1584 cond_type=''
1585 AVAIL_BCOND_WITHOUT="$opt"
fa4bf1df 1586 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
cd445739
AM
1587 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1588 else
1589 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1590 fi
1591 ;;
1592 esac
1593 ;;
1594 esac
1595 done
1596 ;;
1597 esac
1598}
1599
1600run_sub_builder()
1601{
1602 package_name="${1}"
af6b168f 1603 update_shell_title "run_sub_builder $package_name"
cd445739
AM
1604 #
1605